completed work on
[Task #6952] Catalogue Resolver: update on the fly the Application Profile for VRE's used to resolve Product URL git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@144442 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ff5e080b06
commit
c6e3ac624d
|
@ -310,11 +310,14 @@ public class CatalogueResolver extends HttpServlet{
|
|||
public void run() {
|
||||
try {
|
||||
String fullScope = cer.getValueOfParameter(CatalogueRequestParameter.GCUBE_SCOPE.getKey());
|
||||
UpdateApplicationProfileCatalogueResolver.validateEndPoint(scopeToEncDecr, vreName, fullScope);
|
||||
boolean endPointUpdated = UpdateApplicationProfileCatalogueResolver.validateEndPoint(scopeToEncDecr, vreName, fullScope);
|
||||
|
||||
if(endPointUpdated)
|
||||
appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(scopeToEncDecr, true);
|
||||
|
||||
}
|
||||
catch (ApplicationProfileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
logger.error("Error during validating Application Profile", e);
|
||||
}
|
||||
};
|
||||
}.start();
|
||||
|
|
|
@ -40,17 +40,17 @@ public class UpdateApplicationProfileCatalogueResolver {
|
|||
private static Logger logger = Logger.getLogger(UpdateApplicationProfileCatalogueResolver.class);
|
||||
private static boolean useRootScope = false;
|
||||
|
||||
|
||||
/**
|
||||
* Validate end point. If the EndPoint VRE-FULLNAME does not exist it will be added to Application Profile: {@link ApplicationProfileReaderForCatalogueResolver#RESOURCE_NAME}
|
||||
*
|
||||
* @param scopeToInstanceResolver the scope to instance resolver
|
||||
* @param VRE the vre
|
||||
* @param fullScope the full scope
|
||||
* @return true, if Application Profile has been updated. No otherwise
|
||||
* @throws ApplicationProfileNotFoundException the application profile not found exception
|
||||
*/
|
||||
public static void validateEndPoint(String scopeToInstanceResolver, String VRE, String fullScope) throws ApplicationProfileNotFoundException {
|
||||
logger.info("Checking if the VRE_NAME: "+VRE+", exists into Application Profile: "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+" using scope: "+scopeToInstanceResolver);
|
||||
public static boolean validateEndPoint(String scopeToInstanceResolver, String VRE, String fullScope) throws ApplicationProfileNotFoundException {
|
||||
logger.info("Checking if the VRE_NAME: "+VRE+" exists into Application Profile: "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+" using scope: "+scopeToInstanceResolver);
|
||||
ApplicationProfileReaderForCatalogueResolver appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(scopeToInstanceResolver, true);
|
||||
Element root = appPrCatResolver.getRootDocument();
|
||||
String originalScope = null;
|
||||
|
@ -61,11 +61,11 @@ public class UpdateApplicationProfileCatalogueResolver {
|
|||
//List<String> vreName = helper.evaluate("/Resource/Profile/Body/EndPoint[SCOPE='" +scopeFound.toString() + "']/VRE_NAME/text()");
|
||||
if(fullScope.compareTo(scopeFound)==0){
|
||||
logger.info("The full scope: " + fullScope + ", exists into "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+", skipping update VRE_NAME: "+VRE);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("The full scope: " + fullScope + ", does not exist into "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+", creating the new end point VRE_NAME: "+VRE+", fullScope: "+fullScope);
|
||||
logger.info("The full scope: " + fullScope + " does not exist into "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+", creating the new end point VRE_NAME: "+VRE+", fullScope: "+fullScope);
|
||||
NodeList body = root.getElementsByTagName(ApplicationProfileReaderForCatalogueResolver.BODY);
|
||||
|
||||
if(body==null || body.getLength()==0)
|
||||
|
@ -81,7 +81,7 @@ public class UpdateApplicationProfileCatalogueResolver {
|
|||
DOMSource source2 = new DOMSource(document);
|
||||
transformer.transform(source2, result);
|
||||
|
||||
logger.trace("Updated resource: \n"+result.getWriter().toString());
|
||||
logger.debug("Updated resource: \n"+result.getWriter().toString());
|
||||
|
||||
originalScope = ScopeProvider.instance.get();
|
||||
String discoveryScope = useRootScope?ScopeUtil.getInfrastructureNameFromScope(scopeToInstanceResolver):scopeToInstanceResolver;
|
||||
|
@ -90,7 +90,8 @@ public class UpdateApplicationProfileCatalogueResolver {
|
|||
ScopedPublisher rp=RegistryPublisherFactory.scopedPublisher();
|
||||
Resource resource = toResource(result);
|
||||
rp.update(resource);
|
||||
logger.trace("Generic Resource updated on IS successfully");
|
||||
logger.info("Application Profile: "+ApplicationProfileReaderForCatalogueResolver.RESOURCE_NAME+" updated on IS successfully using scope: "+discoveryScope);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Error ", e);
|
||||
|
@ -137,20 +138,24 @@ public class UpdateApplicationProfileCatalogueResolver {
|
|||
|
||||
newEndPoint.appendChild(newScope);
|
||||
newEndPoint.appendChild(newVREName);
|
||||
|
||||
logger.info("Adding the "+ApplicationProfileReaderForCatalogueResolver.END_POINT+":");
|
||||
logger.info(ApplicationProfileReaderForCatalogueResolver.VRE_NAME +": "+VRE +" - "+ApplicationProfileReaderForCatalogueResolver.SCOPE +" "+fullScope);
|
||||
|
||||
document.getElementsByTagName(ApplicationProfileReaderForCatalogueResolver.BODY).item(0).appendChild(newEndPoint);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String scope = "/gcube";
|
||||
try {
|
||||
UpdateApplicationProfileCatalogueResolver.validateEndPoint(
|
||||
scope, "gcube", "/gcube/devsec");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// String scope = "/gcube";
|
||||
// try {
|
||||
// UpdateApplicationProfileCatalogueResolver.validateEndPoint(
|
||||
// scope, "gcube", "/gcube/devsec");
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue