integrated (hybrid) with RMP, still need test

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/service-endpoint-editor@82061 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-09-26 17:10:27 +00:00
parent 922c91380c
commit 97e32176ca
4 changed files with 54 additions and 40 deletions

View File

@ -86,7 +86,6 @@
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>

View File

@ -33,23 +33,28 @@ public class RuntimeResourceCreator implements EntryPoint {
mainPanel.mask("Fetching Scopes, please wait","loading-indicator");
final String resourceToEdit = com.google.gwt.user.client.Window.Location.getParameter("rid");
final String curscope = com.google.gwt.user.client.Window.Location.getParameter("curscope");
runtimeService.getInitialInfo((resourceToEdit != null), resourceToEdit, curscope, new AsyncCallback<InitInfo>() {
runtimeService.getInitialInfo((resourceToEdit != null), resourceToEdit, curscope, new AsyncCallback<InitInfo>() {
@Override
public void onSuccess(InitInfo initialInfo) {
GWT.log("SUCCESS");
mainPanel.unmask();
ArrayList<String> scopes = initialInfo.getScopes();
if (initialInfo.getRr2edit() != null) {
if (initialInfo.getRr2edit().getResourceId() == null) {
MessageBox.alert("Service EndPoint Editor", "There is no Resource in the scope " + curscope + " having id: " + resourceToEdit, null);
if (scopes == null || scopes.isEmpty()) {
MessageBox.alert("Service EndPoint Editor", "We're sorry, it seems you are not authorized to create this resource", null);
}
else {
if (initialInfo.getRr2edit() != null) { //check if the resource to edit exists
if (initialInfo.getRr2edit().getResourceId() == null) {
MessageBox.alert("Service EndPoint Editor", "There is no Resource in the scope " + curscope + " having id: " + resourceToEdit, null);
}
else //resource exists
initialize(scopes, initialInfo.getRr2edit());
}
else {
//it is a create
initialize(scopes, null);
}
else
initialize(scopes, initialInfo.getRr2edit());
}
else
initialize(scopes, null);
}
@Override
@ -64,22 +69,22 @@ public class RuntimeResourceCreator implements EntryPoint {
}
public void initialize(ArrayList<String> scopes, FilledRuntimeResource toEdit) {
if (scopesCache == null)
scopesCache = scopes;
ArrayList<ClientScope> scopesToPass = new ArrayList<ClientScope>();
for (String scope : scopesCache) {
scopesToPass.add(new ClientScope(scope));
}
RuntimeResourceForm form = null;
if (toEdit == null) {
form = new RuntimeResourceForm(this, scopesToPass);
}
else {
form = new RuntimeResourceForm(this, scopesToPass, toEdit);
}
RootPanel.get(CONTAINER_DIV).remove(0);
RootPanel.get(CONTAINER_DIV).add(form);
if (scopesCache == null)
scopesCache = scopes;
ArrayList<ClientScope> scopesToPass = new ArrayList<ClientScope>();
for (String scope : scopesCache) {
scopesToPass.add(new ClientScope(scope));
}
RuntimeResourceForm form = null;
if (toEdit == null) {
form = new RuntimeResourceForm(this, scopesToPass);
}
else {
form = new RuntimeResourceForm(this, scopesToPass, toEdit);
}
RootPanel.get(CONTAINER_DIV).remove(0);
RootPanel.get(CONTAINER_DIV).add(form);
}
}

View File

@ -162,12 +162,21 @@ public class RuntimeResourceCreatorServiceImpl extends RemoteServiceServlet impl
}
@Override
public InitInfo getInitialInfo(boolean isEditMode, String idToEdit, String curscope) {
getASLSession();
ArrayList<String> scopes = getAvailableScopes();
public InitInfo getInitialInfo(boolean isEditMode, String idToEdit, String curScope) {
String rootScope = "";
String user = (String) this.getThreadLocalRequest().getSession().getAttribute("username");
if (user != null) {
rootScope = getASLSession().getScope();
_log.debug("Portal mode, scope = " + rootScope);
}
else {
rootScope = curScope;
_log.debug("Standalone mode, scope = " + rootScope);
}
ArrayList<String> scopes = getAvailableScopes(rootScope);
if (! isEditMode) {
_log.info("Editing Mode OFF");
System.out.println("Editing Mode OFF");
return new InitInfo(scopes, null);
}
/*
@ -241,24 +250,21 @@ public class RuntimeResourceCreatorServiceImpl extends RemoteServiceServlet impl
*
* @return
*/
public ArrayList<String> getAvailableScopes() {
public ArrayList<String> getAvailableScopes(String rootScope) {
ArrayList<String> retval = new ArrayList<String>();
String currentScope = getASLSession().getScopeName();
System.out.println("currentScope: " + currentScope);
System.out.println("currentScope: " + rootScope);
try {
Map<String, ScopeBean> scopes = ScopeManager.readScopes(this.getScopeDataPath());
for (ScopeBean scope : scopes.values()) {
if (scope.toString().startsWith(currentScope))
if (scope.toString().startsWith(rootScope))
retval.add(scope.toString());
}
Collections.sort(retval);
return retval;
} catch (Exception e) {
e.printStackTrace();
retval.add("/gcube");
retval.add("/gcube/devsec");
_log.warn("Exception during getAvailableScopes(), if you run standalone you must pass the scope via GET -> &curscope=$TheScope");
return retval;
}
return retval;
}

View File

@ -5,6 +5,10 @@
width: 92% !important;
}
#footer {
width: 100% !important;
}
.x-menubar {
background: #FFF url(images/bg-pattern.png) repeat;
}