Example usage for java.rmi RemoteException RemoteException

List of usage examples for java.rmi RemoteException RemoteException

Introduction

In this page you can find the example usage for java.rmi RemoteException RemoteException.

Prototype

public RemoteException(String s) 

Source Link

Document

Constructs a RemoteException with the specified detail message.

Usage

From source file:gov.nih.nci.cagrid.identifiers.service.IdentifiersNAServiceImpl.java

/*****************************************
 * This method is used to get the child hierarchy details about the
 * identifiers. This method is a non authentication oriented operation.
 * //from w ww  .j  ava2 s . co m
 * @param identifier
 *            is the GSID for which you would like to get child hierarchy
 *            information.
 * @return a tree representing the child hierarchy.
 * @throws RemoteException
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthoritySecurityFault
 */
public namingauthority.Tree getChildHierarchy(java.lang.String identifier)
        throws RemoteException, gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthoritySecurityFault {
    try {
        LOG.info("getChildHierarchy: USER=========[" + SecurityManager.getManager().getCaller() + "]");
        SecurityInfo secInfo = new SecurityInfoImpl(SecurityManager.getManager().getCaller());
        Tree children = namingAuthority.getChildHierarchy(secInfo, identifier.toString());
        return convert(children);
    } catch (NamingAuthorityConfigurationException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (InvalidIdentifierException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (NamingAuthoritySecurityException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RemoteException(e.toString());
    }
}

From source file:org.sonatype.nexus.plugins.crowd.client.rest.RestClient.java

private void handleHTTPError(HttpResponse response) throws RemoteException {
    StatusLine statusLine = response.getStatusLine();
    int status = statusLine.getStatusCode();
    String statusText = statusLine.getReasonPhrase();
    String body = null;//from   w  ww  . j ava 2  s  .c o m
    if (response.getEntity() != null) {
        body = response.getEntity().toString();
    }

    StringBuilder strBuf = new StringBuilder();
    strBuf.append("Crowd returned HTTP error code:").append(status);
    strBuf.append(" - ").append(statusText);
    if (StringUtils.isNotBlank(body)) {
        strBuf.append("\n").append(body);
    }

    throw new RemoteException(strBuf.toString());
}

From source file:org.molgenis.wikipathways.client.WikiPathwaysRESTBindingStub.java

@Override
public String login(String name, String pass) throws RemoteException {
    try {//from w  w  w  .j a v a 2 s  .  co  m
        String url = baseUrl + "/login?name=" + name + "&pass=" + pass;
        Document jdomDocument = Utils.connect(url, client);
        Element root = jdomDocument.getRootElement();
        String auth = root.getChildText("auth", WSNamespaces.NS1);
        if (auth == null) {
            throw new RemoteException("Invalid username or password");
        }
        return auth;
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    }
}

From source file:org.pathvisio.wikipathways.webservice.WikiPathwaysRESTBindingStub.java

@Override
public String login(String name, String pass) throws RemoteException {
    try {/*w w  w  . j  a  va  2  s .c  om*/
        String url = baseUrl + "/login?name=" + URLEncoder.encode(name, "UTF-8") + "&pass="
                + URLEncoder.encode(pass, "UTF-8");
        Document jdomDocument = Utils.connect(url, client);
        Element root = jdomDocument.getRootElement();
        String auth = root.getChildText("auth", WSNamespaces.NS1);
        if (auth == null) {
            throw new RemoteException("Invalid username or password");
        }
        return auth;
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    }
}

From source file:org.sonatype.nexus.plugins.crowd.client.rest.RestClient.java

private void handleError(Exception e) throws RemoteException {
    LOG.error("Error occured while consuming Crowd REST service", e);
    throw new RemoteException(e.getMessage());
}

From source file:gov.nih.nci.cabig.labviewer.grid.LabViewerStudyConsumer.java

public void rollback(Study study) throws RemoteException, InvalidStudyException {
    String studyGridId = study.getGridId();
    log.debug("Received a Study Rollback StudyGridId" + studyGridId);
    // Obtain Connection
    con = dao.getConnection();/* ww w.j a va  2 s.c  o  m*/
    try {

        java.util.Date insertdate = dao.checkStudyForRollback(con, studyGridId);
        if (insertdate != null) {
            java.util.Date currdate = new Date();
            long milis1 = insertdate.getTime();
            long milis2 = currdate.getTime();
            long diffInMin = (milis2 - milis1) / MILLIS_PER_MINUTE;

            if (insertdate.before(currdate) && diffInMin < THRESHOLD_MINUTE) {
                // Issue Study rollback
                dao.rollbackStudy(con, studyGridId);
            } else {
                log.info("There is no study with in the threshold time for rollback");
            }
        } else {
            // throw remote exception
            StudyCreationException ire = new StudyCreationException();
            ire.setFaultString("Invalid study rollback message- no study found with given gridid");
            log.fatal(ire);
            throw (ire);
        }
    } catch (SQLException se) {
        log.error("Error deleting study", se);
    } finally {
        try {
            con.close();
        } catch (SQLException e) {
            log.error("Error closing connection", e);
            String msg = "Lab Viewer unable to rollback study" + e.getMessage();
            throw new RemoteException(msg);
        }
    }
    log.info("deleted study");
}

From source file:com.urbancode.ud.client.ResourceClient.java

public void waitForResourceCreation(String name) throws IOException, InterruptedException, RemoteException {
    String uri = url + "/cli/resource/info?resource=" + encodePath(name);
    HttpGet method = new HttpGet(uri);
    HttpResponse response = invokeMethod(method);
    int status = response.getStatusLine().getStatusCode();

    long pollInterval = 1000L;
    long timeoutInterval = 10L * 60L * 1000L;
    long start = System.currentTimeMillis();

    while (status == HttpStatus.SC_NOT_FOUND) {
        if (System.currentTimeMillis() - start > timeoutInterval) {
            throw new RemoteException("Timeout waiting for Resource Creation");
        }/*from   w  w  w  . j  av  a  2s .c o m*/
        try {
            discardBody(response);
            Thread.sleep(pollInterval);
            response = invokeMethod(method);
        } catch (IOException e) {
            //swallow
        }
    }
    if (status != HttpStatus.SC_OK) {
        throw new IOException(String.format("%d %s\n%s", response.getStatusLine().getStatusCode(),
                response.getStatusLine().getReasonPhrase(), getBody(response)));
    }
}

From source file:gov.nih.nci.cagrid.identifiers.service.IdentifiersNAServiceImpl.java

/******************************
 * This method is used to register site information related to a globus
 * credential. This is an authentication oriented operation. This operation
 * should be executed before any other authentication operation for a new
 * globus credential. Throws an exception if the globus credentials has
 * already registered a site.// www.j  a v a2s .  com
 * 
 * @param application
 *            is the name of the application
 * @param applicationURL
 *            is the URL of the application
 * @param applicationVersion
 *            is the version of the application
 * @param contactName
 *            is the contact of the site.
 * @param contactEmail
 *            is the email address of the contact of the site.
 * @param contactPhone
 *            is the phone number of the contact.
 * @param organization
 *            is the organization of the site.
 * @throws RemoteException
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthoritySecurityFault
 */
public void registerSite(java.lang.String application, java.lang.String applicationURL,
        java.lang.String applicationVersion, java.lang.String contactName, java.lang.String contactEmail,
        java.lang.String contactPhone, java.lang.String organization)
        throws RemoteException, gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthoritySecurityFault {

    LOG.info("registerSite: USER=========[" + SecurityManager.getManager().getCaller() + "]");
    try {
        SecurityInfo secInfo = new SecurityInfoImpl(SecurityManager.getManager().getCaller());
        namingAuthority.registerSite(secInfo, application, applicationURL, applicationVersion, contactName,
                contactEmail, contactPhone, organization);
    } catch (NamingAuthorityConfigurationException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (InvalidIdentifierException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (NamingAuthoritySecurityException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RemoteException(e.toString());
    }

}

From source file:com.sunrun.crportal.util.CRPortalUtil.java

public static String[] getZipcodesForCityAndState(String city, String state) throws RemoteException {

    final int ZIP_SUCCESS = 0;
    final int ZIP_INVALID_INPUT = 1;
    final int ZIP_INVALID_LICENSE = 2;
    String authkey = getCRPortalProperty("billing-accountlist-cdyne-license-key");
    IPavService service = null;/*  ww  w  .j  a  va  2s.c  o  m*/
    try {
        service = new PavServiceLocator().getpavsoap();
    } catch (ServiceException e) {
        LOG.error("AddressVerifier failed to initialize.", e);
    }
    ZipCodesResponse z = service.getZipCodesForCityAndState(city, state, authkey);
    switch (z.getReturnCode().intValue()) {
    case ZIP_SUCCESS:
        return z.getZipCodes();
    case ZIP_INVALID_INPUT:
        throw new RemoteException("Invalid input.");
    case ZIP_INVALID_LICENSE:
        throw new RemoteException("Invalid license.");
    default:
        return new String[] {};
    }
}

From source file:gov.nih.nci.cagrid.identifiers.service.IdentifiersNAServiceImpl.java

/**************************************************
 * This method checks if the identifier exists in the database or not. if
 * identifier does not exists returns true else false. This is a non
 * authentication oriented operation.//from w w  w  .  jav  a  2  s.  c o  m
 * 
 * @param identifier
 * @return
 * @throws RemoteException
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault
 * @throws gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault
 */
public boolean validateIdentifier(java.lang.String identifier)
        throws RemoteException, gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.InvalidIdentifierValuesFault,
        gov.nih.nci.cagrid.identifiers.stubs.types.NamingAuthorityConfigurationFault {
    try {
        LOG.info("getChildHierarchy: USER=========[" + SecurityManager.getManager().getCaller() + "]");
        SecurityInfo secInfo = new SecurityInfoImpl(SecurityManager.getManager().getCaller());
        boolean flag = namingAuthority.validateIdentifier(secInfo, identifier);
        return flag;
    } catch (NamingAuthorityConfigurationException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (InvalidIdentifierException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (NamingAuthoritySecurityException e) {
        e.printStackTrace();
        throw IdentifiersNAUtil.map(e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RemoteException(e.toString());
    }
}