Author: deepal
Date: Wed Feb 20 22:27:19 2008
New Revision: 13931
Log:
fixing some of the issues with export and import
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryClientUtils.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryClientUtils.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryClientUtils.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryClientUtils.java
Wed Feb 20 22:27:19 2008
@@ -105,36 +105,53 @@
}
}
- private void processExport(String resourcePath,
+ public static void processExport(String resourcePath,
File toFile, Registry registry) throws
RegistryException {
Resource resource = registry.get(resourcePath);
if (resource != null) {
if (resource.isDirectory()) {
- File file = new File(toFile, resource.getPath());
- boolean fileFlag = file.mkdirs();
- if (!fileFlag) {
- log.info("Unable to create the directory " +
resource.getPath());
+ String currentResourcePath = resource.getPath();
+ int verionIndex = currentResourcePath.indexOf("?");
+ if (verionIndex >0) {
+ currentResourcePath =
currentResourcePath.substring(0,verionIndex);
+ }
+ File file = new File(toFile, currentResourcePath);
+ if (file.exists()) {
+ log.info("No need to create the directory " +
currentResourcePath);
} else {
- String childNodes[] = (String[])resource.getContent();
- for (String childNode : childNodes) {
- processExport(childNode, toFile, registry);
+ boolean fileFlag = file.mkdirs();
+ if (!fileFlag) {
+ log.info("Unable to create the directory " +
currentResourcePath);
}
}
+
+ String childNodes[] = (String[])resource.getContent();
+ for (String childNode : childNodes) {
+ processExport(childNode, toFile, registry);
+ }
} else {
- File file = new File(toFile, resource.getPath());
+ String currentResourcePath = resource.getPath();
+ int verionIndex = currentResourcePath.indexOf("?");
+ if (verionIndex >0) {
+ currentResourcePath =
currentResourcePath.substring(0,verionIndex);
+ }
+ File file = new File(toFile, currentResourcePath);
try {
- boolean fileFlag = file.createNewFile();
- if (!fileFlag) {
- log.info("Unable to create the file " +
resource.getPath());
+ if (file.exists()) {
+ log.info("No need to create the file " +
currentResourcePath);
} else {
- FileOutputStream out = new FileOutputStream(file);
- out.write((byte[])resource.getContent());
- out.flush();
- out.close();
+ boolean fileFlag = file.mkdirs();
+ if (!fileFlag) {
+ log.info("Unable to create the file " +
currentResourcePath);
+ }
}
+ FileOutputStream out = new FileOutputStream(file);
+ out.write((byte[])resource.getContent());
+ out.flush();
+ out.close();
} catch (IOException e) {
throw new RegistryException(Messages.getMessage(
- "error.creating.file", resource.getPath()));
+ "error.creating.file", currentResourcePath));
}
}
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev