List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:org.geotools.coverage.io.netcdf.NetCDFMosaicReaderTest.java
@AfterClass public static void close() { System.clearProperty("org.geotools.referencing.forceXY"); System.clearProperty("user.timezone"); System.clearProperty("org.geotools.shapefile.datetime"); CRS.reset("all"); }
From source file:org.eclipse.smarthome.config.dispatch.test.ConfigDispatcherOSGiTest.java
private static void setSystemProperty(String systemProperty, String initialValue) { if (initialValue != null) { System.setProperty(systemProperty, initialValue); } else {//from w w w. j a v a 2 s. c o m /* A system property cannot be set to null, it has to be cleared */ System.clearProperty(systemProperty); } }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void lockResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "lockResources"; String processedIds = null;/*from w w w. 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", "LOCK : " + 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); lockResource(serverId, resourcePath, pathToServersXML); 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:com.jkoolcloud.tnt4j.streams.utils.Utils.java
/** * Sets system property value./* w ww . j a v a2s .com*/ * <p> * If property name is {@code null} - does nothing. If property value is {@code null} - removes property from system * properties list. * * @param pName * the name of the system property * @param pValue * the value of the system property * @return the previous string value of the system property, or {@code null} if name is {@code null} or there was no * property with that name. */ public static String setSystemProperty(String pName, String pValue) { if (StringUtils.isEmpty(pName)) { return null; } if (pValue != null) { return System.setProperty(pName, pValue); } else { return System.clearProperty(pName); } }
From source file:org.witness.ssc.xfer.utils.PublishingUtils.java
private HttpURLConnection getGDataUrlConnection(String urlString) throws IOException { URL url = new URL(urlString); if (useProxy) { //url = new URL("http",,,urlString); System.setProperty("http.proxySet", "true"); System.setProperty("http.proxyHost", PROXY_HOST); System.setProperty("http.proxyPort", PROXY_PORT_HTTP + ""); } else {/* w w w .jav a 2 s . com*/ System.clearProperty("http.proxySet"); System.clearProperty("http.proxyHost"); System.clearProperty("http.proxyPort"); } HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Authorization", String.format("GoogleLogin auth=\"%s\"", clientLoginToken)); connection.setRequestProperty("GData-Version", "2"); connection.setRequestProperty("X-GData-Key", String.format("key=%s", res.getString(R.string.youtube_dev_key))); return connection; }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void unlockResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "unlockResources"; String processedIds = null;//from ww w . ja va 2s . c om // 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", "UNLOCK : " + s1); 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; String comment = null; if (resource.getComment() != null) { comment = resource.getComment(); } 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); unlockResource(serverId, resourcePath, pathToServersXML, comment); 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.apache.solr.cloud.FullSolrCloudTest.java
@Override @After//from www . j ava 2s .c o m public void tearDown() throws Exception { if (VERBOSE || printLayoutOnTearDown) { super.printLayout(); } ((HttpSolrServer) controlClient).shutdown(); if (cloudClient != null) { cloudClient.shutdown(); } if (zkStateReader != null) { zkStateReader.close(); } super.tearDown(); System.clearProperty("zkHost"); System.clearProperty("numShards"); }
From source file:org.eclipse.wb.tests.designer.core.util.reflect.ReflectionUtilsTest.java
/** * Test for {@link ReflectionUtils#propagate(Throwable)}. *//*from www.j a v a2 s.c o m*/ public void test_propagate() throws Exception { // when we throw Exception, it is thrown as is { Throwable toThrow = new Exception(); try { ReflectionUtils.propagate(toThrow); } catch (Throwable e) { assertSame(toThrow, e); } } // when we throw Error, it is thrown as is { Throwable toThrow = new Error(); try { ReflectionUtils.propagate(toThrow); } catch (Throwable e) { assertSame(toThrow, e); } } // coverage: for return from propagate() { String key = "wbp.ReflectionUtils.propagate().forceReturn"; System.setProperty(key, "true"); try { Throwable toThrow = new Exception(); Throwable result = ReflectionUtils.propagate(toThrow); assertSame(null, result); } finally { System.clearProperty(key); } } // coverage: for InstantiationException { String key = "wbp.ReflectionUtils.propagate().InstantiationException"; System.setProperty(key, "true"); try { Throwable toThrow = new Exception(); Throwable result = ReflectionUtils.propagate(toThrow); assertSame(null, result); } finally { System.clearProperty(key); } } // coverage: for InstantiationException { String key = "wbp.ReflectionUtils.propagate().IllegalAccessException"; System.setProperty(key, "true"); try { Throwable toThrow = new Exception(); Throwable result = ReflectionUtils.propagate(toThrow); assertSame(null, result); } finally { System.clearProperty(key); } } }
From source file:org.apache.geode.internal.cache.partitioned.fixed.FixedPartitioningTestBase.java
public static void closeCache() { System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + "DISABLE_MOVE_PRIMARIES_ON_STARTUP"); // System.setProperty("gemfire.DISABLE_MOVE_PRIMARIES_ON_STARTUP", "false"); if (cache != null && !cache.isClosed()) { cache.close();/*from w ww . j a va 2 s. c o m*/ cache.getDistributedSystem().disconnect(); } }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void createFolders(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "createFolders"; String processedIds = null;/* w ww.jav a 2 s. 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", "CREATE : " + s1); // Validate whether the files exist or not 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) { String recursive = "true"; String ignoreErrors = "false"; if (resource.getRecursive() != null) recursive = resource.getRecursive(); // 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; // Get ignore errors if (resource.getIgnoreErrors() != null) ignoreErrors = CommonUtils.extractVariable(prefix, resource.getIgnoreErrors(), propertyFile, true); 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); createFolder(serverId, resourcePath, pathToServersXML, recursive, ignoreErrors); 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); } } }