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, Throwable cause) 

Source Link

Document

Constructs a RemoteException with the specified detail message and cause.

Usage

From source file:edu.clemson.cs.nestbed.server.management.configuration.MoteDeploymentConfigurationManagerImpl.java

private MoteDeploymentConfigurationManagerImpl() throws RemoteException {
    super();//from  w w  w .  j a v a  2 s. c  om

    try {
        managerLock = new ReentrantReadWriteLock(true);
        readLock = managerLock.readLock();
        writeLock = managerLock.writeLock();
        moteDepConfigAdapter = AdapterFactory.createMoteDeploymentConfigurationAdapter(AdapterType.SQL);
        moteDepConfigs = moteDepConfigAdapter.readMoteDeploymentConfigurations();

        log.debug("MoteDeploymentConfigurations read:\n" + moteDepConfigs);
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (Exception ex) {
        String msg = "Exception in MoteDeploymentConfigurationManagerImpl";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

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

@Override
public byte[] getPathwayAs(String fileType, String pwId, int revision) throws RemoteException {
    InputStream instream = null;//from   ww  w  .ja  v  a2 s.co  m
    try {
        String url = baseUrl;
        if (url.contains("webservice/webservice.php")) {
            url = url.replace("webservice/webservice.php", "wpi.php");
        } else if (url.contains("webservicetest")) {
            url = url.replace("webservicetest/webservice.php", "wpi.php");
        } else if (url.contains("webservice.wikipathways.org")) {
            url = "http://www.wikipathways.org/wpi/wpi.php";
        }
        url = url + "?action=downloadFile&type=" + fileType + "&pwTitle=Pathway:" + pwId + "&oldid=" + revision;

        HttpGet httpget = new HttpGet(url);
        HttpResponse response = client.execute(httpget);
        HttpEntity entity = response.getEntity();
        instream = entity.getContent();

        return IOUtils.toByteArray(instream);
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    } finally {
        try {
            if (instream != null) {
                instream.close();
            }
        } catch (Exception e) {
            throw new RemoteException(e.getMessage(), e.getCause());
        }
    }
}

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

@Override
public byte[] getPathwayAs(String fileType, String pwId, int revision) throws RemoteException {
    InputStream instream = null;//from   w ww.  j a  va2 s. c o  m
    try {
        String url = baseUrl;
        if (url.contains("webservice/webservice.php")) {
            url = url.replace("webservice/webservice.php", "wpi.php");
        } else if (url.contains("webservicetest")) {
            url = url.replace("webservicetest/webservice.php", "wpi.php");
        } else if (url.contains("webservice.wikipathways.org")) {
            url = "http://www.wikipathways.org/wpi/wpi.php";
        }
        url = url + "?action=downloadFile&type=" + fileType + "&pwTitle=Pathway:" + pwId + "&oldid=" + revision;

        HttpGet httpget = new HttpGet(url);
        HttpResponse response = client.execute(httpget);
        HttpEntity entity = response.getEntity();
        instream = entity.getContent();

        return IOUtils.toByteArray(instream);
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    } finally {
        try {
            if (instream != null) {
                instream.close();
            }
        } catch (IOException e) {
            throw new RemoteException(e.getMessage(), e.getCause());
        }
    }
}

From source file:gov.loc.www.zing.srw.srw_bindings.SRWSoapBindingImpl.java

public Stream searchRetrieveOperation(de.escidoc.core.domain.sru.SearchRetrieveRequestType request,
        MessageContext msgContext, String handle) throws RemoteException {
    log.debug("Enter: searchRetrieveOperation");
    if (log.isInfoEnabled()) {
        log.info("request: maximumRecords:" + request.getMaximumRecords() + " query:" + request.getQuery()
                + " recordPacking:" + request.getRecordPacking() + " recordSchema:" + request.getRecordSchema()
                + " recordXpath:" + request.getRecordXPath() + " sortKeys:" + request.getSortKeys()
                + " startRecord:" + request.getStartRecord() + " stylesheet:" + request.getStylesheet()
                + " version:" + request.getVersion());
    }//from  www  . ja  v  a2s  .co  m
    long startTime = System.currentTimeMillis();
    try {
        UserContext.setUserContext(handle);
        try {
            UserContext.getSecurityContext();
        } catch (SystemException e1) {
            throw new InvocationTargetException(e1);
        }
    } catch (Exception ex) {
    }
    RestSearchRetrieveResponseType response = null;
    int resultSetIdleTime = ((Integer) msgContext.getProperty("resultSetIdleTime")).intValue();
    NonNegativeInteger nni = request.getResultSetTTL();
    if (log.isDebugEnabled())
        log.debug("resultSetTTL()=" + nni);
    if (nni != null) {
        int ttl = nni.intValue();
        log.debug("ttl=" + ttl);
        if (ttl < resultSetIdleTime)
            resultSetIdleTime = ttl;
    }
    String dbname = (String) msgContext.getProperty("dbname");
    SRWDatabase db = (SRWDatabase) msgContext.getProperty("db");
    if (log.isDebugEnabled())
        log.debug("db=" + db);

    String sortKeys = request.getSortKeys();
    if (sortKeys != null)
        request.setSortKeys(sortKeys);

    String query = request.getQuery();
    if (query.indexOf('%') >= 0) {
        try {
            request.setQuery(java.net.URLDecoder.decode(query, "utf-8"));
        } catch (java.io.UnsupportedEncodingException e) {
        }
    }

    try {
        if (query == null) {
            response = new RestSearchRetrieveResponseType();
            response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType());
            db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied, "query",
                    response.getSearchRetrieveResponse());
        } else if (request.getStartRecord() != null
                && request.getStartRecord().intValue() == Integer.MAX_VALUE) {
            response = new RestSearchRetrieveResponseType();
            response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType());
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "startRecord",
                    response.getSearchRetrieveResponse());
        } else if (request.getMaximumRecords() != null
                && request.getMaximumRecords().intValue() == Integer.MAX_VALUE) {
            response = new RestSearchRetrieveResponseType();
            response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType());
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "maximumRecords",
                    response.getSearchRetrieveResponse());
        } else if (request.getResultSetTTL() != null
                && request.getResultSetTTL().intValue() == Integer.MAX_VALUE) {
            response = new RestSearchRetrieveResponseType();
            response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType());
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "resultSetTTL",
                    response.getSearchRetrieveResponse());
        } else {
            try {
                response = db.doRequest(request);
                if (response == null) {
                    response = new RestSearchRetrieveResponseType();
                    response.setSearchRetrieveResponse(
                            new de.escidoc.core.domain.sru.SearchRetrieveResponseType());
                    response.getSearchRetrieveResponse().setVersion("1.1");
                    setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse());
                    db.diagnostic(SRWDiagnostic.GeneralSystemError, null, response.getSearchRetrieveResponse());
                    return response.toStream(db, true);
                }
                if (msgContext.getProperty("sru") != null && request.getStylesheet() != null) // you can't ask for
                    // a stylesheet in
                    // srw!
                    db.diagnostic(SRWDiagnostic.StylesheetsNotSupported, null,
                            response.getSearchRetrieveResponse());

                setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse());
                if (request.getRecordXPath() != null)
                    db.diagnostic(72, null, response.getSearchRetrieveResponse());
                if (request.getSortKeys() != null && !request.getSortKeys().equals("") && !db.supportsSort())
                    db.diagnostic(SRWDiagnostic.SortNotSupported, null, response.getSearchRetrieveResponse());

                // set extraResponseData
                ExtraDataTO extraDataTo = new ExtraDataTO();

                // we're going to stick the database name in extraResponseData
                // every time
                if (db.databaseTitle != null)
                    extraDataTo.setDatabaseTitle(db.databaseTitle);
                else
                    extraDataTo.setDatabaseTitle(dbname);

                // did they ask for the targetURL to be returned?
                Hashtable extraRequestDataElements = SRWDatabase.parseElements(request.getExtraRequestData());
                String s = (String) extraRequestDataElements.get("returnTargetURL");
                log.info("returnTargetURL=" + s);
                if (s != null && !s.equals("false")) {
                    String targetStr = (String) msgContext.getProperty("targetURL");
                    log.info("targetStr=" + targetStr);
                    if (targetStr != null && targetStr.length() > 0) {
                        URL target = new URL(targetStr);
                        TargetUrlTO targetUrlTo = new TargetUrlTO();
                        targetUrlTo.setHost(target.getHost());
                        targetUrlTo.setPort(Integer.toString(target.getPort()));
                        targetUrlTo.setPath(target.getPath());
                        targetUrlTo.setQuery(Utilities.xmlEncode(target.getQuery()));
                        extraDataTo.setTargetURL(targetUrlTo);
                    }
                }

                // set extraResponseData
                SRWDatabase.setExtraResponseData(response.getSearchRetrieveResponse(), extraDataTo);
            } catch (Exception e) {
                log.error(e, e);
                throw new RemoteException(e.getMessage(), e);
            } finally {
                SRWDatabase.putDb(dbname, db);
            }
            response.getSearchRetrieveResponse().setVersion("1.1");
            log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " ("
                    + (System.currentTimeMillis() - startTime) + "ms)");
            log.debug("Exit: searchRetrieveOperation");
            return response.toStream(db, true);
        }
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e);
    }
    response.getSearchRetrieveResponse().setVersion("1.1");
    log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " ("
            + (System.currentTimeMillis() - startTime) + "ms)");
    log.debug("Exit: searchRetrieveOperation");
    return response.toStream(db, true);
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProgramProfilingMessageSymbolManagerImpl.java

