Example usage for java.util Properties remove

List of usage examples for java.util Properties remove

Introduction

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

Prototype

@Override
    public synchronized Object remove(Object key) 

Source Link

Usage

From source file:lucee.runtime.net.smtp.SMTPClient.java

private static Properties createProperties(Config config, String hostName, int port, String username,
        String password, boolean tls, boolean ssl, int timeout) {
    Properties props = (Properties) System.getProperties().clone();
    String strTimeout = Caster.toString(getTimeout(config, timeout));

    props.put("mail.smtp.host", hostName);
    props.put("mail.smtp.timeout", strTimeout);
    props.put("mail.smtp.connectiontimeout", strTimeout);
    if (port > 0) {
        props.put("mail.smtp.port", Caster.toString(port));
    }/*from   w w  w .j av  a2s.co  m*/
    if (ssl) {
        props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.socketFactory.port", Caster.toString(port));
        props.put("mail.smtp.socketFactory.fallback", "false");
    } else {
        props.put("mail.smtp.socketFactory.class", "javax.net.SocketFactory");
        props.remove("mail.smtp.socketFactory.port");
        props.remove("mail.smtp.socketFactory.fallback");
    }
    if (!StringUtil.isEmpty(username)) {
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", tls ? "true" : "false");

        props.put("mail.smtp.user", username);
        props.put("mail.smtp.password", password);
        props.put("password", password);
    } else {
        props.put("mail.smtp.auth", "false");
        props.remove("mail.smtp.starttls.enable");

        props.remove("mail.smtp.user");
        props.remove("mail.smtp.password");
        props.remove("password");
    }
    return props;
}

From source file:info.novatec.testit.livingdoc.confluence.LivingDocServerConfigurationActivator.java

public void initQuickInstallConfiguration() throws LivingDocServerException {
    LivingDocServerConfiguration customConfiguration = getConfiguration();

    Properties properties = new DefaultServerProperties();

    properties.put("hibernate.c3p0.acquire_increment", "1");
    properties.put("hibernate.c3p0.idle_test_period", "100");
    properties.put("hibernate.c3p0.max_size", "15");
    properties.put("hibernate.c3p0.max_statements", "0");
    properties.put("hibernate.c3p0.min_size", "0");
    properties.put("hibernate.c3p0.timeout", "30");
    properties.remove("hibernate.connection.datasource"); // direct jdbc
    properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
    properties.put("hibernate.connection.url", "jdbc:hsqldb:" + getConfluenceHome() + "/database/ldsdb");
    properties.put("hibernate.connection.username", "sa");
    properties.put("hibernate.connection.password", "");
    properties.put("hibernate.dialect", HSQLDialect.class.getName());

    configuration.setProperties(properties);

    setupDatabaseFromConfiguration(customConfiguration);
}

From source file:org.etudes.jforum.view.install.InstallAction.java

private void doFinalSteps() {
    try {// w  w  w .j  a  v  a 2s.co m
        // Modules Mapping
        String modulesMapping = SystemGlobals.getValue(ConfigKeys.CONFIG_DIR) + "/modulesMapping.properties";
        if (new File(modulesMapping).canWrite()) {
            Properties p = new Properties();
            p.load(new FileInputStream(modulesMapping));

            if (p.containsKey("install")) {
                p.remove("install");

                p.store(new FileOutputStream(modulesMapping), "Modified by JForum Installer");

                this.addToSessionAndContext("mappingFixed", "true");
                ConfigLoader.loadModulesMapping(SystemGlobals.getValue(ConfigKeys.CONFIG_DIR));
            }
        }
    } catch (Exception e) {
        logger.warn("Error while working on modulesMapping.properties: " + e);
    }

    try {
        // Index renaming
        String index = SystemGlobals.getApplicationPath() + "/index.htm";
        File indexFile = new File(index);
        if (indexFile.canWrite()) {
            String newIndex = SystemGlobals.getApplicationPath() + "/new_rename.htm";
            File newIndexFile = new File(newIndex);
            if (newIndexFile.exists()) {
                indexFile.delete();
                newIndexFile.renameTo(indexFile);

                this.addToSessionAndContext("indexFixed", "true");
            }
        }
    } catch (Exception e) {
        logger.warn("Error while renaming index.htm: " + e);
    }
}

From source file:org.mule.transport.soap.axis.AxisServiceComponent.java

protected void processMethodRequest(MessageContext msgContext, MuleEventContext context,
        AxisStringWriter response, EndpointURI endpointUri) throws AxisFault {
    Properties params = endpointUri.getUserParams();

    String method = (String) params.remove(MuleProperties.MULE_METHOD_PROPERTY);
    if (method == null) {
        method = endpointUri.getPath().substring(endpointUri.getPath().lastIndexOf("/") + 1);
    }//from  w  w w .j  av a2  s . c om
    StringBuffer args = new StringBuffer(64);

    Map.Entry entry;
    for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
        entry = (Map.Entry) iterator.next();
        args.append("<").append(entry.getKey()).append(">");
        args.append(entry.getValue());
        args.append("</").append(entry.getKey()).append(">");
    }

    if (method == null) {
        response.setProperty(HttpConstants.HEADER_CONTENT_TYPE, "text/html");
        response.setProperty(HttpConnector.HTTP_STATUS_PROPERTY, "400");
        response.write(
                "<h2>" + Messages.getMessage("error00") + ":  " + Messages.getMessage("invokeGet00") + "</h2>");
        response.write("<p>" + Messages.getMessage("noMethod01") + "</p>");
    } else {
        invokeEndpointFromGet(msgContext, response, method, args.toString());
    }
}

From source file:org.intermine.sql.Database.java

private void removeProperty(Properties props, String propName) {
    if (props.containsKey(propName)) {
        props.remove(propName);
    }/* w  w  w .  j a v a 2 s.com*/
}

From source file:org.wso2.carbon.identity.notification.mgt.NotificationMgtConfigBuilder.java

/**
 * Build a list of subscription by a particular module
 *
 * @param moduleName       Name of the module
 * @param moduleProperties Set of properties which
 * @return A list of subscriptions by the module
 *//*w  ww  .j a va  2 s .c  o m*/
private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) {
    // Get subscribed events
    Properties subscriptions = NotificationManagementUtils.getSubProperties(
            moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION, moduleProperties);

    List<Subscription> subscriptionList = new ArrayList<Subscription>();
    Enumeration propertyNames = subscriptions.propertyNames();
    // Iterate through events and build event objects
    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        String subscriptionName = (String) subscriptions.remove(key);
        // Read all the event properties starting from the event prefix
        Properties subscriptionProperties = NotificationManagementUtils.getPropertiesWithPrefix(
                moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION + "." + subscriptionName,
                moduleProperties);
        Subscription subscription = new Subscription(subscriptionName, subscriptionProperties);
        subscriptionList.add(subscription);
    }
    return subscriptionList;
}

From source file:it.greenvulcano.gvesb.api.controller.GvConfigurationControllerRest.java

@DELETE
@Path("/configuration/{configId}")
@RolesAllowed({ Authority.ADMINISTRATOR, Authority.MANAGER })
public void deleteConfiguration(@PathParam("configId") String id) {
    try {/* www . j  a  va 2s.c o m*/
        Properties descriptions = getConfDescriptionProperties();

        gvConfigurationManager.delete(id);
        descriptions.remove(id);
        saveConfDescriptionProperties(descriptions);

    } catch (Exception e) {
        //TODO: perhaps it is better to allow deleting even if the descriptions data are not found
        LOG.error("Failed to delete configuraton, something bad appened", e);
        throw new WebApplicationException(
                Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build());

    }
}

From source file:com.hp.application.automation.tools.run.RunFromAlmBuilder.java

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {

    // get the alm server settings
    AlmServerSettingsModel almServerSettingsModel = getAlmServerSettingsModel();

    if (almServerSettingsModel == null) {
        listener.fatalError(/*ww w. j  a  v  a 2 s .  c  o  m*/
                "An ALM server is not defined. Go to Manage Jenkins->Configure System and define your ALM server under Application Lifecycle Management");
        return false;
    }

    EnvVars env = null;
    try {
        env = build.getEnvironment(listener);
    } catch (IOException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    VariableResolver<String> varResolver = build.getBuildVariableResolver();

    // now merge them into one list
    Properties mergedProperties = new Properties();

    mergedProperties.putAll(almServerSettingsModel.getProperties());
    mergedProperties.putAll(runFromAlmModel.getProperties(env, varResolver));

    String encAlmPass = "";
    try {

        encAlmPass = EncryptionUtils.Encrypt(runFromAlmModel.getAlmPassword(), EncryptionUtils.getSecretKey());

        mergedProperties.remove(RunFromAlmModel.ALM_PASSWORD_KEY);
        mergedProperties.put(RunFromAlmModel.ALM_PASSWORD_KEY, encAlmPass);

    } catch (Exception e) {
        build.setResult(Result.FAILURE);
        listener.fatalError("problem in qcPassword encription");
    }

    Date now = new Date();
    Format formatter = new SimpleDateFormat("ddMMyyyyHHmmssSSS");
    String time = formatter.format(now);

    // get a unique filename for the params file
    ParamFileName = "props" + time + ".txt";
    ResultFilename = "Results" + time + ".xml";
    //KillFileName = "stop" + time + ".txt";

    mergedProperties.put("runType", RunType.Alm.toString());
    mergedProperties.put("resultsFilename", ResultFilename);

    // get properties serialized into a stream
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    try {
        mergedProperties.store(stream, "");
    } catch (IOException e) {
        build.setResult(Result.FAILURE);
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String propsSerialization = stream.toString();
    InputStream propsStream = IOUtils.toInputStream(propsSerialization);

    // get the remote workspace filesys
    FilePath projectWS = build.getWorkspace();

    // Get the URL to the Script used to run the test, which is bundled
    // in the plugin
    URL cmdExeUrl = Hudson.getInstance().pluginManager.uberClassLoader.getResource(HpToolsLauncher_SCRIPT_NAME);
    if (cmdExeUrl == null) {
        listener.fatalError(HpToolsLauncher_SCRIPT_NAME + " not found in resources");
        return false;
    }

    FilePath propsFileName = projectWS.child(ParamFileName);
    FilePath CmdLineExe = projectWS.child(HpToolsLauncher_SCRIPT_NAME);

    try {
        // create a file for the properties file, and save the properties
        propsFileName.copyFrom(propsStream);

        // Copy the script to the project workspace
        CmdLineExe.copyFrom(cmdExeUrl);
    } catch (IOException e1) {
        build.setResult(Result.FAILURE);
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {
        // Run the HpToolsLauncher.exe
        AlmToolsUtils.runOnBuildEnv(build, launcher, listener, CmdLineExe, ParamFileName);
    } catch (IOException ioe) {
        Util.displayIOException(ioe, listener);
        build.setResult(Result.FAILURE);
        return false;
    } catch (InterruptedException e) {
        build.setResult(Result.ABORTED);
        PrintStream out = listener.getLogger();
        // kill processes
        //FilePath killFile = projectWS.child(KillFileName);
        /* try {
        out.println("Sending abort command");
        killFile.write("\n", "UTF-8");
        while (!killFile.exists())
            Thread.sleep(1000);
        Thread.sleep(1500);
                
        } catch (IOException e1) {
        //build.setResult(Result.FAILURE);
        // TODO Auto-generated catch block
        e1.printStackTrace();
        } catch (InterruptedException e1) {
        //build.setResult(Result.FAILURE);
        // TODO Auto-generated catch block
        e1.printStackTrace();
        }*/

        try {
            AlmToolsUtils.runHpToolsAborterOnBuildEnv(build, launcher, listener, ParamFileName);
        } catch (IOException e1) {
            Util.displayIOException(e1, listener);
            build.setResult(Result.FAILURE);
            return false;
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        out.println("Operation was aborted by user.");
        //build.setResult(Result.FAILURE);
    }
    return true;

}

From source file:org.geowebcache.storage.blobstore.file.FileBlobStore.java

/**
 * @see org.geowebcache.storage.BlobStore#putLayerMetadata(java.lang.String, java.lang.String,
 *      java.lang.String)//from   w  ww . ja  v a2s .c o  m
 */
public void putLayerMetadata(final String layerName, final String key, final String value) {
    Properties metadata = getLayerMetadata(layerName);
    if (null == value) {
        metadata.remove(key);
    } else {
        try {
            metadata.setProperty(key, URLEncoder.encode(value, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    final File metadataFile = getMetadataFile(layerName);

    final String lockObj = metadataFile.getAbsolutePath().intern();
    synchronized (lockObj) {
        OutputStream out;
        try {
            if (!metadataFile.getParentFile().exists()) {
                metadataFile.getParentFile().mkdirs();
            }
            out = new FileOutputStream(metadataFile);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        try {
            String comments = "auto generated file, do not edit by hand";
            metadata.store(out, comments);
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                log.warn(e.getMessage(), e);
            }
        }
    }
}

From source file:com.ecyrd.jspwiki.providers.WikiVersioningFileProvider.java

@Override
public void deleteVersion(String page, int version) throws ProviderException {
    File dir = findOldPageDir(page);
    int latest = findLatestVersion(page);

    if (version == WikiPageProvider.LATEST_VERSION || version == latest || (version == 1 && latest == -1)) { //
        // Delete the properties
        ///*from   w ww  .  j av  a2s . co m*/
        try {
            Properties props = getPageProperties(page);
            props.remove(((latest > 0) ? latest : 1) + ".author");
            putPageProperties(page, props);
        } catch (IOException e) {
            SilverTrace.error("wiki", "WikiVersioningFileProvider.deleteVersion()", "wiki.EX_MODIFY_PROPERTIES",
                    e);
            throw new ProviderException("Could not modify page properties");
        }
        // We can let the FileSystemProvider take care
        // of the actual deletion
        super.deleteVersion(page, WikiPageProvider.LATEST_VERSION);

        //
        // Copy the old file to the new location
        //
        latest = findLatestVersion(page);

        File pageDir = findOldPageDir(page);
        File previousFile = new File(pageDir, Integer.toString(latest) + FILE_EXT);

        InputStream in = null;
        OutputStream out = null;

        try {
            if (previousFile.exists()) {
                in = new BufferedInputStream(new FileInputStream(previousFile));
                File pageFile = findPage(page);
                out = new BufferedOutputStream(new FileOutputStream(pageFile));

                FileUtil.copyContents(in, out);

                //
                // We need also to set the date, since we rely on this.
                //
                pageFile.setLastModified(previousFile.lastModified());
            }
        } catch (IOException e) {
            SilverTrace.fatal("wiki", "WikiVersioningFileProvider.deleteVersion()", "root.EXCEPTION",
                    "Something wrong with the page directory - you may have just lost data!", e);
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }

        return;
    }

    File pageFile = new File(dir, "" + version + FILE_EXT);
    if (pageFile.exists()) {
        if (!pageFile.delete()) {
            SilverTrace.error("wiki", "WikiVersioningFileProvider.deleteVersion()",
                    "wiki.EX_DELETE_PAGE_FAILED");
        }
    } else {
        throw new NoSuchVersionException("Page " + page + ", version=" + version);
    }
}