Example usage for java.rmi RemoteException getMessage

List of usage examples for java.rmi RemoteException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message, including the message from the cause, if any, of this exception.

Usage

From source file:LNISmokeTest.java

/**
 * Execute command line. See Usage string for options and arguments.
 * //from   w w  w  .j  av  a 2 s  .co  m
 * @param argv the argv
 * 
 * @throws Exception the exception
 */
public static void main(String[] argv) throws Exception {
    Options options = new Options();

    OptionGroup func = new OptionGroup();
    func.addOption(new Option("c", "copy", true, "copy <Item> to -C <Collection>"));
    func.addOption(new Option("s", "submit", true, "submit <collection> -P <packager> -i <file>"));
    func.addOption(new Option("d", "disseminate", true, "disseminate <item> -P <packager> -o <file>"));
    func.addOption(new Option("f", "propfind", true, "propfind of all properties or -N <propname>"));
    func.addOption(new Option("r", "rpropfind", true, "recursive propfind, only collections"));
    func.addOption(new Option("n", "names", true, "list all property names on resource"));
    func.addOption(new Option("p", "proppatch", true, "set property: <handle> -N <property> -V <newvalue>"));
    func.setRequired(true);
    options.addOptionGroup(func);

    options.addOption("h", "help", false, "show help message");
    options.addOption("e", "endpoint", true, "SOAP endpoint URL (REQUIRED)");
    options.addOption("P", "packager", true, "Packager to use to import/export a package.");
    options.addOption("C", "collection", true, "Target collection of -c copy");
    options.addOption("o", "output", true, "file to create for new package");
    options.addOption("i", "input", true, "file containing package to submit");
    options.addOption("N", "name", true, "name of property to query/set");
    options.addOption("V", "value", true, "new value for property being set");

    try {
        CommandLine line = (new PosixParser()).parse(options, argv);
        if (line.hasOption("h")) {
            usage(options, 0, null);
        }

        // get SOAP client connection, using the endpoint URL
        String endpoint = line.getOptionValue("e");
        if (endpoint == null) {
            usage(options, 2, "Missing the required -e endpoint argument");
        }
        LNISoapServletServiceLocator loc = new LNISoapServletServiceLocator();
        LNISoapServlet lni = loc.getDSpaceLNI(new URL(endpoint));

        // propfind - with optional single-property Name
        if (line.hasOption("f")) {
            String pfXml = (line.hasOption("N"))
                    ? specificPropPrefix + line.getOptionValue("N") + specificPropSuffix
                    : allProp;
            doPropfind(lni, line.getOptionValue("f"), pfXml, 0, null);
        }

        // recursive propfind limited to collection, community objects
        else if (line.hasOption("r")) {
            doPropfind(lni, line.getOptionValue("r"), someProp, -1, "collection,community");
        } else if (line.hasOption("n")) {
            doPropfind(lni, line.getOptionValue("n"), nameProp, 0, null);
        } else if (line.hasOption("p")) {
            if (line.hasOption("N") && line.hasOption("V")) {
                doProppatch(lni, line.getOptionValue("p"), line.getOptionValue("N"), line.getOptionValue("V"));
            } else {
                usage(options, 13, "Missing required args: -N <name> -V <value>n");
            }
        }

        // submit a package
        else if (line.hasOption("s")) {
            if (line.hasOption("P") && line.hasOption("i")) {
                doPut(lni, line.getOptionValue("s"), line.getOptionValue("P"), line.getOptionValue("i"),
                        endpoint);
            } else {
                usage(options, 13, "Missing required args after -s: -P <packager> -i <file>");
            }
        }

        // Disseminate (GET) item as package
        else if (line.hasOption("d")) {
            if (line.hasOption("P") && line.hasOption("o")) {
                doGet(lni, line.getOptionValue("d"), line.getOptionValue("P"), line.getOptionValue("o"),
                        endpoint);
            } else {
                usage(options, 13, "Missing required args after -d: -P <packager> -o <file>");
            }
        }

        // copy from src to dst
        else if (line.hasOption("c")) {
            if (line.hasOption("C")) {
                doCopy(lni, line.getOptionValue("c"), line.getOptionValue("C"));
            } else {
                usage(options, 13, "Missing required args after -c: -C <collection>\n");
            }
        } else {
            usage(options, 14, "Missing command option.\n");
        }

    } catch (ParseException pe) {
        usage(options, 1, "Error in arguments: " + pe.toString());

    } catch (java.rmi.RemoteException de) {
        System.out.println("ERROR, got RemoteException, message=" + de.getMessage());

        de.printStackTrace();

        die(1, "  Exception class=" + de.getClass().getName());
    }
}

From source file:edu.harvard.med.iccbl.screensaver.soaputils.PugSoapUtil.java

private static String getStatusMessage(PUGStub pug, String key) {
    GetStatusMessage req6 = new GetStatusMessage();
    AnyKeyType anyKey = new AnyKeyType();
    anyKey.setAnyKey(key);/*from w ww. j av  a  2  s  .c  om*/
    req6.setGetStatusMessage(anyKey);
    try {
        return pug.getStatusMessage(req6).getMessage();
    } catch (RemoteException e) {
        log.warn("Server status request failed, unable to provide a status message: " + e.getMessage());
        log.info("Server Status request failed, unable to provide a status message", e);
        return "Server status request failed, unable to provide a status message: " + e.getMessage();
    }
}

From source file:net.sf.farrago.namespace.sfdc.SfdcUdx.java

public static void getLov(String objectName, PreparedStatement resultInserter) throws SQLException {
    try {//www  .  j a  va  2s.c om
        SfdcDataServer server = (SfdcDataServer) FarragoUdrRuntime.getDataServerRuntimeSupport(new Object());
        DescribeSObjectResult describeSObjectResult = (DescribeSObjectResult) server
                .getEntityDescribe(objectName);

        // check the name
        if ((describeSObjectResult != null) && describeSObjectResult.getName().equals(objectName)) {
            com.sforce.soap.partner.Field[] fields = describeSObjectResult.getFields();

            for (int i = 0; i < fields.length; i++) {
                PicklistEntry[] picklistValues = fields[i].getPicklistValues();
                if (picklistValues != null) {
                    for (int j = 0; j < picklistValues.length; j++) {
                        if (picklistValues[j].getLabel() != null) {
                            String fieldString = fields[i].getName();
                            int prec = 25 + server.getVarcharPrecision();
                            if (fieldString.length() > prec) {
                                fieldString = fieldString.substring(0, prec);
                            }
                            resultInserter.setString(1, fieldString);
                            String lovValue = picklistValues[j].getValue();
                            prec = 256 + server.getVarcharPrecision();
                            if (lovValue.length() > prec) {
                                lovValue = lovValue.substring(0, prec);
                            }
                            resultInserter.setString(2, lovValue);
                            resultInserter.executeUpdate();
                        }
                    }
                }
            }
        } else {
            throw SfdcResource.instance().InvalidObjectException.ex(objectName);
        }
    } catch (AxisFault ae) {
        SQLException retryExcn = new SQLException(ae.getFaultString(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(ae.getFaultString(), chainedEx);
    } catch (RemoteException re) {
        SQLException retryExcn = new SQLException(re.getMessage(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(re.getMessage(), chainedEx);
    }
}

From source file:net.sf.farrago.namespace.sfdc.SfdcUdx.java

public static void getDeleted(String objectName, String start, String end, PreparedStatement resultInserter)
        throws SQLException {
    SoapBindingStub binding = (SoapBindingStub) FarragoUdrRuntime.getDataServerRuntimeSupport(null);

    if (((start == null) || start.equals("")) || ((end == null) || end.equals(""))) {
        throw SfdcResource.instance().InvalidRangeException.ex();
    }/*from w  ww. j  a v a2s. c  om*/

    Calendar startTime;
    Calendar endTime;
    Calendar thirtyDaysAgo;

    try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        java.util.Date sd = sdf.parse(start, new ParsePosition(0));
        startTime = Calendar.getInstance();
        startTime.setTime(sd);

        java.util.Date now = new java.util.Date();

        // 30 days == 30*24*60*60*1000 ms
        Long thirty = new Long("2592000000");
        java.util.Date thirtyDate = new java.util.Date(now.getTime() - thirty.longValue());
        thirtyDaysAgo = Calendar.getInstance();
        thirtyDaysAgo.setTime(thirtyDate);

        java.util.Date ed = sdf.parse(end, new ParsePosition(0));
        endTime = Calendar.getInstance();
        endTime.setTime(ed);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw SfdcResource.instance().InvalidTimeException.ex(ex.getMessage());
    }
    if (thirtyDaysAgo.compareTo(startTime) > 0) {
        throw SfdcResource.instance().InvalidStartTimeException.ex(startTime.getTime().toString());
    }

    if (startTime.compareTo(endTime) > 0) {
        throw SfdcResource.instance().InvalidEndTimeException.ex(endTime.getTime().toString(),
                startTime.getTime().toString());
    }

    SfdcDataServer server = (SfdcDataServer) FarragoUdrRuntime.getDataServerRuntimeSupport(new Object());
    try {
        DescribeSObjectResult describeSObjectResult = (DescribeSObjectResult) server
                .getEntityDescribe(objectName);

        // check the name
        if ((describeSObjectResult != null) && describeSObjectResult.getName().equals(objectName)) {
            // check if data replication is allowed on object
            if (!describeSObjectResult.isReplicateable()) {
                throw SfdcResource.instance().ReplicationException.ex(objectName);
            }
        } else {
            throw SfdcResource.instance().InvalidObjectException.ex(objectName);
        }
        GetDeletedResult gdr = binding.getDeleted(objectName, startTime, endTime);
        if ((gdr.getDeletedRecords() != null) && (gdr.getDeletedRecords().length > 0)) {
            for (int i = 0; i < gdr.getDeletedRecords().length; i++) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                StringBuffer sbuf = new StringBuffer();
                String idString = gdr.getDeletedRecords(i).getId();
                int prec = 25 + server.getVarcharPrecision();
                if (idString.length() > prec) {
                    idString = idString.substring(0, prec);
                }
                resultInserter.setString(1, idString);
                String timeStr = sdf
                        .format(gdr.getDeletedRecords(i).getDeletedDate().getTime(), sbuf, new FieldPosition(0))
                        .toString();
                resultInserter.setTimestamp(2, java.sql.Timestamp.valueOf(timeStr));
                resultInserter.executeUpdate();
            }
        }
    } catch (AxisFault ae) {
        SQLException retryExcn = new SQLException(ae.getFaultString(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(ae.getFaultString(), chainedEx);
    } catch (RemoteException re) {
        SQLException retryExcn = new SQLException(re.getMessage(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(re.getMessage(), chainedEx);
    }
}

From source file:net.sf.farrago.namespace.sfdc.SfdcUdx.java

public static void query(String query, String types, PreparedStatement resultInserter) throws SQLException {
    SoapBindingStub binding = (SoapBindingStub) FarragoUdrRuntime.getDataServerRuntimeSupport(null);

    try {/*  w  w  w  .  j  a  v a  2s  .com*/
        QueryOptions qo = new QueryOptions();
        int batchsize = 500;
        qo.setBatchSize(new Integer(batchsize));
        binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "QueryOptions", qo);

        String objName = query;
        int fromIdx = query.lastIndexOf(" from");
        if (fromIdx > 0) {
            objName = query.substring(fromIdx + 6);
        }

        // strip off quotes for boolean values
        query = stripQuotes(query, objName);
        log.info("SFDC Query: " + query);

        QueryResult qr = binding.query(query);
        if (qr.isDone()) {
            if (qr.getRecords() != null) {
                log.info(SfdcResource.instance().RetrievedAllRecordsMsg
                        .str(Integer.toString(qr.getRecords().length), objName));
            }
        } else {
            if (qr.getRecords() != null) {
                log.info(SfdcResource.instance().RetrievingRecordsMsg
                        .str(Integer.toString(qr.getRecords().length), objName));
            }
        }
        SObject[] records = qr.getRecords();
        String[] metadataType = types.split(",");

        // query is of following format:
        // "select col1,col2,... from"
        String cols = query.substring(7);
        fromIdx = cols.lastIndexOf(" from");
        cols = cols.substring(0, fromIdx);
        cols = cols.trim();
        String[] columnValues = new String[metadataType.length];

        if (records != null) {
            boolean bContinue = true;
            while (bContinue) {
                // for each record returned in query,
                // get value of each field
                for (int i = 0; i < records.length; i++) {
                    MessageElement[] elements = records[i].get_any();
                    if (elements != null) {
                        for (int j = 0; j < elements.length; j++) {
                            MessageElement elt = elements[j];
                            String eltVal = elt.getValue();
                            columnValues[j] = (eltVal != null) ? eltVal : "null";

                            if (metadataType[j].indexOf("TIMESTAMP") != -1) {
                                // TIMESTAMP
                                if (eltVal != null) {
                                    String tstampstr = eltVal.replace("T", " ");
                                    tstampstr = tstampstr.substring(0, tstampstr.indexOf("."));
                                    java.sql.Timestamp tstamp = java.sql.Timestamp.valueOf(tstampstr);
                                    resultInserter.setTimestamp(j + 1, tstamp);
                                } else {
                                    resultInserter.setNull(j + 1, java.sql.Types.TIMESTAMP);
                                }
                            } else if (metadataType[j].indexOf("TIME") != -1) {
                                // TIME
                                if (eltVal != null) {
                                    String timestr = eltVal.substring(0, eltVal.indexOf("."));
                                    java.sql.Time time = java.sql.Time.valueOf(timestr);
                                    resultInserter.setTime(j + 1, time);
                                } else {
                                    resultInserter.setNull(j + 1, java.sql.Types.TIME);
                                }
                            } else if (metadataType[j].indexOf("DATE") != -1) {
                                // DATE
                                if (eltVal != null) {
                                    java.sql.Date dt = java.sql.Date.valueOf(eltVal);
                                    resultInserter.setDate(j + 1, dt);
                                } else {
                                    resultInserter.setNull(j + 1, java.sql.Types.DATE);
                                }
                            } else if (metadataType[j].indexOf("INTEGER") != -1) {
                                // INTEGER
                                if (eltVal != null) {
                                    int iValue = 0;
                                    iValue = Integer.parseInt(eltVal);
                                    resultInserter.setInt(j + 1, iValue);
                                } else {
                                    resultInserter.setNull(j + 1, java.sql.Types.INTEGER);
                                }
                            } else if (metadataType[j].indexOf("DOUBLE") != -1) {
                                // DOUBLE
                                if (eltVal != null) {
                                    resultInserter.setDouble(j + 1, Double.parseDouble(eltVal));
                                } else {
                                    resultInserter.setNull(j + 1, java.sql.Types.DOUBLE);
                                }
                            } else if (eltVal != null) {
                                // VARCHAR - default
                                int rightParen = metadataType[j].indexOf(")");
                                int prec = Integer.parseInt(metadataType[j].substring(8, rightParen));
                                if (eltVal.length() > prec) {
                                    eltVal = eltVal.substring(0, prec);
                                    columnValues[j] = eltVal;
                                }
                                resultInserter.setString(j + 1, eltVal);
                            } else {
                                resultInserter.setNull(j + 1, java.sql.Types.VARCHAR);
                            }
                        }
                        resultInserter.executeUpdate();
                    }
                }
                if (qr.isDone()) {
                    bContinue = false;
                } else {
                    boolean relogin = true;
                    int retryCnt = 0;
                    while (relogin) {
                        try {
                            qr = binding.queryMore(qr.getQueryLocator());
                            relogin = false;
                        } catch (AxisFault a) {
                            if (a.getFaultString().contains("Invalid Session ID") && (retryCnt < RETRY_CNT)) {
                                relogin = true;
                                retryCnt++;
                                binding = (SoapBindingStub) FarragoUdrRuntime
                                        .getDataServerRuntimeSupport(binding);
                            } else {
                                throw a;
                            }
                        }
                    }
                    records = qr.getRecords();
                    if (qr.isDone()) {
                        if (qr.getRecords() != null) {
                            log.info(SfdcResource.instance().RetrievedAllRecordsMsg
                                    .str(Integer.toString(qr.getRecords().length), objName));
                        }
                    } else {
                        if (qr.getRecords() != null) {
                            log.info(SfdcResource.instance().RetrievingRecordsMsg
                                    .str(Integer.toString(qr.getRecords().length), objName));
                        }
                    }
                }
            }
        }
    } catch (AxisFault ae) {
        SQLException retryExcn = new SQLException(ae.getFaultString(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(ae.getFaultString(), chainedEx);
    } catch (RemoteException re) {
        SQLException retryExcn = new SQLException(re.getMessage(), null, 460150);
        Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn);
        throw SfdcResource.instance().BindingCallException.ex(re.getMessage(), chainedEx);
    }
}

From source file:is.idega.idegaweb.egov.gumbo.pdf.GumboPDFGenerator.java

private PrintingService getPrintingService() {
    try {//w  w w . j a va2s .  c om
        return (PrintingService) IBOLookup.getServiceInstance(getIWApplicationContext(), PrintingService.class);
    } catch (RemoteException e) {
        throw new IBORuntimeException(e.getMessage());
    }
}

From source file:gridool.tools.cmd.CoordinateReplicaCommand.java

public boolean process(String[] args) throws CommandException {
    String driverClassName = getOption("driverClassName");
    String primaryDbUrl = getOption("primaryDbUrl");
    String user = getOption("user");
    String passwd = getOption("passwd");

    boolean reorg = (args.length == 4);
    int numReplicas = Integer.parseInt(args[2]);
    final CoordinateReplicaJobConf jobConf = new CoordinateReplicaJobConf(driverClassName, primaryDbUrl, user,
            passwd, numReplicas, reorg);

    final Grid grid = new GridClient();
    final GridNode[] failedNodes;
    try {//from   w w w  .jav  a2  s  .c  om
        failedNodes = grid.execute(CoordinateReplicaJob.class, jobConf);
    } catch (RemoteException e) {
        throwException(e.getMessage());
        return false;
    }
    if (failedNodes.length > 0) {
        LOG.warn("Could not coordinate replicas properly. failed on " + Arrays.toString(failedNodes));
        return false;
    }
    LOG.info("Coordinated replicas successfully.");
    return true;
}

From source file:org.openehealth.ipf.labs.maven.confluence.export.ConfluenceExportMojo.java

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    client = new DefaultHttpClient();
    if (hasProxy()) {
        enableAxisProxy();/*w  w w .  j  a  v  a 2  s.c  o m*/
        configureHttpClientProxy();
    }
    initializeConfluenceTemplate();

    boolean isVersion30AndAbove = isConfluenceVersion30andAbove();
    try {
        confluenceTemplate.export(client, exportSpaces, isVersion30AndAbove, this.outputDirectory);
    } catch (RemoteException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (ServiceException e) {
        throw new MojoExecutionException(e.getMessage(), e.getLinkedCause());
    } catch (HttpException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } finally {

        client.getConnectionManager().shutdown();
    }
}

From source file:com.collabnet.ccf.pi.sfee.v44.SFEEConnectionFactory.java

/**
 * Logs out from the TF system and invalidates the session id.
 * //from  w  w w .  ja  v  a 2 s  . c o m
 * @see com.collabnet.ccf.core.eis.connection.ConnectionFactory#closeConnection(java.lang.Object)
 */
public void closeConnection(Connection connection) throws ConnectionException {
    ISourceForgeSoap sfSoap = connection.getSfSoap();
    String sessionId = connection.getSessionId();
    String username = connection.getUserName();
    try {
        sfSoap.logoff(username, sessionId);
    } catch (RemoteException e) {
        String cause = "An error occured while trying to close the connection for " + e.getMessage();
        log.error(cause, e);
        throw new ConnectionException(cause, e);
    }
}

From source file:gov.nih.nci.caarray.services.external.v1_0.grid.client.GridDataApiUtils.java

private TransferServiceContextReference getFileContentsTransfer(CaArrayEntityReference fileRef,
        boolean compressed) throws InvalidReferenceException, DataTransferException, IOException {
    try {/*from  w w w.  ja v a2  s .co  m*/
        return client.getFileContentsTransfer(fileRef, compressed);
    } catch (IncorrectEntityTypeFault f) {
        throw new IncorrectEntityTypeException(f.getCaArrayEntityReference(), GridApiUtils.getMessage(f));
    } catch (NoEntityMatchingReferenceFault f) {
        throw new NoEntityMatchingReferenceException(f.getCaArrayEntityReference(), GridApiUtils.getMessage(f));
    } catch (DataStagingFault f) {
        throw new DataTransferException(GridApiUtils.getMessage(f));
    } catch (RemoteException e) {
        throw new DataTransferException(e.getMessage());
    }
}