Search in sources :

Example 6 with EndpointReferenceType

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;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) X500Principal(javax.security.auth.x500.X500Principal) StorageClient(de.fzj.unicore.uas.client.StorageClient) StorageFactoryClient(de.fzj.unicore.uas.client.StorageFactoryClient)

Example 7 with EndpointReferenceType

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;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) EntryType(org.oasisOpen.docs.wsrf.sg2.EntryType) RegistryClient(de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient)

Aggregations

EndpointReferenceType (org.w3.x2005.x08.addressing.EndpointReferenceType)7 StorageClient (de.fzj.unicore.uas.client.StorageClient)4 GFacException (org.apache.airavata.gfac.core.GFacException)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 JSchException (com.jcraft.jsch.JSchException)2 FactoryClient (de.fzj.unicore.bes.client.FactoryClient)2 StorageFactoryClient (de.fzj.unicore.uas.client.StorageFactoryClient)2 RegistryClient (de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 X500Principal (javax.security.auth.x500.X500Principal)2 AiravataException (org.apache.airavata.common.exception.AiravataException)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)2 SSHApiException (org.apache.airavata.gfac.core.SSHApiException)2 TaskException (org.apache.airavata.gfac.core.task.TaskException)2 JobSubmissionProtocol (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol)2 UnicoreJobSubmission (org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission)2 RegistryException (org.apache.airavata.registry.cpi.RegistryException)2 EntryType (org.oasisOpen.docs.wsrf.sg2.EntryType)2