List of usage examples for org.apache.commons.io FilenameUtils normalize
public static String normalize(String filename)
From source file:org.apache.synapse.deployers.ClassMediatorDeployer.java
/** * This will be called when a particular jar file is deleted from the specified folder. * * @param fileName - filename of the deleted file * @throws DeploymentException - in case of an error in undeployment *///from w ww . j a va2s .co m public void undeploy(String fileName) throws DeploymentException { String mediatorPath = FilenameUtils.normalize(fileName); log.info("Undeploying Class mediator : " + mediatorPath.substring(mediatorPath.lastIndexOf(File.separator) + 1)); getDeploymentStore().removeClassMediatorClassLoader(mediatorPath); }
From source file:org.apache.synapse.deployers.ImportDeployer.java
private String backupFile(File file) throws DeploymentException { String filePath = FilenameUtils.normalize(file.getAbsolutePath()); String backupFilePath = filePath + ".back"; int backupIndex = 0; while (backupIndex >= 0) { if (new File(backupFilePath).exists()) { backupIndex++;/*from w w w .j a v a 2 s . c om*/ backupFilePath = filePath + "." + backupIndex + ".back"; } else { backupIndex = -1; try { FileUtils.moveFile(file, new File(backupFilePath)); } catch (IOException e) { handleSynapseArtifactDeploymentError("Error while backing up the artifact: " + file.getName(), e); } } } return backupFilePath; }
From source file:org.apache.synapse.deployers.LibraryArtifactDeployer.java
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { String libFilePath = FilenameUtils.normalize(deploymentFileData.getAbsolutePath()); if (log.isDebugEnabled()) { log.debug("Deployment of the synapse library artifact from file : " + libFilePath + " : STARTED"); }//w w w . j a v a 2 s . co m // if (getServerContextInformation().getServerState() != // ServerState.STARTED) { // // synapse server has not yet being started // if (log.isDebugEnabled()) { // log.debug("Skipped the library artifact deployment (since the Synapse " // + // "server doesn't seem to be started yet), from file : " // + deploymentFileData.getAbsolutePath()); // } // return; // } try { SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration().getArtifactDeploymentStore(); Library lib = LibDeployerUtils.createSynapseLibrary(libFilePath); String libArtifactName = lib.getQName().toString(); if (this.getSynapseConfiguration().getSynapseLibraries().get(lib.getQName().toString()) != null) { log.warn("Hot deployment thread picked up an already deployed synapse library - Ignoring"); } else { if (log.isDebugEnabled()) { log.debug("Created the Synapse Library : " + libArtifactName + " from : " + libFilePath); } if (deploymentStore.isUpdatingArtifact(libFilePath)) { if (log.isDebugEnabled()) { log.debug("Updating Library artifact detected with filename : " + libFilePath); } // this is an hot-update case String existingArtifactName = deploymentStore.getUpdatingArtifactWithFileName(libFilePath); deploymentStore.removeUpdatingArtifact(libFilePath); undeploySynapseArtifact(existingArtifactName); // deploy from beginning // add the library to synapse Config completeDeployment(lib, libArtifactName); } else { // new artifact hot-deployment case try { // add the library to synapse Config completeDeployment(lib, libArtifactName); } catch (SynapseArtifactDeploymentException sade) { log.error("Deployment of the Synapse Artifact from file : " + libFilePath + " : Failed!", sade); /* * log.info("The file has been backed up into : " + * backupFile(deploymentFileData.getFile())); */ } } if (libArtifactName != null) { deploymentStore.addArtifact(libFilePath, libArtifactName); } log.info("Synapse Library named '" + lib.toString() + "' has been deployed from file : " + libFilePath); } } catch (IOException ex) { handleDeploymentError( "Deployment of synapse artifact failed. Error reading " + libFilePath + " : " + ex.getMessage(), ex); } catch (Exception ex) { handleDeploymentError("Deployment of synapse artifact failed for synapse libray at : " + libFilePath + " : " + ex.getMessage(), ex); } if (log.isDebugEnabled()) { log.debug("Deployment of the synapse artifact from file : " + libFilePath + " : COMPLETED"); } }
From source file:org.apache.synapse.deployers.LibraryArtifactDeployer.java
public void undeploy(String fileName) throws DeploymentException { fileName = FilenameUtils.normalize(fileName); if (log.isDebugEnabled()) { log.debug("UnDeployment of the synapse library from file : " + fileName + " : STARTED"); }//from w ww . j a va2s . c o m SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration().getArtifactDeploymentStore(); if (deploymentStore.containsFileName(fileName)) { File undeployingFile = new File(fileName); if (fileName.contains(File.separator + "tmp" + File.separator + "carbonapps" + File.separator) && fileName.endsWith(".zip")) { undeployingFile.delete(); } // axis2 treats Hot-Update as (Undeployment + deployment), where // synapse needs to differentiate the Hot-Update from the above two, since it needs // some validations for a real undeployment. Also this makes sure a zero downtime of the // synapse artifacts which are being Hot-deployed if (undeployingFile.exists()) { if (log.isDebugEnabled()) { log.debug("Marking artifact as updating from file : " + fileName); } // if the file exists, which means it has been updated and is a // Hot-Update case if (!deploymentStore.isRestoredFile(fileName)) { deploymentStore.addUpdatingArtifact(fileName, deploymentStore.getArtifactNameForFile(fileName)); deploymentStore.removeArtifactWithFileName(fileName); } } else { // if the file doesn't exists then it is an actual undeployment String artifactName = deploymentStore.getArtifactNameForFile(fileName); try { // CarbonApplication instance to delete Library currentMediationLib = null; // undeploying the local entries Collection<Library> appList = getSynapseConfiguration().getSynapseLibraries().values(); for (Library mediationLib : appList) { if (artifactName.equals(mediationLib.getQName().toString())) { currentMediationLib = mediationLib; } } if (currentMediationLib != null) { for (String localEntry : currentMediationLib.getLocalEntries()) { getSynapseConfiguration().removeEntry(localEntry); } } // do un-deployment undeploySynapseArtifact(artifactName); deploymentStore.removeArtifactWithFileName(fileName); log.info("Synapse Library named '" + artifactName + "' has been undeployed"); } catch (SynapseArtifactDeploymentException sade) { log.error("Unable to undeploy the synapse library artifact from file : " + fileName, sade); } } } else { String msg = "Artifact representing the filename " + fileName + " is not deployed on Synapse"; log.error(msg); throw new DeploymentException(msg); } if (log.isDebugEnabled()) { log.debug("UnDeployment of the synapse library artifact from file : " + fileName + " : COMPLETED"); } }
From source file:org.apache.synapse.deployers.SynapseArtifactDeploymentStore.java
public static String getNormalizedAbsolutePath(String fileName) { String path;//from w w w. jav a 2 s. c o m File file = new File(fileName); try { path = file.getCanonicalPath(); } catch (IOException e) { log.warn("Error while computing the canonical path of file: " + fileName); path = file.getAbsolutePath(); } return FilenameUtils.normalize(path); }
From source file:org.apache.synapse.mediators.MediatorTestCase.java
/** * Reads and stores client specific configuration information from descriptor * * @param config Sample descriptor/* ww w. j a va 2 s. co m*/ * @return An Axis2ClientConfiguration instance */ private Axis2ClientConfiguration initClientConfigInfo(OMElement config) { Axis2ClientConfiguration clientConfig = new Axis2ClientConfiguration(); String currentDir = SynapseTestUtils.getCurrentDir(); clientConfig .setAxis2Xml(SynapseTestUtils.getParameter(config, SampleConfigConstants.TAG_CLIENT_CONF_AXIS2_XML, FilenameUtils.normalize(currentDir + SampleConfigConstants.DEFAULT_CLIENT_CONF_AXIS2_XML))); clientConfig.setClientRepo(SynapseTestUtils.getParameter(config, SampleConfigConstants.TAG_CLIENT_CONF_REPO, FilenameUtils.normalize(currentDir + SampleConfigConstants.DEFAULT_CLIENT_CONF_REPO))); return clientConfig; }
From source file:org.apache.synapse.samples.framework.SynapseTestCase.java
protected SynapseTestCase(int sampleId) { if (log.isDebugEnabled()) { log.debug("Creating SynapseTestCase for test " + sampleId); }/*from w w w . j a v a 2s . co m*/ this.sampleId = sampleId; System.setProperty("java.io.tmpdir", FilenameUtils.normalize(SynapseTestUtils.getCurrentDir() + "modules/integration/target/temp")); loadConfiguration(); }
From source file:org.apache.synapse.samples.framework.tests.endpoint.Sample51.java
public void testMTOMOptimization() { String ep = "http://localhost:8280/services/MTOMSwASampleService"; String currentLocation = System.getProperty("user.dir") + File.separator; String filename = FilenameUtils .normalize(currentLocation + "repository/conf/sample/resources/mtom/asf-logo.gif"); MTOMSwASampleClient client = getMTOMSwASampleClient(); log.info("Running test: MTOM optimization and request/response correlation "); SampleClientResult result = client.sendUsingMTOM(filename, ep); assertResponseReceived(result);/* www . java 2s . c o m*/ }
From source file:org.apache.synapse.samples.framework.tests.endpoint.Sample51.java
public void testSWAOptimization() { String ep = "http://localhost:8280/services/MTOMSwASampleService"; String currentLocation = System.getProperty("user.dir") + File.separator; String filename = FilenameUtils .normalize(currentLocation + "repository/conf/sample/resources/mtom/asf-logo.gif"); MTOMSwASampleClient client = getMTOMSwASampleClient(); log.info("Running test:SwA optimization and request/response correlation "); SampleClientResult result = client.sendUsingSWA(filename, ep); assertResponseReceived(result);/*from ww w. j av a 2s .c o m*/ }
From source file:org.apache.synapse.samples.framework.tests.proxy.Sample152.java
public void testTransportAndFormatSwitching() { String url2 = "https://localhost:8243/services/StockQuoteProxy"; String trustStore = FilenameUtils .normalize(System.getProperty("user.dir") + "/modules/integration/src/test/resources/trust.jks"); System.setProperty("javax.net.ssl.trustStore", trustStore); StockQuoteSampleClient client = getStockQuoteClient(); log.info("Running test: Switching transports and message format from SOAP to REST/POX"); SampleClientResult result2 = client.requestStandardQuote(null, url2, null, "IBM", null); assertTrue("Client did not a response with https ", result2.responseReceived()); }