List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:com.hybris.mobile.activity.PaymentDetailActivity.java
@SuppressWarnings("unchecked") private void handleIntent(Intent intent) { if (intent.hasExtra("value")) { try {// w ww . ja va2s .c o m JSONObject payment = new JSONObject(intent.getStringExtra("value")); mPaymentID = payment.getString("id"); for (int i = 0; i < entries.size(); i++) { Hashtable<String, Object> dict = (Hashtable<String, Object>) entries.get(i); String path = "$." + dict.get("property").toString(); String value = ""; try { // We append a String a the end to handle the non String objects value = JsonPath.read(payment.toString(), path) + ""; } catch (Exception exp) { value = ""; } if (value != null) { dict.put("value", value); } } } catch (JSONException e) { LoggingUtils.e(LOG_TAG, "Error parsing Json. " + e.getLocalizedMessage(), Hybris.getAppContext()); } } }
From source file:com.sibvisions.rad.server.security.spring.handler.DefaultAuthenticationMetaDataHandler.java
/** * Sets the properties./*from w ww . j a v a2 s.com*/ * * @param pProperties the properties */ public void setProperties(Hashtable<String, Object> pProperties) { if (pProperties == null || !pProperties.containsKey("authentication")) { throw new IllegalArgumentException("The authentication property was not found"); } authentication = ((Authentication) pProperties.get("authentication")); properties = pProperties; }
From source file:algorithm.JPEGTextAddingTest.java
@Test public void jpegTextAddingTest() { try {/*from w w w .j av a2s .co m*/ File carrier = TestDataProvider.JPG_FILE; File payload1 = TestDataProvider.TXT_FILE; File payload2 = TestDataProvider.TXT_FILE_2; List<File> payloadList = new ArrayList<File>(); payloadList.add(payload1); payloadList.add(payload2); JPEGTextAdding algorithm = new JPEGTextAdding(); File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); assertTrue(outputFile.length() > carrier.length()); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(outputHash.size(), 3); RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload1 = outputHash.get(payload1.getName()); RestoredFile restoredPayload2 = outputHash.get(payload2.getName()); assertEquals(restoredCarrier.length(), carrier.length()); assertEquals(restoredPayload1.length(), payload1.length()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload1); assertNotNull(restoredPayload2); assertEquals(FileUtils.checksumCRC32(carrier), FileUtils.checksumCRC32(restoredCarrier)); assertEquals(FileUtils.checksumCRC32(payload1), FileUtils.checksumCRC32(restoredPayload1)); assertEquals(FileUtils.checksumCRC32(payload2), FileUtils.checksumCRC32(restoredPayload2)); // check restoration metadata: assertEquals("" + carrier.getAbsolutePath(), restoredCarrier.originalFilePath); assertEquals("" + payload1.getAbsolutePath(), restoredPayload1.originalFilePath); assertEquals("" + payload2.getAbsolutePath(), restoredPayload2.originalFilePath); assertEquals(algorithm, restoredCarrier.algorithm); assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload1.checksumValid); assertTrue(restoredPayload2.checksumValid); assertTrue(restoredCarrier.wasCarrier); assertFalse(restoredCarrier.wasPayload); assertTrue(restoredPayload1.wasPayload); assertFalse(restoredPayload1.wasCarrier); assertTrue(restoredPayload2.wasPayload); assertFalse(restoredPayload2.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload1)); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload2)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredPayload2)); assertFalse(restoredPayload1.relatedFiles.contains(restoredPayload1)); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.fcrepo.server.storage.DefaultExternalContentManager.java
/** * Retrieves external content via http or https. * * @return A MIMETypedStream//from w w w . j a v a 2 s.c o m * @throws ModuleInitializationException * @throws GeneralException */ private MIMETypedStream getFromWeb(ContentManagerParams params) throws ModuleInitializationException, GeneralException { String username = params.getUsername(); String password = params.getPassword(); boolean backendSSL = false; String url = params.getUrl(); // in case host is 'local.fedora.server', and has not been normalized (e.g. on validating datastream add) url = DOTranslationUtility.makeAbsoluteURLs(url); if (ServerUtility.isURLFedoraServer(url) && !params.isBypassBackend()) { BackendSecuritySpec m_beSS; BackendSecurity m_beSecurity = (BackendSecurity) getServer() .getModule("org.fcrepo.server.security.BackendSecurity"); try { m_beSS = m_beSecurity.getBackendSecuritySpec(); } catch (Exception e) { throw new ModuleInitializationException( "Can't intitialize BackendSecurity module (in default access) from Server.getModule", getRole()); } Hashtable<String, String> beHash = m_beSS.getSecuritySpec(BackendPolicies.FEDORA_INTERNAL_CALL); username = beHash.get("callUsername"); password = beHash.get("callPassword"); backendSSL = new Boolean(beHash.get("callSSL")).booleanValue(); if (backendSSL) { if (params.getProtocol().equals("http")) { url = url.replaceFirst("http:", "https:"); } url = url.replaceFirst(":" + fedoraServerPort + "/", ":" + fedoraServerRedirectPort + "/"); } if (logger.isDebugEnabled()) { logger.debug("************************* backendUsername: " + username + " backendPassword: " + password + " backendSSL: " + backendSSL); logger.debug("************************* doAuthnGetURL: " + url); } } return get(url, username, password, params.getMimeType()); }
From source file:fedora.server.storage.DefaultExternalContentManager.java
/** * Retrieves external content via http or https. * /*from w w w. j ava 2 s.com*/ * @param url * The url pointing to the content. * @param context * The Map containing parameters. * @param mimeType * The default MIME type to be used in case no MIME type can be * detected. * @return A MIMETypedStream * @throws ModuleInitializationException * @throws GeneralException */ private MIMETypedStream getFromWeb(ContentManagerParams params) throws ModuleInitializationException, GeneralException { String username = params.getUsername(); String password = params.getPassword(); boolean backendSSL = false; String url = params.getUrl(); if (ServerUtility.isURLFedoraServer(url) && !params.isBypassBackend()) { BackendSecuritySpec m_beSS; BackendSecurity m_beSecurity = (BackendSecurity) getServer() .getModule("fedora.server.security.BackendSecurity"); try { m_beSS = m_beSecurity.getBackendSecuritySpec(); } catch (Exception e) { throw new ModuleInitializationException( "Can't intitialize BackendSecurity module (in default access) from Server.getModule", getRole()); } Hashtable<String, String> beHash = m_beSS.getSecuritySpec(BackendPolicies.FEDORA_INTERNAL_CALL); username = (String) beHash.get("callUsername"); password = (String) beHash.get("callPassword"); backendSSL = new Boolean((String) beHash.get("callSSL")).booleanValue(); if (backendSSL) { if (params.getProtocol().equals("http:")) { url = url.replaceFirst("http:", "https:"); } url = url.replaceFirst(":" + fedoraServerPort + "/", ":" + fedoraServerRedirectPort + "/"); } if (LOG.isDebugEnabled()) { LOG.debug("************************* backendUsername: " + username + " backendPassword: " + password + " backendSSL: " + backendSSL); LOG.debug("************************* doAuthnGetURL: " + url); } } return get(url, username, password, params.getMimeType()); }
From source file:net.nosleep.superanalyzer.analysis.views.GenreView.java
private void refreshDataset() { Hashtable genres = _analysis.getHash(Analysis.KIND_GENRE); Vector items = new Vector(); Enumeration e = genres.keys(); while (e.hasMoreElements()) { String genreName = (String) e.nextElement(); Genre genre = (Genre) genres.get(genreName); items.add(new GenreItem(genreName, genre.getStats().getTrackCount())); }//w w w . j av a 2s.c om Collections.sort(items, new GenreItemComparator()); for (int i = 0; i < items.size(); i++) { GenreItem item = (GenreItem) items.elementAt(i); _dataset.addValue(item.Count, Misc.getString("GENRE"), item.GenreName); } }
From source file:algorithm.MetsSubmissionInformationPackageTest.java
@Test public void MetsSipTest() { try {//ww w. j ava2 s. c o m File carrier = TestDataProvider.TXT_FILE; File payload1 = TestDataProvider.TXT_FILE_2; File payload2 = TestDataProvider.XML_FILE; List<File> payloadList = new ArrayList<File>(); payloadList.add(payload1); payloadList.add(payload2); MetsSubmissionInformationPackage algorithm = new MetsSubmissionInformationPackage(); // Test encapsulation: File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); assertTrue(outputFile.length() > carrier.length()); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(4, outputHash.size());// files+map! RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload1 = outputHash.get(payload1.getName()); RestoredFile restoredPayload2 = outputHash.get(payload2.getName()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload1); assertNotNull(restoredPayload2); assertEquals(FileUtils.checksumCRC32(carrier), FileUtils.checksumCRC32(restoredCarrier)); assertEquals(FileUtils.checksumCRC32(payload1), FileUtils.checksumCRC32(restoredPayload1)); assertEquals(FileUtils.checksumCRC32(payload2), FileUtils.checksumCRC32(restoredPayload2)); // check restoration metadata: assertEquals(algorithm, restoredCarrier.algorithm); assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload1.checksumValid); assertTrue(restoredPayload2.checksumValid); // every file in a zip package is payload!: assertTrue(restoredCarrier.wasPayload); assertFalse(restoredCarrier.wasCarrier); assertTrue(restoredPayload1.wasPayload); assertFalse(restoredPayload1.wasCarrier); assertTrue(restoredPayload2.wasPayload); assertFalse(restoredPayload2.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload1)); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload2)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredPayload2)); assertFalse(restoredPayload1.relatedFiles.contains(restoredPayload1)); } catch (IOException e) { e.printStackTrace(); } }
From source file:algorithm.OaiOreSubmissionInformationPackageTest.java
@Test public void OaiOreSipTest() { try {//from ww w . j av a2s .c o m File carrier = TestDataProvider.TXT_FILE; File payload1 = TestDataProvider.TXT_FILE_2; File payload2 = TestDataProvider.XML_FILE; List<File> payloadList = new ArrayList<File>(); payloadList.add(payload1); payloadList.add(payload2); OaiOreSubmissionInformationPackage algorithm = new OaiOreSubmissionInformationPackage(); // Test encapsulation: File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); assertTrue(outputFile.length() > carrier.length()); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(4, outputHash.size());// files+map! RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload1 = outputHash.get(payload1.getName()); RestoredFile restoredPayload2 = outputHash.get(payload2.getName()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload1); assertNotNull(restoredPayload2); assertEquals(FileUtils.checksumCRC32(carrier), FileUtils.checksumCRC32(restoredCarrier)); assertEquals(FileUtils.checksumCRC32(payload1), FileUtils.checksumCRC32(restoredPayload1)); assertEquals(FileUtils.checksumCRC32(payload2), FileUtils.checksumCRC32(restoredPayload2)); // check restoration metadata: assertEquals(algorithm, restoredCarrier.algorithm); assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload1.checksumValid); assertTrue(restoredPayload2.checksumValid); // every file in a zip package is payload!: assertTrue(restoredCarrier.wasPayload); assertFalse(restoredCarrier.wasCarrier); assertTrue(restoredPayload1.wasPayload); assertFalse(restoredPayload1.wasCarrier); assertTrue(restoredPayload2.wasPayload); assertFalse(restoredPayload2.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload1)); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload2)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload1.relatedFiles.contains(restoredPayload2)); assertFalse(restoredPayload1.relatedFiles.contains(restoredPayload1)); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.sourceforge.floggy.persistence.fr2852335.single.FR2852335MigrationTest.java
/** * DOCUMENT ME!/*www .ja v a 2 s . c o m*/ * * @throws Exception DOCUMENT ME! */ public void testMigrationConcreteSubClassOfAbstractSuperClass() throws Exception { MigrationManager um = MigrationManager.getInstance(); Enumeration enumeration = um.start(CSCOfAbstractSuperClass.class, null); assertEquals(1, enumeration.getSize()); assertEquals(SingleStrategyEnumerationImpl.class, enumeration.getClass()); try { while (enumeration.hasMoreElements()) { Hashtable fields = enumeration.nextElement(); assertEquals(checkpoint, fields.get("checkpoint")); assertEquals(name, fields.get("name")); } } finally { um.finish(CSCOfAbstractSuperClass.class); } }
From source file:edu.ku.brc.specify.tasks.BaseTask.java
/** * @return the Hashtable from the SoftReference *///from w w w . ja v a2s . c o m protected Hashtable<String, PermissionOptionPersist> getAndSetDefPerms() { if (taskPermsListSR == null) { taskPermsListSR = new SoftReference<Hashtable<String, PermissionOptionPersist>>(null); } Hashtable<String, PermissionOptionPersist> hash = taskPermsListSR.get(); if (hash == null) { Hashtable<String, Hashtable<String, PermissionOptionPersist>> taskHash = readDefaultPermsFromXML( "tasks.xml"); if (taskHash != null) { hash = taskHash.get(name); if (hash != null) { taskPermsListSR = new SoftReference<Hashtable<String, PermissionOptionPersist>>(hash); } } } return hash; }