use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ActivityDef method makeDescCollection.
public Dependency makeDescCollection(BuiltInCollections collection, DescriptionObject... descs) throws InvalidDataException {
// TODO: restrict membership based on kernel property desc
Dependency descDep = new Dependency(collection.getName());
if (mVersion != null && mVersion > -1) {
descDep.setVersion(mVersion);
}
for (DescriptionObject thisDesc : descs) {
if (thisDesc == null)
continue;
try {
DependencyMember descMem = descDep.addMember(thisDesc.getItemPath());
descMem.setBuiltInProperty(VERSION, thisDesc.getVersion());
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Problem creating description collection for " + thisDesc + " in " + getName());
}
}
return descDep;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class AndSplitDef method getRoutingScript.
public Script getRoutingScript() throws ObjectNotFoundException, InvalidDataException {
String scriptName = (String) getBuiltInProperty(ROUTING_SCRIPT_NAME);
Integer scriptVersion;
try {
String scriptVerStr = (String) getBuiltInProperty(ROUTING_SCRIPT_VERSION);
if (scriptVerStr != null && !scriptVerStr.isEmpty())
scriptVersion = Integer.valueOf(scriptVerStr.toString());
else
throw new ObjectNotFoundException();
} catch (NumberFormatException e) {
throw new InvalidDataException(e.getMessage());
}
return LocalObjectLoader.getScript(scriptName, scriptVersion);
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ActivityRenderer method draw.
/**
* Draws the Activity as a 3D rectangle without borders, with text lines for Name, DefinitionName, State, WaitTime and errors
*/
@Override
public void draw(Graphics2D g2d, Vertex vertex) {
Activity activity = (Activity) vertex;
boolean hasError = !activity.verify();
drawOutline3DRect(g2d, vertex, getActColor(activity, hasError));
// String description = activity.getDescription();
ArrayList<String> linesOfText = new ArrayList<String>();
String type = activity.getTypeName();
if (type != null)
linesOfText.add("(" + type + ")");
linesOfText.add(activity.getName());
if (hasError) {
linesOfText.add(activity.getErrors());
} else {
String stateName = "Invalid State";
try {
stateName = activity.getStateName();
} catch (InvalidDataException | NullPointerException ex) {
}
linesOfText.add(stateName + (" " + getWaitTime(activity.getStateDate())));
}
drawLinesOfTexts(g2d, vertex, linesOfText, mTextPaint);
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class AddDomainPath method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("AddDomainPath: Invalid parameters: " + Arrays.toString(params));
Gateway.getLookupManager().add(new DomainPath(params[0], item));
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class AddNewCollectionDescription method runActivityLogic.
/**
* Params: 0 - collection name 1 - collection type (Aggregation, Dependency)
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException {
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddNewCollectionDescription: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 2)
throw new InvalidDataException("AddNewCollectionDescription: Invalid parameters " + Arrays.toString(params));
String collName = params[0];
String collType = params[1];
// check if collection already exists
try {
Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
throw new ObjectAlreadyExistsException("Collection '" + collName + "' already exists");
} catch (ObjectNotFoundException ex) {
// collection doesn't exist
}
CollectionDescription<?> newCollDesc;
if (collType.equalsIgnoreCase("Aggregation"))
newCollDesc = new AggregationDescription(collName);
else if (collType.equalsIgnoreCase("Dependency"))
newCollDesc = new DependencyDescription(collName);
else
throw new InvalidDataException("AddNewCollectionDescription: Invalid type: '" + collType + "' /Aggregation or Dependency)");
// store it
try {
Gateway.getStorage().put(item, newCollDesc, locker);
} catch (PersistencyException e) {
throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '" + collName + "': " + e.getMessage());
}
return requestData;
}
Aggregations