use of org.w3.x2005.x08.addressing.EndpointReferenceType in project airavata by apache.
the class StorageCreator method createStorage.
// The target site must have storage factory deployed with bes factory
public StorageClient createStorage() throws Exception {
if (factoryUrl == null) {
throw new Exception("Cannot create Storage Factory Url");
}
EndpointReferenceType sfEpr = WSUtilities.makeServiceEPR(factoryUrl, StorageFactory.SMF_PORT);
String dn = findServerName(factoryUrl, sfEpr);
WSUtilities.addServerIdentity(sfEpr, dn);
secProps.getETDSettings().setReceiver(new X500Principal(dn));
secProps.getETDSettings().setIssuerCertificateChain(secProps.getCredential().getCertificateChain());
// TODO: remove it afterwards
if (userName != null) {
secProps.getETDSettings().getRequestedUserAttributes2().put("xlogin", new String[] { userName });
}
StorageFactoryClient sfc = new StorageFactoryClient(sfEpr, secProps);
if (log.isDebugEnabled()) {
log.debug("Using storage factory at <" + sfc.getUrl() + ">");
}
StorageClient sc = null;
try {
sc = sfc.createSMS(getCreateSMSDocument());
String addr = sc.getEPR().getAddress().getStringValue();
log.info(addr);
} catch (Exception ex) {
log.error("Could not create storage", ex);
throw new Exception(ex);
}
return sc;
}
use of org.w3.x2005.x08.addressing.EndpointReferenceType in project airavata by apache.
the class StorageCreator method findServerName.
protected String findServerName(String besUrl, EndpointReferenceType smsEpr) throws Exception {
int besIndex = besUrl.indexOf("StorageFactory?res");
String ss = besUrl.substring(0, besIndex);
ss = ss + "Registry";
EndpointReferenceType eprt = WSUtilities.makeServiceEPR(ss, "default_registry", Registry.REGISTRY_PORT);
RegistryClient registry = new RegistryClient(eprt, secProps);
// first, check if server name is already in the EPR...
String dn = WSUtilities.extractServerIDFromEPR(smsEpr);
if (dn != null) {
return dn;
}
// otherwise find a matching service in the registry
String url = smsEpr.getAddress().getStringValue();
if (url.contains("/services/"))
url = url.substring(0, url.indexOf("/services"));
if (log.isDebugEnabled())
log.debug("Checking for services at " + url);
for (EntryType entry : registry.listEntries()) {
if (entry.getMemberServiceEPR().getAddress().getStringValue().startsWith(url)) {
dn = WSUtilities.extractServerIDFromEPR(entry.getMemberServiceEPR());
if (dn != null) {
return dn;
}
}
}
return null;
}
Aggregations