Example usage for org.apache.commons.collections MapUtils getObject

List of usage examples for org.apache.commons.collections MapUtils getObject

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getObject.

Prototype

public static Object getObject(Map map, Object key, Object defaultValue) 

Source Link

Document

Looks up the given key in the given map, converting null into the given default value.

Usage

From source file:com.hcc.cms.util.PageUtils.java

/**
 * <p>//from w  w  w  .j av a 2s.  c om
 * This method returns the values entered through design dialog.
 * </p>
 *
 * @param objects
 *            holding the objects like sling, resource resolver etc.
 * @param propertyName
 *            holds the design dialog values
 * @param defaultValue
 *            defaultValue to be used in case nothing is provided via design
 *            dialog
 * @return Object this object can be typecasted as required
 */
public static Object getPropertyFromCurrentStyle(final Map<String, Object> objects, final String propertyName,
        final Object defaultValue) {
    return MapUtils.getObject((ValueMap) objects.get(PageConstants.CURRENT_STYLE), propertyName, defaultValue);
}

From source file:com.splout.db.qnode.Deployer.java

/**
 * Generates the list of individual deploy actions that has to be sent to each DNode.
 *///w w  w  .  j  ava 2s.c om
private static Map<String, List<DeployAction>> generateDeployActionsPerDNode(List<DeployRequest> deployRequests,
        long version) {
    HashMap<String, List<DeployAction>> actions = new HashMap<String, List<DeployAction>>();

    long deployDate = System.currentTimeMillis(); // Here is where we decide the data of the deployment for all deployed
    // tablespaces

    for (DeployRequest req : deployRequests) {
        for (Object obj : req.getReplicationMap()) {
            ReplicationEntry rEntry = (ReplicationEntry) obj;
            PartitionEntry pEntry = null;
            for (PartitionEntry partEntry : req.getPartitionMap()) {
                if (partEntry.getShard().equals(rEntry.getShard())) {
                    pEntry = partEntry;
                }
            }
            if (pEntry == null) {
                String msg = "No Partition metadata for shard: " + rEntry.getShard()
                        + " this is very likely to be a software bug.";
                log.error(msg);
                try {
                    log.error("Partition map: " + JSONSerDe.ser(req.getPartitionMap()));
                    log.error("Replication map: " + JSONSerDe.ser(req.getReplicationMap()));
                } catch (JSONSerDe.JSONSerDeException e) {
                    log.error("JSON error", e);
                }
                throw new RuntimeException(msg);
            }
            // Normalize DNode ids -> The convention is that DNodes are identified by host:port . So we need to strip the
            // protocol, if any
            for (int i = 0; i < rEntry.getNodes().size(); i++) {
                String dnodeId = rEntry.getNodes().get(i);
                if (dnodeId.startsWith("tcp://")) {
                    dnodeId = dnodeId.substring("tcp://".length(), dnodeId.length());
                }
                rEntry.getNodes().set(i, dnodeId);
            }
            for (String dNode : rEntry.getNodes()) {
                List<DeployAction> actionsSoFar = (List<DeployAction>) MapUtils.getObject(actions, dNode,
                        new ArrayList<DeployAction>());
                actions.put(dNode, actionsSoFar);
                DeployAction deployAction = new DeployAction();
                deployAction.setDataURI(req.getData_uri() + "/" + rEntry.getShard() + ".db");
                deployAction.setTablespace(req.getTablespace());
                deployAction.setVersion(version);
                deployAction.setPartition(rEntry.getShard());

                // Add partition metadata to the deploy action for DNodes to save it
                PartitionMetadata metadata = new PartitionMetadata();
                metadata.setMinKey(pEntry.getMin());
                metadata.setMaxKey(pEntry.getMax());
                metadata.setNReplicas(rEntry.getNodes().size());
                metadata.setDeploymentDate(deployDate);
                metadata.setInitStatements(req.getInitStatements());
                metadata.setEngineId(req.getEngine());

                deployAction.setMetadata(metadata);
                actionsSoFar.add(deployAction);
            }
        }
    }
    return actions;
}

From source file:org.eclipse.jubula.client.cmd.AbstractLauncher.java

/**
 * {@inheritDoc}//from w  ww.  j a v a 2s.  co  m
 */
public Object start(IApplicationContext context) throws Exception {
    return getAbstractCmdLineClient().run((String[]) MapUtils.getObject(context.getArguments(),
            IApplicationContext.APPLICATION_ARGS, new String[0]));
}