git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@381 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ba50494d88
commit
1484ce8f50
|
@ -46,7 +46,7 @@
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
|
||||||
<xsd:complexType name="UpdateProfileMessage">
|
<xsd:complexType name="UpdateResourceMessage">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="uniqueID" type="xsd:string"/>
|
<xsd:element name="uniqueID" type="xsd:string"/>
|
||||||
<xsd:element name="type" type="xsd:string"/>
|
<xsd:element name="type" type="xsd:string"/>
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
|
|
||||||
<xsd:element name="createResourceResponse" type="xsd:string"/>
|
<xsd:element name="createResourceResponse" type="xsd:string"/>
|
||||||
|
|
||||||
<xsd:element name="updateResource" type="tns:UpdateProfileMessage"/>
|
<xsd:element name="updateResource" type="tns:UpdateResourceMessage"/>
|
||||||
|
|
||||||
<xsd:element name="updateResourceResponse">
|
<xsd:element name="updateResourceResponse">
|
||||||
<xsd:complexType/>
|
<xsd:complexType/>
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.gcube.informationsystem.registry.stubs.RemoveScopeInProfileMessage;
|
||||||
import org.gcube.informationsystem.registry.stubs.SchemaValidationFault;
|
import org.gcube.informationsystem.registry.stubs.SchemaValidationFault;
|
||||||
import org.gcube.informationsystem.registry.stubs.StartRegistration;
|
import org.gcube.informationsystem.registry.stubs.StartRegistration;
|
||||||
import org.gcube.informationsystem.registry.stubs.StartRegistrationResponse;
|
import org.gcube.informationsystem.registry.stubs.StartRegistrationResponse;
|
||||||
import org.gcube.informationsystem.registry.stubs.UpdateProfileMessage;
|
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
|
||||||
import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse;
|
import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse;
|
||||||
import org.gcube.informationsystem.registry.stubs.UpdateScopeInProfileMessage;
|
import org.gcube.informationsystem.registry.stubs.UpdateScopeInProfileMessage;
|
||||||
import org.gcube.informationsystem.registry.stubs.UpdateStateMessage;
|
import org.gcube.informationsystem.registry.stubs.UpdateStateMessage;
|
||||||
|
@ -58,6 +58,25 @@ import org.oasis.wsrf.lifetime.Destroy;
|
||||||
*/
|
*/
|
||||||
public class RegistryFactory extends GCUBEStartupPortType{
|
public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
|
|
||||||
|
public enum ResourceType {
|
||||||
|
RunningInstance,
|
||||||
|
ExternalRunningInstance,
|
||||||
|
Service,
|
||||||
|
Collection,
|
||||||
|
CS,
|
||||||
|
CSInstance,
|
||||||
|
GHN,
|
||||||
|
gLiteSE,
|
||||||
|
gLiteCE,
|
||||||
|
gLiteSite,
|
||||||
|
gLiteService,
|
||||||
|
VRE,
|
||||||
|
Generic,
|
||||||
|
TransformationProgram,
|
||||||
|
MetadataCollection
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UUIDGen
|
* The UUIDGen
|
||||||
|
@ -74,7 +93,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum operationType {create,update,destroy};
|
public enum OperationType {create,update,destroy};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of registration to Notification
|
* Map of registration to Notification
|
||||||
|
@ -157,23 +176,30 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
}
|
}
|
||||||
//check if the Resource already exists
|
//check if the Resource already exists
|
||||||
if (isResourceCreated(resource.getID())) {
|
if (isResourceCreated(resource.getID())) {
|
||||||
logger.debug("A Resource with ID "+ resource.getID()+" is already registered");
|
// update the existing resource
|
||||||
throw new ProfileAlreadyRegisteredFault();
|
logger.warn("A Resource with ID "+ resource.getID()+" is already registered");
|
||||||
}
|
UpdateResourceMessage mess = new UpdateResourceMessage();
|
||||||
//try to create resource
|
mess.setUniqueID(resource.getID());
|
||||||
try {
|
mess.setXmlProfile(inputMessage.getProfile());
|
||||||
logger.debug("Creating the stateful resource for " + resource.getID());
|
mess.setType(inputMessage.getType());
|
||||||
ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
|
this.updateResource(mess);
|
||||||
}
|
//throw new ProfileAlreadyRegisteredFault();
|
||||||
catch (Exception ex) {
|
} else {
|
||||||
String msg = "Error creating Resource";
|
//try to create resource
|
||||||
logger.error(msg,ex);
|
try {
|
||||||
throw new RemoteException(msg);
|
logger.debug("Creating the stateful resource for " + resource.getID());
|
||||||
}
|
ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
|
||||||
try {
|
}
|
||||||
updateCounterInfo (resource.getID(),inputMessage.getType(),operationType.create.name(),Calendar.getInstance());
|
catch (Exception ex) {
|
||||||
} catch (Exception e) {
|
String msg = "Error creating Resource";
|
||||||
logger.error("Error updating Counting info for resource with ID " + resource.getID());
|
logger.error(msg,ex);
|
||||||
|
throw new RemoteException(msg);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
updateCounterInfo (resource.getID(),inputMessage.getType(), OperationType.create.name(),Calendar.getInstance());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error updating Counting info for resource with ID " + resource.getID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
@ -183,6 +209,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Persistence failed for " + resource.getID(), e);
|
logger.error("Persistence failed for " + resource.getID(), e);
|
||||||
}
|
}
|
||||||
|
logger.info("Profile created: " + writer.toString());
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +223,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
* @throws RemoteException Exception
|
* @throws RemoteException Exception
|
||||||
* @throws SchemaValidationException Exception
|
* @throws SchemaValidationException Exception
|
||||||
*/
|
*/
|
||||||
public UpdateResourceResponse updateResource(UpdateProfileMessage mess) throws RemoteException,SchemaValidationFault,GCUBEFault {
|
public UpdateResourceResponse updateResource(UpdateResourceMessage mess) throws RemoteException,SchemaValidationFault,GCUBEFault {
|
||||||
|
|
||||||
logSecurityInfo("updateResource");
|
logSecurityInfo("updateResource");
|
||||||
logger.info("UpdateResource operation invoked");
|
logger.info("UpdateResource operation invoked");
|
||||||
|
@ -232,12 +259,12 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
updateCounterInfo (ID,mess.getType(),operationType.update.name(),Calendar.getInstance());
|
updateCounterInfo (ID,mess.getType(), OperationType.update.name(),Calendar.getInstance());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error updating Counting info for resource with ID " + resource.getID());
|
logger.error("Error updating Counting info for resource with ID " + resource.getID());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
logger.info("Profile updated");
|
logger.info("Profile updated: " + mess.getXmlProfile());
|
||||||
return new UpdateResourceResponse();
|
return new UpdateResourceResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +332,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
}
|
}
|
||||||
logger.info(" Profile destroyed");
|
logger.info(" Profile destroyed");
|
||||||
try {
|
try {
|
||||||
updateCounterInfo(ID,type,operationType.destroy.name(),Calendar.getInstance());
|
updateCounterInfo(ID,type,OperationType.destroy.name(),Calendar.getInstance());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.error("Error updating Counting info for resource with ID " + ID);
|
logger.error("Error updating Counting info for resource with ID " + ID);
|
||||||
|
@ -372,6 +399,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
* @throws Exception Exception
|
* @throws Exception Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private synchronized void updateCounterInfo(String ID, String type, String operationType, Calendar updateTime) throws Exception{
|
private synchronized void updateCounterInfo(String ID, String type, String operationType, Calendar updateTime) throws Exception{
|
||||||
|
|
||||||
RegistryProperty property = new RegistryProperty();
|
RegistryProperty property = new RegistryProperty();
|
||||||
|
@ -429,25 +457,6 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ResourceType {
|
|
||||||
RunningInstance,
|
|
||||||
ExternalRunningInstance,
|
|
||||||
Service,
|
|
||||||
Collection,
|
|
||||||
CS,
|
|
||||||
CSInstance,
|
|
||||||
GHN,
|
|
||||||
gLiteSE,
|
|
||||||
gLiteCE,
|
|
||||||
gLiteSite,
|
|
||||||
gLiteService,
|
|
||||||
VRE,
|
|
||||||
Generic,
|
|
||||||
TransformationProgram,
|
|
||||||
MetadataCollection
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
|
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
|
||||||
import org.gcube.common.core.state.GCUBEWSResource;
|
import org.gcube.common.core.state.GCUBEWSResource;
|
||||||
import org.gcube.informationsystem.registry.impl.util.RegistrationThread;
|
import org.gcube.informationsystem.registry.impl.util.RegistrationThread;
|
||||||
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
|
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
|
||||||
|
@ -53,11 +51,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
protected static final String RunningInstanceRP="RunningInstance";
|
protected static final String RunningInstanceRP="RunningInstance";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String[] getTopicNames() {
|
|
||||||
return RPNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static String[] RPNames = {
|
protected static String[] RPNames = {
|
||||||
RunningInstanceRP,
|
RunningInstanceRP,
|
||||||
ExternalRunningInstanceRP,
|
ExternalRunningInstanceRP,
|
||||||
|
@ -77,6 +70,16 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getTopicNames() {
|
||||||
|
return RPNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getPropertyNames() {
|
||||||
|
return RPNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -93,8 +96,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
/* Initialize the RP's */
|
/* Initialize the RP's */
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
//Topic List creation for registrationto is-Notifier
|
||||||
// Topic List creation for registrationto is-Notifier
|
|
||||||
listQname = new ArrayList<QName>();
|
listQname = new ArrayList<QName>();
|
||||||
for (String rpName : RPNames)
|
for (String rpName : RPNames)
|
||||||
listQname.add(new QName(this.getPorttypeContext().getNamespace(),rpName));
|
listQname.add(new QName(this.getPorttypeContext().getNamespace(),rpName));
|
||||||
|
@ -110,6 +112,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on Initialization of Resource",e);
|
logger.error("Error on Initialization of Resource",e);
|
||||||
|
throw new ResourceException("Failed to initialise the RPs and related topics");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,6 +125,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RI property
|
* @param property The RI property
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setRunningInstance (RegistryProperty property) {
|
public void setRunningInstance (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(RunningInstanceRP).clear();
|
this.getResourcePropertySet().get(RunningInstanceRP).clear();
|
||||||
this.getResourcePropertySet().get(RunningInstanceRP).add(property);
|
this.getResourcePropertySet().get(RunningInstanceRP).add(property);
|
||||||
|
@ -146,6 +150,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setExternalRunningInstance (RegistryProperty property) {
|
public void setExternalRunningInstance (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(ExternalRunningInstanceRP).clear();
|
this.getResourcePropertySet().get(ExternalRunningInstanceRP).clear();
|
||||||
this.getResourcePropertySet().get(ExternalRunningInstanceRP).add(property);
|
this.getResourcePropertySet().get(ExternalRunningInstanceRP).add(property);
|
||||||
|
@ -172,6 +177,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setService (RegistryProperty property) {
|
public void setService (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(ServiceRP).clear();
|
this.getResourcePropertySet().get(ServiceRP).clear();
|
||||||
this.getResourcePropertySet().get(ServiceRP).add(property);
|
this.getResourcePropertySet().get(ServiceRP).add(property);
|
||||||
|
@ -197,6 +203,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setCollection (RegistryProperty property) {
|
public void setCollection (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(CollectionRP).clear();
|
this.getResourcePropertySet().get(CollectionRP).clear();
|
||||||
this.getResourcePropertySet().get(CollectionRP).add(property);
|
this.getResourcePropertySet().get(CollectionRP).add(property);
|
||||||
|
@ -221,6 +228,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setCS (RegistryProperty property) {
|
public void setCS (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(CSRP).clear();
|
this.getResourcePropertySet().get(CSRP).clear();
|
||||||
this.getResourcePropertySet().get(CSRP).add(property);
|
this.getResourcePropertySet().get(CSRP).add(property);
|
||||||
|
@ -245,6 +253,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setCSInstance (RegistryProperty property) {
|
public void setCSInstance (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(CSInstanceRP).clear();
|
this.getResourcePropertySet().get(CSInstanceRP).clear();
|
||||||
this.getResourcePropertySet().get(CSInstanceRP).add(property);
|
this.getResourcePropertySet().get(CSInstanceRP).add(property);
|
||||||
|
@ -270,6 +279,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGHN (RegistryProperty property) {
|
public void setGHN (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(GHNRP).clear();
|
this.getResourcePropertySet().get(GHNRP).clear();
|
||||||
this.getResourcePropertySet().get(GHNRP).add(property);
|
this.getResourcePropertySet().get(GHNRP).add(property);
|
||||||
|
@ -293,6 +303,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGLiteSE (RegistryProperty property) {
|
public void setGLiteSE (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(gLiteSERP).clear();
|
this.getResourcePropertySet().get(gLiteSERP).clear();
|
||||||
this.getResourcePropertySet().get(gLiteSERP).add(property);
|
this.getResourcePropertySet().get(gLiteSERP).add(property);
|
||||||
|
@ -316,6 +327,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGLiteCE (RegistryProperty property) {
|
public void setGLiteCE (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(gLiteCERP).clear();
|
this.getResourcePropertySet().get(gLiteCERP).clear();
|
||||||
this.getResourcePropertySet().get(gLiteCERP).add(property);
|
this.getResourcePropertySet().get(gLiteCERP).add(property);
|
||||||
|
@ -341,6 +353,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGLiteSite (RegistryProperty property) {
|
public void setGLiteSite (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(gLiteSiteRP).clear();
|
this.getResourcePropertySet().get(gLiteSiteRP).clear();
|
||||||
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
|
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
|
||||||
|
@ -365,6 +378,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGLiteService (RegistryProperty property) {
|
public void setGLiteService (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(gLiteServiceRP).clear();
|
this.getResourcePropertySet().get(gLiteServiceRP).clear();
|
||||||
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
|
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
|
||||||
|
@ -388,6 +402,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setVRE (RegistryProperty property) {
|
public void setVRE (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(VRERP).clear();
|
this.getResourcePropertySet().get(VRERP).clear();
|
||||||
this.getResourcePropertySet().get(VRERP).add(property);
|
this.getResourcePropertySet().get(VRERP).add(property);
|
||||||
|
@ -412,6 +427,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setMetaColl (RegistryProperty property) {
|
public void setMetaColl (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
|
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
|
||||||
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
|
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
|
||||||
|
@ -436,6 +452,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setTransProgram (RegistryProperty property) {
|
public void setTransProgram (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).clear();
|
this.getResourcePropertySet().get(TransformationProgramRP).clear();
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
|
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
|
||||||
|
@ -460,6 +477,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
* @param property The RegistryProperty
|
* @param property The RegistryProperty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void setGenericResource (RegistryProperty property) {
|
public void setGenericResource (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(GenericRP).clear();
|
this.getResourcePropertySet().get(GenericRP).clear();
|
||||||
this.getResourcePropertySet().get(GenericRP).add(property);
|
this.getResourcePropertySet().get(GenericRP).add(property);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.gcube.common.core.resources.GCUBEResource;
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IS-Registry service context
|
* IS-Registry service context
|
||||||
*
|
*
|
||||||
|
@ -25,6 +24,17 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
|
|
||||||
protected static ServiceContext cache = new ServiceContext();
|
protected static ServiceContext cache = new ServiceContext();
|
||||||
|
|
||||||
|
protected ISClient client = null;
|
||||||
|
|
||||||
|
protected GCUBERIsFromClassAndName queryRI = null;
|
||||||
|
|
||||||
|
protected GCUBEResourceXPathQuery queryGHN = null;
|
||||||
|
|
||||||
|
protected boolean isNotifierCodeployed = false;
|
||||||
|
|
||||||
|
protected boolean isICCodeployed = false;
|
||||||
|
|
||||||
|
|
||||||
private ServiceContext() {}
|
private ServiceContext() {}
|
||||||
|
|
||||||
public static ServiceContext getContext() {
|
public static ServiceContext getContext() {
|
||||||
|
@ -37,122 +47,40 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReady() throws Exception {
|
protected void onReady() throws Exception {
|
||||||
|
//GCUBERunningInstance GHNManagerProfile = null;
|
||||||
GCUBERunningInstance RegistryRIProfile = null;
|
|
||||||
|
|
||||||
GCUBERunningInstance NotifierRIProfile = null;
|
|
||||||
|
|
||||||
GCUBERunningInstance ISICRIProfile = null;
|
|
||||||
|
|
||||||
GCUBERunningInstance GHNManagerProfile = null;
|
|
||||||
|
|
||||||
GCUBEHostingNode ghnProfile = null;
|
|
||||||
|
|
||||||
String ghnName = "";
|
|
||||||
|
|
||||||
GCUBERIsFromClassAndName queryRI = null;
|
|
||||||
|
|
||||||
GCUBEResourceXPathQuery queryGHN = null;
|
|
||||||
|
|
||||||
boolean isNotifierCodeployed = false;
|
|
||||||
|
|
||||||
boolean isICCodeployed = false;
|
|
||||||
|
|
||||||
ISClient client = null;
|
|
||||||
|
|
||||||
|
|
||||||
//creates the single RegistryResource used to raise notifications about profiles' changes
|
//creates the single RegistryResource used to raise notifications about profiles' changes
|
||||||
logger.info("Creating IS-Registry notification resource...");
|
logger.info("Creating IS-Registry notification resource...");
|
||||||
FactoryContext.getContext().getWSHome().create(
|
new Thread() {
|
||||||
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
FactoryContext.getContext().getWSHome().create(
|
||||||
|
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
||||||
|
} catch (Exception e) {
|
||||||
|
ServiceContext.this.logger.error("Failed to create the notification resource", e);
|
||||||
|
}
|
||||||
|
}}.start();
|
||||||
|
|
||||||
logger.info("IS-Registry notification resource registered");
|
logger.info("IS-Registry notification resource registered");
|
||||||
|
|
||||||
// create GeneralQueryManager
|
try {Thread.sleep(20000);} catch (InterruptedException e1) {
|
||||||
try {
|
logger.error("Unable to get the service instance profile", e1);
|
||||||
client = GHNContext.getImplementation(ISClient.class);
|
|
||||||
queryRI = client.getQuery(GCUBERIsFromClassAndName.class);
|
|
||||||
queryGHN = client.getQuery(GCUBEResourceXPathQuery.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed to create a QueryManger", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
RegistryRIProfile = ServiceContext.getContext().getInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Unable to get the service instance profile", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
NotifierRIProfile = GHNContext.getContext().getServiceContext(
|
|
||||||
ROOT_SERVICES.ISNOTIFIER.getClazz(), ROOT_SERVICES.ISNOTIFIER.getName()).getInstance();
|
|
||||||
isNotifierCodeployed = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn("Unable to detect if the " + ROOT_SERVICES.ISNOTIFIER.getName() + " is co-deployed");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
GHNManagerProfile = GHNContext.getContext().getServiceContext(ROOT_SERVICES.GHNMANAGER.getClazz(), ROOT_SERVICES.GHNMANAGER.getName()).getInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn("Unable to detect if the " + ROOT_SERVICES.GHNMANAGER.getName() + " is co-deployed");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
ISICRIProfile = GHNContext.getContext().getServiceContext( ROOT_SERVICES.ISIC.getClazz(), ROOT_SERVICES.ISIC.getName()).getInstance();
|
|
||||||
isICCodeployed = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn("Unable to detect if the " + ROOT_SERVICES.ISIC.getName() + " is co-deployed");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
ghnProfile = GHNContext.getContext().getGHN();
|
|
||||||
ghnName = ghnProfile.getNodeDescription().getName();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Unable to get the GHN profile", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(20000);
|
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
logger.error("Unable to get the servce instance profile", e1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the Registry profile is already registered
|
// Check if the Registry profile is already registered
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// registers the my profile
|
// registers the my profile
|
||||||
queryRI.setEntryName("gcube/informationsystem/registry/RegistryFactory");
|
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
||||||
queryRI.setResourceClass(this.getServiceClass());
|
this.queryRI.setEntryName("gcube/informationsystem/registry/RegistryFactory");
|
||||||
queryRI.setResourceName(this.getName());
|
this.queryRI.setResourceClass(this.getServiceClass());
|
||||||
if (client.execute(queryRI,
|
this.queryRI.setResourceName(this.getName());
|
||||||
|
if (client.execute(this.queryRI,
|
||||||
GHNContext.getContext().getDefaultScope()).size() == 0)
|
GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
||||||
|
|
||||||
// registers the local IS-Notifier profile
|
this.checkCodeployedServices();
|
||||||
if (isNotifierCodeployed) {
|
|
||||||
queryRI.setEntryName("gcube/informationsystem/notifier/Notifier");
|
|
||||||
queryRI.setResourceClass(ROOT_SERVICES.ISNOTIFIER.getClazz());
|
|
||||||
queryRI.setResourceName(ROOT_SERVICES.ISNOTIFIER.getName());
|
|
||||||
if (client.execute(queryRI,
|
|
||||||
GHNContext.getContext().getDefaultScope()).size() == 0)
|
|
||||||
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// registers the local IS-IC profile
|
|
||||||
if (isICCodeployed) {
|
|
||||||
queryRI.setEntryName("gcube/informationsystem/isic/ISICFactoryService");
|
|
||||||
queryRI.setResourceClass(ROOT_SERVICES.ISIC.getClazz());
|
|
||||||
queryRI.setResourceName(ROOT_SERVICES.ISIC.getName());
|
|
||||||
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size() == 0)
|
|
||||||
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
}
|
|
||||||
// registers the local GHNManager profile
|
|
||||||
queryGHN.setResourceType(GCUBEHostingNode.TYPE);
|
|
||||||
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
|
|
||||||
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size() == 0)
|
|
||||||
registerProfile(ghnProfile, GCUBEHostingNode.TYPE);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to register co-deployed services", e);
|
logger.error("Failed to register co-deployed services", e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -161,7 +89,12 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onInitialisation() throws Exception {}
|
protected void onInitialisation() throws Exception {
|
||||||
|
//get the needed implementation classes
|
||||||
|
this.client = GHNContext.getImplementation(ISClient.class);
|
||||||
|
this.queryRI = this.client.getQuery(GCUBERIsFromClassAndName.class);
|
||||||
|
this.queryGHN = this.client.getQuery(GCUBEResourceXPathQuery.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the Profile
|
* Register the Profile
|
||||||
|
@ -182,4 +115,74 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkCodeployedServices () throws Exception {
|
||||||
|
|
||||||
|
GCUBERunningInstance NotifierRIProfile = null;
|
||||||
|
GCUBERunningInstance ISICRIProfile = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
NotifierRIProfile = GHNContext.getContext().getServiceContext(
|
||||||
|
ROOT_SERVICES.ISNOTIFIER.getClazz(), ROOT_SERVICES.ISNOTIFIER.getName()).getInstance();
|
||||||
|
isNotifierCodeployed = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Unable to detect if the " + ROOT_SERVICES.ISNOTIFIER.getName() + " is co-deployed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*try {
|
||||||
|
ManagerRIProfile = GHNContext.getContext().getServiceContext(ROOT_SERVICES.GHNMANAGER.getClazz(), ROOT_SERVICES.GHNMANAGER.getName()).getInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Unable to detect if the " + ROOT_SERVICES.GHNMANAGER.getName() + " is co-deployed");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
ISICRIProfile = GHNContext.getContext().getServiceContext( ROOT_SERVICES.ISIC.getClazz(), ROOT_SERVICES.ISIC.getName()).getInstance();
|
||||||
|
isICCodeployed = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Unable to detect if the " + ROOT_SERVICES.ISIC.getName() + " is co-deployed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// registers the local IS-Notifier profile
|
||||||
|
if (isNotifierCodeployed) {
|
||||||
|
queryRI.setEntryName("gcube/informationsystem/notifier/Notifier");
|
||||||
|
queryRI.setResourceClass(ROOT_SERVICES.ISNOTIFIER.getClazz());
|
||||||
|
queryRI.setResourceName(ROOT_SERVICES.ISNOTIFIER.getName());
|
||||||
|
if (client.execute(queryRI,
|
||||||
|
GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
|
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// registers the local IS-IC profile
|
||||||
|
if (isICCodeployed) {
|
||||||
|
queryRI.setEntryName("gcube/informationsystem/isic/ISICFactoryService");
|
||||||
|
queryRI.setResourceClass(ROOT_SERVICES.ISIC.getClazz());
|
||||||
|
queryRI.setResourceName(ROOT_SERVICES.ISIC.getName());
|
||||||
|
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
|
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE);
|
||||||
|
}
|
||||||
|
// registers the local GHNManager profile
|
||||||
|
GCUBEHostingNode ghnProfile = GHNContext.getContext().getGHN();
|
||||||
|
String ghnName = ghnProfile.getNodeDescription().getName();
|
||||||
|
queryGHN.setResourceType(GCUBEHostingNode.TYPE);
|
||||||
|
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
|
||||||
|
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
|
registerProfile(ghnProfile, GCUBEHostingNode.TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if the IS-Notifier service is co-deployed on the node
|
||||||
|
*/
|
||||||
|
protected boolean isNotifierCodeployed() {
|
||||||
|
return isNotifierCodeployed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if the IS-IC service is co-deployed on the node
|
||||||
|
*/
|
||||||
|
protected boolean isICCodeployed() {
|
||||||
|
return isICCodeployed;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ import org.gcube.common.core.resources.GCUBEService;
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
||||||
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
||||||
import org.gcube.informationsystem.registry.stubs.UpdateProfileMessage;
|
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
|
||||||
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
||||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public static void main (String[]args ) throws Exception {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
UpdateProfileMessage message = new UpdateProfileMessage();
|
UpdateResourceMessage message = new UpdateResourceMessage();
|
||||||
|
|
||||||
managerSec.useCredentials(cred);
|
managerSec.useCredentials(cred);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue