Example usage for org.apache.commons.configuration HierarchicalConfiguration getString

List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getString

Introduction

In this page you can find the example usage for org.apache.commons.configuration HierarchicalConfiguration getString.

Prototype

public String getString(String key) 

Source Link

Usage

From source file:com.vaushell.superpipes.nodes.A_Node.java

/**
 * Load configuration for this node.//from w w  w  .  ja  va 2  s  .co m
 *
 * @param cNode Configuration
 * @throws Exception
 */
public void load(final HierarchicalConfiguration cNode) throws Exception {
    getProperties().readProperties(cNode);

    antiBurst = getProperties().getConfigDuration("anti-burst", antiBurst);
    delay = getProperties().getConfigDuration("delay", delay);

    // Load transforms IN
    transformsIN.clear();
    final List<HierarchicalConfiguration> cTransformsIN = cNode.configurationsAt("in.transform");
    if (cTransformsIN != null) {
        for (final HierarchicalConfiguration cTransform : cTransformsIN) {
            final List<ConfigProperties> commons = new ArrayList<>();

            final String commonsID = cTransform.getString("[@commons]");
            if (commonsID != null) {
                for (final String commonID : commonsID.split(",")) {
                    final ConfigProperties common = getDispatcher().getCommon(commonID);
                    if (common != null) {
                        commons.add(common);
                    }
                }
            }

            final A_Transform transform = addTransformIN(cTransform.getString("[@type]"), commons);

            transform.load(cTransform);
        }
    }

    // Load transforms OUT
    transformsOUT.clear();
    final List<HierarchicalConfiguration> cTransformsOUT = cNode.configurationsAt("out.transform");
    if (cTransformsOUT != null) {
        for (final HierarchicalConfiguration cTransform : cTransformsOUT) {
            final List<ConfigProperties> commons = new ArrayList<>();

            final String commonsID = cTransform.getString("[@commons]");
            if (commonsID != null) {
                for (final String commonID : commonsID.split(",")) {
                    final ConfigProperties common = getDispatcher().getCommon(commonID);
                    if (common != null) {
                        commons.add(common);
                    }
                }
            }

            final A_Transform transform = addTransformOUT(cTransform.getString("[@type]"), commons);

            transform.load(cTransform);
        }
    }
}

From source file:at.ac.tuwien.auto.iotsys.gateway.connectors.knx.KNXDeviceLoaderImpl.java

public ArrayList<Connector> initDevices(ObjectBroker objectBroker) {
    setConfiguration(devicesConfig);//from ww  w  . java 2 s. c  o  m
    objectBroker.getConfigDb().prepareDeviceLoader(getClass().getName());

    ArrayList<Connector> connectors = new ArrayList<Connector>();

    List<JsonNode> connectorsFromDb = objectBroker.getConfigDb().getConnectors("knx");
    int connectorsSize = 0;

    if (connectorsFromDb.size() <= 0) {
        Object knxConnectors = devicesConfig.getProperty("knx.connector.name");

        if (knxConnectors != null) {
            connectorsSize = 1;
        }

        if (knxConnectors instanceof Collection<?>) {
            connectorsSize = ((Collection<?>) knxConnectors).size();
        }
    } else
        connectorsSize = connectorsFromDb.size();

    for (int connector = 0; connector < connectorsSize; connector++) {

        HierarchicalConfiguration subConfig = devicesConfig.configurationAt("knx.connector(" + connector + ")");

        Object knxConfiguredDevices = subConfig.getProperty("device.type");// just to get the number of devices
        String connectorId = "";
        String connectorName = subConfig.getString("name");
        String routerIP = subConfig.getString("router.ip");
        int routerPort = subConfig.getInteger("router.port", 3671);
        String localIP = subConfig.getString("localIP");
        Boolean enabled = subConfig.getBoolean("enabled", false);

        try {
            connectorId = connectorsFromDb.get(connector).get("_id").asText();
            connectorName = connectorsFromDb.get(connector).get("name").asText();
            enabled = connectorsFromDb.get(connector).get("enabled").asBoolean();
            routerIP = connectorsFromDb.get(connector).get("routerHostname").asText();
            routerPort = connectorsFromDb.get(connector).get("routerPort").asInt();
            localIP = connectorsFromDb.get(connector).get("localIP").asText();
        } catch (Exception e) {
            log.info("Cannot fetch configuration from Database, using devices.xml");
        }

        if (enabled) {
            try {
                KNXConnector knxConnector = new KNXConnector(routerIP, routerPort, localIP);
                knxConnector.setName(connectorName);
                knxConnector.setTechnology("knx");
                knxConnector.setEnabled(enabled);
                //knxConnector.connect();
                connectors.add(knxConnector);

                int numberOfDevices = 0;
                List<Device> devicesFromDb = objectBroker.getConfigDb().getDevices(connectorId);

                if (connectorsFromDb.size() <= 0) {
                    if (knxConfiguredDevices != null) {
                        numberOfDevices = 1; // there is at least one
                                             // device.
                    }
                    if (knxConfiguredDevices instanceof Collection<?>) {
                        Collection<?> knxDevices = (Collection<?>) knxConfiguredDevices;
                        numberOfDevices = knxDevices.size();
                    }
                } else
                    numberOfDevices = devicesFromDb.size();

                log.info(
                        numberOfDevices + " KNX devices found in configuration for connector " + connectorName);
                for (int i = 0; i < numberOfDevices; i++) {

                    String type = subConfig.getString("device(" + i + ").type");
                    List<Object> address = subConfig.getList("device(" + i + ").address");
                    String addressString = address.toString();

                    String ipv6 = subConfig.getString("device(" + i + ").ipv6");
                    String href = subConfig.getString("device(" + i + ").href");

                    String name = subConfig.getString("device(" + i + ").name");

                    String displayName = subConfig.getString("device(" + i + ").displayName");

                    Boolean historyEnabled = subConfig.getBoolean("device(" + i + ").historyEnabled", false);

                    Boolean groupCommEnabled = subConfig.getBoolean("device(" + i + ").groupCommEnabled",
                            false);

                    Integer historyCount = subConfig.getInt("device(" + i + ").historyCount", 0);

                    Boolean refreshEnabled = subConfig.getBoolean("device(" + i + ").refreshEnabled", false);

                    Device deviceFromDb;
                    try {
                        deviceFromDb = devicesFromDb.get(i);
                        type = deviceFromDb.getType();
                        addressString = deviceFromDb.getAddress();
                        String subAddr[] = addressString.substring(1, addressString.length() - 1).split(", ");
                        address = Arrays.asList((Object[]) subAddr);
                        ipv6 = deviceFromDb.getIpv6();
                        href = deviceFromDb.getHref();
                        name = deviceFromDb.getName();
                        displayName = deviceFromDb.getDisplayName();
                        historyEnabled = deviceFromDb.isHistoryEnabled();
                        groupCommEnabled = deviceFromDb.isGroupcommEnabled();
                        refreshEnabled = deviceFromDb.isRefreshEnabled();
                        historyCount = deviceFromDb.getHistoryCount();
                    } catch (Exception e) {
                    }

                    // Transition step: comment when done
                    Device d = new Device(type, ipv6, addressString, href, name, displayName, historyCount,
                            historyEnabled, groupCommEnabled, refreshEnabled);
                    objectBroker.getConfigDb().prepareDevice(connectorName, d);

                    if (type != null && address != null) {
                        int addressCount = address.size();
                        try {
                            Constructor<?>[] declaredConstructors = Class.forName(type)
                                    .getDeclaredConstructors();
                            for (int k = 0; k < declaredConstructors.length; k++) {
                                if (declaredConstructors[k].getParameterTypes().length == addressCount + 1) { // constructor
                                    // that
                                    // takes
                                    // the
                                    // KNX
                                    // connector
                                    // and
                                    // group
                                    // address
                                    // as
                                    // argument
                                    Object[] args = new Object[address.size() + 1];
                                    // first arg is KNX connector

                                    args[0] = knxConnector;
                                    for (int l = 1; l <= address.size(); l++) {
                                        try {
                                            String adr = (String) address.get(l - 1);
                                            if (adr == null || adr.equals("null")) {
                                                args[l] = null;
                                            } else {
                                                args[l] = new GroupAddress(adr);
                                            }
                                        } catch (KNXFormatException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                    try {
                                        // create a instance of the
                                        // specified KNX device
                                        Obj knxDevice = (Obj) declaredConstructors[k].newInstance(args);

                                        knxDevice.setHref(new Uri(
                                                URLEncoder.encode(connectorName, "UTF-8") + "/" + href));

                                        if (name != null && name.length() > 0) {
                                            knxDevice.setName(name);
                                        }

                                        if (displayName != null && displayName.length() > 0) {
                                            knxDevice.setDisplayName(displayName);
                                        }

                                        if (ipv6 != null) {
                                            objectBroker.addObj(knxDevice, ipv6);
                                        } else {
                                            objectBroker.addObj(knxDevice);
                                        }

                                        myObjects.add(knxDevice);

                                        knxDevice.initialize();

                                        if (historyEnabled != null && historyEnabled) {
                                            if (historyCount != null && historyCount != 0) {
                                                objectBroker.addHistoryToDatapoints(knxDevice, historyCount);
                                            } else {
                                                objectBroker.addHistoryToDatapoints(knxDevice);
                                            }
                                        }

                                        if (groupCommEnabled) {
                                            objectBroker.enableGroupComm(knxDevice);
                                        }

                                        if (refreshEnabled != null && refreshEnabled) {
                                            objectBroker.enableObjectRefresh(knxDevice);
                                        }

                                    } catch (IllegalArgumentException e) {
                                        e.printStackTrace();
                                    } catch (InstantiationException e) {
                                        e.printStackTrace();
                                    } catch (IllegalAccessException e) {
                                        e.printStackTrace();
                                    } catch (InvocationTargetException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        } catch (SecurityException e) {
                            e.printStackTrace();
                        } catch (ClassNotFoundException e) {
                            e.printStackTrace();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }

    return connectors;
}

From source file:edu.hawaii.soest.hioos.storx.StorXSource.java

/**
 * A method that processes the data object passed and flushes the
 * data to the DataTurbine given the sensor properties in the XMLConfiguration
 * passed in./*from  www. j  a  v a 2 s  .  c  o  m*/
 *
 * @param xmlConfig - the XMLConfiguration object containing the list of
 *                    sensor properties
 * @param frameMap  - the parsed data as a HierarchicalMap object
 */
public boolean process(XMLConfiguration xmlConfig, HierarchicalMap frameMap) {

    logger.debug("StorXSource.process() called.");
    // do not execute the stream if there is no connection
    if (!isConnected())
        return false;

    boolean success = false;

    try {

        // add channels of data that will be pushed to the server.  
        // Each sample will be sent to the Data Turbine as an rbnb frame.  Information
        // on each channel is found in the XMLConfiguration file (email.account.properties.xml)
        // and the StorXParser object (to get the data string)
        ChannelMap rbnbChannelMap = new ChannelMap(); // used to flush channels
        ChannelMap registerChannelMap = new ChannelMap(); // used to register channels
        int channelIndex = 0;

        // this.storXParser = new StorXParser(storXFrame);

        String sensorName = null;
        String sensorSerialNumber = null;
        String sensorDescription = null;
        boolean isImmersed = false;
        String calibrationURL = null;

        List sensorList = xmlConfig.configurationsAt("account.logger.sensor");

        for (Iterator sIterator = sensorList.iterator(); sIterator.hasNext();) {
            //  
            HierarchicalConfiguration sensorConfig = (HierarchicalConfiguration) sIterator.next();
            sensorSerialNumber = sensorConfig.getString("serialNumber");

            // find the correct sensor configuration properties
            if (sensorSerialNumber.equals(frameMap.get("serialNumber"))) {

                sensorName = sensorConfig.getString("name");
                sensorDescription = sensorConfig.getString("description");
                isImmersed = new Boolean(sensorConfig.getString("isImmersed")).booleanValue();
                calibrationURL = sensorConfig.getString("calibrationURL");

                // get a Calibration instance to interpret raw sensor values
                Calibration calibration = new Calibration();

                if (calibration.parse(calibrationURL)) {

                    // Build the RBNB channel map 

                    // get the sample date and convert it to seconds since the epoch
                    Date sampleDate = (Date) frameMap.get("date");
                    Calendar sampleDateTime = Calendar.getInstance();
                    sampleDateTime.setTime(sampleDate);
                    double sampleTimeAsSecondsSinceEpoch = (double) (sampleDateTime.getTimeInMillis() / 1000);
                    // and create a string formatted date
                    DATE_FORMAT.setTimeZone(TZ);
                    String sampleDateAsString = DATE_FORMAT.format(sampleDate).toString();

                    // get the sample data from the frame map
                    ByteBuffer rawFrame = (ByteBuffer) frameMap.get("rawFrame");
                    StorXFrame storXFrame = (StorXFrame) frameMap.get("parsedFrameObject");
                    String serialNumber = storXFrame.getSerialNumber();
                    int rawAnalogChannelOne = storXFrame.getAnalogChannelOne();
                    int rawAnalogChannelTwo = storXFrame.getAnalogChannelTwo();
                    int rawAnalogChannelThree = storXFrame.getAnalogChannelThree();
                    int rawAnalogChannelFour = storXFrame.getAnalogChannelFour();
                    int rawAnalogChannelFive = storXFrame.getAnalogChannelFive();
                    int rawAnalogChannelSix = storXFrame.getAnalogChannelSix();
                    int rawAnalogChannelSeven = storXFrame.getAnalogChannelSeven();
                    double rawInternalVoltage = new Float(storXFrame.getInternalVoltage()).doubleValue();

                    // apply calibrations to the observed data
                    double analogChannelOne = calibration.apply((double) rawAnalogChannelOne, isImmersed,
                            "AUX_1");
                    double analogChannelTwo = calibration.apply((double) rawAnalogChannelTwo, isImmersed,
                            "AUX_2");
                    double analogChannelThree = calibration.apply((double) rawAnalogChannelThree, isImmersed,
                            "AUX_3");
                    double analogChannelFour = calibration.apply((double) rawAnalogChannelFour, isImmersed,
                            "AUX_4");
                    double analogChannelFive = calibration.apply((double) rawAnalogChannelFive, isImmersed,
                            "AUX_5");
                    double analogChannelSix = calibration.apply((double) rawAnalogChannelSix, isImmersed,
                            "AUX_6");
                    double analogChannelSeven = calibration.apply((double) rawAnalogChannelSeven, isImmersed,
                            "AUX_7");
                    double internalVoltage = calibration.apply(rawInternalVoltage, isImmersed, "SV");

                    String sampleString = "";
                    sampleString += String.format("%s", serialNumber) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelOne) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelTwo) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelThree) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelFour) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelFive) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelSix) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelSeven) + ", ";
                    sampleString += String.format("%05.2f", internalVoltage) + ", ";
                    sampleString += sampleDateAsString;
                    sampleString += storXFrame.getTerminator();

                    // add the sample timestamp to the rbnb channel map
                    //registerChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d);
                    rbnbChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d);

                    // add the BinaryRawSatlanticFrameData channel to the channelMap
                    channelIndex = registerChannelMap.Add("BinaryRawSatlanticFrameData");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("BinaryRawSatlanticFrameData");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsByteArray(channelIndex, rawFrame.array());

                    // add the DecimalASCIISampleData channel to the channelMap
                    channelIndex = registerChannelMap.Add(getRBNBChannelName());
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add(getRBNBChannelName());
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, sampleString);

                    // add the serialNumber channel to the channelMap
                    channelIndex = registerChannelMap.Add("serialNumber");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("serialNumber");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, serialNumber);

                    // add the analogChannelOne channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelOne");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelOne");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelOne });

                    // add the analogChannelTwo channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelTwo");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelTwo");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelTwo });

                    // add the analogChannelThree channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelThree");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelThree");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelThree });

                    // add the analogChannelFour channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelFour");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelFour");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelFour });

                    // add the analogChannelFive channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelFive");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelFive");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelFive });

                    // add the analogChannelSix channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelSix");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelSix");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelSix });

                    // add the analogChannelSeven channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelSeven");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelSeven");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelSeven });

                    // add the internalVoltage channel to the channelMap
                    channelIndex = registerChannelMap.Add("internalVoltage");
                    registerChannelMap.PutUserInfo(channelIndex, "units=V");
                    channelIndex = rbnbChannelMap.Add("internalVoltage");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { internalVoltage });

                    // Now register the RBNB channels, and flush the rbnbChannelMap to the
                    // DataTurbine
                    getSource().Register(registerChannelMap);
                    getSource().Flush(rbnbChannelMap);
                    logger.info("Sample sent to the DataTurbine:" + sampleString);

                    registerChannelMap.Clear();
                    rbnbChannelMap.Clear();

                } else {

                    logger.info("Couldn't apply the calibration coefficients. " + "Skipping this sample.");

                } // end if()

            } // end if()

        } // end for()                                             

        //getSource.Detach();
        success = true;

    } catch (Exception sapie) {
        //} catch ( SAPIException sapie ) {
        // In the event of an RBNB communication  exception, log the exception, 
        // and allow execute() to return false, which will prompt a retry.
        success = false;
        sapie.printStackTrace();
        return success;

    }

    return success;
}

From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java

private DecryptorConfiguration setUpDecryptorConfiguration(List<HierarchicalConfiguration> decryptorConfigs) {

    // create the private key factory out of the configuration parameters
    final HierarchicalConfiguration decryptorConfig = decryptorConfigs.get(0);
    final String algorithm = decryptorConfig.getString("[@algorithm]");
    final String keystore = decryptorConfig.getString("[@keystore]");
    final String password = decryptorConfig.getString("[@password]");
    final String certificateAlias = decryptorConfig.getString("[@certificateAlias]");

    final PrivateKeyFactory privateKeyFactory = KeyStoreFactory.forPkcs12(new File(keystore), certificateAlias,
            password);//from   w ww .j a  v  a  2s  . co  m

    return new DecryptorConfiguration.Builder()
            .setTargetDirectory(new File(clientConfiguration.getWorkingDir(), ClientCommons.INBOX_TMP_DIR))
            .setPrivateKeyFactory(privateKeyFactory).setCipherFactory(CipherFactory.forAlgorithm(algorithm))
            .build();
}

From source file:com.processpuzzle.application.configuration.domain.PersistenceContext.java

private void instantiateSupportedStrategies() {
    List<String> supportedStrategyNames = propertyContext
            .getPropertyList(PropertyKeys.PERSISTENCE_STRATEGY_NAME.getDefaultKey());
    Iterator<String> supportedStrategyIterator = supportedStrategyNames.iterator();
    Integer strategyIndex = 0;//w  w  w.j a  v a  2s  .  co  m
    while (supportedStrategyIterator.hasNext()) {
        String supportedStrategyName = supportedStrategyIterator.next();
        Object[] parameters = { supportedStrategyName };
        List<String> eventHandlerNames = propertyContext.getPropertyListByParameter(
                PropertyKeys.PERSISTENCE_STRATEGY_EVENT_HANDLERS.getDefaultKey(), parameters);
        List<RepositoryEventHandler> eventHandlers = new LinkedList<RepositoryEventHandler>();
        Iterator<String> eventHandlersIterator = eventHandlerNames.iterator();
        Integer eventHandlerIndex = 0;
        while (eventHandlersIterator.hasNext()) {
            String eventHandlerName = eventHandlersIterator.next();
            String configurationAt = MessageFormat.format(PropertyKeys.REPOSITORY_EVENT_HANDLER.getDefaultKey(),
                    new Object[] { strategyIndex.toString(), eventHandlerIndex.toString() });
            HierarchicalConfiguration eventHandlerConfiguration = propertyContext
                    .getConfigurationAt(configurationAt);

            //            ParametrizedConfigurationPropertyHandler propertyHandler = new ParametrizedConfigurationPropertyHandler( eventHandlerConfiguration );
            String eventHandlerClassName = eventHandlerConfiguration
                    .getString(PropertyKeys.EVENT_HANDLER_CLASS.getDefaultKey());
            DefaultRepositoryEventHandler eventHandler = instantiateEventHandler(eventHandlerName,
                    eventHandlerClassName, eventHandlerConfiguration);
            eventHandlers.add(eventHandler);
            eventHandlerIndex++;
        }

        PersistenceStrategy strategy = new DefaultPersistenceStrategy(supportedStrategyName, eventHandlers);
        supportedStrategies.put(supportedStrategyName, strategy);
        strategyIndex++;
    }
}

From source file:net.datenwerke.sandbox.util.SandboxParser.java

protected void configureFileAccess(SandboxContext context, HierarchicalConfiguration rs) {
    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccess.read.suffixes.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.PERMIT,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccess.read.prefixes.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.PERMIT,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.read.exactMatches.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.PERMIT,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.read.regex.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.PERMIT,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));

    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccess.write.suffixes.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.PERMIT,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccess.write.prefixes.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.PERMIT,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.write.exactMatches.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.PERMIT,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.write.regex.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.PERMIT,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));

    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccess.delete.suffixes.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.PERMIT,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccess.delete.prefixes.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.PERMIT,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.delete.exactMatches.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.PERMIT,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccess.delete.regex.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.PERMIT,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));

    Boolean cp = rs.getBoolean("fileAccess[@classpath]", false);
    if (cp)/*from   ww w  . ja v a2 s .  c  om*/
        context.addClasspath();

    Boolean home = rs.getBoolean("fileAccess[@home]", false);
    if (home)
        context.addHome();

    Boolean temp = rs.getBoolean("fileAccess[@temp]", false);
    if (temp)
        context.addTempDir();

    Boolean work = rs.getBoolean("fileAccess[@work]", false);
    if (work)
        context.addWorkDir();

    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccessDeny.read.suffixes.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.DENY,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccessDeny.read.prefixes.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.DENY,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.read.exactMatches.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.DENY,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.read.regex.entry"))
        context.addFilePermission(FileAccess.READ, AccessType.DENY,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));

    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccessDeny.write.suffixes.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.DENY,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccessDeny.write.prefixes.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.DENY,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.write.exactMatches.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.DENY,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.write.regex.entry"))
        context.addFilePermission(FileAccess.WRITE, AccessType.DENY,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));

    for (HierarchicalConfiguration suf : rs.configurationsAt("fileAccessDeny.delete.suffixes.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.DENY,
                new FileSuffixPermission(suf.getString("."), suf.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration prefix : rs.configurationsAt("fileAccessDeny.delete.prefixes.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.DENY,
                new FilePrefixPermission(prefix.getString("."), prefix.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.delete.exactMatches.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.DENY,
                new FileEqualsPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
    for (HierarchicalConfiguration entry : rs.configurationsAt("fileAccessDeny.delete.regex.entry"))
        context.addFilePermission(FileAccess.DELETE, AccessType.DENY,
                new FileRegexPermission(entry.getString("."), entry.getBoolean("[@negate]", false)));
}

From source file:edu.isi.wings.portal.classes.domains.Domain.java

private void initializeDomain() {
    try {//from w w  w.java  2  s . co m
        PropertyListConfiguration config = new PropertyListConfiguration(this.domainConfigFile);

        this.useSharedTripleStore = config.getBoolean("useSharedTripleStore", true);
        this.planEngine = config.getString("executions.engine.plan", "Local");
        this.stepEngine = config.getString("executions.engine.step", "Local");

        this.templateLibrary = new DomainLibrary(config.getString("workflows.library.url"),
                config.getString("workflows.library.map"));
        this.newTemplateDirectory = new UrlMapPrefix(config.getString("workflows.prefix.url"),
                config.getString("workflows.prefix.map"));

        this.executionLibrary = new DomainLibrary(config.getString("executions.library.url"),
                config.getString("executions.library.map"));
        this.newExecutionDirectory = new UrlMapPrefix(config.getString("executions.prefix.url"),
                config.getString("executions.prefix.map"));

        this.dataOntology = new DomainOntology(config.getString("data.ontology.url"),
                config.getString("data.ontology.map"));
        this.dataLibrary = new DomainLibrary(config.getString("data.library.url"),
                config.getString("data.library.map"));
        this.dataLibrary.setStorageDirectory(config.getString("data.library.storage"));

        this.componentLibraryNamespace = config.getString("components.namespace");
        this.abstractComponentLibrary = new DomainLibrary(config.getString("components.abstract.url"),
                config.getString("components.abstract.map"));

        String concreteLibraryName = config.getString("components.concrete");
        List<HierarchicalConfiguration> clibs = config.configurationsAt("components.libraries.library");
        for (HierarchicalConfiguration clib : clibs) {
            String url = clib.getString("url");
            String map = clib.getString("map");
            String name = clib.getString("name");
            String codedir = clib.getString("storage");
            DomainLibrary concreteLib = new DomainLibrary(url, map, name, codedir);
            this.concreteComponentLibraries.add(concreteLib);
            if (name.equals(concreteLibraryName))
                this.concreteComponentLibrary = concreteLib;
        }

        List<HierarchicalConfiguration> perms = config.configurationsAt("permissions.permission");
        for (HierarchicalConfiguration perm : perms) {
            String userid = perm.getString("userid");
            boolean canRead = perm.getBoolean("canRead", false);
            boolean canWrite = perm.getBoolean("canWrite", false);
            boolean canExecute = perm.getBoolean("canExecute", false);
            Permission permission = new Permission(userid, canRead, canWrite, canExecute);
            this.permissions.add(permission);
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}

From source file:com.intuit.tank.persistence.databases.AmazonDynamoDatabaseDocApi.java

private long getCapacity(HierarchicalConfiguration resultsProviderConfig, String key, long defaultValue) {
    long ret = defaultValue;
    if (resultsProviderConfig != null) {
        try {//  ww w.  ja  va  2s.c  om
            String string = resultsProviderConfig.getString(key);
            if (NumberUtils.isDigits(string)) {
                return Long.parseLong(string);
            }
        } catch (Exception e) {
            logger.error(e.toString());
        }
    }
    return ret;
}

From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java

private void setupNativeApps(SenderConfiguration defaultSenderConfiguration, String baseDir,
        ReceiverConfiguration receiverConfiguration) throws ConfigurationException {

    // ************** the native applications
    LOG.info("Configure the native MH applications...");
    final List natives = xmlConfig.configurationsAt("nativeApp");

    // We could use a foreach, but that would involve using objects. I don't like that.
    for (Iterator i = natives.iterator(); i.hasNext();) {
        HierarchicalConfiguration sub = (HierarchicalConfiguration) i.next();

        // the sedex ID of this application
        final String sedexId = sub.getString(".[@participantId]");

        // ************** outboxes
        final List outboxes = sub.configurationsAt(".outbox");

        // We could use a foreach, but that would involve using objects. I don't like that.
        for (Iterator j = outboxes.iterator(); j.hasNext();) {
            setupNativeOutbox(j, baseDir, sedexId, defaultSenderConfiguration);
        }/*w  w w .ja  v  a  2 s.  com*/

        // inboxes
        for (final HierarchicalConfiguration inboxSub : sub.configurationsAt(".inbox")) {
            String inboxDir = inboxSub.getString("[@dirPath]");
            File tmpDir = FileUtils.createPath(baseDir, inboxDir);

            List<HierarchicalConfiguration> decryptorConfigs = inboxSub.configurationsAt(".decrypt");

            final Inbox inbox = decryptorConfigs.isEmpty()
                    ? new NativeAppInbox(tmpDir, sedexId, MessageType.from(inboxSub.getString(MSG_TYPES)))
                    : new DecryptingInbox(tmpDir, sedexId, MessageType.from(inboxSub.getString(MSG_TYPES)));

            checkSedexIdMsgTypes(inbox);
            receiverConfiguration.addInbox(inbox);

            if (!decryptorConfigs.isEmpty()) {
                clientConfiguration.setDecryptor(new Decryptor(setUpDecryptorConfiguration(decryptorConfigs)));
            }

        }
    }
}

From source file:edu.isi.wings.portal.classes.config.Config.java

@SuppressWarnings("rawtypes")
private ExeEngine getExeEngine(HierarchicalConfiguration node) {
    String name = node.getString("name");
    String impl = node.getString("implementation");
    ExeEngine.Type type = ExeEngine.Type.valueOf(node.getString("type"));
    ExeEngine engine = new ExeEngine(name, impl, type);
    for (Iterator it = node.getKeys("properties"); it.hasNext();) {
        String key = (String) it.next();
        String value = node.getString(key);
        engine.addProperty(key.replace("properties.", ""), value);
    }/*from  www  .  j ava 2s .com*/
    return engine;
}