List of usage examples for java.util Properties clone
@Override public synchronized Object clone()
From source file:org.hyperledger.fabric.sdk.EventHub.java
EventHub(String name, String grpcURL, ExecutorService executorService, Properties properties) throws InvalidArgumentException { Exception e = checkGrpcUrl(grpcURL); if (e != null) { throw new InvalidArgumentException("Bad event hub url.", e); }/* ww w . j a v a 2 s. co m*/ if (StringUtil.isNullOrEmpty(name)) { throw new InvalidArgumentException("Invalid name for eventHub"); } this.url = grpcURL; this.name = name; this.executorService = executorService; this.properties = properties == null ? null : (Properties) properties.clone(); //keep our own copy. logger.debug("Created " + toString()); }
From source file:org.hyperledger.fabric.sdk.Orderer.java
Orderer(String name, String url, Properties properties) throws InvalidArgumentException { if (StringUtil.isNullOrEmpty(name)) { throw new InvalidArgumentException("Invalid name for orderer"); }//from w w w . ja va 2s. co m Exception e = checkGrpcUrl(url); if (e != null) { throw new InvalidArgumentException(e); } this.name = name; this.url = url; this.properties = properties == null ? null : (Properties) properties.clone(); //keep our own copy. logger.trace("Created " + toString()); }
From source file:org.impalaframework.resolver.BaseModuleLocationResolver.java
public BaseModuleLocationResolver(Properties properties) { super();// w w w . ja v a2 s .c o m Assert.notNull(properties); this.properties = (Properties) properties.clone(); }
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 {/*from w w w.j a va 2s . co 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>(); } }
From source file:org.opencastproject.scheduler.impl.SchedulerServiceImpl.java
@Override public void updateCaptureAgentMetadata(final Properties configuration, Tuple<Long, DublinCoreCatalog>... events) throws NotFoundException, SchedulerException { for (Tuple<Long, DublinCoreCatalog> e : events) { final long eventId = e.getA(); final DublinCoreCatalog event = e.getB(); // create clone and update with matching values from DC Properties properties = (Properties) configuration.clone(); properties.put("event.title", event.getFirst(DublinCore.PROPERTY_TITLE)); if (StringUtils.isNotBlank(event.getFirst(DublinCore.PROPERTY_IS_PART_OF))) { properties.put("event.series", event.getFirst(DublinCore.PROPERTY_IS_PART_OF)); }/*from w w w. j a v a 2 s .com*/ if (StringUtils.isNotBlank(event.getFirst(DublinCore.PROPERTY_SPATIAL))) { properties.put("event.location", event.getFirst(DublinCore.PROPERTY_SPATIAL)); } // store try { persistence.updateEventWithMetadata(eventId, properties); } catch (SchedulerServiceDatabaseException ex) { logger.error("Failed to update capture agent configuration for event '{}': {}", eventId, ex.getMessage()); throw new SchedulerException(ex); } try { index.index(eventId, properties); } catch (Exception ex) { logger.warn("Unable to update capture agent properties for event with ID '{}': {}", eventId, ex.getMessage()); throw new SchedulerException(ex); } } }
From source file:org.opencastproject.scheduler.impl.SchedulerServiceImplTest.java
private void checkEvent(long eventId, Properties initialCaProps, String title) throws Exception { final Properties updatedCaProps = (Properties) initialCaProps.clone(); updatedCaProps.setProperty("event.title", title); assertTrue("CA properties", eqMap(updatedCaProps, schedSvc.getEventCaptureAgentConfiguration(eventId))); assertEquals(Long.toString(eventId), schedSvc.getEventDublinCore(eventId).getFirst(PROPERTY_IDENTIFIER)); assertEquals("DublinCore title", title, schedSvc.getEventDublinCore(eventId).getFirst(PROPERTY_TITLE)); checkIcalFeed(updatedCaProps, title); }
From source file:org.openlaszlo.sc.ScriptCompiler.java
/** Compiles the specified script into bytecode * * @param script a script//from w w w . jav a2 s. com * @return an array containing the bytecode */ public static byte[] compileToByteArray(String script, Properties properties) { writeIntermediateFile(script); // We only want to keep off the properties that affect the // compilation. Currently, "filename" is the only property // that tends to change and that the script compiler ignores, // so make a copy of properties that neutralizes that. properties = (Properties) properties.clone(); properties.setProperty("filename", ""); // Check the cache. clearCache may clear the cache at any // time, so use a copy of it so that it doesn't change state // between a test that it's null and a method call on it. Item item = null; byte[] code = null; try { if (mScriptCache == null) { return _compileToByteArray(script, properties); } else { // The key is a string representation of the arguments: // properties, and the script. StringWriter writer = new StringWriter(); writer.write(sortedPropertiesList(properties)); writer.getBuffer().append(script); String key = writer.toString(); synchronized (mScriptCache) { item = mScriptCache.findItem(key, null, false); } } if (item.getInfo().getSize() != 0) { code = item.getRawByteArray(); } else { code = _compileToByteArray(script, properties); // Another thread might already have set this since we // called get. That's okay --- it's the same value. synchronized (mScriptCache) { item.update(new ByteArrayInputStream(code), null); item.updateInfo(); item.markClean(); } } mScriptCache.updateCache(item); return (byte[]) code; } catch (IOException e) { throw new CompilationError(e, "IOException in compilation/script-cache"); } }
From source file:org.opennaas.extensions.router.junos.commandsets.velocity.VelocityEngine.java
@Deprecated private void addJarProperties(Properties prop) { Properties oldProps = (Properties) prop.clone(); prop.setProperty("resource.loader", "jar"); prop.setProperty("jar.resource.loader.class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader"); prop.setProperty("jar.resource.loader.cache", "true"); String absolutPath = ""; try {/*from w ww . j a va2s . co m*/ absolutPath = "jar:file:" + (new File(".")).getCanonicalPath(); } catch (IOException e) { log.error("It was impossible to get the canonical path"); // Restore propeties file prop = oldProps; return; } log.info("absoluthPath=" + absolutPath); prop.setProperty("jar.resource.loader.path", absolutPath + "/bundles/net.i2cat.mantychore.commandsets.junos_1.0.0.SNAPSHOT.jar"); // where there are templates prop.setProperty("template.root", "VM_files"); }
From source file:org.pentaho.metadata.util.LocalizationUtil.java
/** * This method returns a list of missing and extra keys specified in a properties bundle * //from w ww . j a v a 2s. c o m * @param domain * the domain object to analyze * @param props * the imported properties to analyze * @param locale * the locale to analyze * @return messages */ public List<String> analyzeImport(Domain domain, Properties props, String locale) { ArrayList<String> messages = new ArrayList<String>(); // determine missing strings Properties origProps = exportLocalizedProperties(domain, locale); Properties cloneOrig = (Properties) origProps.clone(); for (Object key : origProps.keySet()) { if (props.containsKey(key)) { cloneOrig.remove(key); } } // anything left in cloneOrig was missing for (Object key : cloneOrig.keySet()) { messages.add(Messages.getString("LocalizationUtil.MISSING_KEY_MESSAGE", key)); } // determine extra strings Properties cloneProps = (Properties) props.clone(); for (Object key : props.keySet()) { if (origProps.containsKey(key)) { cloneProps.remove(key); } } // anything left in cloneProps was extra for (Object key : cloneProps.keySet()) { messages.add(Messages.getString("LocalizationUtil.EXTRA_KEY_MESSAGE", key)); } return messages; }
From source file:org.pentaho.reporting.engine.classic.extensions.datasources.mondrian.DefaultMondrianConnectionProvider.java
public Object getConnectionHash(final Properties properties) throws ReportDataFactoryException { final ArrayList<Object> list = new ArrayList<Object>(); list.add(getClass().getName());/* w w w .j a va 2 s . c om*/ list.add(properties.clone()); return list; }