git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@212 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f84ab38293
commit
25a098e7c8
|
@ -0,0 +1,101 @@
|
||||||
|
package org.gcube.informationsystem.registry.impl.util;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
|
||||||
|
import javax.xml.rpc.ServiceException;
|
||||||
|
|
||||||
|
import org.diligentproject.informationservice.disic.stubs.DISICServiceLocator;
|
||||||
|
import org.diligentproject.informationservice.disic.stubs.DISICServicePortType;
|
||||||
|
import org.diligentproject.informationservice.disic.stubs.DeleteProfileParams;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScopeNotSupportedException;
|
||||||
|
import org.gcube.common.core.scope.ServiceMap;
|
||||||
|
import org.gcube.common.core.scope.ServiceMap.ServiceType;
|
||||||
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
|
import org.gcube.common.informationsystem.publisher.impl.GCUBEPublisherException;
|
||||||
|
import org.gcube.common.informationsystem.publisher.impl.ProfileManager.ResourceTypes;
|
||||||
|
import org.gcube.informationsystem.registry.impl.core.ServiceContext;
|
||||||
|
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||||
|
import org.ietf.jgss.GSSCredential;
|
||||||
|
|
||||||
|
public class ProfileManager {
|
||||||
|
|
||||||
|
protected static final GCUBELog logger=new GCUBELog(ProfileManager.class);
|
||||||
|
|
||||||
|
protected static final String ISICpostfix = "ISICService";
|
||||||
|
|
||||||
|
protected URL isIcAddress;
|
||||||
|
|
||||||
|
protected String VOMapName;
|
||||||
|
|
||||||
|
public ProfileManager() throws Exception {
|
||||||
|
|
||||||
|
GCUBEScope scope = ServiceContext.getContext().getScope();
|
||||||
|
|
||||||
|
ServiceMap map;
|
||||||
|
try {
|
||||||
|
map = scope.getServiceMap();
|
||||||
|
} catch (GCUBEScopeNotSupportedException e1) {
|
||||||
|
logger.error("error retrieving service map for scope " + scope.toString(), e1);
|
||||||
|
throw new Exception(e1);
|
||||||
|
}
|
||||||
|
isIcAddress = this.getICRegistratinAddress(map);
|
||||||
|
VOMapName = scope.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes from IS-IC a GCUBEResource profile ( not knowing the Resurce Type the removal has been done once for every type of GCUBE Resource
|
||||||
|
*
|
||||||
|
* @param uniqueID the uniqueID to of the GCUBEResource to remove
|
||||||
|
* @param type the type of Profile
|
||||||
|
|
||||||
|
* @throws Exception if the unregistration fails
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void removeFromISIC(String uniqueID, String type, GSSCredential ... credentials) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
logger.debug(" Removing profile from IS-IC " + isIcAddress.toString());
|
||||||
|
|
||||||
|
//check if the type has been specified
|
||||||
|
DISICServiceLocator locator_disic = new DISICServiceLocator();
|
||||||
|
DeleteProfileParams params = new DeleteProfileParams();
|
||||||
|
params.setDILIGENTResourceID(uniqueID);
|
||||||
|
if (type != null && type.compareTo("") !=0) {
|
||||||
|
params.setProfileType(type);
|
||||||
|
try {
|
||||||
|
DISICServicePortType dis_ic = locator_disic.getDISICServicePortTypePort(isIcAddress);
|
||||||
|
dis_ic.deleteProfile(params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("An error occurs while trying to remove the GCUBE Profile with ID " + uniqueID, e);
|
||||||
|
throw new Exception("Unregistration failed for the GCUBE Profile with ID " + uniqueID);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
//the typeof the resource to delete is not specified, try all the resource types
|
||||||
|
logger.debug(" trying to remove profile with UniqueID" + uniqueID);
|
||||||
|
for ( int n = 0 ; n < ResourceTypes.values().length ;n++) {
|
||||||
|
params.setProfileType(ResourceTypes.values()[n].toString());
|
||||||
|
logger.debug(" Removing profile from IS-IC " + isIcAddress.toString());
|
||||||
|
DISICServicePortType dis_ic = locator_disic.getDISICServicePortTypePort(isIcAddress);
|
||||||
|
dis_ic.deleteProfile(params);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(" An error occurs while trying to remove the GCUBE Profile with ID "
|
||||||
|
+ uniqueID, e);
|
||||||
|
throw new Exception("Unregistration failed for the GCUBE Profile with ID " + uniqueID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private URL getICRegistratinAddress(ServiceMap map) throws MalformedURLException {
|
||||||
|
|
||||||
|
String addressISIC = (String) map.getEndpoint(ServiceType.ISPublishService).getAddress().toString();
|
||||||
|
addressISIC = addressISIC.substring(0, addressISIC.lastIndexOf("/") + 1) + ISICpostfix;
|
||||||
|
return new URL(addressISIC);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue