diff options
Diffstat (limited to 'src/main/java/com/c2kernel/entity/proxy/AgentProxy.java')
| -rw-r--r-- | src/main/java/com/c2kernel/entity/proxy/AgentProxy.java | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 10a8f02..7e6b3e4 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -24,10 +24,11 @@ import java.util.Date; import java.util.Iterator;
import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.InvalidTransition;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.Agent;
import com.c2kernel.entity.AgentHelper;
@@ -68,7 +69,7 @@ public class AgentProxy extends ItemProxy **************************************************************************/
protected AgentProxy( org.omg.CORBA.Object ior,
AgentPath agentPath)
- throws ObjectNotFoundException
+ throws ObjectNotFound
{
super(ior, agentPath);
mAgentPath = agentPath;
@@ -83,12 +84,12 @@ public class AgentProxy extends ItemProxy }
@Override
- public Agent narrow() throws ObjectNotFoundException
+ public Agent narrow() throws ObjectNotFound
{
try {
return AgentHelper.narrow(mIOR);
} catch (org.omg.CORBA.BAD_PARAM ex) { }
- throw new ObjectNotFoundException("CORBA Object was not an Agent, or the server is down.");
+ throw new ObjectNotFound("CORBA Object was not an Agent, or the server is down.");
}
/**
@@ -97,21 +98,22 @@ public class AgentProxy extends ItemProxy *
* @param job
* @throws AccessRightsException
- * @throws InvalidDataException
- * @throws InvalidTransitionException
- * @throws ObjectNotFoundException
+ * @throws InvalidData
+ * @throws InvalidTransition
+ * @throws ObjectNotFound
* @throws PersistencyException
- * @throws ObjectAlreadyExistsException
+ * @throws ObjectAlreadyExists
* @throws ScriptErrorException
+ * @throws InvalidCollectionModification
*/
public String execute(Job job)
throws AccessRightsException,
- InvalidDataException,
- InvalidTransitionException,
- ObjectNotFoundException,
+ InvalidData,
+ InvalidTransition,
+ ObjectNotFound,
PersistencyException,
- ObjectAlreadyExistsException,
- ScriptErrorException
+ ObjectAlreadyExists,
+ ScriptErrorException, InvalidCollectionModification
{
ItemProxy item = Gateway.getProxyManager().getProxy(job.getItemPath());
OutcomeValidator validator = null;
@@ -128,12 +130,12 @@ public class AgentProxy extends ItemProxy Schema schema = LocalObjectLoader.getSchema(schemaName, schemaVersion);
if (schema == null)
- throw new InvalidDataException("Job references outcome type "+schemaName+" version "+schemaVersion+" that does not exist in this centre.", "");
+ throw new InvalidData("Job references outcome type "+schemaName+" version "+schemaVersion+" that does not exist in this centre.");
try {
validator = OutcomeValidator.getValidator(schema);
} catch (Exception e) {
- throw new InvalidDataException("Could not create validator: "+e.getMessage(), "");
+ throw new InvalidData("Could not create validator: "+e.getMessage());
}
}
@@ -147,7 +149,7 @@ public class AgentProxy extends ItemProxy String error = validator.validate(job.getOutcomeString());
if (error.length() > 0) {
Logger.error("Outcome not valid: \n " + error);
- throw new InvalidDataException(error, "");
+ throw new InvalidData(error);
}
}
@@ -162,7 +164,7 @@ public class AgentProxy extends ItemProxy Logger.warning("Script errors: "+errorString);
} catch (ScriptingEngineException ex) {
Logger.error(ex);
- throw new InvalidDataException(ex.getMessage(), "");
+ throw new InvalidData(ex.getMessage());
}
}
@@ -170,7 +172,7 @@ public class AgentProxy extends ItemProxy Logger.msg(3, "AgentProxy - validating outcome");
String error = validator.validate(job.getOutcomeString());
if (error.length() > 0)
- throw new InvalidDataException(error, "");
+ throw new InvalidData(error);
}
job.setAgentPath(mAgentPath);
@@ -192,18 +194,18 @@ public class AgentProxy extends ItemProxy public String execute(ItemProxy item, String predefStep, C2KLocalObject obj)
throws AccessRightsException,
- InvalidDataException,
- InvalidTransitionException,
- ObjectNotFoundException,
+ InvalidData,
+ InvalidTransition,
+ ObjectNotFound,
PersistencyException,
- ObjectAlreadyExistsException
+ ObjectAlreadyExists, InvalidCollectionModification
{
String param;
try {
param = marshall(obj);
} catch (Exception ex) {
Logger.error(ex);
- throw new InvalidDataException("Error on marshall", "");
+ throw new InvalidData("Error on marshall");
}
return execute(item, predefStep, param);
}
@@ -220,19 +222,20 @@ public class AgentProxy extends ItemProxy * @return The outcome after processing. May have been altered by the step.
*
* @throws AccessRightsException The agent was not allowed to execute this step
- * @throws InvalidDataException The parameters supplied were incorrect
- * @throws InvalidTransitionException The step wasn't available
- * @throws ObjectNotFoundException Thrown by some steps that try to locate additional objects
+ * @throws InvalidData The parameters supplied were incorrect
+ * @throws InvalidTransition The step wasn't available
+ * @throws ObjectNotFound Thrown by some steps that try to locate additional objects
* @throws PersistencyException Problem writing or reading the database
- * @throws ObjectAlreadyExistsException Thrown by steps that create additional object
+ * @throws ObjectAlreadyExists Thrown by steps that create additional object
+ * @throws InvalidCollectionModification
*/
public String execute(ItemProxy item, String predefStep, String[] params)
throws AccessRightsException,
- InvalidDataException,
- InvalidTransitionException,
- ObjectNotFoundException,
+ InvalidData,
+ InvalidTransition,
+ ObjectNotFound,
PersistencyException,
- ObjectAlreadyExistsException
+ ObjectAlreadyExists, InvalidCollectionModification
{
String schemaName = PredefinedStep.getPredefStepSchemaName(predefStep);
String param;
@@ -254,20 +257,21 @@ public class AgentProxy extends ItemProxy * @param param
* @return
* @throws AccessRightsException
- * @throws InvalidDataException
- * @throws InvalidTransitionException
- * @throws ObjectNotFoundException
+ * @throws InvalidData
+ * @throws InvalidTransition
+ * @throws ObjectNotFound
* @throws PersistencyException
- * @throws ObjectAlreadyExistsException
+ * @throws ObjectAlreadyExists
+ * @throws InvalidCollectionModification
*/
public String execute(ItemProxy item, String predefStep, String param)
throws AccessRightsException,
- InvalidDataException,
- InvalidTransitionException,
- ObjectNotFoundException,
+ InvalidData,
+ InvalidTransition,
+ ObjectNotFound,
PersistencyException,
- ObjectAlreadyExistsException
+ ObjectAlreadyExists, InvalidCollectionModification
{
return execute(item, predefStep, new String[] {param });
}
@@ -282,24 +286,24 @@ public class AgentProxy extends ItemProxy }
/** Let scripts resolve items */
- public ItemProxy searchItem(String name) throws ObjectNotFoundException {
+ public ItemProxy searchItem(String name) throws ObjectNotFound {
Iterator<Path> results = Gateway.getLookup().search(new DomainPath(""),name);
Path returnPath = null;
if (!results.hasNext())
- throw new ObjectNotFoundException(name, "");
+ throw new ObjectNotFound(name);
while(results.hasNext()) {
Path nextMatch = results.next();
if (returnPath != null && nextMatch.getUUID() != null && !returnPath.getUUID().equals(nextMatch.getUUID()))
- throw new ObjectNotFoundException("Too many items with that name");
+ throw new ObjectNotFound("Too many items with that name");
returnPath = nextMatch;
}
return Gateway.getProxyManager().getProxy(returnPath);
}
- public ItemProxy getItem(String itemPath) throws ObjectNotFoundException {
+ public ItemProxy getItem(String itemPath) throws ObjectNotFound {
return (getItem(new DomainPath(itemPath)));
}
@@ -308,11 +312,11 @@ public class AgentProxy extends ItemProxy return mAgentPath;
}
- public ItemProxy getItem(Path itemPath) throws ObjectNotFoundException {
+ public ItemProxy getItem(Path itemPath) throws ObjectNotFound {
return Gateway.getProxyManager().getProxy(itemPath);
}
- public ItemProxy getItemByUUID(String uuid) throws ObjectNotFoundException, InvalidItemPathException {
+ public ItemProxy getItemByUUID(String uuid) throws ObjectNotFound, InvalidItemPathException {
return Gateway.getProxyManager().getProxy(new ItemPath(uuid));
}
}
|
