diff --git a/.classpath b/.classpath index efe22b7..9ed308d 100644 --- a/.classpath +++ b/.classpath @@ -5,9 +5,8 @@ - - + diff --git a/.fbprefs b/.fbprefs index 69ad2ed..54eb51c 100644 --- a/.fbprefs +++ b/.fbprefs @@ -1,5 +1,5 @@ #FindBugs User Preferences -#Tue Nov 04 12:23:33 CET 2008 +#Wed Mar 02 12:43:11 EST 2011 detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true detectorBadAppletConstructor=BadAppletConstructor|false detectorBadResultSetAccess=BadResultSetAccess|true @@ -17,12 +17,14 @@ detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOute detectorCrossSiteScripting=CrossSiteScripting|true detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true +detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true detectorDontUseEnum=DontUseEnum|true detectorDroppedException=DroppedException|true detectorDumbMethodInvocations=DumbMethodInvocations|true detectorDumbMethods=DumbMethods|true detectorDuplicateBranches=DuplicateBranches|true detectorEmptyZipFileEntry=EmptyZipFileEntry|true +detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true detectorFinalizerNullsFields=FinalizerNullsFields|true detectorFindBadCast2=FindBadCast2|true detectorFindBadForLoop=FindBadForLoop|true @@ -81,6 +83,7 @@ detectorInvalidJUnitTest=InvalidJUnitTest|true detectorIteratorIdioms=IteratorIdioms|true detectorLazyInit=LazyInit|true detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true +detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true detectorMethodReturnCheck=MethodReturnCheck|true detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true detectorMutableLock=MutableLock|true @@ -91,6 +94,7 @@ detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true detectorPublicSemaphores=PublicSemaphores|false detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true +detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true detectorRedundantInterfaces=RedundantInterfaces|true detectorRepeatedConditionals=RepeatedConditionals|true @@ -118,6 +122,6 @@ detectorWrongMapIterator=WrongMapIterator|true detectorXMLFactoryBypass=XMLFactoryBypass|true detector_threshold=2 effort=default -filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false -filter_settings_neg=| +filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false +filter_settings_neg=NOISE| run_at_full_build=true diff --git a/README b/README index 1d99a0b..24a6c71 100644 --- a/README +++ b/README @@ -18,7 +18,7 @@ Authors Version and Release Date ------------------------ -v. 1.3.3 (14-5-2010) +v. 2.0.0 (07-02-2011) Description @@ -33,15 +33,14 @@ Source code is available from SVN: http://svn.d4science.research-infrastructures.eu/gcube/trunk/ Binaries can be downloaded from: -http://software.d4science.research-infrastructures.eu/ +https://www.gcube-system.org/index.php?option=com_content&view=article&id=290&Itemid=48 Documentation ------------- Documentation is available on-line from the Projects Documentation Wiki: -https://technical.wiki.d4science.research-infrastructures.eu/documentation/index.php/IS-Registry - +https://gcube.wiki.gcube-system.org/gcube/index.php/IS-Registry Licensing --------- diff --git a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java index eff9499..106a701 100644 --- a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java +++ b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java @@ -1,16 +1,8 @@ package org.gcube.informationsystem.registry.impl.porttypes; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.io.StringWriter; import java.lang.reflect.Method; import java.rmi.RemoteException; import java.util.Calendar; - -import org.apache.axis.components.uuid.UUIDGen; -import org.apache.axis.components.uuid.UUIDGenFactory; import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.contexts.GCUBEServiceContext.Status; import org.gcube.common.core.faults.GCUBEFault; @@ -21,8 +13,6 @@ import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.informationsystem.registry.impl.contexts.FactoryContext; import org.gcube.informationsystem.registry.impl.contexts.ProfileContext; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext; -import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic; -import org.gcube.informationsystem.registry.impl.local.LocalNotifier; import org.gcube.informationsystem.registry.impl.state.ProfileResource; import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource; import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType; @@ -35,6 +25,9 @@ import org.gcube.informationsystem.registry.stubs.ResourceNotAcceptedFault; import org.gcube.informationsystem.registry.stubs.SchemaValidationFault; import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage; import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse; +import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage; +import org.gcube.informationsystem.registry.stubs.resourceregistration.RemoveMessage; +import org.gcube.informationsystem.registry.stubs.resourceregistration.UpdateMessage; import static org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType; @@ -45,10 +38,7 @@ import static org.gcube.informationsystem.registry.impl.state.Definitions.Resour * */ public class RegistryFactory extends GCUBEPortType { - - - /** The UUIDGen */ - private static final UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); + /** Object logger */ protected static final GCUBELog logger = new GCUBELog(RegistryFactory.class); @@ -117,63 +107,17 @@ public class RegistryFactory extends GCUBEPortType { public String createResource(CreateResourceMessage mess) throws SchemaValidationFault, RemoteException, ProfileAlreadyRegisteredFault, ResourceNotAcceptedFault { - GCUBEResource resource = null; - logger.info("CreateResource operation invoked in scope " + ServiceContext.getContext().getScope()); - // logSecurityInfo("createResource"); - - String profile = mess.getProfile(); - if (profile == null || profile.compareTo("") == 0) { - String msg = "Profile file is empty"; - logger.debug(msg); - throw new RemoteException(msg); - } try { - resource = ResourceType.valueOf(mess.getType()).getResourceClass(); - resource.load(new BufferedReader(new InputStreamReader( new ByteArrayInputStream(profile.getBytes("UTF-8")),"UTF-8"))); - - // the parse Profile class allows to extract from profiles - // information about type/SCOPE/UniqueID - // in order to distinguish among different Resource Type - // Adding scopes to Profile - String[] scopes = mess.getScopes(); - if (scopes != null) { - for (String scope : scopes) { - logger.debug(resource.getID() + " Adding Scopes to Profile " + scope); - resource.addScope(GCUBEScope.getScope(scope)); - } - } - // check ID - if (resource.getID() == null || resource.getID().compareTo("") == 0) { - resource.setID(uuidgen.nextUUID()); - } - - } catch (Exception ex) { - logger.error("Error trying to load profile", ex); - throw new SchemaValidationFault(); - } - try { - updateCounterInfo(resource.getID(), ResourceType.valueOf( - mess.getType()), OperationType.create, - Calendar.getInstance(), mess.getProfile()); - - LocalNotifier.notifyEvent(resource, RegistryTopic.CREATE); - } catch (Exception e) { - logger.warn("Error updating Counting info for resource with ID " + resource.getID(), e); - } - - - StringWriter writer = new StringWriter(); - try { - resource.store(writer); - logger.info("Profile " + resource.getID() + " created "); - return writer.toString(); + ResourceRegistration registration = new ResourceRegistration(); + CreateMessage message = new CreateMessage(mess.getProfile(), mess.getType()); + registration.create(message); } catch (Exception e) { - logger.error("Persistence failed for " + resource.getID(), e); - return null; + logger.error("", e); + throw new ResourceNotAcceptedFault(); } - + return ""; } @@ -190,35 +134,16 @@ public class RegistryFactory extends GCUBEPortType { public UpdateResourceResponse updateResource(UpdateResourceMessage mess) throws RemoteException, SchemaValidationFault, ResourceNotAcceptedFault, GCUBEFault { - logger.info("UpdateResource operation invoked"); - String ID = mess.getUniqueID(); - String xmlProfile = mess.getXmlProfile(); - GCUBEResource resource = null; - // validating input parameters - if (ID == null || ID.compareTo("") == 0) { - logger.debug(" ID missing "); - throw new RemoteException("Error, ID missing"); - } - if (xmlProfile == null || xmlProfile.compareTo("") == 0) { - logger.debug("Profile missing"); - throw new RemoteException("Error, profile missing"); - } - try { - resource = ResourceType.valueOf(mess.getType()).getResourceClass(); - resource.load(new StringReader(xmlProfile)); - } catch (Exception e) { - logger.error("Error updating profile for ID " + e); - throw new RemoteException(e.toString()); - } + logger.info("UpdateResource operation invoked in scope " + ServiceContext.getContext().getScope()); try { - updateCounterInfo(ID, ResourceType.valueOf(mess.getType()), - OperationType.update, Calendar.getInstance(), xmlProfile); - LocalNotifier.notifyEvent(resource, RegistryTopic.UPDATE); + ResourceRegistration registration = new ResourceRegistration(); + UpdateMessage message = new UpdateMessage(mess.getType(), mess.getUniqueID(), mess.getXmlProfile()); + registration.update(message); } catch (Exception e) { - logger.warn("Error while updating the counting info for resource with ID " + resource.getID(), e); + logger.error("", e); + throw new ResourceNotAcceptedFault(); } - logger.info("Profile " + mess.getUniqueID() + " updated"); return new UpdateResourceResponse(); } @@ -231,26 +156,18 @@ public class RegistryFactory extends GCUBEPortType { */ public RemoveResourceResponse removeResource( - RemoveResourceMessage inputMessage) throws RemoteException, GCUBEFault { + RemoveResourceMessage mess) throws RemoteException, GCUBEFault { - String ID = inputMessage.getUniqueID(); - String type = inputMessage.getType(); - logger.info("RemoveResource operation invoked on resource ID=" + ID + ", type=" + type); - if (ID == null || ID.compareTo("") == 0) { - logger.warn("Resource ID is missing, cannot manage the resource"); - throw new RemoteException("Resource ID is missing, cannot manage the resource"); + logger.info("RemoveResource operation invoked in scope " + ServiceContext.getContext().getScope()); + + try { + ResourceRegistration registration = new ResourceRegistration(); + RemoveMessage message = new RemoveMessage(mess.getType(), mess.getUniqueID()); + registration.remove(message); + } catch (Exception e) { + logger.error("", e); + throw new RemoteException(); } - try { - GCUBEResource resource = ResourceType.valueOf(type).getResourceClass(); - resource.setID(ID); - LocalNotifier.notifyEvent(resource, RegistryTopic.REMOVE); - updateCounterInfo(ID, ResourceType.valueOf(type),OperationType.destroy, Calendar.getInstance(), null); - } catch (Exception e) { - logger.warn( - "Error updating counting info for resource with ID " - + ID, e); - } - //} return new RemoveResourceResponse(); diff --git a/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java b/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java index 9c1ddff..1dbfa97 100644 --- a/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java +++ b/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java @@ -177,7 +177,7 @@ public class ResourceRegistration extends GCUBEPortType { try { resource = ResourceType.valueOf(type).getResourceClass(); resource.load(new BufferedReader(new InputStreamReader( new ByteArrayInputStream(profile.getBytes("UTF-8")),"UTF-8"))); - resource.addScope(ServiceContext.getContext().getScope()); + //resource.addScope(ServiceContext.getContext().getScope()); // check the ID if (resource.getID() == null || resource.getID().compareTo("") == 0) {