List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:org.fcrepo.integration.auth.webac.WebACRecipesIT.java
@Test public void testDelegatedUserAccess() throws IOException { logger.debug("testing delegated authentication"); final String targetPath = "/rest/foo"; final String targetResource = ingestObj(targetPath); final String acl = ingestAcl("fedoraAdmin", "/acls/11/acl.ttl", "/acls/11/authorization.ttl"); linkToAcl(targetResource, acl);// ww w . j a v a 2 s. co m final HttpGet adminGet = getObjMethod(targetPath); setAuth(adminGet, "fedoraAdmin"); assertEquals("admin can read object", HttpStatus.SC_OK, getStatus(adminGet)); final HttpGet adminDelegatedGet = getObjMethod(targetPath); setAuth(adminDelegatedGet, "fedoraAdmin"); adminDelegatedGet.addHeader("On-Behalf-Of", "user11"); assertEquals("delegated user can read object", HttpStatus.SC_OK, getStatus(adminDelegatedGet)); final HttpGet adminUnauthorizedDelegatedGet = getObjMethod(targetPath); setAuth(adminUnauthorizedDelegatedGet, "fedoraAdmin"); adminUnauthorizedDelegatedGet.addHeader("On-Behalf-Of", "fakeuser"); assertEquals("delegated fakeuser cannot read object", HttpStatus.SC_FORBIDDEN, getStatus(adminUnauthorizedDelegatedGet)); final HttpGet adminDelegatedGet2 = getObjMethod(targetPath); setAuth(adminDelegatedGet2, "fedoraAdmin"); adminDelegatedGet2.addHeader("On-Behalf-Of", "info:user/user2"); assertEquals("delegated user can read object", HttpStatus.SC_OK, getStatus(adminDelegatedGet2)); final HttpGet adminUnauthorizedDelegatedGet2 = getObjMethod(targetPath); setAuth(adminUnauthorizedDelegatedGet2, "fedoraAdmin"); adminUnauthorizedDelegatedGet2.addHeader("On-Behalf-Of", "info:user/fakeuser"); assertEquals("delegated fakeuser cannot read object", HttpStatus.SC_FORBIDDEN, getStatus(adminUnauthorizedDelegatedGet2)); // Now test with the system property in effect System.setProperty(USER_AGENT_BASE_URI_PROPERTY, "info:user/"); System.setProperty(GROUP_AGENT_BASE_URI_PROPERTY, "info:group/"); final HttpGet adminDelegatedGet3 = getObjMethod(targetPath); setAuth(adminDelegatedGet3, "fedoraAdmin"); adminDelegatedGet3.addHeader("On-Behalf-Of", "info:user/user2"); assertEquals("delegated user can read object", HttpStatus.SC_OK, getStatus(adminDelegatedGet3)); final HttpGet adminUnauthorizedDelegatedGet3 = getObjMethod(targetPath); setAuth(adminUnauthorizedDelegatedGet3, "fedoraAdmin"); adminUnauthorizedDelegatedGet3.addHeader("On-Behalf-Of", "info:user/fakeuser"); assertEquals("delegated fakeuser cannot read object", HttpStatus.SC_FORBIDDEN, getStatus(adminUnauthorizedDelegatedGet3)); System.clearProperty(USER_AGENT_BASE_URI_PROPERTY); System.clearProperty(GROUP_AGENT_BASE_URI_PROPERTY); }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void copyResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "copyResources"; String processedIds = null;/*w w w. ja va 2s .com*/ // Extract variables for the resourceIds resourceIds = CommonUtils.extractVariable(prefix, resourceIds, propertyFile, true); // Set the Module Action Objective String s1 = (resourceIds == null) ? "no_resourceIds" : "Ids=" + resourceIds; System.setProperty("MODULE_ACTION_OBJECTIVE", "COPY : " + s1); // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToResourceXML)) { throw new CompositeException("File [" + pathToResourceXML + "] does not exist."); } if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } List<ResourceType> resourceList = getResources(serverId, resourceIds, pathToResourceXML, pathToServersXML); if (resourceList != null && resourceList.size() > 0) { for (ResourceType resource : resourceList) { // Get the identifier and convert any $VARIABLES String resourceId = CommonUtils.extractVariable(prefix, resource.getId(), propertyFile, true); /** * Possible values for archives * 1. csv string like import1,import2 (we process only resource names which are passed in) * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case) * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix * like -import1,import3 (we ignore passed in resources and process rest of the in the input xml */ if (DeployUtil.canProcessResource(resourceIds, resourceId)) { // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + resourceId; if (resource.getResourcePath() != null && resource.getResourcePath().size() > 0) { for (int i = 0; i < resource.getResourcePath().size(); i++) { String resourcePath = resource.getResourcePath().get(i); System.setProperty("RESOURCE_ID", resourceId); copyResource(serverId, resourcePath, pathToServersXML, resource.getTargetContainerPath(), resource.getNewName(), resource.getCopyMode()); System.clearProperty("RESOURCE_ID"); } } else { if (logger.isInfoEnabled()) { logger.info("No resource paths found for resourceId " + resourceId); } } } } // Determine if any resourceIds were not processed and report on this if (processedIds != null) { if (logger.isInfoEnabled()) { logger.info("Resource entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries were processed for the input list. resourceIds=" + resourceIds; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries found for Resource Module XML at path=" + pathToResourceXML; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } }
From source file:org.fcrepo.auth.webac.WebACRolesProviderTest.java
@Test public void noAclTestOkRdf3() throws RepositoryException { final String agent1 = "testAdminUser"; when(mockResource.getTriples(anyObject(), eq(PROPERTIES))) .thenReturn(new DefaultRdfStream(createURI("subject"))); when(mockResource.getPath()).thenReturn("/"); when(mockResource.getTypes()).thenReturn(Arrays.asList(URI.create(REPOSITORY_NAMESPACE + "Resource"))); System.setProperty(ROOT_AUTHORIZATION_PROPERTY, "./target/test-classes/test-root-authorization.ttl"); final Map<String, Collection<String>> roles = roleProvider.getRoles(mockNode, true); System.clearProperty(ROOT_AUTHORIZATION_PROPERTY); assertEquals("There should be exactly one agent", 1, roles.size()); assertEquals("The agent should have one mode", 1, roles.get(agent1).size()); assertTrue("The agent should be able to read", roles.get(agent1).contains(WEBAC_MODE_READ_VALUE)); }
From source file:org.fcrepo.integration.auth.webac.WebACRecipesIT.java
@Test public void testAccessToRoot() throws IOException { final String id = "/rest/" + getRandomUniqueId(); final String testObj = ingestObj(id); final String acl = ingestAcl("fedoraAdmin", "/acls/06/acl.ttl", "/acls/06/authorization.ttl", "/acls/06/noslash.ttl"); logger.debug("Anonymous can't read (no ACL): {}", id); final HttpGet requestGet1 = getObjMethod(id); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet1)); logger.debug("Can username 'user06a' read {} (no ACL)", id); final HttpGet requestGet2 = getObjMethod(id); setAuth(requestGet2, "user06a"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet2)); logger.debug("Can username 'notuser06b' read {} (no ACL)", id); final HttpGet requestGet3 = getObjMethod(id); setAuth(requestGet3, "user06b"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet3)); System.setProperty(ROOT_AUTHORIZATION_PROPERTY, "./target/test-classes/test-root-authorization2.ttl"); logger.debug("Can username 'user06a' read {} (overridden system ACL)", id); final HttpGet requestGet4 = getObjMethod(id); setAuth(requestGet4, "user06a"); assertEquals(HttpStatus.SC_OK, getStatus(requestGet4)); System.clearProperty(ROOT_AUTHORIZATION_PROPERTY); // Add ACL to root linkToAcl("/rest/", acl); logger.debug("Anonymous still can't read (ACL present)"); final HttpGet requestGet5 = getObjMethod(id); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet5)); logger.debug("Can username 'user06a' read {} (ACL present)", testObj); final HttpGet requestGet6 = getObjMethod(id); setAuth(requestGet6, "user06a"); assertEquals(HttpStatus.SC_OK, getStatus(requestGet6)); logger.debug("Can username 'user06b' read {} (ACL present)", testObj); final HttpGet requestGet7 = getObjMethod(id); setAuth(requestGet7, "user06b"); assertEquals(HttpStatus.SC_OK, getStatus(requestGet7)); }
From source file:net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Load Taverna's Truststore from a file on a disk. If the Truststore does * not already exist, a new empty one will be created and contents of Java's * truststore located in <JAVA_HOME>/lib/security/cacerts will be copied * over to the Truststore.//w ww. j av a 2 s .c om */ private void loadTruststore() throws CMException { if (truststore != null) return; try { /* * Try to create Taverna's Truststore as Bouncy Castle UBER-type * keystore. */ truststore = KeyStore.getInstance("UBER", "BC"); } catch (Exception ex) { /* * The requested keystore type is not available from security * providers. */ throw new CMException("Failed to instantiate Taverna's Truststore", ex); } if (truststoreFile.exists()) { /* * If the Truststore file already exists, open it and load the * Truststore */ try (FileInputStream fis = new FileInputStream(truststoreFile)) { // Load the Truststore from the file truststore.load(fis, masterPassword.toCharArray()); } catch (Exception ex) { /* Clear out things that are useless/hindering now */ truststore = null; masterPassword = null; String exMessage = "Failed to load Taverna's Truststore from " + truststoreFile.getAbsolutePath() + ". Possible reason: incorrect password or corrupted file."; logger.error(exMessage, ex); throw new CMException(exMessage, ex); } deleteRevokedCertificates(); } else { /* * Otherwise create a new empty Truststore and load it with certs * from Java's truststore. */ File javaTruststoreFile = new File(System.getProperty("java.home"), "lib/security/cacerts"); KeyStore javaTruststore = null; // Java's truststore is of type "JKS" - try to load it try { javaTruststore = KeyStore.getInstance("JKS"); } catch (Exception ex) { // The requested keystore type is not available from the // provider throw new CMException( "Failed to instantiate a 'JKS'-type keystore " + "for reading Java's truststore.", ex); } boolean loadedJavaTruststore = false; /* * Load Java's truststore from the file - try with the default Java * truststore passwords. */ for (String password : defaultTrustStorePasswords) { logger.info("Trying to load Java truststore using password: " + password); try (FileInputStream fis = new FileInputStream(javaTruststoreFile)) { javaTruststore.load(fis, password.toCharArray()); loadedJavaTruststore = true; break; } catch (IOException ioex) { /* * If there is an I/O or format problem with the keystore * data, or if the given password was incorrect. (Thank you * Sun, now I can't know if it is the file or the * password..) */ logger.info(String.format( "Failed to load the Java truststore to copy " + "over certificates using default password: " + "%s from %s", password, javaTruststoreFile)); } catch (NoSuchAlgorithmException e) { logger.error("Unknown encryption algorithm " + "while loading Java truststore from " + javaTruststoreFile, e); break; } catch (CertificateException e) { logger.error("Certificate error while " + "loading Java truststore from " + javaTruststoreFile, e); break; } } /* * Default Java truststore passwords failed - possibly the user has * changed it. Ask the Java truststore password providers if they * can help - this will typically pop up a dialog to ask the user if * we are in a graphical environment. If not, we will simply not * copy the default truststore certificates into Credential * Manager's Truststore. */ if (!loadedJavaTruststore && !loadJavaTruststoreUsingPasswordProviders(javaTruststore, javaTruststoreFile)) { String error = "Credential manager failed to load" + " certificates from Java's truststore."; String help = "Try using the system property -D" + PROPERTY_TRUSTSTORE_PASSWORD + "=TheTrustStorePassword"; logger.error(error + " " + help); // FIXME Writes to standard error! System.err.println(error); System.err.println(help); } // Create a new empty Truststore for Taverna try (FileOutputStream fos = new FileOutputStream(truststoreFile)) { truststore.load(null, null); if (loadedJavaTruststore) { // Copy certificates into Taverna's Truststore from // Java's truststore. Enumeration<String> aliases = javaTruststore.aliases(); while (aliases.hasMoreElements()) { Certificate certificate = javaTruststore.getCertificate(aliases.nextElement()); if (certificate instanceof X509Certificate) truststore.setCertificateEntry( createTrustedCertificateAlias((X509Certificate) certificate), certificate); } } // Insert special trusted CA certificates logger.info( "Loading certificates of trusted CAs so as to establish trust into our services such as BioCatalogue, BiodiversityCatalogue, heater, etc."); CertificateFactory cf = CertificateFactory.getInstance("X.509"); for (URL trustedCertURL : getSpecialTrustedCertificates()) // Load the certificate (possibly a chain) from the // stream try (InputStream stream = trustedCertURL.openStream()) { for (Certificate c : cf.generateCertificates(stream)) truststore.setCertificateEntry(createTrustedCertificateAlias((X509Certificate) c), c); } catch (Exception cex) { logger.error("Failed to insert trusted certificate entry in the Truststore", cex); } // Immediately save the new Truststore to the file truststore.store(fos, masterPassword.toCharArray()); } catch (Exception ex) { /* * make truststore null as it was just created but failed to * save so we should retry next time */ truststore = null; throw new CMException("Failed to generate new empty Taverna's Truststore", ex); } } /* * Taverna distro for MAC contains info.plist file with some Java system * properties set to use the Keychain which clashes with what we are * setting here so we need to clear them. */ System.clearProperty(PROPERTY_TRUSTSTORE_TYPE); System.clearProperty(PROPERTY_TRUSTSTORE_PROVIDER); /* * Not quite sure why we still need to set these two properties since we * are creating our own SSLSocketFactory with our own TrustManager that * uses Taverna's Truststore, but seem like after Taverna starts up and * the first time it needs SSLSocketFactory for HTTPS connection it is * still using the default Java's truststore unless these properties are * set. Set the system property "javax.net.ssl.Truststore" to use * Taverna's truststore. */ /* * Axis 1 likes reading from these properties but seems to work as well * with Taverna's SSLSocetFactory as well. We do not want to expose * these as they can be read from Beanshells. */ // System.setProperty(PROPERTY_TRUSTSTORE, truststoreFile.getAbsolutePath()); // System.setProperty(PROPERTY_TRUSTSTORE_PASSWORD, masterPassword); System.clearProperty(PROPERTY_TRUSTSTORE); System.clearProperty(PROPERTY_TRUSTSTORE_PASSWORD); }
From source file:org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Load Taverna's Truststore from a file on a disk. If the Truststore does * not already exist, a new empty one will be created and contents of Java's * truststore located in <JAVA_HOME>/lib/security/cacerts will be copied * over to the Truststore.//from w w w . j av a 2s. c o m */ private void loadTruststore() throws CMException { if (truststore == null) { try { // Try to create Taverna's Truststore as Bouncy Castle UBER-type // keystore. truststore = KeyStore.getInstance("UBER", "BC"); } catch (Exception ex) { // The requested keystore type is not available from security // providers. throw new CMException("Failed to instantiate Taverna's Truststore", ex); } if (truststoreFile.exists()) { // If the Truststore file already exists, open it and load the // Truststore try (FileInputStream fis = new FileInputStream(truststoreFile)) { // Load the Truststore from the file truststore.load(fis, masterPassword.toCharArray()); // Delete the old revoked or unnecessary BioCatalogue, // BiodiversityCatalogue and heater's certificates, if present deleteRevokedCertificates(); } catch (Exception ex) { /* Clear out things that are useless/hindering now */ truststore = null; masterPassword = null; String exMessage = "Failed to load Taverna's Truststore from " + truststoreFile.getAbsolutePath() + ". Possible reason: incorrect password or corrupted file."; logger.error(exMessage, ex); throw new CMException(exMessage, ex); } } else { /* * Otherwise create a new empty Truststore and load it with * certs from Java's truststore. */ File javaTruststoreFile = new File(System.getProperty("java.home"), "lib/security/cacerts"); KeyStore javaTruststore = null; // Java's truststore is of type "JKS" - try to load it try { javaTruststore = KeyStore.getInstance("JKS"); } catch (Exception ex) { // The requested keystore type is not available from the // provider throw new CMException( "Failed to instantiate a 'JKS'-type keystore " + "for reading Java's truststore.", ex); } boolean loadedJavaTruststore = false; /* * Load Java's truststore from the file - try with the default * Java truststore passwords. */ for (String password : defaultTrustStorePasswords) { logger.info("Trying to load Java truststore using password: " + password); try (FileInputStream fis = new FileInputStream(javaTruststoreFile)) { javaTruststore.load(fis, password.toCharArray()); loadedJavaTruststore = true; break; } catch (IOException ioex) { /* * If there is an I/O or format problem with the * keystore data, or if the given password was incorrect * (Thank you Sun, now I can't know if it is the file or * the password..) */ logger.info(String.format( "Failed to load the Java truststore to copy " + "over certificates using default password: " + "%s from %s", password, javaTruststoreFile)); } catch (NoSuchAlgorithmException e) { logger.error("Unknown encryption algorithm " + "while loading Java truststore from " + javaTruststoreFile, e); break; } catch (CertificateException e) { logger.error( "Certificate error while " + "loading Java truststore from " + javaTruststoreFile, e); break; } } /* * Default Java truststore passwords failed - possibly the user * has changed it. Ask the Java truststore password providers if * they can help - this will typically pop up a dialog to ask * the user if we are in a graphical environment. If not, we * will simply not copy the default truststore certificates into * Credential Manager's Truststore. */ if (!loadedJavaTruststore) if (!(loadJavaTruststoreUsingPasswordProviders(javaTruststore, javaTruststoreFile))) { String error = "Credential manager failed to load" + " certificates from Java's truststore."; String help = "Try using the system property -D" + PROPERTY_TRUSTSTORE_PASSWORD + "=TheTrustStorePassword"; logger.error(error + " " + help); // FIXME Writes to standard error! System.err.println(error); System.err.println(help); } // Create a new empty Truststore for Taverna try (FileOutputStream fos = new FileOutputStream(truststoreFile)) { truststore.load(null, null); if (loadedJavaTruststore) { // Copy certificates into Taverna's Truststore from // Java's truststore. Enumeration<String> aliases = javaTruststore.aliases(); while (aliases.hasMoreElements()) { Certificate certificate = javaTruststore.getCertificate(aliases.nextElement()); if (certificate instanceof X509Certificate) truststore.setCertificateEntry( createTrustedCertificateAlias((X509Certificate) certificate), certificate); } } // Insert special trusted CA certificates logger.info( "Loading certificates of trusted CAs so as to establish trust into our services such as BioCatalogue, BiodiversityCatalogue, heater, etc."); CertificateFactory cf = CertificateFactory.getInstance("X.509"); for (URL trustedCertURL : getSpecialTrustedCertificates()) // Load the certificate (possibly a chain) from the // stream try (InputStream stream = trustedCertURL.openStream()) { for (Certificate c : cf.generateCertificates(stream)) truststore.setCertificateEntry(createTrustedCertificateAlias((X509Certificate) c), c); } catch (Exception cex) { logger.error("Failed to insert trusted certificate entry in the Truststore", cex); } // Immediately save the new Truststore to the file truststore.store(fos, masterPassword.toCharArray()); } catch (Exception ex) { /* * make truststore null as it was just created but failed to * save so we should retry next time */ truststore = null; throw new CMException("Failed to generate new empty Taverna's Truststore", ex); } } /* * Taverna distro for MAC contains info.plist file with some Java * system properties set to use the Keychain which clashes with what * we are setting here so we need to clear them. */ System.clearProperty(PROPERTY_TRUSTSTORE_TYPE); System.clearProperty(PROPERTY_TRUSTSTORE_PROVIDER); /* * Not quite sure why we still need to set these two properties * since we are creating our own SSLSocketFactory with our own * TrustManager that uses Taverna's Truststore, but seem like after * Taverna starts up and the first time it needs SSLSocketFactory * for HTTPS connection it is still using the default Java's * truststore unless these properties are set. Set the system * property "javax.net.ssl.Truststore" to use Taverna's truststore. */ /* * Axis 1 likes reading from these properties but seems to work as * well with Taverna's SSLSocetFactory as well. We do not want to * expose these as they can be read from Beanshells. */ // System.setProperty(PROPERTY_TRUSTSTORE, truststoreFile.getAbsolutePath()); // System.setProperty(PROPERTY_TRUSTSTORE_PASSWORD, masterPassword); System.clearProperty(PROPERTY_TRUSTSTORE); System.clearProperty(PROPERTY_TRUSTSTORE_PASSWORD); } }
From source file:com.seleniumtests.it.reporter.TestSeleniumTestsReporter2.java
/** * Check format of messages in detailed report * @throws Exception//from w w w.j a v a2 s . co m */ @Test(groups = { "it" }) public void testReportDetailsMessageStyles() throws Exception { reporter = spy(new SeleniumTestsReporter2()); try { System.setProperty("customTestReports", "PERF::xml::reporter/templates/report.perf.vm,SUP::xml::reporter/templates/report.supervision.vm"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions", "testInError", "testWithException" }); // check style of messages String detailedReportContent = readTestMethodResultFile("testInError"); Assert.assertTrue(detailedReportContent.contains("<div class=\"message-info\">click ok</div>")); Assert.assertTrue(detailedReportContent .contains("<div class=\"message-warning\">Warning: Some warning message</div>")); Assert.assertTrue( detailedReportContent.contains("<div class=\"message-info\">Some Info message</div>")); Assert.assertTrue( detailedReportContent.contains("<div class=\"message-error\">Some Error message</div>")); Assert.assertTrue(detailedReportContent.contains("<div class=\"message-log\">Some log message</div>")); Assert.assertTrue(detailedReportContent.contains( "<table class=\"table table-bordered table-condensed\"><tr><th width=\"15%\">Key</th><th width=\"60%\">Message</th><th width=\"25%\">Value</th></tr><tr><td>key</td><td>we found a value of</td><td>10</td></tr></table>")); Assert.assertTrue(detailedReportContent.contains("<li>send keyboard action</li>")); } finally { System.clearProperty("customTestReports"); } }
From source file:org.apache.solr.SolrTestCaseJ4.java
/** * Shuts down the test harness, and makes the best attempt possible * to delete dataDir, unless the system property "solr.test.leavedatadir" * is set.// w w w . j ava 2 s .co m */ public static void deleteCore() { log.info("###deleteCore"); if (h != null) { // If the test case set up Zk, it should still have it as available, // otherwise the core close will just be unnecessarily delayed. CoreContainer cc = h.getCoreContainer(); if (!cc.getCores().isEmpty() && cc.isZooKeeperAware()) { try { cc.getZkController().getZkClient().exists("/", false); } catch (KeeperException e) { log.error("Testing connectivity to ZK by checking for root path failed", e); fail("Trying to tear down a ZK aware core container with ZK not reachable"); } catch (InterruptedException ignored) { } } h.close(); } if (factoryProp == null) { System.clearProperty("solr.directoryFactory"); } solrConfig = null; h = null; lrf = null; configString = schemaString = null; }
From source file:com.inmobi.conduit.local.LocalStreamServiceTest.java
@Test public void testThrottle() throws Exception { System.setProperty(ConduitConstants.FILES_PER_COLLECETOR_PER_LOCAL_STREAM, String.valueOf(((NUMBER_OF_FILES + 1) / 2))); LOG.info("Running LocalStreamIntegration for filename test-lss-conduit.xml"); testMapReduce("test-lss-conduit.xml", 1, true); System.clearProperty(ConduitConstants.FILES_PER_COLLECETOR_PER_LOCAL_STREAM); }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void moveResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "moveResources"; String processedIds = null;/*from w ww .j a v a 2 s. co m*/ // Extract variables for the resourceIds resourceIds = CommonUtils.extractVariable(prefix, resourceIds, propertyFile, true); // Set the Module Action Objective String s1 = (resourceIds == null) ? "no_resourceIds" : "Ids=" + resourceIds; System.setProperty("MODULE_ACTION_OBJECTIVE", "MOVE : " + s1); // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToResourceXML)) { throw new CompositeException("File [" + pathToResourceXML + "] does not exist."); } if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } List<ResourceType> resourceList = getResources(serverId, resourceIds, pathToResourceXML, pathToServersXML); if (resourceList != null && resourceList.size() > 0) { for (ResourceType resource : resourceList) { // Get the identifier and convert any $VARIABLES String resourceId = CommonUtils.extractVariable(prefix, resource.getId(), propertyFile, true); /** * Possible values for archives * 1. csv string like import1,import2 (we process only resource names which are passed in) * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case) * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix * like -import1,import3 (we ignore passed in resources and process rest of the in the input xml */ if (DeployUtil.canProcessResource(resourceIds, resourceId)) { // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + resourceId; if (resource.getResourcePath() != null && resource.getResourcePath().size() > 0) { for (int i = 0; i < resource.getResourcePath().size(); i++) { String resourcePath = resource.getResourcePath().get(i); System.setProperty("RESOURCE_ID", resourceId); moveResource(serverId, resourcePath, pathToServersXML, resource.getTargetContainerPath(), resource.getNewName()); System.clearProperty("RESOURCE_ID"); } } else { if (logger.isInfoEnabled()) { logger.info("No resource paths found for resourceId " + resourceId); } } } } // Determine if any resourceIds were not processed and report on this if (processedIds != null) { if (logger.isInfoEnabled()) { logger.info("Resource entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries were processed for the input list. resourceIds=" + resourceIds; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries found for Resource Module XML at path=" + pathToResourceXML; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } }