gCore dep removed except for logging

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@81325 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-09-12 16:47:59 +00:00
parent 878cc7ffc5
commit 756f7a96d7
21 changed files with 260 additions and 293 deletions

View File

@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER/GWT (5)"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

23
pom.xml
View File

@ -35,6 +35,12 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- Google Web Toolkit (GWT) --> <!-- Google Web Toolkit (GWT) -->
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
@ -49,23 +55,6 @@
<version>2.2.5</version> <version>2.2.5</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>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>ghn-client-runtime</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.resourcemanagement</groupId> -->
<!-- <artifactId>resource-manager-stubs</artifactId> -->
<!-- <version>[2.0.1-SNAPSHOT, 3.0.0-SNAPSHOT)</version> -->
<!-- </dependency> -->
<!-- FWS DEPS --> <!-- FWS DEPS -->
<dependency> <dependency>
<groupId>org.gcube.resources.discovery</groupId> <groupId>org.gcube.resources.discovery</groupId>

View File

@ -42,12 +42,6 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.resources.gcore.utils.XPathHelper;
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;
@ -79,7 +73,6 @@ import org.xml.sax.SAXException;
* @author Daniele Strollo * @author Daniele Strollo
*/ */
public class ISClientRequester { public class ISClientRequester {
static GCUBEClientLog _log = new GCUBEClientLog(ISClientRequester.class);
private static final ISQueryCache CACHE = new ISQueryCache(); private static final ISQueryCache CACHE = new ISQueryCache();
private static final String LOG_PREFIX = "[ISCLIENT-REQS]"; private static final String LOG_PREFIX = "[ISCLIENT-REQS]";
@ -254,7 +247,7 @@ public class ISClientRequester {
retval.put(type, subtypes); retval.put(type, subtypes);
} }
} catch (Exception e) { } catch (Exception e) {
_log.error(LOG_PREFIX, e); ServerConsole.error(LOG_PREFIX, e);
} }
} }
@ -301,8 +294,8 @@ public class ISClientRequester {
DiscoveryClient<String> client = client(); DiscoveryClient<String> client = client();
isQuery.addParameter("RES_ID", id.trim()); isQuery.addParameter("RES_ID", id.trim());
//add the return statement
isQuery.addParameter("RESOURCE", QueryLoader.getQuery(QueryLocation.valueOf("LIST_RELATED_RETURN_" + type)));
ISQueryCacheKeyT cacheKey = new ISQueryCacheKeyT(queryScope.toString(), isQuery.expression(), "getResourceRelated"); ISQueryCacheKeyT cacheKey = new ISQueryCacheKeyT(queryScope.toString(), isQuery.expression(), "getResourceRelated");
@ -317,6 +310,7 @@ public class ISClientRequester {
} }
} }
if (resultz == null || resultz.size() == 0) { if (resultz == null || resultz.size() == 0) {
ServerConsole.debug(LOG_PREFIX, "[getResourcesRelated] Got No Results");
return null; return null;
} }
// ENDOF Handle cache // ENDOF Handle cache
@ -583,32 +577,36 @@ public class ISClientRequester {
return null; return null;
} }
public static Map<String, GenericResourcePlugin> getGenericResourcePlugins(final GCUBEScope scope) throws Exception { public static Map<String, GenericResourcePlugin> getGenericResourcePlugins(final ScopeBean scope) throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class); //set the scope
GCUBEGenericQuery isQuery = null; ScopeProvider.instance.set(scope.toString());
isQuery = client.getQuery(GCUBEGenericQuery.class);
isQuery.setExpression(QueryLoader.getQuery(QueryLocation.GET_GENERIC_RESOURCE_PLUGINS)); Query isQuery = new QueryBox(QueryLoader.getQuery(QueryLocation.GET_GENERIC_RESOURCE_PLUGINS));
List<XMLResult> results = client.execute(isQuery, scope); DiscoveryClient<String> client = client();
List<String> resultz= client.submit(isQuery);
Map<String, GenericResourcePlugin> retval = new HashMap<String, GenericResourcePlugin>(); Map<String, GenericResourcePlugin> retval = new HashMap<String, GenericResourcePlugin>();
gonext: for (XMLResult plugin : results) { gonext: for (String plugin : resultz) {
try { try {
for (String entry : plugin.evaluate("/CMPlugins/Plugin/Entry")) { DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(plugin))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
for (String entry : helper.evaluate("/CMPlugins/Plugin/Entry")) {
Document doc = ScopeManager.getDocumentGivenXML(entry); Document doc = ScopeManager.getDocumentGivenXML(entry);
String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue(); String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-PLUGIN] found: *** name " + name); ServerConsole.trace("[LOAD-PLUGIN] found: *** name " + name);
String pluginType = doc.getElementsByTagName("Type").item(0).getFirstChild().getNodeValue(); String pluginType = doc.getElementsByTagName("Type").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-PLUGIN] found: *** type " + pluginType); ServerConsole.trace("[LOAD-PLUGIN] found: *** type " + pluginType);
String description = doc.getElementsByTagName("description").item(0).getFirstChild().getNodeValue(); String description = doc.getElementsByTagName("description").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-PLUGIN] found: *** description " + description); ServerConsole.trace("[LOAD-PLUGIN] found: *** description " + description);
String namespace = null; String namespace = null;
try { try {
namespace = doc.getElementsByTagName("namespace").item(0).getFirstChild().getNodeValue(); namespace = doc.getElementsByTagName("namespace").item(0).getFirstChild().getNodeValue();
_log.debug("[LOAD-PLUGIN] found: *** namespace " + namespace); ServerConsole.debug("[LOAD-PLUGIN] found: *** namespace " + namespace);
} catch (Exception e) { } catch (Exception e) {
_log.warn("[LOAD-PLUGIN] namespace not found"); ServerConsole.warn("[LOAD-PLUGIN] namespace not found");
} }
GenericResourcePlugin toAdd = new GenericResourcePlugin(name, namespace, description, pluginType); GenericResourcePlugin toAdd = new GenericResourcePlugin(name, namespace, description, pluginType);
@ -629,7 +627,7 @@ public class ISClientRequester {
} }
} }
_log.trace("[LOAD-PLUGIN] found: param " + paramName); ServerConsole.trace("[LOAD-PLUGIN] found: param " + paramName);
GenericResourcePlugin.Field paramField = new GenericResourcePlugin.Field(paramName, GenericResourcePlugin.FieldType.string); GenericResourcePlugin.Field paramField = new GenericResourcePlugin.Field(paramName, GenericResourcePlugin.FieldType.string);
if (paramDefinition != null) { if (paramDefinition != null) {
@ -688,32 +686,36 @@ public class ISClientRequester {
* @return a map containing the plugin name as key and a List of formfield * @return a map containing the plugin name as key and a List of formfield
* @throws Exception * @throws Exception
*/ */
public static HashMap<String, ArrayList<TMPluginFormField>> getGenericResourceTreeManagerPlugins(final GCUBEScope scope) throws Exception { public static HashMap<String, ArrayList<TMPluginFormField>> getGenericResourceTreeManagerPlugins(final ScopeBean scope) throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBEGenericQuery isQuery = null; ScopeProvider.instance.set(scope.toString());
isQuery = client.getQuery(GCUBEGenericQuery.class);
isQuery.setExpression(QueryLoader.getQuery(QueryLocation.GET_GENERIC_RESOURCE_TREE_MANAGER_PLUGINS)); Query isQuery = new QueryBox(QueryLoader.getQuery(QueryLocation.GET_GENERIC_RESOURCE_TREE_MANAGER_PLUGINS));
List<XMLResult> results = client.execute(isQuery, scope); DiscoveryClient<String> client = client();
List<String> resultz= client.submit(isQuery);
HashMap<String, ArrayList<TMPluginFormField>> retval = new HashMap<String, ArrayList<TMPluginFormField>>(); HashMap<String, ArrayList<TMPluginFormField>> retval = new HashMap<String, ArrayList<TMPluginFormField>>();
gonext: for (XMLResult plugin : results) { gonext: for (String plugin : resultz) {
try { try {
for (String entry : plugin.evaluate("/TMPlugins/Plugin/Entry")) { DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(plugin))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
for (String entry : helper.evaluate("/TMPlugins/Plugin/Entry")) {
String requestName = null; String requestName = null;
boolean foundRequest = false; boolean foundRequest = false;
Document doc = ScopeManager.getDocumentGivenXML(entry); Document doc = ScopeManager.getDocumentGivenXML(entry);
String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue(); String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-TMPLUGIN] found: *** name " + name); ServerConsole.trace("[LOAD-TMPLUGIN] found: *** name " + name);
String pluginType = doc.getElementsByTagName("Type").item(0).getFirstChild().getNodeValue(); String pluginType = doc.getElementsByTagName("Type").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-TMPLUGIN] found: *** type " + pluginType); ServerConsole.trace("[LOAD-TMPLUGIN] found: *** type " + pluginType);
String description = doc.getElementsByTagName("description").item(0).getFirstChild().getNodeValue(); String description = doc.getElementsByTagName("description").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-TMPLUGIN] found: *** description " + description); ServerConsole.trace("[LOAD-TMPLUGIN] found: *** description " + description);
String namespace = null; String namespace = null;
try { try {
namespace = doc.getElementsByTagName("namespace").item(0).getFirstChild().getNodeValue(); namespace = doc.getElementsByTagName("namespace").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-TMPLUGIN] found: *** namespace " + namespace); ServerConsole.trace("[LOAD-TMPLUGIN] found: *** namespace " + namespace);
} catch (Exception e) { } catch (Exception e) {
_log.warn("[LOAD-TMPLUGIN] namespace not found"); ServerConsole.warn("[LOAD-TMPLUGIN] namespace not found");
} }
NodeList params = doc.getElementsByTagName("param"); NodeList params = doc.getElementsByTagName("param");
@ -831,7 +833,7 @@ public class ISClientRequester {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node xnode = docBuilder.parse(new InputSource(new StringReader(node))).getDocumentElement(); Node xnode = docBuilder.parse(new InputSource(new StringReader(node))).getDocumentElement();
XPathHelper helper = new XPathHelper(xnode); XPathHelper helper = new XPathHelper(xnode);
if (type.equalsIgnoreCase(ResourceTypeDecorator.GHN.name())) { if (type.equalsIgnoreCase(ResourceTypeDecorator.GHN.name())) {
try { try {
return helper.evaluate("/Resource/Profile/GHNDescription/Name/text()").get(0); return helper.evaluate("/Resource/Profile/GHNDescription/Name/text()").get(0);

View File

@ -20,8 +20,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.common.core.informationsystem.client.XMLResult;
class ISQueryCacheKeyT { class ISQueryCacheKeyT {
String keyValue = null; String keyValue = null;
String queryExpression = null; String queryExpression = null;

View File

@ -49,14 +49,18 @@ public enum QueryLocation {
// To retrieve the list of generic resources publishing plugins // To retrieve the list of generic resources publishing plugins
// to deploy activation records // to deploy activation records
GET_GENERIC_RESOURCE_PLUGINS("getPlugins.xq"), GET_GENERIC_RESOURCE_PLUGINS("getPlugins.xq"),
RETURN_GET_GENERIC_RESOURCE_PLUGINS("RETURN_getPlugins.xq"),
// to deploy activation records for Tree manager // to deploy activation records for Tree manager
GET_GENERIC_RESOURCE_TREE_MANAGER_PLUGINS("getTreeManagerPlugins.xq"), GET_GENERIC_RESOURCE_TREE_MANAGER_PLUGINS("getTreeManagerPlugins.xq"),
// Related resources // Related resources
LIST_RELATED_GHN("related/GHN.xq"), LIST_RELATED_GHN("related/GHN.xq"),
LIST_RELATED_RETURN_GHN("related/RETURN_GHN.xq"),
LIST_RELATED_RunningInstance("related/RunningInstance.xq"), LIST_RELATED_RunningInstance("related/RunningInstance.xq"),
LIST_RELATED_RETURN_RunningInstance("related/RETURN_RunningInstance.xq"),
LIST_RELATED_Service("related/Service.xq"), LIST_RELATED_Service("related/Service.xq"),
LIST_RELATED_RETURN_Service("related/RETURN_Service.xq"),
// Queries for sweeper // Queries for sweeper
SWEEPER_EXPIRED_GHN("sweeper/expiredGhns.xq"), SWEEPER_EXPIRED_GHN("sweeper/expiredGhns.xq"),

View File

@ -1,4 +1,3 @@
for $_outer in collection("/db/Properties")//Document for $_outer in collection("/db/Properties")//Document
where ($_outer//Document/Data/child::*[local-name()='ServiceClass']/text() = 'ContentManagement' where ($_outer//Document/Data/child::*[local-name()='ServiceClass']/text() = 'ContentManagement'
and exists($_outer/Data/child::*[local-name()='Plugin']/name)) and exists($_outer/Data/child::*[local-name()='Plugin']/name))

View File

@ -15,11 +15,4 @@
for $ris in collection('/db/Profiles/RunningInstance')//Resource for $ris in collection('/db/Profiles/RunningInstance')//Resource
where $ris//Resource/Profile/GHN/@UniqueID/string() eq '<RES_ID/>' where $ris//Resource/Profile/GHN/@UniqueID/string() eq '<RES_ID/>'
return return
<Resource> <RESOURCE/>
{$ris/ID}
{$ris/Profile/ServiceName}
{$ris/Profile/ServiceClass}
<ServiceVersion>{$ris//Resource/@version/string()}</ServiceVersion>
<MainVersion>{$ris/Profile/Version/text()}</MainVersion>
<Status>{$ris/Profile/DeploymentData/Status/text()}</Status>
</Resource>

View File

@ -0,0 +1,8 @@
<Resource>
{$ris/ID}
{$ris/Profile/ServiceName}
{$ris/Profile/ServiceClass}
<ServiceVersion>{$ris//Resource/@version/string()}</ServiceVersion>
<MainVersion>{$ris/Profile/Version/text()}</MainVersion>
<Status>{$ris/Profile/DeploymentData/Status/text()}</Status>
</Resource>

View File

@ -0,0 +1,45 @@
<Resources>
<Resource>
<Key>ID</Key>
<Value>{$ri//Resource/ID/string()}</Value>
</Resource>
<Resource>
<Key>ServiceStatus</Key>
<Value>{$ri/Profile/DeploymentData/Status/string()}</Value>
</Resource>
<Resource>
<Key>ActivationTime</Key>
<Value>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</Value>
</Resource>
<Resource>
<Key>GHNName</Key>
<Value>{$ghn-name}</Value>
</Resource>
<Resource>
<Key>GHNSite</Key>
<Value>{$relatedghn/Profile/Site/Domain/string()}</Value>
</Resource>
<Resource>
<Key>GHNStatus</Key>
<Value>{$relatedghn/Profile/GHNDescription/Status/string()}</Value>
</Resource>
<Resource>
<Key>GHNActivationTime</Key>
<Value>{$relatedghn/Profile/GHNDescription/ActivationTime/string()}</Value>
</Resource>
<Resource>
<Key>GHNLastUpdate</Key>
<Value>{$relatedghn/Profile/GHNDescription/LastUpdate/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad15Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last15Min/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad5Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last5Min/string()}</Value>
</Resource><Resource>
<Key>GHNLoad1Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last1Min/string()}</Value>
</Resource>
</Resources>

View File

@ -0,0 +1,21 @@
<Resource>
<!-- INFORMATION ABOUT THE RI -->
<RIID>{$ri/ID/string()}</RIID>
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
<RIVersion>{$ri/Profile/Version/string()}</RIVersion>
<!-- INFORMATION about GHN -->
<GHNID>{$ghn-id}</GHNID>
<GHNName>{$ghn/Profile/GHNDescription/Name/string()}</GHNName>
<GHNSite>{$ghn/Profile/Site/Domain/string()}</GHNSite>
<GHNStatus>{$ghn/Profile/GHNDescription/Status/string()}</GHNStatus>
<GHNLoad15Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad15Min>
<GHNLoad5Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad5Min>
<GHNLoad1Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad1Min>
<GHNActivationTime>{$ghn/Profile/GHNDescription/ActivationTime/string()}</GHNActivationTime>
<GHNLastUpdate>{$ghn/Profile/GHNDescription/LastUpdate/string()}</GHNLastUpdate>
</Resource>
return
<Resources>
{$relatedris}
</Resources>

View File

@ -1,55 +1,11 @@
<!-- <!--
Notice: the <Resources> node must be removed in using the resource grid factory. Notice: the <Resources> node must be removed in using the resource grid factory.
--> -->
let $profiles := collection('/db/Profiles/<RES_TYPE ISdefault ='RunningInstance'>')//Resource[ID/string() eq '<RES_ID/>'] let $profiles := collection('/db/Profiles/<RES_TYPE ISdefault ='RunningInstance'/>')//Resource[ID/string() eq '<RES_ID/>']
let $relatedghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $profiles/Profile/GHN/@UniqueID/string()] let $relatedghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $profiles/Profile/GHN/@UniqueID/string()]
let $ghn-name := if (empty($relatedghn/Profile/GHNDescription/Name/string())) let $ghn-name := if (empty($relatedghn/Profile/GHNDescription/Name/string()))
then $profiles/Profile/GHN/@UniqueID/string() then $profiles/Profile/GHN/@UniqueID/string()
else $relatedghn/Profile/GHNDescription/Name/string() else $relatedghn/Profile/GHNDescription/Name/string()
for $ri in $profiles for $ri in $profiles
return return
<Resources> <RESOURCE/>
<Resource>
<Key>ID</Key>
<Value>{$ri//Resource/ID/string()}</Value>
</Resource>
<Resource>
<Key>ServiceStatus</Key>
<Value>{$ri/Profile/DeploymentData/Status/string()}</Value>
</Resource>
<Resource>
<Key>ActivationTime</Key>
<Value>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</Value>
</Resource>
<Resource>
<Key>GHNName</Key>
<Value>{$ghn-name}</Value>
</Resource>
<Resource>
<Key>GHNSite</Key>
<Value>{$relatedghn/Profile/Site/Domain/string()}</Value>
</Resource>
<Resource>
<Key>GHNStatus</Key>
<Value>{$relatedghn/Profile/GHNDescription/Status/string()}</Value>
</Resource>
<Resource>
<Key>GHNActivationTime</Key>
<Value>{$relatedghn/Profile/GHNDescription/ActivationTime/string()}</Value>
</Resource>
<Resource>
<Key>GHNLastUpdate</Key>
<Value>{$relatedghn/Profile/GHNDescription/LastUpdate/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad15Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last15Min/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad5Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last5Min/string()}</Value>
</Resource><Resource>
<Key>GHNLoad1Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last1Min/string()}</Value>
</Resource>
</Resources>

View File

@ -13,24 +13,4 @@ let $relatedris :=
let $ghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $ghn-id] let $ghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $ghn-id]
<!-- and $ri//Profile/Version/string() eq $ServiceVersion --> <!-- and $ri//Profile/Version/string() eq $ServiceVersion -->
return return
<Resource> <RESOURCE/>
<!-- INFORMATION ABOUT THE RI -->
<RIID>{$ri/ID/string()}</RIID>
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
<RIVersion>{$ri/Profile/Version/string()}</RIVersion>
<!-- INFORMATION about GHN -->
<GHNID>{$ghn-id}</GHNID>
<GHNName>{$ghn/Profile/GHNDescription/Name/string()}</GHNName>
<GHNSite>{$ghn/Profile/Site/Domain/string()}</GHNSite>
<GHNStatus>{$ghn/Profile/GHNDescription/Status/string()}</GHNStatus>
<GHNLoad15Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad15Min>
<GHNLoad5Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad5Min>
<GHNLoad1Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad1Min>
<GHNActivationTime>{$ghn/Profile/GHNDescription/ActivationTime/string()}</GHNActivationTime>
<GHNLastUpdate>{$ghn/Profile/GHNDescription/LastUpdate/string()}</GHNLastUpdate>
</Resource>
return
<Resources>
{$relatedris}
</Resources>

View File

@ -22,9 +22,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.ScopeGroup;
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.common.scope.impl.ScopeBean.Type; import org.gcube.common.scope.impl.ScopeBean.Type;
@ -63,7 +61,6 @@ public abstract class AbstractResourceManager {
private String name = null; private String name = null;
private AllowedResourceTypes type = null; private AllowedResourceTypes type = null;
private String subType = null; private String subType = null;
private GCUBESecurityManagerImpl managerSec = null;
private RegistryPublisher publisher = null; private RegistryPublisher publisher = null;
private static final String LOG_PREFIX = "[AbstractResMgr]"; private static final String LOG_PREFIX = "[AbstractResMgr]";
@ -77,15 +74,6 @@ public abstract class AbstractResourceManager {
this.type = type; this.type = type;
/**
* Initially the security management is disabled.
*/
this.managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
}
};
try { try {
this.publisher = RegistryPublisherFactory.create(); this.publisher = RegistryPublisherFactory.create();
} catch (Exception e) { } catch (Exception e) {
@ -135,20 +123,6 @@ public abstract class AbstractResourceManager {
return publisher; return publisher;
} }
public final void setSecurityManager(final GCUBESecurityManagerImpl securityManager) {
this.managerSec = securityManager;
}
/**
* The security manager is initially instantiated with empty permissions.
* The {@link AbstractResourceManager#setSecurityManager} can be used to
* change it.
* @return
*/
public final GCUBESecurityManagerImpl getSecurityManager() {
return this.managerSec;
}
/** /**
* All resources must be identifiable through an unique ID. * All resources must be identifiable through an unique ID.
* <br/> * <br/>
@ -201,7 +175,7 @@ public abstract class AbstractResourceManager {
* @throws ResourceParameterException if the parameters are invalid * @throws ResourceParameterException if the parameters are invalid
*/ */
public final RMBinderLibrary getResourceManager(String scope) throws AbstractResourceException { public final RMBinderLibrary getResourceManager(String scope) throws AbstractResourceException {
String currScope = ScopeProvider.instance.get();
ScopeBean bscope = new ScopeBean(scope); ScopeBean bscope = new ScopeBean(scope);
if (bscope.is(Type.VRE)) { if (bscope.is(Type.VRE)) {
scope = bscope.enclosingScope().toString(); scope = bscope.enclosingScope().toString();
@ -212,7 +186,6 @@ public abstract class AbstractResourceManager {
if (rml == null) { // no managers found if (rml == null) { // no managers found
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString()); throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
} }
ScopeProvider.instance.set(currScope);
return rml; return rml;
} }
@ -224,7 +197,6 @@ public abstract class AbstractResourceManager {
* @throws ResourceParameterException if the parameters are invalid * @throws ResourceParameterException if the parameters are invalid
*/ */
public final RMReportingLibrary getReportResourceManager(String scope) throws AbstractResourceException { public final RMReportingLibrary getReportResourceManager(String scope) throws AbstractResourceException {
String currScope = ScopeProvider.instance.get();
ScopeBean bscope = new ScopeBean(scope); ScopeBean bscope = new ScopeBean(scope);
if (bscope.is(Type.VRE)) { if (bscope.is(Type.VRE)) {
scope = bscope.enclosingScope().toString(); scope = bscope.enclosingScope().toString();
@ -236,7 +208,6 @@ public abstract class AbstractResourceManager {
if (rml == null) { // no managers found if (rml == null) { // no managers found
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString()); throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
} }
ScopeProvider.instance.set(currScope);
return rml; return rml;
} }
@ -259,7 +230,9 @@ public abstract class AbstractResourceManager {
LOG_PREFIX, LOG_PREFIX,
"[BIND-SCOPE-ENTER] Adding " + this.getType() + " " + this.getID() + " to scope [" + "[BIND-SCOPE-ENTER] Adding " + this.getType() + " " + this.getID() + " to scope [" +
targetScope.toString() + "]"); targetScope.toString() + "]");
String curr = ScopeProvider.instance.get();
ScopeProvider.instance.set(targetScope.toString());
AddResourcesParameters addParam = new AddResourcesParameters(); AddResourcesParameters addParam = new AddResourcesParameters();
ResourceItem toAdd = new ResourceItem(); ResourceItem toAdd = new ResourceItem();
toAdd.setId(this.getID()); toAdd.setId(this.getID());
@ -275,7 +248,6 @@ public abstract class AbstractResourceManager {
RMBinderLibrary manager = this.getResourceManager(targetScope); RMBinderLibrary manager = this.getResourceManager(targetScope);
try { try {
String curr = ScopeProvider.instance.get();
ScopeBean scope = new ScopeBean(targetScope); ScopeBean scope = new ScopeBean(targetScope);
if (scope.is(Type.VRE)) { if (scope.is(Type.VRE)) {
ScopeProvider.instance.set(scope.enclosingScope().toString()); ScopeProvider.instance.set(scope.enclosingScope().toString());
@ -305,7 +277,7 @@ public abstract class AbstractResourceManager {
/** /**
* Add a scope to a gHN and the related Service Map is already available on the gHN. * Add a scope to a Resource
* @param nestingPublication true for resources different from gHN and RI. * @param nestingPublication true for resources different from gHN and RI.
* @return the reportID generated * @return the reportID generated
*/ */
@ -314,7 +286,9 @@ public abstract class AbstractResourceManager {
checker.validate(sourceScope != null, new ResourceParameterException("Invalid parameter sourceScope. null not allowed.")); checker.validate(sourceScope != null, new ResourceParameterException("Invalid parameter sourceScope. null not allowed."));
checker.validate(targetScope != null, new ResourceParameterException("Invalid parameter targetScope. null not allowed.")); checker.validate(targetScope != null, new ResourceParameterException("Invalid parameter targetScope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid resource ID. null not allowed.")); checker.validate(this.getID() != null, new ResourceOperationException("Invalid resource ID. null not allowed."));
String curr = ScopeProvider.instance.get();
ScopeProvider.instance.set(sourceScope.toString());
ReportBuilder report = new ReportBuilder(); ReportBuilder report = new ReportBuilder();
ServerConsole.trace( ServerConsole.trace(
@ -345,7 +319,10 @@ public abstract class AbstractResourceManager {
targetScope.toString() + " the remote report ID is: " + targetScope.toString() + " the remote report ID is: " +
this.bindToScope(targetScope.toString()), true)); this.bindToScope(targetScope.toString()), true));
return report.getXML();
String toReturn = report.getXML();
ScopeProvider.instance.set(curr);
return toReturn;
} }
@ -431,7 +408,6 @@ public abstract class AbstractResourceManager {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>(); Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(this.getID() != null, new ResourceAccessException("Cannot execute on resources with no ID.")); checker.validate(this.getID() != null, new ResourceAccessException("Cannot execute on resources with no ID."));
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
// Phase 1. retrieve the resource to copy // Phase 1. retrieve the resource to copy
@ -447,7 +423,6 @@ public abstract class AbstractResourceManager {
if (results == null || results.isEmpty()) if (results == null || results.isEmpty())
throw new ResourceAccessException("Cannot retrieve the IS profile for resource: " + this.getID() + throw new ResourceAccessException("Cannot retrieve the IS profile for resource: " + this.getID() +
" in scope: " + scope.toString()); " in scope: " + scope.toString());
ScopeProvider.instance.set(currScope);
return results.get(0).toString(); return results.get(0).toString();
} }
@ -482,10 +457,8 @@ public abstract class AbstractResourceManager {
ServerConsole.trace(LOG_PREFIX, "[REMOVE-FROM-SCOPE] Sending the Remove Resource request...."); ServerConsole.trace(LOG_PREFIX, "[REMOVE-FROM-SCOPE] Sending the Remove Resource request....");
try { try {
RMBinderLibrary manager = this.getResourceManager(scope.toString()); RMBinderLibrary manager = this.getResourceManager(scope.toString());
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
retval = manager.removeResources(params); retval = manager.removeResources(params);
ScopeProvider.instance.set(currScope);
} catch (Exception e) { } catch (Exception e) {
throw new ResourceOperationException("During removeFrom scope of " throw new ResourceOperationException("During removeFrom scope of "
+ this.getType() + this.getType()
@ -503,12 +476,9 @@ public abstract class AbstractResourceManager {
checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed.")); checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed.")); checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
String retval = this.basicRemoveFromScope(scope); String retval = this.basicRemoveFromScope(scope);
ScopeProvider.instance.set(currScope);
return retval; return retval;
} }
@ -558,7 +528,6 @@ public abstract class AbstractResourceManager {
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed.")); checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
System.out.println("DELETING TYPE: "+ this.getType()); System.out.println("DELETING TYPE: "+ this.getType());
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
Resource resStub = this.getResource(scope); Resource resStub = this.getResource(scope);
@ -578,7 +547,6 @@ public abstract class AbstractResourceManager {
} catch (Exception e) { } catch (Exception e) {
} }
ScopeProvider.instance.set(currScope);
} }
} }

View File

@ -16,11 +16,6 @@
package org.gcube.resourcemanagement.support.server.managers.resources; package org.gcube.resourcemanagement.support.server.managers.resources;
import java.io.StringReader;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.resources.GCUBECollection;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource;
import org.gcube.resourcemanagement.support.server.exceptions.AbstractResourceException; import org.gcube.resourcemanagement.support.server.exceptions.AbstractResourceException;
import org.gcube.resourcemanagement.support.server.exceptions.ResourceAccessException; import org.gcube.resourcemanagement.support.server.exceptions.ResourceAccessException;

View File

@ -44,6 +44,7 @@ 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.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -139,7 +140,6 @@ public class GenericResourceManager extends AbstractResourceManager {
if (subType != null) if (subType != null)
resource.profile().type(subType.trim()); resource.profile().type(subType.trim());
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
RegistryPublisher publisher = getRegistryPublisher(); RegistryPublisher publisher = getRegistryPublisher();
String id = publisher.update(resource).id(); String id = publisher.update(resource).id();
@ -147,13 +147,11 @@ public class GenericResourceManager extends AbstractResourceManager {
if (id == null || id.length() == 0) { if (id == null || id.length() == 0) {
throw new Exception("The GenericResource has not been updated"); throw new Exception("The GenericResource has not been updated");
} }
ScopeProvider.instance.set(currScope);
ServerConsole.info(LOG_PREFIX, "Resource Updated with ID: " + id); ServerConsole.info(LOG_PREFIX, "Resource Updated with ID: " + id);
} }
private GenericResource getResourceToEditById(String id, ScopeBean scope) throws Exception { private GenericResource getResourceToEditById(String id, ScopeBean scope) throws Exception {
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
SimpleQuery query = queryFor(GenericResource.class); SimpleQuery query = queryFor(GenericResource.class);
@ -163,7 +161,6 @@ public class GenericResourceManager extends AbstractResourceManager {
List<GenericResource> r = client.submit(query); List<GenericResource> r = client.submit(query);
ScopeProvider.instance.set(currScope);
if (r == null || r.isEmpty()) if (r == null || r.isEmpty())
throw new Exception("Could not retrieve GenericResource profile with id " + id + " in scope + " +scope); throw new Exception("Could not retrieve GenericResource profile with id " + id + " in scope + " +scope);
else else
@ -194,7 +191,7 @@ public class GenericResourceManager extends AbstractResourceManager {
GenericResourceManager gm = new GenericResourceManager(); GenericResourceManager gm = new GenericResourceManager();
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope.toString()); ScopeProvider.instance.set(scope.toString());
RegistryPublisher publisher = gm.getRegistryPublisher(); RegistryPublisher publisher = gm.getRegistryPublisher();
String id = publisher.create(resource).id(); String id = publisher.create(resource).id();
@ -202,7 +199,6 @@ public class GenericResourceManager extends AbstractResourceManager {
if (id == null || id.length() == 0) { if (id == null || id.length() == 0) {
throw new Exception("The GenericResource has not been created"); throw new Exception("The GenericResource has not been created");
} }
ScopeProvider.instance.set(currScope);
ServerConsole.info(LOG_PREFIX, "Resource Created with ID: " + id); ServerConsole.info(LOG_PREFIX, "Resource Created with ID: " + id);
return id; return id;
} }
@ -227,12 +223,21 @@ public class GenericResourceManager extends AbstractResourceManager {
* @throws SAXException * @throws SAXException
* @throws ParserConfigurationException * @throws ParserConfigurationException
*/ */
public static void appendXmlFragment(Node parent, String fragment) throws IOException, SAXException, ParserConfigurationException { public static void appendXmlFragment(Node parent, String fragment) throws IOException, ParserConfigurationException {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = parent.getOwnerDocument(); Document doc = parent.getOwnerDocument();
Node fragmentNode = docBuilder.parse(new InputSource(new StringReader(fragment))).getDocumentElement(); Node fragmentNode;
fragmentNode = doc.importNode(fragmentNode, true); try {
parent.appendChild(fragmentNode); fragmentNode = docBuilder.parse(new InputSource(new StringReader(fragment))).getDocumentElement();
fragmentNode = doc.importNode(fragmentNode, true);
parent.appendChild(fragmentNode);
} catch (SAXException e) {
//in case no xml is entered, just text
System.out.println("to append: " + fragment);
Text text = doc.createTextNode(fragment);
doc.importNode(text, true);
}
} }
} }

View File

@ -66,12 +66,7 @@ public class ManagementUtils {
* @param targetScope * @param targetScope
* @return the generated report ID * @return the generated report ID
*/ */
public static final synchronized String addToExistingScope( public static final synchronized String addToExistingScope(AllowedResourceTypes type, String[] resourceIDs, ScopeBean sourceScope, ScopeBean targetScope) throws Exception {
final AllowedResourceTypes type,
final String[] resourceIDs,
final ScopeBean sourceScope,
final ScopeBean targetScope)
throws Exception {
ServerConsole.trace( ServerConsole.trace(
LOG_PREFIX, LOG_PREFIX,
"[ADD-ToExistingScope] Adding from scope [" + "[ADD-ToExistingScope] Adding from scope [" +
@ -97,10 +92,10 @@ public class ManagementUtils {
for (String id : resourceIDs) { for (String id : resourceIDs) {
AbstractResourceManager res = ResourceFactory.createResourceManager(type, id); AbstractResourceManager res = ResourceFactory.createResourceManager(type, id);
Resource resStub = res.getResource(sourceScope); Resource resStub = res.getResource(sourceScope);
String curr = ScopeProvider.instance.get();
ScopeProvider.instance.set(targetScope.toString()); ScopeProvider.instance.set(targetScope.toString());
res.getRegistryPublisher().update(resStub); res.getRegistryPublisher().update(resStub);
ScopeProvider.instance.set(curr);
} }
} catch (Exception e) { } catch (Exception e) {
throw new ResourceAccessException(e.getMessage()); throw new ResourceAccessException(e.getMessage());

View File

@ -16,32 +16,37 @@
package org.gcube.resourcemanagement.support.server.managers.scope; package org.gcube.resourcemanagement.support.server.managers.scope;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
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.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.ISException; import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.core.informationsystem.client.AtomicCondition; import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.core.informationsystem.client.ISClient; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.core.resources.GCUBEGenericResource; import org.gcube.resourcemanagement.support.server.gcube.CacheManager;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.resourcemanagement.support.server.gcube.ISClientRequester;
import org.gcube.common.core.scope.ServiceMap;
import org.gcube.common.core.scope.VO;
import org.gcube.common.core.scope.VRE;
import org.gcube.resourcemanagement.support.server.utils.ServerConsole; import org.gcube.resourcemanagement.support.server.utils.ServerConsole;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -52,18 +57,18 @@ import org.xml.sax.SAXException;
* *
*/ */
public class ScopeManager { public class ScopeManager {
private static final Map<String, GCUBEScope> SCOPES = new LinkedHashMap<String, GCUBEScope>(); private static final Map<String, ScopeBean> SCOPES = new LinkedHashMap<String, ScopeBean>();
private static String confFile = null; private static String confFile = null;
private static final String LOG_PREFIX = "[SCOPE-MGR]"; private static final String LOG_PREFIX = "[SCOPE-MGR]";
public static GCUBEScope getScope(final String scope) throws Exception { public static ScopeBean getScope(final String scope) throws Exception {
synchronized (SCOPES) { synchronized (SCOPES) {
if (getAvailableScopes().containsKey(scope)) { if (getAvailableScopes().containsKey(scope)) {
return getAvailableScopes().get(scope); return getAvailableScopes().get(scope);
} }
} }
ServerConsole.warn(LOG_PREFIX, "Using DEFAULT scope manager"); ServerConsole.warn(LOG_PREFIX, "Using DEFAULT scope manager");
return GCUBEScope.getScope(scope); return new ScopeBean(scope);
} }
public static void setScopeConfigFile(final String file) { public static void setScopeConfigFile(final String file) {
@ -74,7 +79,7 @@ public class ScopeManager {
* Refreshes the list of scopes and associated maps. * Refreshes the list of scopes and associated maps.
*/ */
public static Map<String, GCUBEScope> getAvailableScopes() public static Map<String, ScopeBean> getAvailableScopes()
throws Exception { throws Exception {
if (SCOPES.size() == 0) { if (SCOPES.size() == 0) {
update(); update();
@ -100,25 +105,24 @@ public class ScopeManager {
String voString = voDetails.item(5).getFirstChild().getNodeValue(); String voString = voDetails.item(5).getFirstChild().getNodeValue();
String fileName = voDetails.item(3).getFirstChild().getNodeValue(); String fileName = voDetails.item(3).getFirstChild().getNodeValue();
// String voName = voDetails.item(1).getFirstChild().getNodeValue(); // String voName = voDetails.item(1).getFirstChild().getNodeValue();
GCUBEScope vo = GCUBEScope.getScope(voString); ScopeBean vo = new ScopeBean(voString);
try { try {
vo.setServiceMap(loadServiceMap((VO) vo, fileName)); //vo.setServiceMap(loadServiceMap((VO) vo, fileName));
SCOPES.put(vo.toString(), vo); SCOPES.put(vo.toString(), vo);
ServerConsole.info(LOG_PREFIX, " Scopes in VO " + vo.toString()); ServerConsole.info(LOG_PREFIX, " Scopes in VO " + vo.toString());
try { try {
for (VRE vre : getVREFromVO((VO) vo)) { for (String vre : getVREFromVO(vo)) {
// This operation overrides the vo map // This operation overrides the vo map
vre.getEnclosingScope().setServiceMap(vo.getServiceMap()); SCOPES.put(vre.toString(), new ScopeBean(vo.toString()+"/"+vre));
SCOPES.put(vre.toString(), vre);
} }
} catch (ISException e) { } catch (Exception e) {
ServerConsole.error(LOG_PREFIX, "Exception raised while loading VREs for VO : " + vo, e); ServerConsole.error(LOG_PREFIX, "Exception raised while loading VREs for VO : " + vo, e);
} }
} }
catch (FileNotFoundException e) { catch (Exception e) {
ServerConsole.warn(LOG_PREFIX, "skipping... map not found for VO : " + vo, e); ServerConsole.warn(LOG_PREFIX, "skipping... map not found for VO : " + vo, e);
} }
@ -127,36 +131,23 @@ public class ScopeManager {
ServerConsole.info(LOG_PREFIX, "*** found scopes : " + SCOPES.keySet()); ServerConsole.info(LOG_PREFIX, "*** found scopes : " + SCOPES.keySet());
} }
protected static List<VRE> getVREFromVO(final VO vo) protected static List<String> getVREFromVO(final ScopeBean vo) throws Exception {
throws Exception { ServerConsole.info(LOG_PREFIX, "Starting Retrieving VREs for VO : " + vo);
ServerConsole.info(LOG_PREFIX, "*******************\n\n********************\nStarting Retrieving VREs for VO : " + vo); List<String> toReturn = new ArrayList<String>();
List<VRE> toReturn = new ArrayList<VRE>();
ISClient client = GHNContext.getImplementation(ISClient.class); ScopeProvider.instance.set(vo.toString());
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'VRE'");
// FIXME query to get VREs DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
try {
GCUBEGenericResourceQuery query = client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/SecondaryType", "VRE"));
//query.addGenericCondition("not($result/Scopes/Scope/string() eq '" + vo.toString() + "')");
System.out.println( "************** \n\n\n *****************\nready to query : " + query.getExpression());
for (GCUBEGenericResource resource : client.execute(query, vo)) { List<GenericResource> gRes = client.submit(query);
ServerConsole.info(LOG_PREFIX, "Found: " + resource.getName());
for (String vreName : resource.getScopes().keySet()) {
GCUBEScope vre = resource.getScopes().get(vreName);
if (vre.getType().equals(GCUBEScope.Type.VRE)) {
toReturn.add((VRE) vre);
}
}
} for (GenericResource res : gRes) {
} catch (Exception e) { ServerConsole.info(LOG_PREFIX, "Found: " + res.profile().name());
ServerConsole.error(LOG_PREFIX, e); toReturn.add(res.profile().name());
} }
return toReturn; return toReturn;
} }
/** /**
@ -167,7 +158,7 @@ public class ScopeManager {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public static String getMapXML(final GCUBEScope searchvo) throws Exception { public static String getMapXML(final ScopeBean searchvo) throws Exception {
if (confFile == null) { if (confFile == null) {
throw new NullPointerException("the scope file has not been defined"); throw new NullPointerException("the scope file has not been defined");
} }
@ -180,7 +171,7 @@ public class ScopeManager {
String voString = voDetails.item(5).getFirstChild().getNodeValue(); String voString = voDetails.item(5).getFirstChild().getNodeValue();
String fileName = voDetails.item(3).getFirstChild().getNodeValue(); String fileName = voDetails.item(3).getFirstChild().getNodeValue();
// String voName = voDetails.item(1).getFirstChild().getNodeValue(); // String voName = voDetails.item(1).getFirstChild().getNodeValue();
GCUBEScope vo = GCUBEScope.getScope(voString); ScopeBean vo = new ScopeBean(voString);
if (vo.equals(searchvo)) { if (vo.equals(searchvo)) {
return fileToString(System.getenv("GLOBUS_LOCATION") + File.separator + "config" + File.separator + fileName); return fileToString(System.getenv("GLOBUS_LOCATION") + File.separator + "config" + File.separator + fileName);
@ -190,13 +181,13 @@ public class ScopeManager {
return null; return null;
} }
private static ServiceMap loadServiceMap(final VO vo, final String fileName) throws Exception { // private static ServiceMap loadServiceMap(final VO vo, final String fileName) throws Exception {
ServiceMap map = new ServiceMap(); // ServiceMap map = new ServiceMap();
String filePath = System.getenv("GLOBUS_LOCATION") + File.separator + "config" + File.separator + fileName; // String filePath = System.getenv("GLOBUS_LOCATION") + File.separator + "config" + File.separator + fileName;
ServerConsole.info(LOG_PREFIX, "--- Loading " + vo.getName() + " from: " + filePath); // ServerConsole.info(LOG_PREFIX, "--- Loading " + vo.getName() + " from: " + filePath);
map.load(new FileReader(filePath)); // map.load(new FileReader(filePath));
return map; // return map;
} // }
public static String fileToString(final String path) throws IOException { public static String fileToString(final String path) throws IOException {
BufferedReader filebuf = null; BufferedReader filebuf = null;

View File

@ -22,30 +22,31 @@
package org.gcube.resourcemanagement.support.server.tests; package org.gcube.resourcemanagement.support.server.tests;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.File; import java.io.File;
import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.gcube.common.core.scope.GCUBEScope; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.resources.gcore.HostingNode; import org.gcube.common.resources.gcore.HostingNode;
import org.gcube.common.resources.gcore.utils.XPathHelper;
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.resourcemanagement.support.client.utils.StatusHandler;
import org.gcube.resourcemanagement.support.server.gcube.CacheManager; import org.gcube.resourcemanagement.support.server.gcube.CacheManager;
import org.gcube.resourcemanagement.support.server.gcube.ISClientRequester; import org.gcube.resourcemanagement.support.server.gcube.ISClientRequester;
import org.gcube.resourcemanagement.support.server.gcube.queries.QueryLoader;
import org.gcube.resourcemanagement.support.server.gcube.queries.QueryLocation;
import org.gcube.resourcemanagement.support.server.managers.resources.GHNManager; import org.gcube.resourcemanagement.support.server.managers.resources.GHNManager;
import org.gcube.resourcemanagement.support.server.managers.resources.GenericResourceManager; import org.gcube.resourcemanagement.support.server.managers.resources.GenericResourceManager;
import org.gcube.resourcemanagement.support.server.managers.resources.ManagementUtils;
import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager; import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager;
import org.gcube.resourcemanagement.support.server.types.AllowedResourceTypes;
import org.gcube.resourcemanagement.support.server.utils.ServerConsole; import org.gcube.resourcemanagement.support.server.utils.ServerConsole;
import org.gcube.resourcemanagement.support.shared.types.datamodel.ResourceDescriptor; import org.gcube.resourcemanagement.support.shared.types.datamodel.ResourceDescriptor;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.w3c.dom.Node;
import org.gcube.resources.discovery.client.queries.api.Query; import org.xml.sax.InputSource;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
/** /**
* @author Daniele Strollo (ISTI-CNR) * @author Daniele Strollo (ISTI-CNR)
@ -63,9 +64,9 @@ public class GenericTest {
resID = GenericResourceManager.create( resID = GenericResourceManager.create(
null, null,
new ScopeBean("/gcube/devsec"), new ScopeBean("/gcube/devsec"),
"RMP Test", "RMP Test " + new Date(),
"RMP Test Description", "RMP Test Description",
"<TestBody>Hello</TestBody>", "Hello",
"test"); "test");
ServerConsole.trace(null, "Generic Resource Created with ID: " + resID); ServerConsole.trace(null, "Generic Resource Created with ID: " + resID);
} catch (Exception e) { } catch (Exception e) {
@ -79,10 +80,12 @@ public class GenericTest {
public static void testScopeCopy(final String resID, final String fromScope, final String toScope) { public static void testScopeCopy(final String resID, final String fromScope, final String toScope) {
System.out.println("\n\n\n******************** TEST SCOPE COPY ***************"); System.out.println("\n\n\n******************** TEST SCOPE COPY ***************");
try { try {
GenericResourceManager res = new GenericResourceManager(resID); // GenericResourceManager res = new GenericResourceManager(resID);
ServerConsole.trace(null, // ServerConsole.trace(null,
res.addToExistingScope(new ScopeBean(fromScope), new ScopeBean(toScope)) // res.addToExistingScope(new ScopeBean(fromScope), new ScopeBean(toScope))
); // );
String[] ids = {resID};
ManagementUtils.addToExistingScope(AllowedResourceTypes.GenericResource, ids, new ScopeBean(fromScope), new ScopeBean(toScope));
} catch (Exception e) { } catch (Exception e) {
ServerConsole.error(LOG_PREFIX, e); ServerConsole.error(LOG_PREFIX, e);
} finally { } finally {
@ -161,9 +164,12 @@ public class GenericTest {
} }
} }
List<ResourceDescriptor> descs = ISClientRequester.getResourceModels(scope, "GenericResource", null, null); List<String> descs = ISClientRequester.getResourcesByType(cm, scope, "GenericResource", "VRE");
for (ResourceDescriptor resourceDescriptor : descs) { for (String resourceDescriptor : descs) {
System.out.println(resourceDescriptor); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(resourceDescriptor))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
System.out.println(helper.evaluate("/Resource/Name/text()").get(0));
} }
} }
@ -174,21 +180,21 @@ public class GenericTest {
ScopeProvider.instance.set("/gcube/devsec"); ScopeProvider.instance.set("/gcube/devsec");
//testTree( new ScopeBean("/gcube")); testTree( new ScopeBean("/gcube/devsec"));
// boolean deepTest = true; // boolean deepTest = true;
// //
// // testGHN(); // // testGHN();
// if (deepTest) { // if (deepTest) {
String resID = testCreation(); // String resID = testCreation();
testScopeCopy(resID, "/gcube/devsec", "/gcube/devsec/devVRE"); // testScopeCopy(resID, "/gcube/devsec", "/gcube/devsec/devVRE");
////// //////
// System.out.println("\n\nWaiting for resource refresh 20secs.\n\n\n"); // System.out.println("\n\nWaiting for resource refresh 20secs.\n\n\n");
// Thread.sleep(20000); // Thread.sleep(20000);
// //
// //
// //testResourceEdit(resID, new ScopeBean("/gcube/devsec")); // //testResourceEdit(resID, new ScopeBean("/gcube/devsec"));
// //testDelete(resID, new ScopeBean("/gcube/devsec")); //testDelete(resID, new ScopeBean("/gcube/devsec"));
// //
// testRemoveFromScope(resID, new ScopeBean("/gcube/devsec/devVRE")); // testRemoveFromScope(resID, new ScopeBean("/gcube/devsec/devVRE"));
// } else { // } else {

View File

@ -18,13 +18,17 @@ package org.gcube.resourcemanagement.support.server.utils;
import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.resourcemanagement.support.server.managers.resources.AbstractResourceManager; import org.gcube.resourcemanagement.support.server.managers.resources.AbstractResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @author Daniele Strollo (ISTI-CNR) * @author Daniele Strollo (ISTI-CNR)
* *
*/ */
public class ServerConsole { public class ServerConsole {
//private static final Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManager.class);
private static final GCUBEClientLog LOGGER = new GCUBEClientLog(AbstractResourceManager.class); private static final GCUBEClientLog LOGGER = new GCUBEClientLog(AbstractResourceManager.class);
private static final String LOG_PREFIX = "*** [RMP] "; private static final String LOG_PREFIX = "*** [RMP] ";
public static void error(final String prefix, final String msg) { public static void error(final String prefix, final String msg) {
@ -48,13 +52,16 @@ public class ServerConsole {
public static void trace(final String prefix, final String msg) { public static void trace(final String prefix, final String msg) {
LOGGER.trace(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg); LOGGER.trace(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg);
} }
public static void trace(final String msg) {
LOGGER.trace(msg);
}
public static void debug(final String msg) {
LOGGER.debug(msg);
}
public static void warn(final String msg) {
LOGGER.warn(msg);
}
public static void debug(final String prefix, final String msg) { public static void debug(final String prefix, final String msg) {
LOGGER.debug(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg); LOGGER.debug(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg);
} }
public static void fatal(final String prefix, final String msg) {
LOGGER.fatal(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg);
}
public static void fatal(final String prefix, final String msg, final Throwable exc) {
LOGGER.fatal(LOG_PREFIX + ((prefix != null) ? prefix + " " : "") + msg, exc);
}
} }

View File

@ -2,7 +2,7 @@ package org.gcube.resourcemanagement.support.server.utils.persistence;
import java.io.File; import java.io.File;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager; import org.gcube.resourcemanagement.support.server.managers.scope.ScopeManager;
import org.gcube.resourcemanagement.support.server.utils.ServerConsole; import org.gcube.resourcemanagement.support.server.utils.ServerConsole;
@ -12,12 +12,12 @@ public class TestPersistence {
* @param args * @param args
*/ */
public static void main(final String[] args) { public static void main(final String[] args) {
PersistentItem<GCUBEScope[]> persistentScopes = new PersistentItem<GCUBEScope[]>("data.xml", 10000) { PersistentItem<ScopeBean[]> persistentScopes = new PersistentItem<ScopeBean[]>("data.xml", 10000) {
// Builds the data to persist // Builds the data to persist
private void refreshData() { private void refreshData() {
try { try {
GCUBEScope[] toStore = ScopeBean[] toStore =
ScopeManager.getAvailableScopes().values().toArray(new GCUBEScope[]{}); ScopeManager.getAvailableScopes().values().toArray(new ScopeBean[]{});
this.setData(toStore); this.setData(toStore);
} catch (Exception e) { } catch (Exception e) {
ServerConsole.error(LOG_PREFIX, e); ServerConsole.error(LOG_PREFIX, e);
@ -32,7 +32,7 @@ public class TestPersistence {
public void onRefresh() { public void onRefresh() {
this.refreshData(); this.refreshData();
GCUBEScope[] scopes = this.getData(); ScopeBean[] scopes = this.getData();
System.out.println(scopes); System.out.println(scopes);
} }
public void onDestroy() { public void onDestroy() {

View File

@ -128,7 +128,12 @@ public class ResourceDetailModel {
@Override @Override
public String render(BaseModelData model, String property, ColumnData config, public String render(BaseModelData model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) { int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
int val = Integer.parseInt((String)model.get(property)); int val = 0;
try {
val = Integer.parseInt((String)model.get(property));
} catch (NumberFormatException e) {
val = 0;
}
String style = val < 1000000 ? "red" : "green"; String style = val < 1000000 ? "red" : "green";
String toDisplay = number.format(val); String toDisplay = number.format(val);
if (toDisplay.length() > 4) if (toDisplay.length() > 4)