public void deleteProgramProfilingMessageSymbolWithProgMsgSymID(int pmsID) throws RemoteException {
    log.info("Request to delete ProgramProfilingMessageSymbol for " + "ProgramMessageSymbol: " + pmsID);

    try {/*from ww w  .j av  a 2  s.  co  m*/
        List<ProgramProfilingMessageSymbol> list;
        list = new ArrayList<ProgramProfilingMessageSymbol>(ppmSymbols.values());

        for (ProgramProfilingMessageSymbol i : list) {
            if (i.getProgramMessageSymbolID() == pmsID) {
                deleteProgramProfilingMessageSymbol(i.getID());
            }
        }
    } catch (RemoteException ex) {
        throw ex;
    } catch (Exception ex) {
        String msg = "Exception in " + "deleteProgramProfilingMessageSymbolWithProgMsgSymID";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProgramProfilingSymbolManagerImpl.java

private ProgramProfilingSymbolManagerImpl() throws RemoteException {
    super();/*from  w  w w. j  ava 2 s .co m*/

    try {
        this.managerLock = new ReentrantReadWriteLock(true);
        this.readLock = managerLock.readLock();
        this.writeLock = managerLock.writeLock();
        progProfSymbolAdapter = AdapterFactory.createProgramProfilingSymbolAdapter(AdapterType.SQL);
        progProfSymbols = progProfSymbolAdapter.readProgramProfilingSymbols();

        log.debug("ProgramProfilingSymbols read:\n" + progProfSymbols);
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (Exception ex) {
        String msg = "Exception in ProgramProfilingSymbolManagerImpl";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:com.edmunds.etm.netscaler.NetScalerLoadBalancer.java

@Override
public synchronized void addPoolMember(String serverName, PoolMember member)
        throws PoolMemberExistsException, RemoteException {

    final NsMonitor monitor = getMonitor(serverName);

    final String ipAddress = member.getHostAddress().getIpAddress();
    final String serviceName = "ip_" + ipAddress;

    final NsServer nsServer = new NsServer();
    nsServer.setName(serviceName);/*from  ww w.j av a2s.  c  o m*/
    nsServer.setIpAddress(ipAddress);

    final NsService nsService = new NsService();
    nsService.setName(serviceName);
    nsService.setServiceType(NsServiceType.HTTP);
    nsService.setPort(member.getHostAddress().getPort());
    nsService.setServer(nsServer);

    try {
        final NsVirtualServer nsVirtualServer = nitroService.getVirtualServers().get(serverName);

        try {
            nitroService.getServers().create(nsServer);
        } catch (NitroExceptionResourceExists e) {
            // Ignore since we still need to handle the service and binding
        }

        try {
            nitroService.getServices().create(nsService);
        } catch (NitroExceptionResourceExists e) {
            // Ignore since we still need to handle the service and binding
        }

        if (monitor != null) {
            nsService.bindMonitor(monitor);
        }

        nsVirtualServer.bindService(nsService);
    } catch (NitroExceptionResourceExists e) {
        throw new PoolMemberExistsException(serviceName, e);
    } catch (NitroException e) {
        throw new RemoteException("Add Pool Member Failed", e);
    }
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProgramProfilingMessageSymbolManagerImpl.java

private ProgramProfilingMessageSymbolManagerImpl() throws RemoteException {
    super();// w  w w  . j a  va2 s.  co  m

    try {
        this.managerLock = new ReentrantReadWriteLock(true);
        this.readLock = managerLock.readLock();
        this.writeLock = managerLock.writeLock();
        ppmsAdapter = AdapterFactory.createProgramProfilingMessageSymbolAdapter(AdapterType.SQL);

        ppmSymbols = ppmsAdapter.readProgramProfilingMessageSymbols();

        log.debug("ProgramProfilingMessageSymbols read:\n" + ppmSymbols);
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (Exception ex) {
        String msg = "Exception in " + "ProgramProfilingMessageSymbolManagerImpl";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

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

@Override
public WSPathwayInfo[] getPathwaysByOntologyTerm(String term) throws RemoteException {
    try {/*from ww  w .  java2 s .c  o  m*/
        term = term.replace(" ", "+");
        String url = baseUrl + "/getPathwaysByOntologyTerm?term=" + term;
        Document jdomDocument = Utils.connect(url, client);
        Element root = jdomDocument.getRootElement();
        List<Element> list = root.getChildren("pathways", WSNamespaces.NS1);
        WSPathwayInfo[] info = new WSPathwayInfo[list.size()];
        for (int i = 0; i < list.size(); i++) {
            info[i] = Utils.parseWSPathwayInfo(list.get(i));
        }
        return info;
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    }
}

From source file:com.edmunds.etm.netscaler.NetScalerLoadBalancer.java

private NsMonitor getMonitor(String serverName) throws RemoteException {
    try {//  w w w  . ja  va  2 s . c  o  m
        final String monitorName = getMonitorName(serverName);
        return nitroService.getMonitors().get(monitorName);
    } catch (NitroExceptionNoSuchResource e) {
        return null;
    } catch (NitroException e) {
        throw new RemoteException("Unable to retrieve Monitor", e);
    }
}