diff options
Diffstat (limited to 'source/com/c2kernel/entity/transfer/TransferItem.java')
| -rw-r--r-- | source/com/c2kernel/entity/transfer/TransferItem.java | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/source/com/c2kernel/entity/transfer/TransferItem.java b/source/com/c2kernel/entity/transfer/TransferItem.java index e4e84ec..9234650 100644 --- a/source/com/c2kernel/entity/transfer/TransferItem.java +++ b/source/com/c2kernel/entity/transfer/TransferItem.java @@ -1,17 +1,23 @@ package com.c2kernel.entity.transfer;
import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.*;
+import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.entity.TraceableEntity;
import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.lookup.*;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.process.Gateway;
-import com.c2kernel.property.*;
-import com.c2kernel.utils.*;
+import com.c2kernel.property.Property;
+import com.c2kernel.property.PropertyArrayList;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.FileStringUtility;
+import com.c2kernel.utils.Logger;
public class TransferItem {
public ArrayList<String> domainPaths;
@@ -31,7 +37,7 @@ public class TransferItem { this.sysKey = sysKey;
domainPaths = new ArrayList<String>();
Property name = (Property)Gateway.getStorage().get(sysKey, ClusterStorage.PROPERTY + "/Name", null);
- Enumeration paths = Gateway.getLDAPLookup().search(new DomainPath(), name.getValue());
+ Enumeration<?> paths = Gateway.getLDAPLookup().search(new DomainPath(), name.getValue());
while (paths.hasMoreElements()) {
DomainPath thisPath = (DomainPath)paths.nextElement();
domainPaths.add(thisPath.toString());
@@ -43,8 +49,8 @@ public class TransferItem { String[] contents = Gateway.getStorage().getClusterContents(sysKey, path);
if (contents.length > 0) {
FileStringUtility.createNewDir(dir.getCanonicalPath());
- for (int i = 0; i < contents.length; i++) {
- exportItem(new File(dir, contents[i]), path + "/" + contents[i]);
+ for (String content : contents) {
+ exportItem(new File(dir, content), path + "/" + content);
}
} else { //no children, try to dump object
try {
@@ -66,12 +72,11 @@ public class TransferItem { } catch (Exception ex) {
}
- ArrayList events, outcomes, viewpoints = new ArrayList();
// retrieve objects
- ArrayList objectFiles = FileStringUtility.listDir(dir.getCanonicalPath(), false, true);
+ ArrayList<?> objectFiles = FileStringUtility.listDir(dir.getCanonicalPath(), false, true);
ArrayList<C2KLocalObject> objects = new ArrayList<C2KLocalObject>();
- for (Iterator iter = objectFiles.iterator(); iter.hasNext();) {
- String element = (String)iter.next();
+ for (Object name : objectFiles) {
+ String element = (String)name;
String xmlFile = FileStringUtility.file2String(element);
C2KLocalObject newObj;
String choppedPath = element.substring(dir.getCanonicalPath().length()+1, element.length()-4);
@@ -88,12 +93,11 @@ public class TransferItem { EntityPath entityPath = new EntityPath(sysKey);
TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath);
Gateway.getLDAPLookup().add(entityPath);
-
+
PropertyArrayList props = new PropertyArrayList();
Workflow wf = null;
// put objects
- for (Iterator iter = objects.iterator(); iter.hasNext();) {
- C2KLocalObject obj = (C2KLocalObject)iter.next();
+ for (C2KLocalObject obj : objects) {
if (obj instanceof Property)
props.list.add((Property)obj);
else if (obj instanceof Workflow)
@@ -102,7 +106,7 @@ public class TransferItem { if (wf == null)
throw new Exception("No workflow found in import for "+sysKey);
-
+
// init item
newItem.initialise(importAgentId, CastorXMLUtility.marshall(props), CastorXMLUtility.marshall(wf.search("workflow/domain")));
@@ -113,19 +117,17 @@ public class TransferItem { importByType(ClusterStorage.VIEWPOINT, objects);
Gateway.getStorage().commit(this);
// add domPaths
- for (Iterator iter = domainPaths.iterator(); iter.hasNext();) {
- String element = (String)iter.next();
+ for (String element : domainPaths) {
DomainPath newPath = new DomainPath(element, entityPath);
Gateway.getLDAPLookup().add(newPath);
}
}
-
- private void importByType(String type, ArrayList objects) throws Exception {
- for (Iterator iter = objects.iterator(); iter.hasNext();) {
- C2KLocalObject element = (C2KLocalObject)iter.next();
+
+ private void importByType(String type, ArrayList<C2KLocalObject> objects) throws Exception {
+ for (C2KLocalObject element : objects) {
if (element.getClusterType().equals(type))
Gateway.getStorage().put(sysKey, element, this);
}
-
+
}
}
\ No newline at end of file |
