Example usage for java.util Properties contains

List of usage examples for java.util Properties contains

Introduction

In this page you can find the example usage for java.util Properties contains.

Prototype

@Override
    public boolean contains(Object value) 

Source Link

Usage

From source file:org.opencastproject.capture.impl.CaptureAgentImpl.java

/**
 * {@inheritDoc}/*from   ww w  .  j  av a 2s.com*/
 * 
 * @see org.opencastproject.capture.api.CaptureAgent#startCapture(MediaPackage, Properties)
 */
@Override
public String startCapture(MediaPackage mediaPackage, Properties properties) {
    logger.debug("startCapture(mediaPackage, properties): {} {}", mediaPackage, properties);
    // Stop the confidence monitoring if its pipeline is playing.
    if (confidence) {
        logger.info("Confidence monitoring disabled for capturing.");
        ConfidenceMonitorImpl.getInstance().stopMonitoring();
    }

    // Check to make sure we're not already capturing something
    if (currentRecID != null || !agentState.equals(AgentState.IDLE)) {
        logger.warn("Unable to start capture, a different capture is still in progress in {}.",
                pendingRecordings.get(currentRecID).getBaseDir().getAbsolutePath());
        // Set the recording's state to error
        if (properties != null && properties.getProperty(CaptureParameters.RECORDING_ID) != null) {
            setRecordingState(properties.getProperty(CaptureParameters.RECORDING_ID),
                    RecordingState.CAPTURE_ERROR);
        } else {
            setRecordingState("Unscheduled-" + agentName + "-" + System.currentTimeMillis(),
                    RecordingState.CAPTURE_ERROR);
        }
        return null;
    } else {
        setAgentState(AgentState.CAPTURING);
    }

    // Generate a combined properties object for this capture
    Properties capProperties = configService.merge(properties, false);

    // Create the recording
    RecordingImpl newRec = createRecording(mediaPackage, capProperties);
    if (newRec == null) {
        if (capProperties != null && capProperties.contains(CaptureParameters.RECORDING_ID)) {
            resetOnFailure((String) capProperties.get(CaptureParameters.RECORDING_ID));
        } else {
            resetOnFailure("Unscheduled-" + agentName + "-" + System.currentTimeMillis());
        }
        return null;
    }

    String recordingID = newRec.getID();

    try {
        captureFramework.start(newRec, this);
    } catch (UnableToStartCaptureException exception) {
        logger.error(exception.getMessage());
        resetOnFailure(newRec.getID());
        return null;
    }

    // Keep track of how long it has been since the capture started.
    startTime = System.currentTimeMillis();

    // Great, capture is running. Set the agent state appropriately.
    setRecordingState(recordingID, RecordingState.CAPTURING);
    // If the recording does *not* have a scheduled endpoint then schedule one.
    if (newRec.getProperty(CaptureParameters.RECORDING_END) == null) {
        if (!scheduleStop(newRec.getID())) {
            // If the attempt to schedule an end to the recording fails then shut everything down.
            stopCapture(newRec.getID(), false);
            resetOnFailure(newRec.getID());
        }
    }

    serializeRecording(recordingID);
    return recordingID;
}

From source file:org.apache.juddi.v3.client.mapping.wadl.WADL2UDDI.java

