From 8ac030e295e379ea260f36daaeeae7ddda8be361 Mon Sep 17 00:00:00 2001 From: "nikolas.laskaris" Date: Tue, 3 Sep 2013 09:43:58 +0000 Subject: [PATCH] Renamed ASLGenericResource to GenericResource - as it was named before the FeatherWeight reformation. Because there is a GenericResource class in the feaherweight libs, we refer to that with the full path org.gcube.common.resources.gcore.GenericResource git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@81020 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../core/security/ServiceContextManager.java | 33 ++++++--------- ...ericResource.java => GenericResource.java} | 42 +++++++++---------- .../gcube/common/core/scope/GCUBEScope.java | 20 +++++++++ 3 files changed, 53 insertions(+), 42 deletions(-) rename src/main/java/org/gcube/application/framework/core/util/{ASLGenericResource.java => GenericResource.java} (87%) create mode 100644 src/main/java/org/gcube/common/core/scope/GCUBEScope.java diff --git a/src/main/java/org/gcube/application/framework/core/security/ServiceContextManager.java b/src/main/java/org/gcube/application/framework/core/security/ServiceContextManager.java index d7b9d13..7930941 100644 --- a/src/main/java/org/gcube/application/framework/core/security/ServiceContextManager.java +++ b/src/main/java/org/gcube/application/framework/core/security/ServiceContextManager.java @@ -11,40 +11,31 @@ import org.gcube.soa3.connector.common.security.Credentials; //import org.gcube.common.core.security.GCUBESecurityManager; import org.ietf.jgss.GSSCredential; +/** + * SHOULD RECODE CLASS THE FUNCTIONS, USING THE NEW FEATHERWEIGHT SECURITY MODEL + * + * @author nikolas + * + * @param + */ public class ServiceContextManager { -/* - public static PORTTYPE applySecurity(PORTTYPE stub, ASLSession session) throws Exception - { - + //TODO: SHOULD RECODE THE FUNCTIONS, USING THE NEW FEATHERWEIGHT SECURITY MODEL + /* + public static PORTTYPE applySecurity(PORTTYPE stub, ASLSession session) throws Exception{ Credentials credentials = CredentialManager.instance.get(); - - secController = - - GCUBESecurityManager secManager = new PortalSecurityManager(session); - - if(secManager.isSecurityEnabled()) - { secManager.useCredentials(session.getCredential()); - } return GCUBERemotePortTypeContext.getProxy(stub , session.getScope(), secManager); - } - - public static PORTTYPE applySecurity(PORTTYPE stub, String scope, GSSCredential cred) throws Exception - { - + public static PORTTYPE applySecurity(PORTTYPE stub, String scope, GSSCredential cred) throws Exception{ GCUBESecurityManager secManager = new PortalSecurityManager(scope); if(secManager.isSecurityEnabled()) - { secManager.useCredentials(cred); - } return GCUBERemotePortTypeContext.getProxy(stub , scope, secManager); - } -*/ + */ } diff --git a/src/main/java/org/gcube/application/framework/core/util/ASLGenericResource.java b/src/main/java/org/gcube/application/framework/core/util/GenericResource.java similarity index 87% rename from src/main/java/org/gcube/application/framework/core/util/ASLGenericResource.java rename to src/main/java/org/gcube/application/framework/core/util/GenericResource.java index 05ed8e7..4b6a2c0 100644 --- a/src/main/java/org/gcube/application/framework/core/util/ASLGenericResource.java +++ b/src/main/java/org/gcube/application/framework/core/util/GenericResource.java @@ -41,7 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.gcube.resources.discovery.icclient.ICFactory.*; -import org.gcube.common.resources.gcore.GenericResource; +//import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource.Type; import org.gcube.common.resources.gcore.Resources; @@ -51,10 +51,10 @@ import org.gcube.common.resources.gcore.Resources; * @author Valia Tsagkalidou (NKUA) * @author Nikolas Laskaris (NKUA) -- refactored August 2013 to conform to FeatherWeight stack standards */ -public class ASLGenericResource implements GenericResourceInfoI { +public class GenericResource implements GenericResourceInfoI { /** The logger. */ - private static final Logger logger = LoggerFactory.getLogger(ASLGenericResource.class); + private static final Logger logger = LoggerFactory.getLogger(GenericResource.class); /** * A static IS publisher in order to communicate with IS (FeatherWeight) @@ -64,7 +64,7 @@ public class ASLGenericResource implements GenericResourceInfoI { protected static ScopedPublisher scopedPublisher = null; protected static RegistryPublisher publisher = null; - protected static DiscoveryClient client = null; + protected static DiscoveryClient client = null; /** * The D4Science session to be used @@ -76,7 +76,7 @@ public class ASLGenericResource implements GenericResourceInfoI { * @param extrenalSessionID the external session id which is used for the D4ScienceSession (usually the session.getId() of the HttpSession or PortletSession) * @param username the username of the user that called this constructor */ - public ASLGenericResource(String extrenalSessionID, String username) + public GenericResource(String extrenalSessionID, String username) { session = SessionManager.getInstance().getASLSession(extrenalSessionID, username); @@ -90,7 +90,7 @@ public class ASLGenericResource implements GenericResourceInfoI { if(client == null) { try { - client = clientFor(GenericResource.class); //GHNContext.getImplementation(ISClient.class); + client = clientFor(org.gcube.common.resources.gcore.GenericResource.class); //GHNContext.getImplementation(ISClient.class); } catch (Exception e) { // TODO Auto-generated catch block logger.error("Exception:", e); @@ -105,7 +105,7 @@ public class ASLGenericResource implements GenericResourceInfoI { * Constructs a GenericReosurce object * @param session the D4Science session to be used for retrieving information needed */ - public ASLGenericResource(ASLSession session) { + public GenericResource(ASLSession session) { super(); this.session = session; try { @@ -118,7 +118,7 @@ public class ASLGenericResource implements GenericResourceInfoI { if(client == null) { try { - client = clientFor(GenericResource.class); + client = clientFor(org.gcube.common.resources.gcore.GenericResource.class); } catch (Exception e) { // TODO Auto-generated catch block logger.error("Exception:", e); @@ -158,7 +158,7 @@ public class ASLGenericResource implements GenericResourceInfoI { public String createGenericResource(ISGenericResource genericResource) throws RemoteException { try { //maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors. - GenericResource gCubeRes = Resources.unmarshal(GenericResource.class, ASLGenericResource.class.getClassLoader().getResourceAsStream("generic.xml")); + org.gcube.common.resources.gcore.GenericResource gCubeRes = Resources.unmarshal(org.gcube.common.resources.gcore.GenericResource.class, org.gcube.common.resources.gcore.GenericResource.class.getClassLoader().getResourceAsStream("generic.xml")); gCubeRes.profile().name(genericResource.getName()); gCubeRes.profile().description(genericResource.getDescription()); gCubeRes.profile().body().setTextContent(genericResource.getBody()); @@ -184,17 +184,17 @@ public class ASLGenericResource implements GenericResourceInfoI { try { //maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors. logger.info("Updating generic resource by ID"); - SimpleQuery query = queryFor(GenericResource.class); + SimpleQuery query = queryFor(org.gcube.common.resources.gcore.GenericResource.class); query.addCondition("$resource/ID eq '"+genericResource.getId()+"'"); - List result = client.submit(query); + List result = client.submit(query); if (result == null || result.size() == 0) { logger.info("Error during updateGenericResourceByID: Couldn't find the resource to update"); return; } - GenericResource gCubeRes = result.get(0); + org.gcube.common.resources.gcore.GenericResource gCubeRes = result.get(0); gCubeRes.profile().name(genericResource.getName()); gCubeRes.profile().description(genericResource.getDescription()); @@ -249,9 +249,9 @@ public class ASLGenericResource implements GenericResourceInfoI { List pairs = new ArrayList(); SimpleQuery queryMan = null; try { - queryMan = queryFor(GenericResource.class); - List results = client.submit(queryMan); - for(GenericResource gr : results) + queryMan = queryFor(org.gcube.common.resources.gcore.GenericResource.class); + List results = client.submit(queryMan); + for(org.gcube.common.resources.gcore.GenericResource gr : results) pairs.add(new Pair(gr.profile().name(), gr.id())); return pairs; } catch (Exception e) { @@ -309,14 +309,14 @@ public class ASLGenericResource implements GenericResourceInfoI { public void removeGenericResource(ISGenericResource genericResource) throws RemoteException { try { //maybe should add the ScopeProvider.instance.set(session.getScope()); here and not in the constructors. - SimpleQuery query = queryFor(GenericResource.class); + SimpleQuery query = queryFor(org.gcube.common.resources.gcore.GenericResource.class); query.addCondition("$resource/ID eq '"+genericResource.getId()+"'"); - List result = client.submit(query); + List result = client.submit(query); if (result == null || result.size() == 0) { logger.error("Couldn't find the resource to delete! Returning..."); return; } - GenericResource gCubeRes = result.get(0); + org.gcube.common.resources.gcore.GenericResource gCubeRes = result.get(0); publisher = RegistryPublisherFactory.create(); Resource res = publisher.remove(gCubeRes); logger.info("Removed generic resource from IS"); @@ -374,7 +374,7 @@ public class ASLGenericResource implements GenericResourceInfoI { List result = null; try { - result = ASLGenericResource.retrieveGenericResourcesFromNameParts(xsltType, session.getScope()); + result = GenericResource.retrieveGenericResourcesFromNameParts(xsltType, session.getScope()); } catch (Exception e) { logger.error("Exception:", e); } @@ -447,14 +447,14 @@ public class ASLGenericResource implements GenericResourceInfoI { //READ COMMENT BELOW !!! query.addCondition("$resource/Profile/Name eq '"+nameParts+"'"); // on the above, we check if it is equal. what we want in order to have the previous functionality is to seaarch "like", not "eq" - List queryResults = null; + List queryResults = null; queryResults = client.submit(query); if (queryResults == null || queryResults.size() == 0) { logger.error("Couldn't find the resource from name! Returning null"); return null; } List results = new LinkedList(); - for(GenericResource gr : queryResults){ + for(org.gcube.common.resources.gcore.GenericResource gr : queryResults){ String[] nameAndID = { gr.profile().name() , gr.id() }; results.add(nameAndID); } diff --git a/src/main/java/org/gcube/common/core/scope/GCUBEScope.java b/src/main/java/org/gcube/common/core/scope/GCUBEScope.java new file mode 100644 index 0000000..95ab50b --- /dev/null +++ b/src/main/java/org/gcube/common/core/scope/GCUBEScope.java @@ -0,0 +1,20 @@ +package org.gcube.common.core.scope; + +public class GCUBEScope { + private String scope; + + public GCUBEScope() { + scope = null; + } + + public void setScope(String scope){ + this.scope = scope; + } + + public String getScope() { + return this.scope; + + } + + +}