Skip to Content.
Sympa Menu

perfsonar-dev - [GEANT/SA2/ps-java-services] r5598 - trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration

Subject: perfsonar development work

List archive

[GEANT/SA2/ps-java-services] r5598 - trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration


Chronological Thread 
  • From:
  • To:
  • Subject: [GEANT/SA2/ps-java-services] r5598 - trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration
  • Date: Mon, 26 Apr 2010 17:10:22 +0100

Author: psnc.trzaszczka
Date: 2010-04-26 17:10:22 +0100 (Mon, 26 Apr 2010)
New Revision: 5598

Modified:

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
Log:
added logs

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
2010-04-26 15:43:02 UTC (rev 5597)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
2010-04-26 16:10:22 UTC (rev 5598)
@@ -7,6 +7,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
@@ -42,7 +43,13 @@
*/
protected Collection<File> getFiles() throws IOException {
final Collection<File> result = new ArrayList<File>();
- final File file = new File(configPath);
+ //final File file = new File(configPath);
+ File file;
+ try {
+ file = new
File(Thread.currentThread().getContextClassLoader().getResource(configPath).toURI());
+ } catch (URISyntaxException ex) {
+ throw new IOException(ex.getMessage(), ex);
+ }
if (!file.exists())
throw new FileNotFoundException("File: " +
file.getAbsolutePath() + " does not exist.");
if (!file.isDirectory())

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
2010-04-26 15:43:02 UTC (rev 5597)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
2010-04-26 16:10:22 UTC (rev 5598)
@@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;

import org.apache.log4j.Logger;
import org.perfsonar.base2.service.configuration.Component;
@@ -53,18 +54,23 @@
@Override
public void run() throws PerfSONARException {
try {
- engine.createFileFromTemplate(
- new
File(getFullPath("configuration.xml.template")),
- getFullPath("configuration.xml"));
+ final String templateFilePath =
getFullPath("configuration.xml.template");
+ final String configurationFile =
getFullPath("configuration.xml");
+ logger.info("Creating configuration file: " +
configurationFile + " from template: " + templateFilePath + "...");
+ engine.createFileFromTemplate(new
File(templateFilePath), configurationFile);
+ logger.info("Configuration file: " +
configurationFile + " created successfully from template: " +
templateFilePath);

configFiles.removeFiles();
} catch (IOException ex) {
logger.error(ex.getMessage(), ex);
throw new PerfSONARException(ex.getMessage());
+ } catch (URISyntaxException ex) {
+ logger.error(ex.getMessage(), ex);
+ throw new PerfSONARException(ex.getMessage());
}
}

- private String getFullPath(String fileName) {
- return "perfsonar" + File.separator + "conf" + File.separator
+ fileName;
+ private String getFullPath(String fileName) throws URISyntaxException
{
+ return
Thread.currentThread().getContextClassLoader().getResource("perfsonar" +
File.separator + "conf" + File.separator + fileName).getPath();
}
}

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
2010-04-26 15:43:02 UTC (rev 5597)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
2010-04-26 16:10:22 UTC (rev 5598)
@@ -90,7 +90,7 @@
*/
public File createFileFromTemplate(File template, String newFileName)
throws IOException {
if (!template.exists())
- throw new FileNotFoundException();
+ throw new FileNotFoundException("File: " +
template.getAbsolutePath() + " does not exist.");
if (!template.isFile())
throw new IOException("Template must be an existing
file.");
final File result = new File(newFileName);



  • [GEANT/SA2/ps-java-services] r5598 - trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration, svn-noreply, 04/26/2010

Archive powered by MHonArc 2.6.16.

Top of Page