Example usage for java.rmi RemoteException toString

List of usage examples for java.rmi RemoteException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:nz.co.jsrsolutions.ds3.provider.EodDataEodDataProvider.java

public synchronized int getExchangeMonths(String exchange) throws EodDataProviderException {

    try {/*  w  ww. j  ava2 s  .  c  o m*/

        DataStub.ExchangeMonths exchangeMonthsRequest = new DataStub.ExchangeMonths();
        exchangeMonthsRequest.setToken(token);

        DataStub.ExchangeMonthsResponse exchangeMonthsResponse = eodDataStub
                .exchangeMonths(exchangeMonthsRequest);
        String monthsString = exchangeMonthsResponse.getExchangeMonthsResult().getMONTHS();

        int months = Integer.parseInt(monthsString);

        if (months == 0) {
            months = DEFAULT_MONTHS_HISTORY;
        }

        if (logger.isDebugEnabled()) {

            StringBuffer logMessageBuffer = new StringBuffer();
            logMessageBuffer.append(" Exchange [ ");
            logMessageBuffer.append(exchange);
            logMessageBuffer.append(" ] has [ ");
            logMessageBuffer.append(months);
            logMessageBuffer.append(" ] months of history available. ");
            logger.debug(logMessageBuffer.toString());

        }

        return months;

    } catch (java.rmi.RemoteException re) {

        logger.error(re.toString());
        EodDataProviderException edpe = new EodDataProviderException("Unable to get exchanges");
        edpe.initCause(re);

        throw edpe;

    }

}

From source file:nz.co.jsrsolutions.ds3.provider.EodDataEodDataProvider.java

public synchronized SYMBOL[] getSymbols(String exchange) throws EodDataProviderException {

    try {/*from  www . j av a 2s .co  m*/

        if (logger.isInfoEnabled()) {
            logger.info("Retrieving symbols available on [ " + exchange + " ] ");
        }

        // symbolList
        DataStub.SymbolList symbolListRequest = new DataStub.SymbolList();
        symbolListRequest.setToken(token);
        symbolListRequest.setExchange(exchange);

        DataStub.SymbolListResponse symbolListResponse = eodDataStub.symbolList(symbolListRequest);

        if (symbolListResponse == null) {
            return null;
        }

        DataStub.SYMBOL[] symbolArray = symbolListResponse.getSymbolListResult().getSYMBOLS().getSYMBOL();

        for (DataStub.SYMBOL symbol : symbolArray) {

            if (logger.isDebugEnabled()) {

                StringBuffer logMessageBuffer = new StringBuffer();
                logMessageBuffer.append(" [ ");
                logMessageBuffer.append(symbol.getCode());
                logMessageBuffer.append(" ]  [ ");
                logMessageBuffer.append(symbol.getName());
                logMessageBuffer.append(" ] [ ");
                logMessageBuffer.append(symbol.getLongName());
                logMessageBuffer.append(" ]");
                logger.debug(logMessageBuffer.toString());

            }
        }
        return symbolArray;

    } catch (java.rmi.RemoteException re) {

        logger.error(re.toString());
        EodDataProviderException edpe = new EodDataProviderException("Unable to get symbols");
        edpe.initCause(re);

        throw edpe;

    }
}

From source file:nz.co.jsrsolutions.ds3.provider.EodDataEodDataProvider.java

public synchronized QUOTE[] getQuotes(String exchange, String symbol, Calendar startCalendar,
        Calendar endCalendar, String period) throws EodDataProviderException {

    try {/*from ww w. j a v a2s  .com*/

        StringBuffer startDate = new StringBuffer();
        startDate.append(Integer.toString(startCalendar.get(Calendar.YEAR)));
        startDate.append(String.format("%02d", startCalendar.get(Calendar.MONTH) + 1));
        startDate.append(String.format("%02d", startCalendar.get(Calendar.DAY_OF_MONTH)));

        StringBuffer endDate = new StringBuffer();
        endDate.append(Integer.toString(endCalendar.get(Calendar.YEAR)));
        endDate.append(String.format("%02d", endCalendar.get(Calendar.MONTH) + 1));
        endDate.append(String.format("%02d", endCalendar.get(Calendar.DAY_OF_MONTH)));

        DataStub.SymbolHistoryPeriodByDateRange symbolHistoryPeriodByDateRangeRequest = new DataStub.SymbolHistoryPeriodByDateRange();
        symbolHistoryPeriodByDateRangeRequest.setToken(token);
        symbolHistoryPeriodByDateRangeRequest.setExchange(exchange);
        symbolHistoryPeriodByDateRangeRequest.setSymbol(symbol);
        symbolHistoryPeriodByDateRangeRequest.setStartDate(startDate.toString());
        symbolHistoryPeriodByDateRangeRequest.setEndDate(endDate.toString());
        symbolHistoryPeriodByDateRangeRequest.setPeriod(period);

        DataStub.SymbolHistoryPeriodByDateRangeResponse symbolHistoryPeriodByDateRangeResponse = eodDataStub
                .symbolHistoryPeriodByDateRange(symbolHistoryPeriodByDateRangeRequest);

        DataStub.RESPONSE response = symbolHistoryPeriodByDateRangeResponse
                .getSymbolHistoryPeriodByDateRangeResult();

        if (logger.isDebugEnabled()) {
            logger.debug(response.getMessage());
        }

        if (response.getQUOTES() == null) {
            logger.debug("Failed to retrieve quotes");
            return null;
        }

        DataStub.QUOTE[] quotes = response.getQUOTES().getQUOTE();

        if (quotes == null) {
            return null;
        }

        // This is a fix to cope with the web service occasionally returning 
        // null values for a quote symbol.  It is not understood why this occurs.
        for (QUOTE quote : quotes) {
            if (quote.getSymbol() == null) {
                quote.setSymbol(symbol);
            }
        }

        return quotes;

    } catch (java.rmi.RemoteException re) {

        logger.error(re.toString());
        EodDataProviderException edpe = new EodDataProviderException("Unable to get symbol history");
        edpe.initCause(re);

        throw edpe;

    }

}

From source file:nz.co.jsrsolutions.ds3.provider.EodDataEodDataProvider.java

public QUOTE[] getQuotes(String exchange) throws EodDataProviderException {

    try {/*from  w ww. j  ava 2 s .co  m*/

        DataStub.QuoteList quoteListRequest = new DataStub.QuoteList();
        quoteListRequest.setToken(token);
        quoteListRequest.setExchange(exchange);

        DataStub.QuoteListResponse quoteListResponse = eodDataStub.quoteList(quoteListRequest);
        DataStub.RESPONSE response = quoteListResponse.getQuoteListResult();

        logger.info(response.getMessage());

        if (response.getQUOTES() == null) {
            throw new EodDataProviderException("Failed to retrieve quotes");
        }

        DataStub.QUOTE[] quotes = response.getQUOTES().getQUOTE();

        if (quotes == null) {
            throw new EodDataProviderException("Failed to retrieve quotes");
        }

        if (logger.isDebugEnabled()) {
            for (QUOTE quote : quotes) {
                StringBuffer messageBuffer = new StringBuffer();
                messageBuffer.append(exchange);
                messageBuffer.append(".");
                messageBuffer.append(quote.getSymbol());
                messageBuffer.append(".");

                Calendar calendar = quote.getDateTime();
                messageBuffer.append(Integer.toString(calendar.get(Calendar.YEAR)));
                messageBuffer.append(String.format("%02d", calendar.get(Calendar.MONTH)));
                messageBuffer.append(String.format("%02d", calendar.get(Calendar.DAY_OF_MONTH)));
                messageBuffer.append(",");
                messageBuffer.append(Double.toString(quote.getClose()));

                //          messageBuffer.append(quote.getDateTime());
                messageBuffer.append(" [ ");
                messageBuffer.append(quote.getBid());
                messageBuffer.append(",");
                messageBuffer.append(quote.getAsk());
                messageBuffer.append(" ] ");
                logger.debug(messageBuffer.toString());
            }
        }

        return quotes;

    } catch (java.rmi.RemoteException re) {

        logger.error(re.toString());
        EodDataProviderException edpe = new EodDataProviderException("Unable to get symbol history");
        edpe.initCause(re);

        throw edpe;

    }

}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.HippoWorkflowUtils.java

private static String createHippoFolderNodeByWorkflow(final Session session, Node folderNode,
        String nodeTypeName, String name) throws RepositoryException, WorkflowException {
    try {//from w  ww  .ja v  a  2  s .  co  m
        folderNode = getHippoCanonicalNode(folderNode);
        Workflow wf = getHippoWorkflow(session, DEFAULT_HIPPO_FOLDER_WORKFLOW_CATEGORY, folderNode);

        if (wf instanceof FolderWorkflow) {
            FolderWorkflow fwf = (FolderWorkflow) wf;

            String category = DEFAULT_NEW_DOCUMENT_WORKFLOW_CATEGORY;

            if (nodeTypeName.equals(DEFAULT_HIPPO_FOLDER_NODE_TYPE)) {
                category = DEFAULT_NEW_FOLDER_WORKFLOW_CATEGORY;

                // now check if there is some more specific workflow for hippostd:folder
                if (fwf.hints() != null && fwf.hints().get("prototypes") != null) {
                    Object protypesMap = fwf.hints().get("prototypes");
                    if (protypesMap instanceof Map) {
                        for (Object o : ((Map) protypesMap).entrySet()) {
                            Entry entry = (Entry) o;
                            if (entry.getKey() instanceof String && entry.getValue() instanceof Set) {
                                if (((Set) entry.getValue()).contains(DEFAULT_HIPPO_FOLDER_NODE_TYPE)) {
                                    // we found possibly a more specific workflow for folderNodeTypeName. Use the key as category
                                    category = (String) entry.getKey();
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            String nodeName = DEFAULT_URI_ENCODING.encode(name);
            String added = fwf.add(category, nodeTypeName, nodeName);
            if (added == null) {
                throw new WorkflowException("Failed to add document/folder for type '" + nodeTypeName
                        + "'. Make sure there is a prototype.");
            }
            Node addedNode = folderNode.getSession().getNode(added);
            if (!nodeName.equals(name)) {
                DefaultWorkflow defaultWorkflow = (DefaultWorkflow) getHippoWorkflow(session,
                        DEFAULT_WORKFLOW_CATEGORY, addedNode);
                defaultWorkflow.setDisplayName(name);
            }

            if (DEFAULT_NEW_DOCUMENT_WORKFLOW_CATEGORY.equals(category)) {

                // added new document : because the document must be in 'preview' availability, we now set this explicitly
                if (addedNode.isNodeType("hippostd:publishable")) {
                    log.info("Added document '{}' is pusblishable so set status to preview.",
                            addedNode.getPath());
                    addedNode.setProperty("hippostd:state", "unpublished");
                    addedNode.setProperty(HippoNodeType.HIPPO_AVAILABILITY, new String[] { "preview" });
                } else {
                    log.info("Added document '{}' is not publishable so set status to live & preview directly.",
                            addedNode.getPath());
                    addedNode.setProperty(HippoNodeType.HIPPO_AVAILABILITY, new String[] { "live", "preview" });
                }

                if (addedNode.isNodeType("hippostd:publishableSummary")) {
                    addedNode.setProperty("hippostd:stateSummary", "new");
                }
                addedNode.getSession().save();
            }
            return added;
        } else {
            throw new WorkflowException("Can't create folder " + name + " [" + nodeTypeName + "] in the folder "
                    + folderNode.getPath()
                    + ", because there is no FolderWorkflow possible on the folder node: " + wf);
        }
    } catch (RemoteException e) {
        throw new WorkflowException(e.toString(), e);
    }
}

From source file:org.onehippo.forge.content.exim.core.util.HippoNodeUtils.java

/**
 * Creates a hippo folder by using Hippo Repository Workflow.
 * @param session JCR session//from w  w  w.  j a  v a 2 s .  c  om
 * @param folderNode base folder node
 * @param nodeTypeName folder node type name
 * @param name folder node name
 * @return absolute path of the created folder
 * @throws RepositoryException if unexpected repository exception occurs
 * @throws WorkflowException if unexpected workflow exception occurs
 */
static String createHippoFolderNodeByWorkflow(final Session session, Node folderNode, String nodeTypeName,
        String name) throws RepositoryException, WorkflowException {
    try {
        folderNode = getHippoCanonicalNode(folderNode);
        Workflow wf = getHippoWorkflow(session, DEFAULT_HIPPO_FOLDER_WORKFLOW_CATEGORY, folderNode);

        if (wf instanceof FolderWorkflow) {
            FolderWorkflow fwf = (FolderWorkflow) wf;

            String category = DEFAULT_NEW_DOCUMENT_WORKFLOW_CATEGORY;

            if (nodeTypeName.equals(DEFAULT_HIPPO_FOLDER_NODE_TYPE)) {
                category = DEFAULT_NEW_FOLDER_WORKFLOW_CATEGORY;

                // now check if there is some more specific workflow for hippostd:folder
                if (fwf.hints() != null && fwf.hints().get("prototypes") != null) {
                    Object protypesMap = fwf.hints().get("prototypes");
                    if (protypesMap instanceof Map) {
                        for (Object o : ((Map) protypesMap).entrySet()) {
                            Entry entry = (Entry) o;
                            if (entry.getKey() instanceof String && entry.getValue() instanceof Set) {
                                if (((Set) entry.getValue()).contains(DEFAULT_HIPPO_FOLDER_NODE_TYPE)) {
                                    // we found possibly a more specific workflow for folderNodeTypeName. Use the key as category
                                    category = (String) entry.getKey();
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            String nodeName = DEFAULT_URI_ENCODING.encode(name);
            String added = fwf.add(category, nodeTypeName, nodeName);
            if (added == null) {
                throw new WorkflowException("Failed to add document/folder for type '" + nodeTypeName
                        + "'. Make sure there is a prototype.");
            }
            Node addedNode = folderNode.getSession().getNode(added);
            if (!nodeName.equals(name)) {
                DefaultWorkflow defaultWorkflow = (DefaultWorkflow) getHippoWorkflow(session,
                        DEFAULT_WORKFLOW_CATEGORY, addedNode);
                defaultWorkflow.setDisplayName(name);
            }

            if (DEFAULT_NEW_DOCUMENT_WORKFLOW_CATEGORY.equals(category)) {

                // added new document : because the document must be in 'preview' availability, we now set this explicitly
                if (addedNode.isNodeType("hippostd:publishable")) {
                    log.info("Added document '{}' is pusblishable so set status to preview.",
                            addedNode.getPath());
                    addedNode.setProperty("hippostd:state", "unpublished");
                    addedNode.setProperty(HippoNodeType.HIPPO_AVAILABILITY, new String[] { "preview" });
                } else {
                    log.info("Added document '{}' is not publishable so set status to live & preview directly.",
                            addedNode.getPath());
                    addedNode.setProperty(HippoNodeType.HIPPO_AVAILABILITY, new String[] { "live", "preview" });
                }

                if (addedNode.isNodeType("hippostd:publishableSummary")) {
                    addedNode.setProperty("hippostd:stateSummary", "new");
                }
                addedNode.getSession().save();
            }
            return added;
        } else {
            throw new WorkflowException("Can't create folder " + name + " [" + nodeTypeName + "] in the folder "
                    + folderNode.getPath()
                    + ", because there is no FolderWorkflow possible on the folder node: " + wf);
        }
    } catch (RemoteException e) {
        throw new WorkflowException(e.toString(), e);
    }
}