works like a charm
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/service-endpoint-editor@81630 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cf10d3f49c
commit
4036c73816
11
pom.xml
11
pom.xml
|
@ -71,6 +71,11 @@
|
||||||
<artifactId>rmp-common-library</artifactId>
|
<artifactId>rmp-common-library</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-encryption</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
<artifactId>aslcore</artifactId>
|
<artifactId>aslcore</artifactId>
|
||||||
|
@ -89,12 +94,6 @@
|
||||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.core</groupId>
|
|
||||||
<artifactId>gcf</artifactId>
|
|
||||||
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Liferay, Servlets Etc -->
|
<!-- Liferay, Servlets Etc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.mail</groupId>
|
<groupId>javax.mail</groupId>
|
||||||
|
|
|
@ -8,10 +8,10 @@ import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,8 +31,8 @@ public class RuntimeResourceCreator implements EntryPoint {
|
||||||
|
|
||||||
mainPanel.setSize("100%","600");
|
mainPanel.setSize("100%","600");
|
||||||
mainPanel.mask("Fetching Scopes, please wait","loading-indicator");
|
mainPanel.mask("Fetching Scopes, please wait","loading-indicator");
|
||||||
String resourceToEdit = com.google.gwt.user.client.Window.Location.getParameter("rid");
|
final String resourceToEdit = com.google.gwt.user.client.Window.Location.getParameter("rid");
|
||||||
String curscope = com.google.gwt.user.client.Window.Location.getParameter("curscope");
|
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>() {
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@ public class RuntimeResourceCreator implements EntryPoint {
|
||||||
mainPanel.unmask();
|
mainPanel.unmask();
|
||||||
ArrayList<String> scopes = initialInfo.getScopes();
|
ArrayList<String> scopes = initialInfo.getScopes();
|
||||||
if (initialInfo.getRr2edit() != null) {
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
initialize(scopes, initialInfo.getRr2edit());
|
initialize(scopes, initialInfo.getRr2edit());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -60,7 +64,6 @@ public class RuntimeResourceCreator implements EntryPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(ArrayList<String> scopes, FilledRuntimeResource toEdit) {
|
public void initialize(ArrayList<String> scopes, FilledRuntimeResource toEdit) {
|
||||||
GWT.log("initialize" + scopes.toString());
|
|
||||||
if (scopesCache == null)
|
if (scopesCache == null)
|
||||||
scopesCache = scopes;
|
scopesCache = scopes;
|
||||||
ArrayList<ClientScope> scopesToPass = new ArrayList<ClientScope>();
|
ArrayList<ClientScope> scopesToPass = new ArrayList<ClientScope>();
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package org.gcube.portlets.admin.sepeditor.client;
|
package org.gcube.portlets.admin.sepeditor.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.Category;
|
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
||||||
|
|
||||||
|
@ -14,7 +11,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("serviceendpointEditor")
|
@RemoteServiceRelativePath("serviceendpointEditor")
|
||||||
public interface RuntimeResourceCreatorService extends RemoteService {
|
public interface RuntimeResourceCreatorService extends RemoteService {
|
||||||
ArrayList<Category> getCategories();
|
|
||||||
|
|
||||||
InitInfo getInitialInfo(boolean isEditMode, String idToEdit, String curscope);
|
InitInfo getInitialInfo(boolean isEditMode, String idToEdit, String curscope);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package org.gcube.portlets.admin.sepeditor.client;
|
package org.gcube.portlets.admin.sepeditor.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.Category;
|
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
||||||
|
|
||||||
|
@ -13,8 +10,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
*/
|
*/
|
||||||
public interface RuntimeResourceCreatorServiceAsync {
|
public interface RuntimeResourceCreatorServiceAsync {
|
||||||
|
|
||||||
void getCategories(AsyncCallback<ArrayList<Category>> callback);
|
|
||||||
|
|
||||||
void createRuntimeResource(String scope, FilledRuntimeResource resource, boolean isUpdate,
|
void createRuntimeResource(String scope, FilledRuntimeResource resource, boolean isUpdate,
|
||||||
AsyncCallback<Boolean> callback);
|
AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,10 @@ public class AccesPointPanel extends ContentPanel {
|
||||||
desc.setFieldLabel("Description");
|
desc.setFieldLabel("Description");
|
||||||
desc.setAllowBlank(false);
|
desc.setAllowBlank(false);
|
||||||
|
|
||||||
interfaceEntryNameAttr.setFieldLabel("[Interface] interfaceEntry name ");
|
interfaceEntryNameAttr.setFieldLabel("Name");
|
||||||
interfaceEntryNameAttr.setAllowBlank(false);
|
interfaceEntryNameAttr.setAllowBlank(false);
|
||||||
|
|
||||||
interfaceEndPoint.setFieldLabel("[Interface] interfaceEndPoint ");
|
interfaceEndPoint.setFieldLabel("Address");
|
||||||
interfaceEndPoint.setAllowBlank(false);
|
interfaceEndPoint.setAllowBlank(false);
|
||||||
|
|
||||||
username.setFieldLabel("Username");
|
username.setFieldLabel("Username");
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class RuntimeResourceForm extends ContentPanel {
|
||||||
public RuntimeResourceForm(RuntimeResourceCreator caller, ArrayList<ClientScope> scopes) {
|
public RuntimeResourceForm(RuntimeResourceCreator caller, ArrayList<ClientScope> scopes) {
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
this.setHeaderVisible(true);
|
this.setHeaderVisible(true);
|
||||||
this.setHeading("Runtime Resource Creation");
|
this.setHeading("Service EndPoint Editor");
|
||||||
//this.setModal(true);
|
//this.setModal(true);
|
||||||
this.setAutoWidth(true);
|
this.setAutoWidth(true);
|
||||||
this.setHeight(650);
|
this.setHeight(650);
|
||||||
|
@ -83,7 +83,7 @@ public class RuntimeResourceForm extends ContentPanel {
|
||||||
this.toEdit = toEdit;
|
this.toEdit = toEdit;
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
this.setHeaderVisible(true);
|
this.setHeaderVisible(true);
|
||||||
this.setHeading("Runtime Resource Creation [EDIT MODE]");
|
this.setHeading("Service EndPoint Editor [EDIT MODE]");
|
||||||
//this.setModal(true);
|
//this.setModal(true);
|
||||||
this.setAutoWidth(true);
|
this.setAutoWidth(true);
|
||||||
this.setHeight(650);
|
this.setHeight(650);
|
||||||
|
@ -251,18 +251,18 @@ public class RuntimeResourceForm extends ContentPanel {
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
form.unmask();
|
form.unmask();
|
||||||
if (result) {
|
if (result) {
|
||||||
MessageBox.alert("Runtime Resource Creation", "Request for registration successfully sent", null);
|
MessageBox.info("Service EndPoint Editor", "Request for registration successfully sent", null);
|
||||||
|
caller.initialize(null, null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBox.alert("Runtime Resource Creation", "Request for registration failed, please check server logs", null);
|
MessageBox.alert("Service EndPoint Editor", "We're sorry, Request for registration failed on server, please check server logs", null);
|
||||||
}
|
}
|
||||||
caller.initialize(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable arg0) {
|
public void onFailure(Throwable arg0) {
|
||||||
form.unmask();
|
form.unmask();
|
||||||
MessageBox.alert("Runtime Resource Creation", "Request for registration Failed", null);
|
MessageBox.alert("Service EndPoint Editor", "Request for registration Failed", null);
|
||||||
caller.initialize(null, null);
|
caller.initialize(null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,45 +10,33 @@ import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
import org.gcube.application.framework.core.session.SessionManager;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
|
||||||
import org.gcube.common.core.informationsystem.ISException;
|
|
||||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBERuntimeResourceQuery;
|
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
|
||||||
import org.gcube.common.core.resources.GCUBERuntimeResource;
|
|
||||||
import org.gcube.common.core.resources.common.PlatformDescription;
|
|
||||||
import org.gcube.common.core.resources.runtime.AccessPoint;
|
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
|
||||||
import org.gcube.common.core.scope.ServiceMap;
|
import org.gcube.common.core.scope.ServiceMap;
|
||||||
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
import org.gcube.common.encryption.StringEncrypter;
|
||||||
import org.gcube.common.resources.gcore.GenericResource;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||||
import org.gcube.portlets.admin.sepeditor.client.RuntimeResourceCreatorService;
|
import org.gcube.portlets.admin.sepeditor.client.RuntimeResourceCreatorService;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.Category;
|
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
import org.gcube.portlets.admin.sepeditor.shared.FilledRuntimeResource;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
import org.gcube.portlets.admin.sepeditor.shared.InitInfo;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.Property;
|
import org.gcube.portlets.admin.sepeditor.shared.Property;
|
||||||
import org.gcube.portlets.admin.sepeditor.shared.RRAccessPoint;
|
import org.gcube.portlets.admin.sepeditor.shared.RRAccessPoint;
|
||||||
|
import org.gcube.resourcemanagement.support.server.managers.resources.RuntimeResourceManager;
|
||||||
import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager;
|
import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
@ -92,87 +80,76 @@ public class RuntimeResourceCreatorServiceImpl extends RemoteServiceServlet impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean createRuntimeResource(String scope, FilledRuntimeResource rs, boolean isUpdate) {
|
public Boolean createRuntimeResource(String scope, FilledRuntimeResource rs, boolean isUpdate) {
|
||||||
|
String currScope = ScopeProvider.instance.get();
|
||||||
GCUBERuntimeResource rt;
|
ScopeProvider.instance.set(scope);
|
||||||
|
ServiceEndpoint rt;
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
try {
|
try {
|
||||||
if (!isUpdate) {
|
if (!isUpdate) {
|
||||||
_log.info("Trying creating Runtime Resource: " + rs.getResourceName() + " SCOPE: " + scope);
|
_log.info("Trying creating Runtime Resource: " + rs.getResourceName() + " SCOPE: " + scope);
|
||||||
rt =GHNContext.getImplementation(GCUBERuntimeResource.class);
|
rt = new ServiceEndpoint();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||||
GCUBERuntimeResourceQuery query = client.getQuery(GCUBERuntimeResourceQuery.class);
|
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||||
query.addAtomicConditions(new AtomicCondition("//ID", rs.getResourceId()));
|
query.addCondition("$resource/ID/text() eq '" + rs.getResourceId() + "'");
|
||||||
_log.info("Trying editing Runtime Resource ID: " + rs.getResourceId());
|
_log.info("Trying editing Runtime Resource ID: " + rs.getResourceId());
|
||||||
rt = client.execute(query,GCUBEScope.getScope(scope)).get(0); //only one rr per id
|
rt = client.submit(query).get(0); //only one rr per id
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
rt.setCategory(rs.getCategory());
|
rt.newProfile();
|
||||||
rt.setDescription(rs.getDescription());
|
rt.profile().category(rs.getCategory());
|
||||||
rt.setGHN(rs.getRuntimegHNUniqueID());
|
rt.profile().description(rs.getDescription());
|
||||||
rt.setHostedOn(rs.getRuntimeHostedOn());
|
rt.profile().newRuntime().ghnId(rs.getRuntimegHNUniqueID());
|
||||||
rt.setName(rs.getResourceName());
|
rt.profile().runtime().hostedOn(rs.getRuntimeHostedOn());
|
||||||
rt.setStatus(rs.getRuntimeStatus());
|
rt.profile().name(rs.getResourceName());
|
||||||
PlatformDescription platform = new PlatformDescription();
|
rt.profile().runtime().status(rs.getRuntimeStatus());
|
||||||
platform.setName(rs.getPlatformName());
|
|
||||||
platform.setVersion((short) Integer.parseInt( (rs.getPlatformVersion().equals("")) ? "0" : rs.getPlatformVersion()) );
|
|
||||||
|
|
||||||
platform.setMinorVersion((short) Integer.parseInt( (rs.getPlatformMinorVersion().equals("")) ? "0" : rs.getPlatformMinorVersion()) );
|
rt.profile().newPlatform().name(rs.getPlatformName());
|
||||||
platform.setRevisionVersion((short) Integer.parseInt( (rs.getPlatformRevisionVersion().equals("")) ? "0" : rs.getPlatformRevisionVersion()) );
|
rt.profile().platform().version((short) Integer.parseInt( (rs.getPlatformVersion().equals("")) ? "0" : rs.getPlatformVersion()) );
|
||||||
platform.setBuildVersion((short) Integer.parseInt( (rs.getPlatformBuildVersion().equals("")) ? "0" : rs.getPlatformBuildVersion()) );
|
|
||||||
rt.setPlatform(platform);
|
rt.profile().platform().minorVersion((short) Integer.parseInt( (rs.getPlatformMinorVersion().equals("")) ? "0" : rs.getPlatformMinorVersion()) );
|
||||||
|
rt.profile().platform().revisionVersion((short) Integer.parseInt( (rs.getPlatformRevisionVersion().equals("")) ? "0" : rs.getPlatformRevisionVersion()) );
|
||||||
|
rt.profile().platform().buildVersion((short) Integer.parseInt( (rs.getPlatformBuildVersion().equals("")) ? "0" : rs.getPlatformBuildVersion()) );
|
||||||
|
|
||||||
ArrayList<RRAccessPoint> myAccessPoints = rs.getRRAccessPoints();
|
ArrayList<RRAccessPoint> myAccessPoints = rs.getRRAccessPoints();
|
||||||
|
|
||||||
List<AccessPoint> accessPoints = new ArrayList<AccessPoint>();
|
|
||||||
for (RRAccessPoint p : myAccessPoints) {
|
for (RRAccessPoint p : myAccessPoints) {
|
||||||
AccessPoint a = new AccessPoint();
|
AccessPoint a = new AccessPoint();
|
||||||
a.setEndpoint(p.getInterfaceEndPoint());
|
a.address(p.getInterfaceEndPoint());
|
||||||
a.setEntryname(p.getInterfaceEntryNameAttr());
|
a.name(p.getInterfaceEntryNameAttr());
|
||||||
a.setDescription(p.getDesc());
|
a.description(p.getDesc());
|
||||||
|
|
||||||
a.setUsername(p.getUsername());
|
String encryptedPassword = StringEncrypter.getEncrypter().encrypt(p.getPassword());
|
||||||
a.setPassword(p.getPassword());
|
a.credentials(encryptedPassword, p.getUsername());
|
||||||
|
|
||||||
for (Property prop : p.getProperties()) {
|
for (Property prop : p.getProperties()) {
|
||||||
a.addProperty(prop.getKey(), prop.getValue(), prop.isCrypted());
|
String propValue = prop.isCrypted() ? StringEncrypter.getEncrypter().encrypt(prop.getValue()) : prop.getValue();
|
||||||
|
org.gcube.common.resources.gcore.ServiceEndpoint.Property pToAdd =
|
||||||
|
new org.gcube.common.resources.gcore.ServiceEndpoint.Property().nameAndValue(prop.getKey(), propValue);
|
||||||
|
pToAdd.encrypted(prop.isCrypted());
|
||||||
|
a.properties().add(pToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
accessPoints.add(a);
|
rt.profile().accessPoints().add(a);
|
||||||
}
|
}
|
||||||
rt.setAccessPoints(accessPoints );
|
|
||||||
|
|
||||||
rt.addScope(GCUBEScope.getScope(scope));
|
ScopeProvider.instance.set(scope.toString());
|
||||||
|
RuntimeResourceManager gm = new RuntimeResourceManager();
|
||||||
|
RegistryPublisher publisher = gm.getRegistryPublisher();
|
||||||
|
|
||||||
ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class);
|
|
||||||
if (! isUpdate) {
|
if (! isUpdate) {
|
||||||
String xmlProfile = publisher.registerGCUBEResource(rt, GCUBEScope.getScope(scope), new GCUBESecurityManagerImpl() {
|
String id = publisher.create(rt).id();
|
||||||
|
_log.trace("Created new RR sent, Got from publisher: id=" + id);
|
||||||
@Override
|
|
||||||
public boolean isSecurityEnabled() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
System.out.println("Created");
|
|
||||||
_log.trace("Created new RR sent, Got from publisher: \n" + xmlProfile);
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Updating " + rs.getResourceId());
|
System.out.println("Updating " + rs.getResourceId());
|
||||||
for (String scope2Update: rt.getScopes().keySet()) {
|
for (String scope2Update: rt.scopes()) {
|
||||||
GCUBEScope gScope = GCUBEScope.getScope(scope2Update);
|
ScopeProvider.instance.set(scope2Update);
|
||||||
ServiceMap map = loadServiceMap(scope2Update);
|
publisher.update(rt);
|
||||||
gScope.setServiceMap(map);
|
|
||||||
publisher.updateGCUBEResource(rt, gScope, new GCUBESecurityManagerImpl() {
|
|
||||||
@Override
|
|
||||||
public boolean isSecurityEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
System.out.println("Updated " + rs.getResourceId() + " on " + scope2Update);
|
System.out.println("Updated " + rs.getResourceId() + " on " + scope2Update);
|
||||||
}
|
}
|
||||||
System.out.println("Updated " + rt.getID());
|
_log.trace("Updated RR sent");
|
||||||
_log.trace("Updated RR sent, id: " + rt.getID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -181,6 +158,7 @@ public class RuntimeResourceCreatorServiceImpl extends RemoteServiceServlet impl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_log.info("Registration Request successfully Sent");
|
_log.info("Registration Request successfully Sent");
|
||||||
|
ScopeProvider.instance.set(currScope);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -227,72 +205,62 @@ public class RuntimeResourceCreatorServiceImpl extends RemoteServiceServlet impl
|
||||||
}
|
}
|
||||||
|
|
||||||
private FilledRuntimeResource getResource2EditById(String id) {
|
private FilledRuntimeResource getResource2EditById(String id) {
|
||||||
GCUBEScope scope = null;
|
|
||||||
try {
|
try {
|
||||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||||
GCUBERuntimeResourceQuery query = client.getQuery(GCUBERuntimeResourceQuery.class);
|
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||||
query.addAtomicConditions(new AtomicCondition("//ID", id));
|
query.addCondition("$resource/ID/text() eq '" + id + "'");
|
||||||
|
String currScope = ScopeProvider.instance.get();
|
||||||
scope = GCUBEScope.getScope(getASLSession().getScopeName());
|
ScopeProvider.instance.set(getASLSession().getScopeName());
|
||||||
|
List<ServiceEndpoint> resources = client.submit(query);
|
||||||
GCUBERuntimeResource rRes = client.execute(query,scope).get(0); //only one rr per id
|
ScopeProvider.instance.set(currScope);
|
||||||
|
ServiceEndpoint sEndPoint = null;
|
||||||
|
try {
|
||||||
|
sEndPoint = resources.get(0);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
return new FilledRuntimeResource();
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<RRAccessPoint> acPoints = new ArrayList<RRAccessPoint>();
|
ArrayList<RRAccessPoint> acPoints = new ArrayList<RRAccessPoint>();
|
||||||
for (AccessPoint ac : rRes.getAccessPoints()) {
|
for (AccessPoint ac : sEndPoint.profile().accessPoints()) {
|
||||||
RRAccessPoint rac = new RRAccessPoint();
|
RRAccessPoint rac = new RRAccessPoint();
|
||||||
|
|
||||||
rac.setInterfaceEndPoint(ac.getEndpoint());
|
rac.setInterfaceEndPoint(ac.address());
|
||||||
rac.setInterfaceEntryNameAttr(ac.getEntryname());
|
rac.setInterfaceEntryNameAttr(ac.name());
|
||||||
rac.setDesc(ac.getDescription());
|
rac.setDesc(ac.description());
|
||||||
rac.setUsername(ac.getUsername());
|
rac.setUsername(ac.username());
|
||||||
rac.setPassword(ac.getPassword());
|
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(ac.password());
|
||||||
|
rac.setPassword(decryptedPassword);
|
||||||
|
|
||||||
ArrayList<Property> props = new ArrayList<Property>();
|
ArrayList<Property> props = new ArrayList<Property>();
|
||||||
for (String prop : ac.getAllPropertyNames()) {
|
for (org.gcube.common.resources.gcore.ServiceEndpoint.Property prop : ac.properties()) {
|
||||||
String propValue = ac.getProperty(prop);
|
String propDecValue = prop.isEncrypted() ? StringEncrypter.getEncrypter().decrypt(prop.value()) :prop.value();
|
||||||
props.add(new Property(prop, propValue, ac.isPropertyEncrypted(prop)));
|
props.add(new Property(prop.name(), propDecValue, prop.isEncrypted()));
|
||||||
}
|
}
|
||||||
rac.setProperties(props);
|
rac.setProperties(props);
|
||||||
acPoints.add(rac);
|
acPoints.add(rac);
|
||||||
}
|
}
|
||||||
return new FilledRuntimeResource(id, acPoints, rRes.getName(), rRes.getVersion(), rRes.getCategory(), rRes.getDescription(),
|
return new FilledRuntimeResource(
|
||||||
rRes.getPlatform().getName(), ""+rRes.getPlatform().getVersion(), ""+rRes.getPlatform().getMinorVersion(), ""+rRes.getPlatform().getRevisionVersion(),
|
id,
|
||||||
""+rRes.getPlatform().getBuildVersion(), rRes.getHostedOn(), rRes.getStatus(), rRes.getGHN());
|
acPoints,
|
||||||
|
sEndPoint.profile().name(),
|
||||||
|
sEndPoint.profile().version(),
|
||||||
|
sEndPoint.profile().category(),
|
||||||
|
sEndPoint.profile().description(),
|
||||||
|
sEndPoint.profile().platform().name(),
|
||||||
|
""+sEndPoint.profile().platform().version(),
|
||||||
|
""+sEndPoint.profile().platform().minorVersion(),
|
||||||
|
""+sEndPoint.profile().platform().revisionVersion(),
|
||||||
|
""+sEndPoint.profile().platform().buildVersion(),
|
||||||
|
sEndPoint.profile().runtime().hostedOn(),
|
||||||
|
sEndPoint.profile().runtime().status(),
|
||||||
|
sEndPoint.profile().runtime().ghnId());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return new FilledRuntimeResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOT USED
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ArrayList<Category> getCategories() {
|
|
||||||
Set<Category> mySet = new HashSet<Category>();
|
|
||||||
ArrayList<Category> toReturn = new ArrayList<Category>();
|
|
||||||
GCUBEScope scope = null;
|
|
||||||
scope = GCUBEScope.getScope(getASLSession().getScopeName());
|
|
||||||
ISClient client;
|
|
||||||
try {
|
|
||||||
_log.info("Fetching gCube Runtime resource categories into " + scope.getName());
|
|
||||||
client = GHNContext.getImplementation(ISClient.class);
|
|
||||||
GCUBERuntimeResourceQuery query = client.getQuery(GCUBERuntimeResourceQuery.class);
|
|
||||||
for (GCUBERuntimeResource rRes : client.execute(query,scope)) {
|
|
||||||
toReturn.add(new Category(rRes.getCategory()));
|
|
||||||
}
|
|
||||||
for (Category category : mySet) {
|
|
||||||
toReturn.add(category);
|
|
||||||
}
|
|
||||||
return toReturn;
|
|
||||||
} catch (Exception e) {
|
|
||||||
_log.error("Generic Exception for " + scope.getName() + " " + e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
Loading…
Reference in New Issue