public WADL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties)
        throws ConfigurationException {
    super();//from  www  .j av a2s . c  o m
    this.clerk = clerk;
    this.urlLocalizer = urlLocalizer;
    this.properties = properties;

    if (clerk != null) {
        if (!properties.containsKey("keyDomain")) {
            throw new ConfigurationException("Property keyDomain is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("businessKey") && !properties.containsKey("businessName")) {
            throw new ConfigurationException(
                    "Either property businessKey, or businessName, is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("nodeName")) {
            if (properties.containsKey("serverName") && properties.containsKey("serverPort")) {
                String nodeName = properties.getProperty("serverName") + "_"
                        + properties.getProperty("serverPort");
                properties.setProperty("nodeName", nodeName);
            } else {
                throw new ConfigurationException(
                        "Property nodeName is not defined and is a required property when using WADL2UDDI.");
            }
        }
    }

    //Obtaining values from the properties
    this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
    if (properties.contains(Property.BUSINESS_KEY)) {
        this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
    } else {
        //using the BusinessKey Template, and the businessName to construct the key 
        this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
    }
    this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
}

From source file:org.olat.core.util.i18n.I18nManager.java

/**
 * Enable or disable the inline translation mode for a specific key. If
 * disabled, the inline translation mode will not be available for this key.
 * <p>//from ww w. j  av  a  2 s  .  c om
 * Disable inline translation for keys that have issues with the inline
 * translation system such as default values that are used in forms that
 * have length checks.
 * 
 * @param bundleName
 * @param key
 * @param enable
 */
public void setInlineTranslationEnabledForKey(String bundleName, String key, boolean enable) {
    Properties metadataProperties = getPropertiesWithoutResolvingRecursively(null, bundleName);
    String propertyKey = key + METADATA_KEY_INLINEREANSLATION_POSTFIX;
    if (enable) {
        if (metadataProperties.contains(propertyKey)) {
            metadataProperties.remove(propertyKey);
        }
    } else {
        metadataProperties.setProperty(propertyKey, METADATA_KEY_INLINEREANSLATION_VALUE_DISABLED);
    }
    saveOrUpdateProperties(metadataProperties, null, bundleName);
}

From source file:org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI.java

/**
 * Required Properties are: businessName, for example: 'Apache'
 * nodeName, for example: 'uddi.example.org_80' keyDomain, for example:
 * juddi.apache.org/*  w  w w  . j av  a2 s  .  c om*/
 *
 * Optional Properties are: lang: for example: 'nl'
 *
 * @param clerk - can be null if register/unregister methods are not
 * used.
 * @param urlLocalizer - A reference to an custom
 * @param properties - required values keyDomain, businessKey, nodeName
 * @throws ConfigurationException
 */
public WSDL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties)
        throws ConfigurationException {
    super();
    if (properties == null) {
        throw new IllegalArgumentException("properties");
    }
    this.clerk = clerk;
    this.urlLocalizer = urlLocalizer;
    this.properties = properties;

    if (clerk != null) {
        if (!properties.containsKey("keyDomain")) {
            throw new ConfigurationException("Property keyDomain is a required property when using WSDL2UDDI.");
        }
        if (!properties.containsKey("businessKey") && !properties.containsKey("businessName")) {
            throw new ConfigurationException(
                    "Either property businessKey, or businessName, is a required property when using WSDL2UDDI.");
        }
        if (!properties.containsKey("nodeName")) {
            if (properties.containsKey("serverName") && properties.containsKey("serverPort")) {
                String nodeName = properties.getProperty("serverName") + "_"
                        + properties.getProperty("serverPort");
                properties.setProperty("nodeName", nodeName);
            } else {
                throw new ConfigurationException(
                        "Property nodeName is not defined and is a required property when using WSDL2UDDI.");
            }
        }
    }

    //Obtaining values from the properties
    this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
    if (properties.contains(Property.BUSINESS_KEY)) {
        this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
    } else {
        //using the BusinessKey Template, and the businessName to construct the key 
        this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
    }
    this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
}

From source file:com.izforge.izpack.compiler.CompilerConfig.java

/**
 * Variable declaration is a fragment of the xml file. For example:
 * <p/>/*from w  w w  .  j av a 2s .  co m*/
 * <p/>
 *
 * <pre>
 * &lt;p/&gt;
 * &lt;p/&gt;
 * &lt;p/&gt;
 * &lt;p/&gt;
 *        &lt;variables&gt;
 *          &lt;variable name=&quot;nom&quot; value=&quot;value&quot;/&gt;
 *          &lt;variable name=&quot;foo&quot; value=&quot;pippo&quot;/&gt;
 *        &lt;/variables&gt;
 * &lt;p/&gt;
 * &lt;p/&gt;
 * &lt;p/&gt;
 * &lt;p/&gt;
 * </pre>
 * <p/>
 * <p/>
 * variable declared in this can be referred to in parsable files.
 *
 * @param data The XML data.
 * @throws CompilerException Description of the Exception
 */
protected void addVariables(IXMLElement data) throws CompilerException {
    notifyCompilerListener("addVariables", CompilerListener.BEGIN, data);
    // We get the varible list
    IXMLElement root = data.getFirstChildNamed("variables");
    if (root == null) {
        return;
    }

    Properties variables = packager.getVariables();

    for (IXMLElement variableNode : root.getChildrenNamed("variable")) {
        String name = xmlCompilerHelper.requireAttribute(variableNode, "name");
        String value = xmlCompilerHelper.requireAttribute(variableNode, "value");
        if (variables.contains(name)) {
            assertionHelper.parseWarn(variableNode, "Variable '" + name + "' being overwritten");
        }
        variables.setProperty(name, value);
    }
    notifyCompilerListener("addVariables", CompilerListener.END, data);
}

From source file:com.buaa.cfs.conf.Configuration.java

/**
 * Sets all deprecated properties that are not currently set but have a corresponding new property that is set.
 * Useful for iterating the properties when all deprecated properties for currently set properties need to be
 * present.//from  w w  w  .  j a v a2s.  com
 */
public void setDeprecatedProperties() {
    DeprecationContext deprecations = deprecationContext.get();
    Properties props = getProps();
    Properties overlay = getOverlay();
    for (Entry<String, DeprecatedKeyInfo> entry : deprecations.getDeprecatedKeyMap().entrySet()) {
        String depKey = entry.getKey();
        if (!overlay.contains(depKey)) {
            for (String newKey : entry.getValue().newKeys) {
                String val = overlay.getProperty(newKey);
                if (val != null) {
                    props.setProperty(depKey, val);
                    overlay.setProperty(depKey, val);
                    break;
                }
            }
        }
    }
}

From source file:org.apache98.hadoop.conf.Configuration.java

/**
 * Sets all deprecated properties that are not currently set but have a
 * corresponding new property that is set. Useful for iterating the
 * properties when all deprecated properties for currently set properties
 * need to be present.//from   ww  w.  j  a va2  s  .c  o m
 */
public void setDeprecatedProperties() {
    DeprecationContext deprecations = deprecationContext.get();
    Properties props = getProps();
    Properties overlay = getOverlay();
    for (Map.Entry<String, DeprecatedKeyInfo> entry : deprecations.getDeprecatedKeyMap().entrySet()) {
        String depKey = entry.getKey();
        if (!overlay.contains(depKey)) {
            for (String newKey : entry.getValue().newKeys) {
                String val = overlay.getProperty(newKey);
                if (val != null) {
                    props.setProperty(depKey, val);
                    overlay.setProperty(depKey, val);
                    break;
                }
            }
        }
    }
}