diff options
Diffstat (limited to 'src/main/java/com/c2kernel/entity/imports')
6 files changed, 49 insertions, 55 deletions
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java index a436a03..33619fa 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java @@ -22,10 +22,10 @@ package com.c2kernel.entity.imports; import java.util.ArrayList;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.ObjectAlreadyExists;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.entity.agent.ActiveEntity;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.ItemPath;
@@ -51,7 +51,7 @@ public class ImportAgent extends ModuleImport { }
@Override
- public void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException {
+ public void create(AgentPath agentPath, boolean reset) throws ObjectNotFound, ObjectCannotBeUpdated, CannotManage, ObjectAlreadyExists {
AgentPath newAgent = new AgentPath(getItemPath(), name);
newAgent.setPassword(password);
ActiveEntity newAgentEnt = Gateway.getCorbaServer().createAgent(newAgent);
@@ -63,14 +63,14 @@ public class ImportAgent extends ModuleImport { newAgentEnt.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null);
} catch (Exception ex) {
Logger.error(ex);
- throw new CannotManageException("Error initialising new agent");
+ throw new CannotManage("Error initialising new agent");
}
for (String role : roles) {
RolePath thisRole;
try {
thisRole = Gateway.getLookup().getRolePath(role);
- } catch (ObjectNotFoundException ex) {
- throw new ObjectNotFoundException("Role "+role+" does not exist.", "");
+ } catch (ObjectNotFound ex) {
+ throw new ObjectNotFound("Role "+role+" does not exist.");
}
Gateway.getLookupManager().addRole(newAgent, thisRole);
}
@@ -83,7 +83,7 @@ public class ImportAgent extends ModuleImport { try {
AgentPath existAgent = Gateway.getLookup().getAgentPath(name);
itemPath = existAgent;
- } catch (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound ex) {
itemPath = new AgentPath(new ItemPath(), name);
}
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java index b8e9eb2..5d2c350 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java @@ -25,8 +25,9 @@ import java.util.ArrayList; import com.c2kernel.collection.Aggregation;
import com.c2kernel.collection.AggregationDescription;
import com.c2kernel.collection.AggregationInstance;
-import com.c2kernel.collection.MembershipException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.InvalidItemPathException;
@@ -52,7 +53,7 @@ public class ImportAggregation { this.isDescription = isDescription;
}
- public com.c2kernel.collection.Aggregation create() throws MembershipException, ObjectNotFoundException {
+ public com.c2kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFound, ObjectAlreadyExists {
Aggregation newAgg = isDescription?new AggregationDescription(name):new AggregationInstance(name);
if (version!= null) newAgg.setVersion(version);
for (ImportAggregationMember thisMem : aggregationMemberList) {
@@ -73,15 +74,16 @@ public class ImportAggregation { classProps.append((classProps.length()>0?",":"")).append(pd.getName());
}
}
+ ItemPath itemPath = null;
if (thisMem.itemPath != null && thisMem.itemPath.length()>0) {
- ItemPath itemPath;
+
try {
itemPath = new ItemPath(thisMem.itemPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemPath).getItemPath();
}
- newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
}
+ newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
}
return newAgg;
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java index 3f528bf..7373bdb 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java @@ -24,8 +24,9 @@ import java.util.ArrayList; import com.c2kernel.collection.Dependency;
import com.c2kernel.collection.DependencyDescription;
-import com.c2kernel.collection.MembershipException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
@@ -64,8 +65,9 @@ public class ImportDependency { /**
* @return
+ * @throws ObjectAlreadyExists
*/
- public com.c2kernel.collection.Dependency create() throws MembershipException, ObjectNotFoundException {
+ public com.c2kernel.collection.Dependency create() throws InvalidCollectionModification, ObjectNotFound, ObjectAlreadyExists {
Dependency newDep = isDescription?new DependencyDescription(name):new Dependency(name);
if (version!= null) newDep.setVersion(version);
if (itemDescriptionPath != null && itemDescriptionPath.length()>0) {
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportItem.java b/src/main/java/com/c2kernel/entity/imports/ImportItem.java index ba24289..74362d5 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportItem.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportItem.java @@ -29,12 +29,13 @@ import org.custommonkey.xmlunit.XMLUnit; import com.c2kernel.collection.Aggregation;
import com.c2kernel.collection.CollectionArrayList;
import com.c2kernel.collection.Dependency;
-import com.c2kernel.collection.MembershipException;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectAlreadyExists;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.TraceableEntity;
import com.c2kernel.events.Event;
import com.c2kernel.events.History;
@@ -44,7 +45,6 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.persistency.outcome.Viewpoint;
import com.c2kernel.process.Gateway;
@@ -90,7 +90,7 @@ public class ImportItem extends ModuleImport { if (existingItem.exists()) {
try {
itemPath = existingItem.getItemPath();
- } catch (ObjectNotFoundException ex) { }
+ } catch (ObjectNotFound ex) { }
}
}
if (itemPath == null) itemPath = new ItemPath();
@@ -109,12 +109,12 @@ public class ImportItem extends ModuleImport { }
@Override
- public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
+ public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFound, CannotManage, ObjectAlreadyExists, InvalidCollectionModification {
DomainPath domPath = new DomainPath(new DomainPath(initialPath), name);
if (domPath.exists()) {
ItemPath domItem = domPath.getItemPath();
if (!getItemPath().equals(domItem))
- throw new CannotManageException("Item "+domPath+" was found with the wrong itemPath ("+domPath.getItemPath()+" vs "+getItemPath()+")", "");
+ throw new CannotManage("Item "+domPath+" was found with the wrong itemPath ("+domPath.getItemPath()+" vs "+getItemPath()+")");
}
TraceableEntity newItem;
@@ -139,32 +139,22 @@ public class ImportItem extends ModuleImport { else usedWfVer = workflowVer.intValue();
try {
compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, usedWfVer);
- } catch (ObjectNotFoundException ex) {
- throw new CannotManageException("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath, "");
- } catch (InvalidDataException e) {
- throw new CannotManageException("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid", "");
+ } catch (ObjectNotFound ex) {
+ throw new CannotManage("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath);
+ } catch (InvalidData e) {
+ throw new CannotManage("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid");
}
// create collections
CollectionArrayList colls = new CollectionArrayList();
for (ImportDependency element: dependencyList) {
- try {
- Dependency newDep = element.create();
- colls.put(newDep);
- } catch (MembershipException ex) {
- Logger.error(ex);
- throw new CannotManageException("A specified member is not of the correct type in "+element.name, "");
- }
+ Dependency newDep = element.create();
+ colls.put(newDep);
}
for (ImportAggregation element : aggregationList) {
- try {
- Aggregation newAgg = element.create();
- colls.put(newAgg);
- } catch (MembershipException ex) {
- Logger.error(ex);
- throw new CannotManageException("A specified member is not of the correct type in "+element.name, "");
- }
+ Aggregation newAgg = element.create();
+ colls.put(newAgg);
}
// (re)initialise the new item with properties, workflow and collections
@@ -177,7 +167,7 @@ public class ImportItem extends ModuleImport { } catch (Exception ex) {
Logger.error("Error initialising new item "+name );
Logger.error(ex);
- throw new CannotManageException("Problem initialising new item. See server log.", "");
+ throw new CannotManage("Problem initialising new item. See server log.");
}
// import outcomes
@@ -202,12 +192,12 @@ public class ImportItem extends ModuleImport { continue;
}
}
- } catch (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound ex) {
Logger.msg(3, "View "+thisOutcome.schema+"/"+thisOutcome.viewname+" not found in "+name+". Creating.");
impView = new Viewpoint(getItemPath(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, -1);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
throw new ObjectCannotBeUpdated("Could not check data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name);
- } catch (InvalidDataException e) {
+ } catch (InvalidData e) {
throw new ObjectCannotBeUpdated("Could not check previous event for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name);
}
@@ -219,7 +209,7 @@ public class ImportItem extends ModuleImport { try {
Gateway.getStorage().put(getItemPath(), newOutcome, null);
Gateway.getStorage().put(getItemPath(), impView, null);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
throw new ObjectCannotBeUpdated("Could not store data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name);
}
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java b/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java index 60279dc..915f52d 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java @@ -20,7 +20,7 @@ */
package com.c2kernel.entity.imports;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.process.Gateway;
public class ImportOutcome {
@@ -38,7 +38,7 @@ public class ImportOutcome { this.path = path;
}
- public String getData(String ns) throws ObjectNotFoundException {
+ public String getData(String ns) throws ObjectNotFound {
if (data == null)
data = Gateway.getResource().getTextResource(ns, path);
return data;
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportRole.java b/src/main/java/com/c2kernel/entity/imports/ImportRole.java index 25e6c36..2c24887 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportRole.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportRole.java @@ -22,10 +22,10 @@ package com.c2kernel.entity.imports; import java.util.Iterator;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.ObjectAlreadyExists;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.Path;
import com.c2kernel.lookup.RolePath;
@@ -40,7 +40,7 @@ public class ImportRole extends ModuleImport { }
@Override
- public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException {
+ public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExists, ObjectCannotBeUpdated, CannotManage, ObjectNotFound {
RolePath parent = new RolePath();
if (name.indexOf('/') > -1) {
String[] roleComp = name.split("/");
@@ -55,7 +55,7 @@ public class ImportRole extends ModuleImport { break;
}
}
- if (!found) throw new ObjectNotFoundException("Parent role "+roleComp[i]+" was not found", "");
+ if (!found) throw new ObjectNotFound("Parent role "+roleComp[i]+" was not found");
}
name = roleComp[roleComp.length-1];
}
|
