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
This commit is contained in:
parent
948345c7e6
commit
8ac030e295
|
@ -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 <PORTTYPE>
|
||||
*/
|
||||
public class ServiceContextManager<PORTTYPE extends Remote> {
|
||||
|
||||
/*
|
||||
public static <PORTTYPE extends Remote> PORTTYPE applySecurity(PORTTYPE stub, ASLSession session) throws Exception
|
||||
{
|
||||
|
||||
//TODO: SHOULD RECODE THE FUNCTIONS, USING THE NEW FEATHERWEIGHT SECURITY MODEL
|
||||
/*
|
||||
public static <PORTTYPE extends Remote> 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 extends Remote> PORTTYPE applySecurity(PORTTYPE stub, String scope, GSSCredential cred) throws Exception
|
||||
{
|
||||
|
||||
public static <PORTTYPE extends Remote> 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);
|
||||
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -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<GenericResource> client = null;
|
||||
protected static DiscoveryClient<org.gcube.common.resources.gcore.GenericResource> 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 <GenericResource> result = client.submit(query);
|
||||
List <org.gcube.common.resources.gcore.GenericResource> 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<Pair> pairs = new ArrayList<Pair>();
|
||||
SimpleQuery queryMan = null;
|
||||
try {
|
||||
queryMan = queryFor(GenericResource.class);
|
||||
List <GenericResource> results = client.submit(queryMan);
|
||||
for(GenericResource gr : results)
|
||||
queryMan = queryFor(org.gcube.common.resources.gcore.GenericResource.class);
|
||||
List <org.gcube.common.resources.gcore.GenericResource> 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 <GenericResource> result = client.submit(query);
|
||||
List <org.gcube.common.resources.gcore.GenericResource> 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<String[]> 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 <GenericResource> queryResults = null;
|
||||
List <org.gcube.common.resources.gcore.GenericResource> 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<String[]> results = new LinkedList<String[]>();
|
||||
for(GenericResource gr : queryResults){
|
||||
for(org.gcube.common.resources.gcore.GenericResource gr : queryResults){
|
||||
String[] nameAndID = { gr.profile().name() , gr.id() };
|
||||
results.add(nameAndID);
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue