List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.apache.archiva.metadata.repository.file.FileMetadataRepository.java
@Override public void removeArtifact(String repoId, String namespace, String project, String version, String id) throws MetadataRepositoryException { try {//www . j a v a2s . com File directory = new File(getDirectory(repoId), namespace + "/" + project + "/" + version); Properties properties = readOrCreateProperties(directory, PROJECT_VERSION_METADATA_KEY); properties.remove("artifact:updated:" + id); properties.remove("artifact:whenGathered:" + id); properties.remove("artifact:size:" + id); properties.remove("artifact:md5:" + id); properties.remove("artifact:sha1:" + id); properties.remove("artifact:version:" + id); properties.remove("artifact:facetIds:" + id); String prefix = "artifact:facet:" + id + ":"; for (Object key : new ArrayList(properties.keySet())) { String property = (String) key; if (property.startsWith(prefix)) { properties.remove(property); } } FileUtils.deleteDirectory(directory); //writeProperties( properties, directory, PROJECT_VERSION_METADATA_KEY ); } catch (IOException e) { throw new MetadataRepositoryException(e.getMessage(), e); } }
From source file:com.photon.phresco.framework.rest.api.FeatureService.java
private FeatureConfigure getTemplateConfigFile(String appDirName, String customerId, ServiceManager serviceManager, String featureName, String rootModulePath, String subModuleName) throws PhrescoException { List<PropertyTemplate> propertyTemplates = new ArrayList<PropertyTemplate>(); try {/*from ww w. ja v a 2 s .c o m*/ FeatureConfigure featureConfigure = new FeatureConfigure(); FrameworkServiceUtil frameworkServiceUtil = new FrameworkServiceUtil(); ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName); List<Configuration> featureConfigurations = frameworkServiceUtil .getApplicationProcessor(appDirName, customerId, serviceManager, rootModulePath, subModuleName) .preFeatureConfiguration(projectInfo.getAppInfos().get(0), featureName); Properties properties = null; boolean hasCustomProperty = false; if (CollectionUtils.isNotEmpty(featureConfigurations)) { for (Configuration featureConfiguration : featureConfigurations) { properties = featureConfiguration.getProperties(); String expandableProp = properties.getProperty("expandable"); if (StringUtils.isEmpty(expandableProp)) { hasCustomProperty = true; } else { hasCustomProperty = Boolean.valueOf(expandableProp); } if (properties.containsKey("expandable")) { properties.remove("expandable"); } Set<Object> keySet = properties.keySet(); for (Object key : keySet) { String keyStr = (String) key; if (!"expandable".equalsIgnoreCase(keyStr)) { String dispName = keyStr.replace(".", " "); PropertyTemplate propertyTemplate = new PropertyTemplate(); propertyTemplate.setKey(keyStr); propertyTemplate.setName(dispName); propertyTemplates.add(propertyTemplate); } } } } featureConfigure.setHasCustomProperty(hasCustomProperty); featureConfigure.setProperties(properties); featureConfigure.setPropertyTemplates(propertyTemplates); return featureConfigure; } catch (PhrescoException e) { throw new PhrescoException(e); } }
From source file:view.CertificateManagementDialog.java
private void btnAcceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAcceptActionPerformed Properties properties = new Properties(); String configFile = "aCCinaPDF.cfg"; try {// w w w. j av a 2 s . c o m properties.load(new FileInputStream(configFile)); } catch (IOException ex) { Logger.getLogger(CertificateManagementDialog.class.getName()).log(Level.SEVERE, null, ex); } if (rbUseDefaultKeystore.isSelected()) { if (!CCInstance.getInstance().getKeystore().equals(CCInstance.getInstance().getDefaultKeystore())) { CCInstance.getInstance().setKeystore(CCInstance.getInstance().getDefaultKeystore()); Settings.getSettings().setKeystorePath(null); properties.remove("keystore"); } } else { if (null == lastOpened) { lastOpened = new File(tfCustomKeystore.getText()); } try { KeyStore ks = isValidKeystore(lastOpened, false); if (!ks.equals(CCInstance.getInstance().getKeystore())) { CCInstance.getInstance().setKeystore(ks); String keystorePath = lastOpened.getAbsolutePath(); Settings.getSettings().setKeystorePath(keystorePath); properties.setProperty("keystore", keystorePath); } } catch (Exception e) { JOptionPane.showMessageDialog(this, Bundle.getBundle().getString("selectValidKeystore"), "", JOptionPane.INFORMATION_MESSAGE); return; } } try { FileOutputStream fileOut = new FileOutputStream(configFile); properties.store(fileOut, "Settings"); fileOut.close(); } catch (IOException ex) { JOptionPane.showMessageDialog(this, Bundle.getBundle().getString("errorSavingConfigFile"), "", JOptionPane.ERROR_MESSAGE); } this.dispose(); }
From source file:es.juntadeandalucia.framework.ticket.impl.DefaultTicket.java
public Map<String, String> getProperties(String ticket) throws Exception { byte[] propertiesBytes = decrypt(Base32.decode(ticket)); Properties properties = new Properties(); properties.load(new ByteArrayInputStream(propertiesBytes)); if (ticketLifeTime > 0) { long currentTimeMillis = getCurrentTimeMillisUTC(); long ticketExpiryTime; String expiryTime = properties.getProperty(TIME_TICKET_EXPIRY); if (expiryTime == null) { Exception e = new Exception(msg.getString("ticket.error.noexpirytime")); //$NON-NLS-1$ log.error(e);//from w w w. j a va 2s . c o m throw e; } try { ticketExpiryTime = Long.parseLong(expiryTime); } catch (NumberFormatException nfe) { Exception e = new Exception(msg.getString("ticket.error.invalidexpirytime"), nfe); //$NON-NLS-1$ log.error(e); throw e; } if (ticketExpiryTime - currentTimeMillis < 0) { Exception e = new Exception(msg.getString("ticket.error.ticketexpired")); //$NON-NLS-1$ log.warn(e); throw e; } properties.remove(TIME_TICKET_EXPIRY); } return typedMap(properties, String.class, String.class); }
From source file:org.apache.archiva.metadata.repository.file.FileMetadataRepository.java
@Override public void removeArtifact(ArtifactMetadata artifactMetadata, String baseVersion) throws MetadataRepositoryException { try {//w w w. j ava 2s . co m File directory = new File(getDirectory(artifactMetadata.getRepositoryId()), artifactMetadata.getNamespace() + "/" + artifactMetadata.getProject() + "/" + baseVersion); Properties properties = readOrCreateProperties(directory, PROJECT_VERSION_METADATA_KEY); String id = artifactMetadata.getId(); properties.remove("artifact:updated:" + id); properties.remove("artifact:whenGathered:" + id); properties.remove("artifact:size:" + id); properties.remove("artifact:md5:" + id); properties.remove("artifact:sha1:" + id); properties.remove("artifact:version:" + id); properties.remove("artifact:facetIds:" + id); String prefix = "artifact:facet:" + id + ":"; for (Object key : new ArrayList(properties.keySet())) { String property = (String) key; if (property.startsWith(prefix)) { properties.remove(property); } } writeProperties(properties, directory, PROJECT_VERSION_METADATA_KEY); } catch (IOException e) { throw new MetadataRepositoryException(e.getMessage(), e); } }
From source file:org.apache.ivory.workflow.engine.OozieWorkflowEngine.java
@Override public void reRun(String cluster, String jobId, Properties props) throws IvoryException { OozieClient client = OozieClientFactory.get(cluster); try {/*from w w w.j ava 2s .c o m*/ WorkflowJob jobInfo = client.getJobInfo(jobId); Properties jobprops = OozieUtils.toProperties(jobInfo.getConf()); if (props == null || props.isEmpty()) jobprops.put(OozieClient.RERUN_FAIL_NODES, "false"); else for (Entry<Object, Object> entry : props.entrySet()) { jobprops.put(entry.getKey(), entry.getValue()); } jobprops.remove(OozieClient.COORDINATOR_APP_PATH); jobprops.remove(OozieClient.BUNDLE_APP_PATH); client.reRun(jobId, jobprops); assertStatus(cluster, jobId, WorkflowJob.Status.RUNNING); LOG.info("Rerun job " + jobId + " on cluster " + cluster); } catch (Exception e) { LOG.error("Unable to rerun workflows", e); throw new IvoryException(e); } }
From source file:org.paxle.core.filter.impl.FilterManager.java
/** * @param config the CM configuration that belongs to this component * @throws IOException /* w w w .j a v a2 s. c o m*/ * @throws IOException * @throws ConfigurationException * @throws ConfigurationException */ public FilterManager(IResourceBundleTool resourceBundleTool, Configuration config, final BundleContext context, Properties props) throws IOException, ConfigurationException { if (config == null) throw new NullPointerException("The configuration object is null"); if (props == null) throw new NullPointerException("The property object is null"); this.resourceBundleTool = resourceBundleTool; this.locales = this.resourceBundleTool.getLocaleArray(IFilterManager.class.getSimpleName(), Locale.ENGLISH); this.config = config; this.props = props; // initialize CM values if (config.getProperties() == null) { // ensure to reset known-filter list props.remove(PROPS_KNOWN_FILTERCONTEXTS); // using default configuration config.update(this.getCMDefaults()); } // update configuration of this component this.updated(config.getProperties()); // reading list of known filters if (props.containsKey(PROPS_KNOWN_FILTERCONTEXTS)) { String filtersStr = (String) props.get(PROPS_KNOWN_FILTERCONTEXTS); if (filtersStr.length() > 2) { String[] filterContextPIDs = filtersStr.substring(1, filtersStr.length() - 1).split(","); for (String filterContextPID : filterContextPIDs) { this.knownFilterContexts.add(filterContextPID.trim()); } } } // getting the meta-data service this.metaDataTracker = new ServiceTracker(context, IMetaDataService.class.getName(), null); this.metaDataTracker.open(); }
From source file:org.apache.nutch.parse.ms.MSBaseParser.java
/** * Parses a Content with a specific {@link MSExtractor Microsoft document * extractor}./* w w w.ja va 2 s . c o m*/ */ protected ParseResult getParse(MSExtractor extractor, Content content) { String text = null; String title = null; Outlink[] outlinks = null; Properties properties = null; try { byte[] raw = content.getContent(); String contentLength = content.getMetadata().get(Metadata.CONTENT_LENGTH); if ((contentLength != null) && (raw.length != Integer.parseInt(contentLength))) { return new ParseStatus(ParseStatus.FAILED, ParseStatus.FAILED_TRUNCATED, "Content truncated at " + raw.length + " bytes. " + "Parser can't handle incomplete file.") .getEmptyParseResult(content.getUrl(), this.conf); } extractor.extract(new ByteArrayInputStream(raw)); text = extractor.getText(); properties = extractor.getProperties(); outlinks = OutlinkExtractor.getOutlinks(text, content.getUrl(), getConf()); } catch (Exception e) { return new ParseStatus(ParseStatus.FAILED, "Can't be handled as Microsoft document. " + e) .getEmptyParseResult(content.getUrl(), this.conf); } // collect meta data Metadata metadata = new Metadata(); if (properties != null) { title = properties.getProperty(DublinCore.TITLE); properties.remove(DublinCore.TITLE); metadata.setAll(properties); } if (text == null) { text = ""; } if (title == null) { title = ""; } ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS, title, outlinks, content.getMetadata(), metadata); return ParseResult.createParseResult(content.getUrl(), new ParseImpl(text, parseData)); }
From source file:org.pentaho.platform.plugin.services.importexport.ZipExportProcessor.java
/** * for each locale stored in in Jcr create a .locale file with the stored node properties * @param zos/*from w w w . ja v a 2 s . c o m*/ * @param repositoryFile * @param filePath * @throws IOException */ private void createLocales(RepositoryFile repositoryFile, String filePath, boolean isFolder, OutputStream outputStrean) throws IOException { ZipEntry entry; String zipName; String name; String localeName; Properties properties; ZipOutputStream zos = (ZipOutputStream) outputStrean; //only process files and folders that we know will have locale settings if (supportedLocaleFileExt(repositoryFile)) { List<LocaleMapDto> locales = getAvailableLocales(repositoryFile.getId()); zipName = getZipEntryName(repositoryFile, filePath); name = repositoryFile.getName(); for (LocaleMapDto locale : locales) { localeName = locale.getLocale().equalsIgnoreCase("default") ? "" : "_" + locale.getLocale(); if (isFolder) { zipName = getZipEntryName(repositoryFile, filePath) + "index"; name = "index"; } properties = unifiedRepository.getLocalePropertiesForFileById(repositoryFile.getId(), locale.getLocale()); if (properties != null) { properties.remove("jcr:primaryType");//Pentaho Type InputStream is = createLocaleFile(name + localeName, properties, locale.getLocale()); if (is != null) { entry = new ZipEntry(zipName + localeName + LOCALE_EXT); zos.putNextEntry(entry); IOUtils.copy(is, outputStrean); zos.closeEntry(); is.close(); } } } } }
From source file:org.apache.phoenix.query.BaseTest.java
private static void deletePriorTables(long ts, String tenantId, String url) throws Exception { Properties props = new Properties(); props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024)); if (ts != HConstants.LATEST_TIMESTAMP) { props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts)); }/* w w w . j a va2s . c om*/ Connection conn = DriverManager.getConnection(url, props); try { deletePriorTables(ts, conn, url); deletePriorSequences(ts, conn); // Make sure all tables and views have been dropped props.remove(CURRENT_SCN_ATTRIB); try (Connection seeLatestConn = DriverManager.getConnection(url, props)) { DatabaseMetaData dbmd = seeLatestConn.getMetaData(); ResultSet rs = dbmd.getTables(null, null, null, new String[] { PTableType.VIEW.toString(), PTableType.TABLE.toString() }); boolean hasTables = rs.next(); if (hasTables) { fail("The following tables are not deleted that should be:" + getTableNames(rs)); } } } finally { conn.close(); } }