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:org.filteredpush.qc.sciname.services.WoRMSService.java

/**
 * Find a taxon name record in WoRMS.//from  w ww .  j a v a 2  s  .  c  om
 * 
 * @param taxon name to look for
 * @param author authority to look for
 * 
 * @return aphia id for the taxon
 * 
 * @throws Exception
 */
public static String simpleNameSearch(String taxon, String author, boolean marineOnly) throws Exception {
    String id = null;

    AphiaNameServicePortTypeProxy wormsService = new AphiaNameServicePortTypeProxy();

    try {
        AphiaRecord[] resultsArr = wormsService.getAphiaRecords(taxon, false, false, marineOnly, 1);
        if (resultsArr != null || resultsArr.length == 1) {
            List<AphiaRecord> results = Arrays.asList(resultsArr);
            Iterator<AphiaRecord> i = results.iterator();
            logger.debug(resultsArr.length);
            while (i.hasNext()) {
                AphiaRecord ar = i.next();
                if (ar != null && ar.getScientificname() != null && taxon != null
                        && ar.getScientificname().equalsIgnoreCase(taxon)) {
                    logger.debug(ar.getScientificname());
                    logger.debug(ar.getAuthority());

                    String foundId = ar.getLsid();
                    String foundTaxon = ar.getScientificname();
                    String foundAuthor = ar.getAuthority();
                    AuthorNameComparator comparator = AuthorNameComparator.authorNameComparatorFactory(author,
                            null);
                    NameComparison comparison = comparator.compare(author, foundAuthor);
                    String match = comparison.getMatchType();
                    logger.debug(taxon + ":" + author + " " + match + " " + foundAuthor);
                    if (foundTaxon.equalsIgnoreCase(taxon)
                            && (author.toLowerCase().equals(foundAuthor.toLowerCase())
                                    || match.equals(NameComparison.MATCH_EXACT)
                                    || match.equals(NameComparison.MATCH_SAMEBUTABBREVIATED)
                                    || match.equals(NameComparison.MATCH_SIMILAREXACTYEAR)
                                    || match.equals(NameComparison.MATCH_EXACTADDSYEAR)
                                    || match.equals(NameComparison.MATCH_EXACTMISSINGYEAR))) {
                        logger.debug(foundId);
                        id = foundId;
                    }

                }
            }
        }

    } catch (NullPointerException ex) {
        // no match found
        id = null;
    } catch (RemoteException e) {
        throw new Exception(
                "WoRMSService failed to access WoRMS Aphia service for " + taxon + ". " + e.getMessage());
    }

    return id;
}

From source file:org.glite.authz.pap.ui.cli.papmanagement.RefreshCache.java

@Override
protected int executeCommand(CommandLine commandLine) throws RemoteException {

    String[] args = commandLine.getArgs();
    List<String> aliasList;

    if (args.length == 1) {
        aliasList = getAllAliases();//from  w  w w.j  a v  a 2  s .  co  m
    } else {
        aliasList = new LinkedList<String>();
        for (int i = 1; i < args.length; i++) {
            aliasList.add(args[i]);
        }
    }

    if (aliasList.isEmpty()) {
        System.out.println("No remote PAPs found.");
        return ExitStatus.SUCCESS.ordinal();
    }

    boolean success = false;
    boolean failure = false;

    for (String alias : aliasList) {
        System.out.print("Refreshing cache for pap \"" + alias + "\"...");

        try {
            boolean papExists = papMgmtClient.refreshCache(alias);

            if (papExists) {
                System.out.println(" ok.");
                success = true;
            } else {
                System.out.println(" error: pap doesn't exist");
                failure = true;
            }

        } catch (RemoteException e) {
            System.out.println("error: " + e.getMessage());
            failure = true;
            continue;
        }
    }

    if (success && failure) {
        return ExitStatus.PARTIAL_SUCCESS.ordinal();
    }

    if (!success && failure) {
        return ExitStatus.FAILURE.ordinal();
    }

    return ExitStatus.SUCCESS.ordinal();
}

