List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:eu.dnetlib.maven.plugin.properties.WritePredefinedProjectProperties.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { Properties properties = new Properties(); // Add project properties properties.putAll(project.getProperties()); if (includeEnvironmentVariables) { // Add environment variables, overriding any existing properties with the same key properties.putAll(getEnvironmentVariables()); }//from w w w .jav a 2 s . c o m if (includeSystemProperties) { // Add system properties, overriding any existing properties with the same key properties.putAll(System.getProperties()); } // Remove properties as appropriate trim(properties, exclude, include); String comment = "# " + new Date() + "\n"; List<String> escapeTokens = getEscapeChars(escapeChars); if (antEchoPropertiesMode) { escapeTokens = Arrays.asList(ANT_ESCAPE_CHARS); comment = getAntHeader(); properties.remove("DSTAMP"); properties.remove("TODAY"); properties.remove("TSTAMP"); } getLog().info("Creating " + outputFile); writeProperties(outputFile, comment, properties, escapeTokens); }
From source file:org.apache.gobblin.service.FlowConfigResourceLocalHandler.java
/** * Get flow config/*w w w . j a va 2 s .c o m*/ */ public FlowConfig getFlowConfig(FlowId flowId) throws FlowConfigLoggedException { log.info("[GAAS-REST] Get called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); try { URI flowCatalogURI = new URI("gobblin-flow", null, "/", null, null); URI flowUri = new URI(flowCatalogURI.getScheme(), flowCatalogURI.getAuthority(), "/" + flowId.getFlowGroup() + "/" + flowId.getFlowName(), null, null); FlowSpec spec = (FlowSpec) flowCatalog.getSpec(flowUri); FlowConfig flowConfig = new FlowConfig(); Properties flowProps = spec.getConfigAsProperties(); Schedule schedule = null; if (flowProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) { schedule = new Schedule(); schedule.setCronSchedule(flowProps.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY)); } if (flowProps.containsKey(ConfigurationKeys.JOB_TEMPLATE_PATH)) { flowConfig.setTemplateUris(flowProps.getProperty(ConfigurationKeys.JOB_TEMPLATE_PATH)); } else if (spec.getTemplateURIs().isPresent()) { flowConfig.setTemplateUris(StringUtils.join(spec.getTemplateURIs().get(), ",")); } else { flowConfig.setTemplateUris("NA"); } if (schedule != null) { if (flowProps.containsKey(ConfigurationKeys.FLOW_RUN_IMMEDIATELY)) { schedule.setRunImmediately( Boolean.valueOf(flowProps.getProperty(ConfigurationKeys.FLOW_RUN_IMMEDIATELY))); } flowConfig.setSchedule(schedule); } // remove keys that were injected as part of flowSpec creation flowProps.remove(ConfigurationKeys.JOB_SCHEDULE_KEY); flowProps.remove(ConfigurationKeys.JOB_TEMPLATE_PATH); StringMap flowPropsAsStringMap = new StringMap(); flowPropsAsStringMap.putAll(Maps.fromProperties(flowProps)); return flowConfig .setId(new FlowId().setFlowGroup(flowId.getFlowGroup()).setFlowName(flowId.getFlowName())) .setProperties(flowPropsAsStringMap); } catch (URISyntaxException e) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowId.getFlowName(), e); } catch (SpecNotFoundException e) { throw new FlowConfigLoggedException(HttpStatus.S_404_NOT_FOUND, "Flow requested does not exist: " + flowId.getFlowName(), null); } }
From source file:nl.strohalm.cyclos.services.customization.TranslationMessageServiceImpl.java
private void importNewAndModifiedProperties(final Properties properties, final boolean emptyOnly) { // Process existing messages. This is done with Object[], otherwise hibernate will load each message with a separate select final Iterator<Object[]> existing = translationMessageDao.listData(); try {//from w ww .j a va 2 s. c o m while (existing.hasNext()) { final Object[] data = existing.next(); final String key = (String) data[1]; final String currentValue = (String) data[2]; final String newValue = properties.getProperty(key); if (newValue != null) { final boolean shallUpdate = !newValue.equals(currentValue) && (!emptyOnly || StringUtils.isEmpty(currentValue)); if (shallUpdate) { final TranslationMessage message = new TranslationMessage(); message.setId((Long) data[0]); message.setKey(key); message.setValue(newValue); translationMessageDao.update(message, false); } properties.remove(key); } } } finally { DataIteratorHelper.close(existing); } fetchService.clearCache(); // Only those who have to be inserted are left in properties insertAll(properties); }
From source file:org.wso2.developerstudio.eclipse.distribution.project.editor.DistProjectEditorPage.java
private Properties identifyNonProjectProperties(Properties properties) { Map<String, DependencyData> dependencies = getProjectList(); for (Iterator iterator = dependencies.values().iterator(); iterator.hasNext();) { DependencyData dependency = (DependencyData) iterator.next(); String artifactInfoAsString = DistProjectUtils.getArtifactInfoAsString(dependency.getDependency()); if (properties.containsKey(artifactInfoAsString)) { properties.remove(artifactInfoAsString); }/* www. jav a 2 s .c om*/ } // Removing the artifact.type properties.remove("artifact.types"); return properties; }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.Shipper.java
/** * Sends an email to the given id including a link to the password page. The * link contains the refID./* www. j a v a 2s. c o m*/ * * @param emailType * - refers to the email that shall be sent, 0 sends an email for * newly registered users, 1 sends a standard password-reset * email * @param emailaddress * @param refID * @return */ public boolean sendPasswordLinkToEmail(int emailType, User user, String refID) { String salutation = ""; if (user.getGender().equalsIgnoreCase("male")) { salutation = "geehrter Herr " + user.getName(); } else { salutation = "geehrte Frau " + user.getName(); } MailAuthenticator auth = new MailAuthenticator(emailProperties.getProperty("mail.user"), emailProperties.getProperty("mail.user.password")); // Login Properties props = (Properties) emailProperties.clone(); props.remove("mail.user"); props.remove("mail.user.password"); Session session = Session.getInstance(props, auth); String htmlContent = emailBody; htmlContent = htmlContent.replaceFirst("TITLE", emailProperties.getProperty("mail.skeleton.type." + emailType + ".title")); htmlContent = htmlContent.replaceFirst("MESSAGESUBJECT", emailProperties.getProperty("mail.skeleton.type." + emailType + ".messagesubject")); htmlContent = htmlContent.replaceFirst("HEADER1", emailProperties.getProperty("mail.skeleton.type." + emailType + ".header1")); htmlContent = htmlContent.replaceFirst("MESSAGE", emailProperties.getProperty("mail.skeleton.type." + emailType + ".message")); htmlContent = htmlContent.replaceFirst("SALUTATION", salutation); htmlContent = htmlContent.replaceFirst("TOPLEVELDOMAIN", emailProperties.getProperty("mail.service.domain")); htmlContent = htmlContent.replaceFirst("SERVICENAME", emailProperties.getProperty("mail.service.name")); htmlContent = htmlContent.replaceFirst("REFERER", refID); htmlContent = htmlContent.replaceFirst("BCKRGIMAGE", "'cid:header-image'"); htmlContent = htmlContent.replaceFirst("DASH", "'cid:dash'"); String textContent = emailProperties.getProperty("mail.skeleton.type." + emailType + ".title") + " - " + emailProperties.getProperty("mail.skeleton.type." + emailType + ".messagesubject") + "\n \n" + emailProperties.getProperty("mail.skeleton.type." + emailType + ".message"); textContent = textContent.replaceFirst("TOPLEVELDOMAIN", emailProperties.getProperty("mail.service.domain")); textContent = textContent.replaceFirst("SERVICENAME", emailProperties.getProperty("mail.service.name")); textContent = textContent.replaceFirst("REFERER", refID); textContent = textContent.replaceFirst("SALUTATION", salutation); textContent = textContent.replaceAll("<br>", "\n"); try { MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(emailProperties.getProperty("mail.user"))); msg.setRecipients(javax.mail.Message.RecipientType.TO, user.getEmailaddress()); msg.setSentDate(new Date()); msg.setSubject(emailProperties.getProperty("mail.skeleton.type." + emailType + ".subject")); Multipart mp = new MimeMultipart("alternative"); // plaintext MimeBodyPart textPart = new MimeBodyPart(); textPart.setText(textContent); mp.addBodyPart(textPart); // html MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent(htmlContent, "text/html; charset=UTF-8"); mp.addBodyPart(htmlPart); MimeBodyPart imagePart = new MimeBodyPart(); DataSource fds = null; try { fds = new FileDataSource( new File(new URL((String) emailProperties.get("mail.image.headerbackground")).getFile())); } catch (MalformedURLException e) { Logger.getLogger(this.getClass()).error(e); } imagePart.setDataHandler(new DataHandler(fds)); imagePart.setHeader("Content-ID", "header-image"); mp.addBodyPart(imagePart); MimeBodyPart imagePart2 = new MimeBodyPart(); DataSource fds2 = null; try { fds2 = new FileDataSource( new File(new URL((String) emailProperties.get("mail.image.dash")).getFile())); } catch (MalformedURLException e) { Logger.getLogger(this.getClass()).error(e); } imagePart2.setDataHandler(new DataHandler(fds2)); imagePart2.setHeader("Content-ID", "dash"); mp.addBodyPart(imagePart2); msg.setContent(mp); Transport.send(msg); } catch (Exception e) { Logger.getLogger(this.getClass()).error(e); return false; } return true; }
From source file:org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer.java
/** * Serialize sequence metadata.//from w w w. j a va2 s .co m */ protected void serializeSequence(SequenceMetaData meta) throws SAXException { if (!_annos && meta.getSourceType() == meta.SRC_ANNOTATIONS) return; Log log = getLog(); if (log.isInfoEnabled()) log.info(_loc.get("ser-sequence", meta.getName())); addComments(meta); addAttribute("name", meta.getName()); // parse out the datastore sequence name, if any String plugin = meta.getSequencePlugin(); String clsName = Configurations.getClassName(plugin); String props = Configurations.getProperties(plugin); String ds = null; if (props != null) { Properties map = Configurations.parseProperties(props); ds = (String) map.remove("Sequence"); if (ds != null) { props = Configurations.serializeProperties(map); plugin = Configurations.getPlugin(clsName, props); } } if (ds != null) addAttribute("sequence-name", ds); else if (plugin != null && !SequenceMetaData.IMPL_NATIVE.equals(plugin)) addAttribute("sequence-name", plugin); if (meta.getInitialValue() != 0 && meta.getInitialValue() != -1) addAttribute("initial-value", String.valueOf(meta.getInitialValue())); if (meta.getAllocate() != 50 && meta.getAllocate() != -1) addAttribute("allocation-size", String.valueOf(meta.getAllocate())); startElement("sequence-generator"); endElement("sequence-generator"); }
From source file:tvbrowser.extras.reminderplugin.ReminderPlugin.java
private void loadSettings(Properties settings) { if (settings == null) { settings = new Properties(); }/*from ww w .j a v a 2s . c om*/ if (settings.getProperty("usemsgbox") == null) { settings.setProperty("usemsgbox", "true"); } mSettings = settings; if (settings.containsKey("usethisplugin") || settings.containsKey("usesendplugin")) { String plugins = settings.getProperty("usethisplugin", "").trim(); boolean sendEnabled = settings.getProperty("usesendplugin", "").compareToIgnoreCase("true") == 0; settings.remove("usethisplugin"); settings.remove("usesendplugin"); if (plugins.length() > 0 && sendEnabled) { if (plugins.indexOf(';') == -1) { mClientPluginTargets = new ProgramReceiveTarget[1]; mClientPluginTargets[0] = ProgramReceiveTarget .createDefaultTargetForProgramReceiveIfId(plugins); } else { String[] ids = plugins.split(";"); mClientPluginTargets = new ProgramReceiveTarget[ids.length]; for (int i = 0; i < ids.length; i++) { mClientPluginTargets[i] = ProgramReceiveTarget .createDefaultTargetForProgramReceiveIfId(ids[i]); } } } } if (settings.containsKey("autoCloseReminderAtProgramEnd")) { if (settings.getProperty("autoCloseReminderAtProgramEnd", "true").equalsIgnoreCase("true")) { settings.setProperty("autoCloseBehaviour", "onEnd"); } settings.remove("autoCloseReminderAtProgramEnd"); } }
From source file:gobblin.service.FlowConfigsResource.java
/** * Retrieve the flow configuration with the given key * @param key flow config id key containing group name and flow name * @return {@link FlowConfig} with flow configuration *///w ww .j a va2s. c om @Override public FlowConfig get(ComplexResourceKey<FlowId, EmptyRecord> key) { String flowGroup = key.getKey().getFlowGroup(); String flowName = key.getKey().getFlowName(); LOG.info("Get called with flowGroup " + flowGroup + " flowName " + flowName); try { URI flowCatalogURI = new URI("gobblin-flow", null, "/", null, null); URI flowUri = new URI(flowCatalogURI.getScheme(), flowCatalogURI.getAuthority(), "/" + flowGroup + "/" + flowName, null, null); FlowSpec spec = (FlowSpec) getFlowCatalog().getSpec(flowUri); FlowConfig flowConfig = new FlowConfig(); Properties flowProps = spec.getConfigAsProperties(); Schedule schedule = null; if (flowProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) { schedule = new Schedule(); schedule.setCronSchedule(flowProps.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY)); } if (flowProps.containsKey(ConfigurationKeys.JOB_TEMPLATE_PATH)) { flowConfig.setTemplateUris(flowProps.getProperty(ConfigurationKeys.JOB_TEMPLATE_PATH)); } else if (spec.getTemplateURIs().isPresent()) { flowConfig.setTemplateUris(StringUtils.join(spec.getTemplateURIs().get(), ",")); } else { flowConfig.setTemplateUris("NA"); } if (schedule != null) { if (flowProps.containsKey(ConfigurationKeys.FLOW_RUN_IMMEDIATELY)) { schedule.setRunImmediately( Boolean.valueOf(flowProps.getProperty(ConfigurationKeys.FLOW_RUN_IMMEDIATELY))); } flowConfig.setSchedule(schedule); } // remove keys that were injected as part of flowSpec creation flowProps.remove(ConfigurationKeys.JOB_SCHEDULE_KEY); flowProps.remove(ConfigurationKeys.JOB_TEMPLATE_PATH); StringMap flowPropsAsStringMap = new StringMap(); flowPropsAsStringMap.putAll(Maps.fromProperties(flowProps)); return flowConfig.setId(new FlowId().setFlowGroup(flowGroup).setFlowName(flowName)) .setProperties(flowPropsAsStringMap); } catch (URISyntaxException e) { logAndThrowRestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowName, e); } catch (SpecNotFoundException e) { logAndThrowRestLiServiceException(HttpStatus.S_404_NOT_FOUND, "Flow requested does not exist: " + flowName, null); } return null; }
From source file:org.ebayopensource.turmeric.eclipse.test.util.ProjectArtifactValidator.java
@Override public boolean visit(IResource resource) throws CoreException { // if (!matches) // return false; IPath path = resource.getProjectRelativePath(); String filePath = path.toString(); if (StringUtils.isEmpty(filePath)) return true; for (String dir : filterDirList) { IPath dirPath = new Path(dir); if (path.matchingFirstSegments(dirPath) == dirPath.segmentCount()) { return true; }//from w w w . ja v a 2s . co m } String lastSegment = path.lastSegment(); for (String file : this.filterFileList) { if (lastSegment.equalsIgnoreCase(file)) return true; } // now compare with the files in the gold copy IPath rsrcPath = resource.getProject().getLocation().append(path); if (rsrcPath.toFile().isFile()) { if (!rsrcPath.toFile().exists() && (new File(goldCopyDir + File.separator + path.toString()).exists())) { formatMessage(rsrcPath, "generated copy does not exist"); } System.out.println(" --- Functional test generated file : " + rsrcPath.toOSString()); if ("properties".equals(rsrcPath.getFileExtension())) { Properties srcProp = new Properties(); InputStream ins = null; try { ins = new FileInputStream(rsrcPath.toFile()); srcProp.load(ins); } catch (Exception e) { e.printStackTrace(); matches = false; } finally { IOUtils.closeQuietly(ins); } Properties goldCopyProp = new Properties(); try { ins = new FileInputStream(new File(goldCopyDir + File.separator + path.toString())); goldCopyProp.load(ins); } catch (Exception e) { e.printStackTrace(); matches = false; } finally { IOUtils.closeQuietly(ins); } if (matches) { if (srcProp.containsKey("original_wsdl_uri")) { srcProp.remove("original_wsdl_uri"); goldCopyProp.remove("original_wsdl_uri"); } if (PropertiesFileUtil.isEqual(srcProp, goldCopyProp) == false) { formatMessage(rsrcPath, "gold copy did not match"); System.out.println("the following did not match: " + goldCopyDir + "/" + path); matches = false; } } } else { try { if ("java".equals(rsrcPath.getFileExtension())) { // if(rsrcPath.lastSegment().contains("TypeDefsBuilder")){ // //failing in linux box. // return true; // // } System.out.println("java file : " + rsrcPath.toOSString()); File goldCopyJava = new File(goldCopyDir + File.separator + path.toString()); if (!goldCopyJava.exists()) { formatMessage(rsrcPath, "gold copy do not exist"); System.out.println("File not in gold copy" + goldCopyDir + "/" + path); matches = false; return true; } if (compareTwoFiles(rsrcPath.toFile(), goldCopyJava) == false) { formatMessage(rsrcPath, "gold copy did not match"); System.out.println("the following did not match: " + goldCopyDir + "/" + path); matches = false; } } else { if ("xml".equals(rsrcPath.getFileExtension())) { System.out.println("xml file : " + rsrcPath.toOSString()); /* * if (FileUtils.contentEquals( rsrcPath.toFile(), * new File(goldCopyDir + "/" + path.toString())) == * false) { formatMessage(rsrcPath); System.out * .println("the following did not match: " + * goldCopyDir + "/" + path); matches = false; } */ try { String xmlfile = readFileAsString(rsrcPath.toOSString()); // Only Validated if we have a schema with the // file // XMLAssert.assertXMLValid(xmlfile); // XMLAssert.assertXMLValid(goldCopyDir // + File.separator + path); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreWhitespace(true); String goldFile = readFileAsString(goldCopyDir + File.separator + path); // XMLAssert.assertXMLEqual(goldFile,xmlfile); Diff diff = new Diff(goldFile, xmlfile); //Whichever element has the attribute "name" in the goldfile will be compared with //all the elements that have attribute "name" in the xmlfile, takes care of order differences diff.overrideElementQualifier(new ElementNameAndAttributeQualifier("name")); if (!diff.similar()) { formatMessage(rsrcPath, "gold copy did not match"); System.out.println("the following did not match: " + goldCopyDir + "/" + path); matches = false; } // XMLAssert.assertXMLEqual(goldFile,xmlfile); } catch (Exception e) { formatMessage(rsrcPath, "gold copy did not match"); e.printStackTrace(); } } else if ("wsdl".equals(rsrcPath.getFileExtension())) { System.out.println("wsdlFile file : " + rsrcPath.toOSString()); } else { System.out.println("other file : " + rsrcPath.toOSString()); if (FileUtils.contentEquals(rsrcPath.toFile(), new File(goldCopyDir + "/" + path.toString())) == false) { formatMessage(rsrcPath, "gold copy did not match"); System.out.println("the following did not match: " + goldCopyDir + "/" + path); matches = false; } } } } catch (FileNotFoundException fnfe) { formatMessage(rsrcPath, "file not found exception"); } catch (IOException e) { e.printStackTrace(); System.out.println("the following did not match: " + goldCopyDir + "/" + path); matches = false; } } } else { files.remove(new File(goldCopyDir + "/" + path.toString())); } return true; }
From source file:org.jahia.services.usermanager.JahiaUserManagerService.java
public Set<JCRUserNode> searchUsers(final Properties searchCriterias, String siteKey, final String[] providerKeys, boolean excludeProtected, JCRSessionWrapper session) { try {/* ww w .j a v a 2 s .c o m*/ int limit = 0; Set<JCRUserNode> users = new HashSet<JCRUserNode>(); if (session.getWorkspace().getQueryManager() != null) { StringBuilder query = new StringBuilder(); // Add provider to query if (providerKeys != null) { List<JCRStoreProvider> providers = getProviders(siteKey, providerKeys, session); if (!providers.isEmpty()) { query.append("("); for (JCRStoreProvider provider : providers) { query.append(query.length() > 1 ? " OR " : ""); if (provider.isDefault()) { query.append("u.[j:external] = false"); } else { query.append("ISDESCENDANTNODE('").append(provider.getMountPoint()).append("')"); } } query.append(")"); } else { return users; } } // Add criteria if (searchCriterias != null && !searchCriterias.isEmpty()) { Properties filters = (Properties) searchCriterias.clone(); String operation = " OR "; if (filters.containsKey(MULTI_CRITERIA_SEARCH_OPERATION)) { if (((String) filters.get(MULTI_CRITERIA_SEARCH_OPERATION)).trim().toLowerCase() .equals("and")) { operation = " AND "; } filters.remove(MULTI_CRITERIA_SEARCH_OPERATION); } if (filters.containsKey(COUNT_LIMIT)) { limit = Integer.parseInt((String) filters.get(COUNT_LIMIT)); logger.debug("Limit of results has be set to " + limit); filters.remove(COUNT_LIMIT); } // Avoid wildcard attribute if (!(filters.containsKey("*") && filters.size() == 1 && filters.getProperty("*").equals("*"))) { Iterator<Map.Entry<Object, Object>> criteriaIterator = filters.entrySet().iterator(); if (criteriaIterator.hasNext()) { query.append(query.length() > 0 ? " AND " : "").append(" ("); while (criteriaIterator.hasNext()) { Map.Entry<Object, Object> entry = criteriaIterator.next(); String propertyKey = (String) entry.getKey(); if ("username".equals(propertyKey)) { propertyKey = "j:nodename"; } String propertyValue = (String) entry.getValue(); if ("*".equals(propertyValue)) { propertyValue = "%"; } else { if (propertyValue.indexOf('*') != -1) { propertyValue = Patterns.STAR.matcher(propertyValue).replaceAll("%"); } else { propertyValue = propertyValue + "%"; } } propertyValue = JCRContentUtils.sqlEncode(propertyValue); if ("*".equals(propertyKey)) { query.append("(CONTAINS(u.*,'" + QueryParser .escape(Patterns.PERCENT.matcher(propertyValue).replaceAll("")) + "') OR LOWER(u.[j:nodename]) LIKE '") .append(propertyValue.toLowerCase()).append("') "); } else { query.append("LOWER(u.[" + Patterns.DOT.matcher(propertyKey).replaceAll("\\\\.") + "])").append(" LIKE '").append(propertyValue.toLowerCase()) .append("'"); } if (criteriaIterator.hasNext()) { query.append(operation); } } query.append(")"); } } } if (query.length() > 0) { query.insert(0, " and "); } if (excludeProtected) { query.insert(0, " and [j:nodename] <> '" + GUEST_USERNAME + "'"); } String s = (siteKey == null) ? "/users/" : "/sites/" + siteKey + "/users/"; query.insert(0, "SELECT * FROM [" + Constants.JAHIANT_USER + "] as u where isdescendantnode(u,'" + JCRContentUtils.sqlEncode(s) + "')"); if (logger.isDebugEnabled()) { logger.debug(query.toString()); } Query q = session.getWorkspace().getQueryManager().createQuery(query.toString(), Query.JCR_SQL2); if (limit > 0) { q.setLimit(limit); } QueryResult qr = q.execute(); NodeIterator ni = qr.getNodes(); while (ni.hasNext()) { Node userNode = ni.nextNode(); users.add((JCRUserNode) userNode); } } return users; } catch (RepositoryException e) { logger.error("Error while searching for users", e); return new HashSet<JCRUserNode>(); } }