Example usage for java.util Properties equals

List of usage examples for java.util Properties equals

Introduction

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

Prototype

@Override
    public synchronized boolean equals(Object o) 

Source Link

Usage

From source file:org.eclipse.kura.net.admin.visitor.linux.util.KuranetConfig.java

public static void storeProperties(Properties props) throws IOException, KuraException {
    Properties oldProperties = KuranetConfig.getProperties();

    if (oldProperties == null || !oldProperties.equals(props)) {
        FileOutputStream fos = null;
        try {/*w w  w.j  a v  a 2 s  .c om*/
            fos = new FileOutputStream(KURANET_TMP_FILENAME);
            props.store(fos, null);
            fos.flush();
            fos.getFD().sync();

            // move the file if we made it this far
            File tmpFile = new File(KURANET_TMP_FILENAME);
            File file = new File(KURANET_FILENAME);
            if (!FileUtils.contentEquals(tmpFile, file)) {
                if (tmpFile.renameTo(file)) {
                    s_logger.trace("Successfully wrote kuranet props file");
                } else {
                    s_logger.error("Failed to write kuranet props file");
                    throw new KuraException(KuraErrorCode.CONFIGURATION_ERROR,
                            "error while building up new configuration file for kuranet props");
                }
            } else {
                s_logger.info("Not rewriting kuranet props file because it is the same");
            }
        } finally {
            fos.close();
        }
    }
}

From source file:org.opencastproject.capture.admin.impl.CaptureAgentStateServiceImpl.java

/**
 * {@inheritDoc}/*  ww  w.  ja  v a  2 s  .  c om*/
 * 
 * @see org.opencastproject.capture.admin.api.CaptureAgentStateService#setAgentConfiguration
 */
public boolean setAgentConfiguration(String agentName, Properties configuration) {
    if (StringUtils.isBlank(agentName))
        throw new IllegalArgumentException("Unable to set agent state, agent name is blank or null.");

    String orgId = securityService.getOrganization().getId();
    AgentImpl agent;
    try {
        Properties agentConfig = getAgentFromCache(agentName, orgId).getB();
        if (agentConfig.equals(configuration))
            return false;

        agent = (AgentImpl) getAgent(agentName);
        logger.debug("Setting Agent {}'s capabilities", agentName);
        agent.setConfiguration(configuration);
    } catch (NotFoundException e) {
        // If the agent doesn't exists, but the name is not null nor empty, create a new one.
        logger.debug("Creating Agent {} with state {}.", agentName, UNKNOWN);
        agent = new AgentImpl(agentName, orgId, UNKNOWN, "", configuration);
    }
    updateAgentInDatabase(agent);
    return true;
}

From source file:org.wso2.bps.samples.propertyreader.PropertyReaderExtensionOperation.java

@Override
protected void runSync(ExtensionContext extensionContext, Element element) throws FaultException {

    Properties properties = null;
    String fileLocation = element.getAttribute("location").trim();

    String source = fileLocation.split(":")[0];

    if (source.equals("file")) {
        properties = getPropertiesFromLocalFile(fileLocation.split(":")[1]);
    } else if (source.equals("conf")) {
        properties = getPropertiesFromConfigRegistryFile(fileLocation.split(":")[1]);
    } else if (source.equals("gov")) {
        properties = getPropertiesFromGovernanceFile(fileLocation.split(":")[1]);
    } else {/*  w ww .  ja  va2s.c  o  m*/
        System.out.println("File Location Error !!");
    }

    NodeList propertyNameList = element.getElementsByTagName("property");

    for (int i = 0; i < propertyNameList.getLength() && !properties.equals(null); i++) {
        Element property = (Element) propertyNameList.item(i);
        String propertyName = property.getAttribute("name").trim();
        String value = properties.getProperty(propertyName, "");
        Element to = (Element) property.getElementsByTagName("to").item(0);
        String variable = to.getAttribute("variable").trim();
        extensionContext.readVariable(variable.trim()).setTextContent(value.trim());
    }

}