List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:gov.loc.www.zing.srw.srw_bindings.SRWSoapBindingImpl.java
public SearchRetrieveResponseType searchRetrieveOperation(SearchRetrieveRequestType request) throws RemoteException { log.debug("Enter: searchRetrieveOperation"); if (log.isInfoEnabled()) { log.info("request: maximumRecords:" + request.getMaximumRecords() + " query:" + request.getQuery() + " recordPacking:" + request.getRecordPacking() + " recordSchema:" + request.getRecordSchema() + " recordXpath:" + request.getRecordXPath() + " sortKeys:" + request.getSortKeys() + " startRecord:" + request.getStartRecord() + " stylesheet:" + request.getStylesheet() + " version:" + request.getVersion()); }/*from w w w .java 2 s . c om*/ long startTime = System.currentTimeMillis(); MessageContext msgContext = MessageContext.getCurrentContext(); SearchRetrieveResponseType response; int resultSetIdleTime = ((Integer) msgContext.getProperty("resultSetIdleTime")).intValue(); NonNegativeInteger nni = request.getResultSetTTL(); if (log.isDebugEnabled()) log.debug("resultSetTTL()=" + nni); if (nni != null) { int ttl = nni.intValue(); log.debug("ttl=" + ttl); if (ttl < resultSetIdleTime) resultSetIdleTime = ttl; } String dbname = (String) msgContext.getProperty("dbname"); SRWDatabase db = (SRWDatabase) msgContext.getProperty("db"); if (log.isDebugEnabled()) log.debug("db=" + db); String sortKeys = request.getSortKeys(); if (sortKeys != null) request.setSortKeys(sortKeys); String query = request.getQuery(); if (query.indexOf('%') >= 0) try { request.setQuery(java.net.URLDecoder.decode(query, "utf-8")); } catch (java.io.UnsupportedEncodingException e) { } if (query == null) { response = new SearchRetrieveResponseType(); db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied, "query", response); } else if (request.getStartRecord() != null && request.getStartRecord().intValue() == Integer.MAX_VALUE) { response = new SearchRetrieveResponseType(); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "startRecord", response); } else if (request.getMaximumRecords() != null && request.getMaximumRecords().intValue() == Integer.MAX_VALUE) { response = new SearchRetrieveResponseType(); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "maximumRecords", response); } else if (request.getResultSetTTL() != null && request.getResultSetTTL().intValue() == Integer.MAX_VALUE) { response = new SearchRetrieveResponseType(); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "resultSetTTL", response); } else try { response = db.doRequest(request); if (response == null) { response = new SearchRetrieveResponseType(); response.setVersion("1.1"); setEchoedSearchRetrieveRequestType(request, response); db.diagnostic(SRWDiagnostic.GeneralSystemError, null, response); return response; } if (msgContext.getProperty("sru") != null && request.getStylesheet() != null) // you can't ask for a stylesheet in srw! db.diagnostic(SRWDiagnostic.StylesheetsNotSupported, null, response); setEchoedSearchRetrieveRequestType(request, response); if (request.getRecordXPath() != null) db.diagnostic(72, null, response); if (request.getSortKeys() != null && !request.getSortKeys().equals("") && !db.supportsSort()) db.diagnostic(SRWDiagnostic.SortNotSupported, null, response); // set extraResponseData StringBuffer extraResponseData = new StringBuffer(); // we're going to stick the database name in extraResponseData every time if (db.databaseTitle != null) extraResponseData.append("<databaseTitle>").append(db.databaseTitle).append("</databaseTitle>"); else extraResponseData.append("<databaseTitle>").append(dbname).append("</databaseTitle>"); // did they ask for the targetURL to be returned? Hashtable extraRequestDataElements = SRWDatabase.parseElements(request.getExtraRequestData()); String s = (String) extraRequestDataElements.get("returnTargetURL"); log.info("returnTargetURL=" + s); if (s != null && !s.equals("false")) { String targetStr = (String) msgContext.getProperty("targetURL"); log.info("targetStr=" + targetStr); if (targetStr != null && targetStr.length() > 0) { URL target = new URL(targetStr); extraResponseData.append("<targetURL>").append("<host>").append(target.getHost()) .append("</host>").append("<port>").append(target.getPort()).append("</port>") .append("<path>").append(target.getPath()).append("</path>").append("<query>") .append(Utilities.xmlEncode(target.getQuery())).append("</query>") .append("</targetURL>"); } } // set extraResponseData SRWDatabase.setExtraResponseData(response, extraResponseData.toString()); } catch (Exception e) { log.error(e, e); throw new RemoteException(e.getMessage(), e); } finally { SRWDatabase.putDb(dbname, db); } response.setVersion("1.1"); log.info("\"" + query + "\"==>" + response.getNumberOfRecords() + " (" + (System.currentTimeMillis() - startTime) + "ms)"); log.debug("Exit: searchRetrieveOperation"); return response; }
From source file:com.hs.mail.mailet.RemoteDelivery.java
/** * For this message, we take the list of recipients, organize these into * distinct servers, and deliver the message for each of these servers. *///w ww .ja va 2s . c om public void service(Set<Recipient> recipients, SmtpMessage message) throws MessagingException { // Organize the recipients into distinct servers (name made case insensitive) Hashtable<String, Collection<Recipient>> targets = new Hashtable<String, Collection<Recipient>>(); for (Recipient recipient : recipients) { String targetServer = recipient.getHost().toLowerCase(Locale.US); if (!Config.isLocal(targetServer)) { String key = (null == gateway) ? targetServer : gateway; Collection<Recipient> temp = targets.get(key); if (temp == null) { temp = new ArrayList<Recipient>(); targets.put(key, temp); } temp.add(recipient); } } if (targets.isEmpty()) { return; } // We have the recipients organized into distinct servers List<Recipient> undelivered = new ArrayList<Recipient>(); MimeMessage mimemsg = message.getMimeMessage(); boolean deleteMessage = true; for (String targetServer : targets.keySet()) { Collection<Recipient> temp = targets.get(targetServer); if (!deliver(targetServer, temp, message, mimemsg)) { // Retry this message later deleteMessage = false; if (!temp.isEmpty()) { undelivered.addAll(temp); } } } if (!deleteMessage) { try { message.setRetryCount(message.getRetryCount() + 1); message.setLastUpdate(new Date()); recipients.clear(); recipients.addAll(undelivered); message.store(); } catch (IOException e) { } } }
From source file:graficos.GraficoGantt.java
private void agregarTareasFicticias(Hashtable<Integer, Date> actFecha_com, Hashtable<Integer, Date> actFecha_fin, Vector<Actividad> vec_ficticias) { for (Iterator<Actividad> it = vec_ficticias.iterator(); it.hasNext();) { Actividad a = it.next();/*from w ww .jav a 2 s . c om*/ Vector<Actividad> vec_ent = a.getSucesoOrigen().getActividadesEntrantes(); Vector<Actividad> vec_sal = a.getSucesoFin().getActividadesSalientes(); boolean listo_fc = false; boolean listo_ff = false; Date fecha_com = new Date(); Date fecha_fin = new Date(); for (Iterator<Actividad> it0 = vec_ent.iterator(); it0.hasNext() && !listo_fc;) { Actividad ae = it0.next(); if (!ae.esFicticia()) { fecha_com = actFecha_fin.get(ae.getIdentificador()); listo_fc = true; } } for (Iterator<Actividad> it0 = vec_sal.iterator(); it0.hasNext() && !listo_ff;) { Actividad as = it0.next(); if (!as.esFicticia()) { fecha_fin = actFecha_com.get(as.getIdentificador()); listo_ff = true; } } if (listo_fc && listo_ff) { Task tarea = new Task("F (" + a.getIdentificador().toString() + ") " + a.getDescripcion(), new SimpleTimePeriod(fecha_com, fecha_fin)); serie_tareas_nc.add(tarea); } } }
From source file:edu.stanford.cfuller.imageanalysistools.filter.WatershedFilter.java
/** * Gets the seed Image for the watershed segmentation. If no seed Image has been set externally, one is created from * the set of pixels at the lowest greylevel. If a seed Image has been set externally, the seedImage retrieved is the external one. * // w w w. ja va2s .c o m * @param greylevelLookup A hashtable mapping greylevel values in the Image to coordinates in the Image. * @param im The Image being segmented. * @param h A Histogram of the Image being segmented, constructed before the beginning of segmentation. * @return An Image containing the seeds for the watershed algorithm. */ protected WritableImage getSeedImage(java.util.Hashtable<Double, java.util.Vector<Vector3D>> greylevelLookup, Image im, Histogram h) { if (!(this.seedImage == null)) { return ImageFactory.createWritable(this.seedImage); } WritableImage tempSeed = null; if (this.seedImage == null) { tempSeed = ImageFactory.createWritable(im.getDimensionSizes(), 0.0f); } else { tempSeed = ImageFactory.createWritable(this.seedImage); } double minValue = h.getMinValue(); java.util.Vector<Vector3D> minPoints = greylevelLookup.get(minValue); ImageCoordinate ic = ImageCoordinate.createCoordXYZCT(0, 0, 0, 0, 0); for (Vector3D v : minPoints) { ic.set(ImageCoordinate.X, (int) (v.getX())); ic.set(ImageCoordinate.Y, (int) (v.getY())); ic.set(ImageCoordinate.Z, (int) (v.getZ())); tempSeed.setValue(ic, 1); } ic.recycle(); LabelFilter lf = new LabelFilter(); lf.apply(tempSeed); if (this.seedImage != null) this.seedImage = tempSeed; return tempSeed; }
From source file:com.vodafone360.people.service.transport.http.photouploadmanager.PhotoUploadManager.java
/** * first chunk.// w ww . jav a 2s.c o m * @param resp * @return long */ Long getUploadIDFromUploadStart(HttpResponse resp) { byte[] ret = null; HttpEntity entity = resp.getEntity(); Long uploadid = null; InputStream is = null; try { if (null != entity) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); is = entity.getContent(); } MicroHessianInput mhi = null; if (is != null) { mhi = new MicroHessianInput(is); } HessianDecoder hessianDecoder = new HessianDecoder(); int tag = is.read(); // initial map tag or fail if (tag == 'r') { // reply / response is.read(); // read major and minor is.read(); tag = is.read(); // read next tag // usesReplyTag = true; } Hashtable<String, Object> map = (Hashtable<String, Object>) mhi.decodeType(tag); Enumeration<String> e = map.keys(); while (e.hasMoreElements()) { Object key = e.nextElement(); Object value = map.get(key); String keyObj = (String) key; String upload = new String("uploadid"); if (keyObj.compareTo(upload) == 0) { uploadid = (Long) value; break; } String numOfChunk = new String("numofchunks"); if (numOfChunk.compareTo(keyObj) == 0) { mchunkNumber = (Integer) value; } } entity.consumeContent(); } catch (IOException e) { } return uploadid; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.config.fileextension.FileExtensionMainHandler.java
private String checkDependencies(FileExtensionImpl fileExtension, HttpSession session) { ResourceBundle bundle = PageHandler.getBundle(session); FileExtensionDependencyChecker depChecker = new FileExtensionDependencyChecker(); Hashtable catDeps = depChecker.categorizeDependencies(fileExtension); StringBuffer deps = new StringBuffer(); if (catDeps.size() == 0) { return null; }/* w w w.ja v a 2s .c o m*/ deps.append("<span class=\"errorMsg\">"); Object[] args = { bundle.getString("lb_file_extension") }; deps.append(MessageFormat.format(bundle.getString("msg_dependency"), args)); for (Enumeration e = catDeps.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); deps.append("<p>*** " + bundle.getString(key) + " ***<br>"); Vector values = (Vector) catDeps.get(key); for (int i = 0; i < values.size(); i++) { deps.append((String) values.get(i)); deps.append("<br>"); } } deps.append("</span>"); return deps.toString(); }
From source file:it.okkam.exhibit.JSONSerializer.java
protected Hashtable buildPropsTable(Resource resource, int depth) { StmtIterator it = resource.listProperties(); // set up a hashtable of property to value mappings, so it's easy to differentiate single and // multi- value props Hashtable propsTable = new Hashtable(); while (it.hasNext()) { Statement s = it.nextStatement(); // get the property name String propName = s.getPredicate().getURI(); ArrayList vals;//ww w .j a va 2 s . c o m if (propsTable.containsKey(propName)) { vals = (ArrayList) propsTable.get(propName); } else { vals = new ArrayList(); propsTable.put(propName, vals); } RDFNode node = s.getObject(); if (node.isLiteral()) // add to the values { vals.add(node); } else // check if we should follow { if (arcs.containsKey(propName)) { int max = ((Integer) arcs.get(propName)).intValue(); if (max < 0 || depth < max) { vals.add(node); } } } } return propsTable; }
From source file:com.alfaariss.oa.engine.user.provisioning.translator.standard.StandardProfile.java
/** * Returns the user object, using the provided ExternalStorage * as userstore/*ww w . ja v a 2 s.c o m*/ */ public ProvisioningUser getUser(IExternalStorage oExternalStorage, String sOrganization, String id) throws UserException { ProvisioningUser oProvisioningUser = null; try { Hashtable<String, Object> htFields = oExternalStorage.getFields(id, _vAllFields); Boolean boolEnabled = (Boolean) getValue(_itemEnabled, htFields); oProvisioningUser = new ProvisioningUser(sOrganization, id, boolEnabled); /* 2011/03/10; dopey adds: */ // Remember fetched attributes from _itemEnabled-list to oProvisioningUser's // attributes collection: Iterator<String> itFields = htFields.keySet().iterator(); String sCurrentField; while (itFields.hasNext()) { sCurrentField = itFields.next(); oProvisioningUser.getAttributes().put(sCurrentField, htFields.get(sCurrentField)); } Enumeration enumMethodIDs = _htProfile.keys(); while (enumMethodIDs.hasMoreElements()) { String sMethodID = (String) enumMethodIDs.nextElement(); ProfileItem itemRegistered = _htProfile.get(sMethodID); Boolean boolRegistered = (Boolean) getValue(itemRegistered, htFields); oProvisioningUser.putRegistered(sMethodID, boolRegistered); } } catch (UserException e) { throw e; } catch (Exception e) { _logger.fatal("Could not retrieve user information for user with id: " + id, e); throw new UserException(SystemErrors.ERROR_INTERNAL); } return oProvisioningUser; }
From source file:org.forgerock.openam.mobile.auth.AuthenticationClient.java
/** * Interrogates a JSONObject representing an authentication module stage, and puts the appropriate * data into the appropriate location. As per the rest of this file, only works for NameCallback * and PasswordCallback types./* www .j a v a2 s .c o m*/ * * @param authObj The JSON object representing the current stage of authentication * @param values The id:value pairs to insert into the JSON * * @throws org.json.JSONException If we cannot alter the JSON correctly */ public void replaceAuthenticateInputVals(JSONObject authObj, Hashtable<String, String> values) throws JSONException { JSONArray callbacks = authObj.getJSONArray(AuthNConstants.CALLBACKS); for (int i = 0; i < callbacks.length(); i++) { JSONObject callback = callbacks.getJSONObject(i); JSONArray inputs = callback.getJSONArray(AuthNConstants.INPUT); for (int k = 0; k < inputs.length(); k++) { JSONObject input = inputs.getJSONObject(k); if (values.containsKey(input.getString(AuthNConstants.NAME))) { input.put(AuthNConstants.VALUE, values.get(input.getString(AuthNConstants.NAME))); } } } }
From source file:gov.loc.www.zing.srw.srw_bindings.SRWSoapBindingImpl.java
public Stream searchRetrieveOperation(de.escidoc.core.domain.sru.SearchRetrieveRequestType request, MessageContext msgContext, String handle) throws RemoteException { log.debug("Enter: searchRetrieveOperation"); if (log.isInfoEnabled()) { log.info("request: maximumRecords:" + request.getMaximumRecords() + " query:" + request.getQuery() + " recordPacking:" + request.getRecordPacking() + " recordSchema:" + request.getRecordSchema() + " recordXpath:" + request.getRecordXPath() + " sortKeys:" + request.getSortKeys() + " startRecord:" + request.getStartRecord() + " stylesheet:" + request.getStylesheet() + " version:" + request.getVersion()); }/*from w w w . ja v a2 s.c om*/ long startTime = System.currentTimeMillis(); try { UserContext.setUserContext(handle); try { UserContext.getSecurityContext(); } catch (SystemException e1) { throw new InvocationTargetException(e1); } } catch (Exception ex) { } RestSearchRetrieveResponseType response = null; int resultSetIdleTime = ((Integer) msgContext.getProperty("resultSetIdleTime")).intValue(); NonNegativeInteger nni = request.getResultSetTTL(); if (log.isDebugEnabled()) log.debug("resultSetTTL()=" + nni); if (nni != null) { int ttl = nni.intValue(); log.debug("ttl=" + ttl); if (ttl < resultSetIdleTime) resultSetIdleTime = ttl; } String dbname = (String) msgContext.getProperty("dbname"); SRWDatabase db = (SRWDatabase) msgContext.getProperty("db"); if (log.isDebugEnabled()) log.debug("db=" + db); String sortKeys = request.getSortKeys(); if (sortKeys != null) request.setSortKeys(sortKeys); String query = request.getQuery(); if (query.indexOf('%') >= 0) { try { request.setQuery(java.net.URLDecoder.decode(query, "utf-8")); } catch (java.io.UnsupportedEncodingException e) { } } try { if (query == null) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied, "query", response.getSearchRetrieveResponse()); } else if (request.getStartRecord() != null && request.getStartRecord().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "startRecord", response.getSearchRetrieveResponse()); } else if (request.getMaximumRecords() != null && request.getMaximumRecords().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "maximumRecords", response.getSearchRetrieveResponse()); } else if (request.getResultSetTTL() != null && request.getResultSetTTL().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "resultSetTTL", response.getSearchRetrieveResponse()); } else { try { response = db.doRequest(request); if (response == null) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse( new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); response.getSearchRetrieveResponse().setVersion("1.1"); setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse()); db.diagnostic(SRWDiagnostic.GeneralSystemError, null, response.getSearchRetrieveResponse()); return response.toStream(db, true); } if (msgContext.getProperty("sru") != null && request.getStylesheet() != null) // you can't ask for // a stylesheet in // srw! db.diagnostic(SRWDiagnostic.StylesheetsNotSupported, null, response.getSearchRetrieveResponse()); setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse()); if (request.getRecordXPath() != null) db.diagnostic(72, null, response.getSearchRetrieveResponse()); if (request.getSortKeys() != null && !request.getSortKeys().equals("") && !db.supportsSort()) db.diagnostic(SRWDiagnostic.SortNotSupported, null, response.getSearchRetrieveResponse()); // set extraResponseData ExtraDataTO extraDataTo = new ExtraDataTO(); // we're going to stick the database name in extraResponseData // every time if (db.databaseTitle != null) extraDataTo.setDatabaseTitle(db.databaseTitle); else extraDataTo.setDatabaseTitle(dbname); // did they ask for the targetURL to be returned? Hashtable extraRequestDataElements = SRWDatabase.parseElements(request.getExtraRequestData()); String s = (String) extraRequestDataElements.get("returnTargetURL"); log.info("returnTargetURL=" + s); if (s != null && !s.equals("false")) { String targetStr = (String) msgContext.getProperty("targetURL"); log.info("targetStr=" + targetStr); if (targetStr != null && targetStr.length() > 0) { URL target = new URL(targetStr); TargetUrlTO targetUrlTo = new TargetUrlTO(); targetUrlTo.setHost(target.getHost()); targetUrlTo.setPort(Integer.toString(target.getPort())); targetUrlTo.setPath(target.getPath()); targetUrlTo.setQuery(Utilities.xmlEncode(target.getQuery())); extraDataTo.setTargetURL(targetUrlTo); } } // set extraResponseData SRWDatabase.setExtraResponseData(response.getSearchRetrieveResponse(), extraDataTo); } catch (Exception e) { log.error(e, e); throw new RemoteException(e.getMessage(), e); } finally { SRWDatabase.putDb(dbname, db); } response.getSearchRetrieveResponse().setVersion("1.1"); log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " (" + (System.currentTimeMillis() - startTime) + "ms)"); log.debug("Exit: searchRetrieveOperation"); return response.toStream(db, true); } } catch (Exception e) { throw new RemoteException(e.getMessage(), e); } response.getSearchRetrieveResponse().setVersion("1.1"); log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " (" + (System.currentTimeMillis() - startTime) + "ms)"); log.debug("Exit: searchRetrieveOperation"); return response.toStream(db, true); }