List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java
/** * Given a list of locale pairs, remove them from the list of all locale * pairs. Then create a hashtable where the key is the source locale, and * the value is all possible target locales. * /* w ww. j av a 2 s .c o m*/ */ public static Hashtable getRemainingLocales(List currentLocales) throws EnvoyServletException { Hashtable remaining = new Hashtable(); Vector sourceLocales = UserHandlerHelper.getAllSourceLocales(); for (int i = 0; i < sourceLocales.size(); i++) { GlobalSightLocale curLocale = (GlobalSightLocale) sourceLocales.elementAt(i); Vector validTargets = UserHandlerHelper.getTargetLocales(curLocale); remaining.put(curLocale, validTargets); } // Now that we have a hashtable of all valid source locales and // their target locales, removes the ones that already exist for // this vendor. for (int i = 0; i < currentLocales.size(); i++) { LocalePair pair = (LocalePair) currentLocales.get(i); GlobalSightLocale target = pair.getTarget(); Vector targets = (Vector) remaining.get(pair.getSource()); if (targets != null && targets.contains(target)) { targets.remove(target); if (targets.size() == 0) { // no valid targets left so remove the entry in the hash remaining.remove(pair.getSource()); } } } return remaining; }
From source file:com.fluidinfo.fom.Namespace.java
@Override public void getItem() throws FluidException, IOException, FOMException, JSONException { Hashtable<String, String> args = new Hashtable<String, String>(); args.put("returnDescription", "True"); args.put("returnNamespaces", "True"); args.put("returnTags", "True"); FluidResponse response = this.Call(Method.GET, 200, "", args); JSONObject jsonResult = this.getJsonObject(response); this.id = jsonResult.getString("id"); this.description = jsonResult.getString("description"); this.namespaces = StringUtil.getStringArrayFromJSONArray(jsonResult.getJSONArray("namespaceNames")); this.tags = StringUtil.getStringArrayFromJSONArray(jsonResult.getJSONArray("tagNames")); }
From source file:com.adobe.people.jedelson.aemslack.impl.Notifier.java
@Activate private void activate(ComponentContext ctx) { queue = Executors.newSingleThreadExecutor(); httpClient = new HttpClient(); Dictionary<?, ?> props = ctx.getProperties(); url = PropertiesUtil.toString(props.get(PROP_URL), null); if (url == null) { throw new IllegalArgumentException("URL is not defined"); }// ww w .j ava 2 s.c o m usernameMappings = PropertiesUtil.toMap(props.get(PROP_MAPPING), new String[0]); BundleContext bundleContext = ctx.getBundleContext(); Hashtable<String, Object> serviceProps = new Hashtable<String, Object>(); serviceProps.put(EventConstants.EVENT_TOPIC, CommentingEvent.EVENT_TOPIC_BASE + "/" + CommentingEvent.Type.COMMENTED.name().toLowerCase()); commentListenerRegistration = bundleContext.registerService(EventHandler.class.getName(), new CommentListener(), serviceProps); serviceProps.put(EventConstants.EVENT_TOPIC, TaskEvent.TOPIC); taskListenerRegistration = bundleContext.registerService(EventHandler.class.getName(), new TaskListener(), serviceProps); }
From source file:com.fluidinfo.FluidDB.java
/** * Given a query, will return a list of object ids that match. From the FluidDB docs: * /*from www.j av a 2 s . c o m*/ * FluidDB provides a simple query language that allows applications to search for objects * based on their tags values. The following kinds of queries are possible: * * * Numeric: To find objects based on the numeric value of tags. For example, tim/rating > 5. * * * Textual: To find objects based on text matching of their tag values, e.g., * sally/opinion matches fantastic. Text matching is done with Lucene, meaning that * Lucene matching capabilities and style will be available [NOT YET IMPLEMENTED]. * * * Presence: Use has to request objects that have a given tag. For example, has * sally/opinion. * * * Set contents: A tag on an object can hold a set of strings. For example, a tag called * mary/product-reviews/keywords might be on an object with a value of [ "cool", "kids", * "adventure" ]. The contains operator can be used to select objects with a matching value. * The query mary/product-reviews/keywords contains "kids" would match the object in this * example. * * * Exclusion: You can exclude objects with the except keyword. For example has * nytimes.com/appeared except has james/seen. The except operator performs a set difference. * * * Logic: Query components can be combined with and and or. For example, has sara/rating and * tim/rating > 5. * * * Grouping: Parentheses can be used to group query components. For example, has sara/rating * and (tim/rating > 5 or mike/rating > 7). * * Thats it! * * @param query The query * @return An array of the matching object ids * @throws IOException * @throws FluidException * @throws JSONException */ public String[] searchObjects(String query) throws FluidException, IOException, JSONException { Hashtable<String, String> args = new Hashtable<String, String>(); args.put("query", query); FluidResponse r = this.fdb.Call(Method.GET, "/objects", "", args); if (r.getResponseCode() == 200) { JSONArray ids = StringUtil.getJsonObjectFromString(r.getResponseContent()).getJSONArray("ids"); return StringUtil.getStringArrayFromJSONArray(ids); } else { // Lets generate a helpful exception... StringBuilder sb = new StringBuilder(); sb.append("FluidDB returned the following error: "); sb.append(r.getResponseCode()); sb.append(" ("); sb.append(r.getResponseMessage()); sb.append(") "); sb.append(r.getResponseError()); sb.append(" - with the request ID: "); sb.append(r.getErrorRequestID()); throw new FluidException(sb.toString().trim()); } }
From source file:net.solarnetwork.node.dao.jdbc.derby.DerbyMaintenanceRegistrationListener.java
/** * Callback when a JdbcDao has been registered. * /*from ww w . ja va2 s . c o m*/ * @param jdbcDao * the DAO * @param properties * the service properties */ public void onBind(JdbcDao jdbcDao, Map<String, ?> properties) { if (log.isDebugEnabled()) { log.debug("Bind called on [" + jdbcDao + "] with props " + properties); } List<ServiceRegistration<?>> services = new ArrayList<ServiceRegistration<?>>(); Hashtable<String, Object> serviceProps = new Hashtable<String, Object>(); serviceProps.put("Bundle-SymbolicName", getBundleContext().getBundle().getSymbolicName()); for (String tableName : jdbcDao.getTableNames()) { JobDetailBean jobDetail = getCompressJobDetail(jdbcDao.getSchemaName(), tableName, getJobName(jdbcDao.getSchemaName(), tableName, TASK_COMPRESS)); CronTriggerBean trigger = getCronTrigger( getTaskPropertyValue(jdbcDao.getSchemaName(), tableName, TASK_COMPRESS + ".cron", compressTableCronExpression), jobDetail, getTriggerName(jdbcDao.getSchemaName(), tableName, TASK_COMPRESS)); SimpleTriggerAndJobDetail tjd = new SimpleTriggerAndJobDetail(); tjd.setJobDetail(jobDetail); tjd.setTrigger(trigger); tjd.setMessageSource(jdbcDao.getMessageSource()); ServiceRegistration<TriggerAndJobDetail> reg = getBundleContext() .registerService(TriggerAndJobDetail.class, tjd, serviceProps); services.add(reg); } this.addRegisteredService(new RegisteredService<JdbcDao>(jdbcDao, properties), services); }
From source file:com.sterlingcommerce.xpedx.webchannel.services.XPEDXGetAllReportsAction.java
public void getConnection() throws SQLException { String XCOM_MST_CUST = getCustomerNo(getWCContext().getBuyerOrgCode()); String DBUrl = YFSSystem.getProperty("datasource_url"); String DBName = YFSSystem.getProperty("datasource_name"); //String DBUrl= "t3://localhost:7002"; //String DBName= "SeptJNDI"; Connection connection = null; Statement stmt = null;/* w w w. j a v a 2 s . c o m*/ ResultSet rs = null; XPEDXReportBean rpBean = null; try { Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ht.put("java.naming.provider.url", DBUrl); Context env = new InitialContext(ht); //InitialContext context = new InitialContext(ht); DataSource dataSource = (DataSource) env.lookup(DBName); connection = dataSource.getConnection(); if (log.isDebugEnabled()) { log.debug("Connection successful.."); } //String schemaName=YFSSystem.getProperty("schemaname"); //String Query="select distinct RPT_CUID, RPT_NAME,RPT_ID,RPT_KIND, RPT_DESC from " + schemaName + ".xpedx_custom_rpt_dtl where XCOM_MST_CUST=" + "'"+ XCOM_MST_CUST +"'"+"AND CUST_ROLE in ("; String Query = "select distinct RPT_CUID, RPT_NAME,RPT_ID,RPT_KIND, RPT_DESC from DH.xpedx_custom_rpt_dtl where XCOM_MST_CUST=" + "'" + XCOM_MST_CUST + "'" + "AND CUST_ROLE in ("; Query = getUserRole(Query); stmt = connection.createStatement(); boolean test = stmt.execute(Query); dataExchangeReportList = new ArrayList<Report>(); if (test == true) { rs = stmt.getResultSet(); while (rs.next()) { Report report = new Report(); report.setCuid(rs.getString("RPT_CUID")); report.setName(rs.getString("RPT_NAME")); report.setKind(rs.getString("RPT_KIND")); report.setId(rs.getInt("RPT_ID")); report.setDescription(rs.getString("RPT_DESC")); dataExchangeReportList.add(report); } } } catch (Exception e) { LOG.debug("Not able to connect to DEV Datasource:->" + e.getMessage()); } finally { stmt.close(); connection.close(); } }
From source file:com.sibvisions.rad.server.security.spring.SpringSecurityManager.java
/** * {@inheritDoc}//from w w w.j a v a 2 s.c om */ public void validateAuthentication(ISession pSession) { SecurityContext securityContext = SecurityContextHolder.getContext(); if (securityContext != null) { Authentication authentication = securityContext.getAuthentication(); if (authentication != null && authentication.isAuthenticated()) { Hashtable<String, Object> metadataProperties = new Hashtable<String, Object>(); metadataProperties.put("authentication", authentication); ISpringMetaDataHandler metaDataHandler = getAuthenticationMetaDataHandler(metadataProperties, pSession); if (pSession instanceof AbstractSession) { ((AbstractSession) pSession).setUserName(metaDataHandler.getUsername()); ((AbstractSession) pSession).setPassword(metaDataHandler.getPassword()); } pSession.setProperty(METADATA_HANDLER, metaDataHandler); if (!(authentication instanceof WrappedAuthentication)) { authentication = new WrappedAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication); } // set the jvx session id into the authentication object for the logout (success) handler ((WrappedAuthentication) authentication).setProperty(SESSION_ID, pSession.getId()); // set the logout process url Object logoutProcessUrl = ((WrappedAuthentication) authentication).getProperty(LOGOUT_PROCESS_URL); if (logoutProcessUrl == null) { HttpContext context = HttpContext.getCurrentInstance(); if (context != null) { HttpSession session = ((HttpServletRequest) context.getRequest()).getSession(false); if (session != null) { logoutProcessUrl = session.getAttribute(LOGOUT_PROCESS_URL); } } } pSession.setProperty(LOGOUT_PROCESS_URL, logoutProcessUrl); } else { throw new SecurityException("Access denied! The authentication could not be established."); } } else { throw new SecurityException("Access denied! The security context could not be established."); } }
From source file:com.flexive.faces.FxJsfUtils.java
/** * Gets all faces messages grouped by a equal summary and wrapped as * FxFacesMessage (which gives access to the clientId). In case of a grouped message * the details of the original FacesMessage can be retrieved by calling getDetails() of * the FxFacesMessage.//from w w w . j a va 2 s. c o m * * @return a array holding all (grouped) messages */ public static List<FxFacesMessages> getGroupedFxMessages() { ArrayList<FxFacesMessage> ffm = getFxMessages(); Hashtable<String, FxFacesMessages> grouped = new Hashtable<String, FxFacesMessages>(ffm.size()); for (FxFacesMessage msg : ffm) { String key = msg.getSeverity() + ":" + msg.getSummary(); FxFacesMessages exists = grouped.get(key); if (exists != null) { exists.addMessage(msg); } else { grouped.put(key, new FxFacesMessages(msg.getSummary(), msg.getSeverity(), msg)); } } return new ArrayList<FxFacesMessages>(grouped.values()); }
From source file:algorithm.TarPackagingTest.java
@Test public void singleTarPackagingTest() { try {//from www . j av a2s . c o m File carrier = TestDataProvider.TXT_FILE; File payload = TestDataProvider.XML_FILE; TarPackaging algorithm = new TarPackaging(); // Test encapsulation: List<File> carrierList = new ArrayList<File>(); carrierList.add(carrier); List<File> payloadList = new ArrayList<File>(); payloadList.add(payload); File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(2, outputHash.size()); RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload = outputHash.get(payload.getName()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload); assertEquals(FileUtils.checksumCRC32(carrier), FileUtils.checksumCRC32(restoredCarrier)); assertEquals(FileUtils.checksumCRC32(payload), FileUtils.checksumCRC32(restoredPayload)); // check restoration metadata: // assertEquals("" + carrier.getAbsolutePath(), // restoredCarrier.originalFilePath); // assertEquals("" + payload.getAbsolutePath(), // restoredPayload.originalFilePath); assertEquals(algorithm, restoredCarrier.algorithm); assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload.checksumValid); // Every file in a .tar archive is a payload file! assertTrue(restoredCarrier.wasPayload); assertFalse(restoredCarrier.wasCarrier); assertTrue(restoredPayload.wasPayload); assertFalse(restoredPayload.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload.relatedFiles.contains(restoredCarrier)); assertFalse(restoredPayload.relatedFiles.contains(restoredPayload)); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.globalsight.util.file.XliffFileUtil.java
/** * Process Xliff file which has multiple <File> tags * /* w w w. j a va 2s .c om*/ * If current file contains multiple <File> tags, it needs to be separated * into sub files in single file level. And the list of files needs to add * all separated files with corresponding file profiles. Otherwise, file and * its file profile are just put into the list. * * @param p_files * List of files contained all processed files * @param p_filename * File name * @param p_fp * File profile of file * * @version 1.0 * @since 8.2.2 */ public static void processMultipleFileTags(Hashtable<String, FileProfile> p_files, String p_filename, FileProfile p_fp) { MultipleFileTagsXliff multipleFileTagsXliff = processMultipleFileTags(p_filename); if (multipleFileTagsXliff != null) { ArrayList<String> separatedFile = multipleFileTagsXliff.getSeparatedFiles(); for (int j = 0; j < separatedFile.size(); j++) { p_files.put(separatedFile.get(j), p_fp); } } else { p_files.put(p_filename, p_fp); } }