use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class AgentImplementation method refreshJobList.
/**
* Updates an Agent's list of Jobs relating to a particular activity. Only
* Activities that are assigned to a Role that is flagged to push Jobs do this.
*/
@Override
public synchronized void refreshJobList(SystemKey sysKey, String stepPath, String newJobs) {
try {
ItemPath itemPath = new ItemPath(sysKey);
JobArrayList newJobList = (JobArrayList) Gateway.getMarshaller().unmarshall(newJobs);
List<String> keysToRemove = currentJobs.getKeysForStep(itemPath, stepPath);
// merge new jobs in first, so the RemoteMap.getLastId() used during addJob() returns the next unique id
for (Job newJob : newJobList.list) {
Logger.msg(6, "AgentImplementation.refreshJobList() - Adding job:" + newJob.getItemPath() + "/" + newJob.getStepPath() + ":" + newJob.getTransition().getName());
currentJobs.addJob(newJob);
}
// remove old jobs for this item0
for (String key : keysToRemove) currentJobs.remove(key);
Gateway.getStorage().commit(mItemPath);
} catch (Throwable ex) {
Logger.error("Could not refresh job list.");
Logger.error(ex);
Gateway.getStorage().abort(mItemPath);
}
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class AgentProxy method searchItem.
/**
* Let scripts resolve items
*/
public ItemProxy searchItem(Path root, String name) throws ObjectNotFoundException {
Iterator<Path> results = Gateway.getLookup().search(root, name);
Path returnPath = null;
if (!results.hasNext()) {
throw new ObjectNotFoundException(name);
} else {
while (results.hasNext()) {
Path nextMatch = results.next();
if (returnPath != null) {
// found already one but search if there are another, which is an error
if (isItemPathAndNotNull(nextMatch)) {
// test if another itemPath with same name
if (!returnPath.getItemPath().getUUID().equals(nextMatch.getItemPath().getUUID())) {
throw new ObjectNotFoundException("Too many different items with name:" + name);
} else {
returnPath = nextMatch;
}
}
} else {
if (isItemPathAndNotNull(nextMatch)) {
returnPath = nextMatch;
// found one but continue search
Logger.msg(5, "AgentProxy.searchItem() - found for " + name + " UUID = " + returnPath.getItemPath().getUUID());
}
}
}
}
// test if nothing found in the results
if (returnPath == null) {
throw new ObjectNotFoundException(name);
}
return Gateway.getProxyManager().getProxy(returnPath);
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class ProxyClientConnection method setSocket.
@Override
public synchronized void setSocket(Socket newSocket) {
try {
Logger.msg(1, "ProxyClientConnection.setSocket() - clientID " + thisClientId + " connect from " + newSocket.getInetAddress() + ":" + newSocket.getPort());
newSocket.setSoTimeout(500);
clientSocket = newSocket;
response = new PrintWriter(clientSocket.getOutputStream(), true);
subscribedItems = new ArrayList<ItemPath>();
} catch (SocketException ex) {
Logger.error("ProxyClientConnection.setSocket() - Could not set socket timeout:");
Logger.error(ex);
closeSocket();
} catch (IOException ex) {
Logger.error("ProxyClientConnection.setSocket() - Could not setup output stream:");
Logger.error(ex);
closeSocket();
}
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class ProxyClientConnection method sendMessage.
public synchronized void sendMessage(ProxyMessage message) {
// idle
if (clientSocket == null)
return;
boolean relevant = message.getItemPath() == null;
synchronized (subscribedItems) {
for (Iterator<ItemPath> iter = subscribedItems.iterator(); iter.hasNext() && !relevant; ) {
ItemPath thisKey = iter.next();
if (thisKey.equals(message.getItemPath()))
relevant = true;
}
}
// not for our client
if (!relevant)
return;
response.println(message);
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class ImportAggregation method create.
public org.cristalise.kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
Aggregation newAgg = isDescription ? new AggregationDescription(name) : new AggregationInstance(name);
if (version != null)
newAgg.setVersion(version);
for (ImportAggregationMember thisMem : aggregationMemberList) {
StringBuffer classProps = new StringBuffer();
ItemPath itemPath = null;
if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length() > 0) {
try {
itemPath = new ItemPath(thisMem.itemDescriptionPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemDescriptionPath).getItemPath();
}
String descVer = thisMem.itemDescriptionVersion == null ? "last" : thisMem.itemDescriptionVersion;
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
for (PropertyDescription pd : propList.list) {
thisMem.props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
}
}
if (thisMem.itemPath != null && thisMem.itemPath.length() > 0) {
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);
}
return newAgg;
}
Aggregations