From source file:org.globus.workspace.remoting.admin.client.AdminClient.java

private void run_addNodes() throws ParameterProblem, ExecutionProblem {
    if (!this.nodeMemoryConfigured) {
        throw new ParameterProblem(
                "Node max memory must be specified as an argument (" + Opts.MEMORY_LONG + ") or config value");
    }//from   w w  w . j a v  a2s. c om

    if (this.nodeNetworks == null) {
        throw new ParameterProblem("Node network associations must be specified as an argument ("
                + Opts.NETWORKS_LONG + ") or config value");
    }

    if (this.nodePool == null) {
        throw new ParameterProblem(
                "Node pool name must be specified as an argument (" + Opts.POOL_LONG + ") or config value");
    }

    final List<VmmNode> nodes = new ArrayList<VmmNode>(this.hosts.size());
    for (String hostname : this.hosts) {
        nodes.add(new VmmNode(hostname, this.nodeActive, this.nodePool, this.nodeMemory, this.nodeNetworks,
                true));
    }
    final String nodesJson = gson.toJson(nodes);
    NodeReport[] reports = null;
    try {
        final String reportJson = this.remoteNodeManagement.addNodes(nodesJson);
        reports = gson.fromJson(reportJson, NodeReport[].class);
    } catch (RemoteException e) {
        handleRemoteException(e);
    }

    try {
        reporter.report(nodeReportsToMaps(reports), this.outStream);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.AdminClient.java

private void run_listNodes() throws ExecutionProblem {
    VmmNode[] nodes = null;//from   w  w  w  .  j a  v  a2  s.  co  m
    try {
        final String nodesJson = this.remoteNodeManagement.listNodes();
        nodes = this.gson.fromJson(nodesJson, VmmNode[].class);
    } catch (RemoteException e) {
        handleRemoteException(e);
    }

    try {
        reporter.report(nodesToMaps(nodes), this.outStream);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.AdminClient.java

private void run_removeNodes() throws ExecutionProblem {
    NodeReport[] reports = null;//from www  .j a  v  a2 s. c om
    try {
        final String[] hostnames = this.hosts.toArray(new String[this.hosts.size()]);
        final String reportJson = this.remoteNodeManagement.removeNodes(hostnames);
        reports = gson.fromJson(reportJson, NodeReport[].class);
    } catch (RemoteException e) {
        handleRemoteException(e);
    }

    try {
        reporter.report(nodeReportsToMaps(reports), this.outStream);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.AdminClient.java

private void run_updateNodes() throws ExecutionProblem {

    final String[] hostnames = this.hosts.toArray(new String[this.hosts.size()]);
    final Boolean active = this.nodeActiveConfigured ? this.nodeActive : null;
    final String resourcepool = this.nodePool;
    final Integer memory = this.nodeMemoryConfigured ? this.nodeMemory : null;
    final String networks = this.nodeNetworks;

    NodeReport[] reports = null;//from www  .j av  a 2  s  . co  m
    try {
        final String reportJson = this.remoteNodeManagement.updateNodes(hostnames, active, resourcepool, memory,
                networks);
        reports = gson.fromJson(reportJson, NodeReport[].class);
    } catch (RemoteException e) {
        super.handleRemoteException(e);
    }

    try {
        reporter.report(nodeReportsToMaps(reports), this.outStream);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.AdminClient.java

private void run_poolAvail() throws ExecutionProblem {
    AssociationEntry[] entries = null;/*from   w  w w .j av  a  2  s.  c  o m*/
    try {
        if (this.nodePool != null) {
            final String entriesJson = this.remoteNodeManagement.getNetworkPool(this.nodePool, this.inUse);
            if (entriesJson == null) {
                System.err.println("No entries with pool name " + nodePool + " found");
                return;
            }
            entries = gson.fromJson(entriesJson, AssociationEntry[].class);
        } else {
            final String entriesJson = this.remoteNodeManagement.getAllNetworkPools(this.inUse);
            if (entriesJson == null) {
                System.err.println("No pool entries found");
                return;
            }
            entries = gson.fromJson(entriesJson, AssociationEntry[].class);
        }
    } catch (RemoteException e) {
        System.err.println(e.getMessage());
    }

    try {
        reporter.report(nodeAllocationToMaps(entries), this.outStream);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.RemoteAdminToolsMain.java

private void listVMs() throws ExecutionProblem {
    try {//from   w w w  .  j  a  v a2s .co  m
        VMTranslation[] vms;
        if (numOpts > 1) {
            System.err.println("You may select only one of --user, --dn, --gid, --gname, or --host");
            return;
        }
        if (this.user != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getVMsByUser(user);
            if (vmsJson == null) {
                System.err.println("No vms with user " + user + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else if (this.userDN != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getVMsByDN(userDN);
            if (vmsJson == null) {
                System.err.println("No vms with DN " + userDN + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else if (this.groupId != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getAllVMsByGroupId(groupId);
            if (vmsJson == null) {
                System.err.println("No vms with group id " + groupId + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else if (this.groupName != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getAllVMsByGroupName(groupName);
            if (vmsJson == null) {
                System.err.println("No vms with group name " + groupName + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else if (this.hostname != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getAllVMsByHost(hostname);
            if (vmsJson == null) {
                System.err.println("No vms with host " + hostname + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else if (this.state != null) {
            final String vmsJson = this.remoteAdminToolsManagement.getVMsByState(state);
            if (vmsJson == null) {
                System.err.println("No vms with state " + state + " found");
                return;
            }
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        } else {
            final String vmsJson = this.remoteAdminToolsManagement.getAllRunningVMs();
            vms = gson.fromJson(vmsJson, VMTranslation[].class);
        }
        if (vms == null) {
            System.err.println("No Running vms found");
            return;
        }
        reporter.report(vmsToMaps(vms), this.outStream);
    } catch (RemoteException e) {
        super.handleRemoteException(e);
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.RemoteAdminToolsMain.java

private void listNodes() throws ExecutionProblem {
    try {/*from   ww w .  ja  v a 2s.c  om*/
        Hashtable ht = this.remoteAdminToolsManagement.showVMsForAllHosts();
        if (ht == null)
            System.err.println("No nodes with running VMs found");
        else
            reporter.report(nodesToMaps(ht), this.outStream);
    } catch (RemoteException e) {
        System.err.println(e.getMessage());
    } catch (IOException e) {
        throw new ExecutionProblem("Problem writing output: " + e.getMessage(), e);
    }
}

From source file:org.globus.workspace.remoting.admin.client.RemoteAdminToolsMain.java

private void shutdownVM() {
    try {//from  w ww .  j  a va  2s.c  o m
        String result = "";
        String feedback;
        if (numOpts > 1) {
            result = "You must select only one of --all, --id, --user, --dn, --gid, --gname, or --host";
            System.err.println(result);
            return;
        }
        if (allVMs) {
            result = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_ALL, null,
                    seconds, force);
        } else if (vmIDs != null) {
            for (int i = 0; i < vmIDs.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_ID,
                        vmIDs.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else if (userList != null) {
            for (int i = 0; i < userList.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_UNAME,
                        userList.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else if (DNList != null) {
            for (int i = 0; i < DNList.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_DN,
                        DNList.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else if (gidList != null) {
            for (int i = 0; i < gidList.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_GID,
                        gidList.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else if (gnameList != null) {
            for (int i = 0; i < gnameList.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_GNAME,
                        gnameList.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else if (hostList != null) {
            for (int i = 0; i < hostList.size(); i++) {
                feedback = this.remoteAdminToolsManagement.shutdown(RemoteAdminToolsManagement.SHUTDOWN_HOST,
                        hostList.get(i), seconds, force);
                if (feedback != null)
                    result += feedback + "\n";
            }
        } else {
            result = "Shutdown requires either --all, --id, --user, --dn, --gid, --gname, or --host option";
        }
        if (result != null && !result.isEmpty())
            System.err.println(result);
    } catch (RemoteException e) {
        System.err.println(e.getMessage());
    }
}