Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Releasing 3.6.0 - Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
kovax committed Jan 5, 2019
2 parents ee63d58 + 7845981 commit d68d711
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 98 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<groupId>org.cristalise</groupId>
<artifactId>cristalise-kernel</artifactId>
<name>cristalise-kernel</name>
<version>3.5.0</version>
<version>3.6.0</version>
<description>Cristal-ise is a description-driven software platform originally developed to track the construction of
the CMS ECAL detector of the LHC at CERN. This is its core library, known as the kernel, which manages
business objects called Items. Items are entirely configured from data, called descriptions, held in other Items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public String delegatedAction(SystemKey agentId, SystemKey delegateId, String st
catch (AccessRightsException | InvalidTransitionException | ObjectNotFoundException | PersistencyException |
InvalidDataException | ObjectAlreadyExistsException | InvalidCollectionModification ex)
{
if (Logger.doLog(8)) Logger.error(ex);
Logger.error(ex);

String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);

Expand All @@ -270,7 +270,7 @@ public String delegatedAction(SystemKey agentId, SystemKey delegateId, String st
}
}
catch (InvalidAgentPathException | ObjectCannotBeUpdated | CannotManageException ex) {
if (Logger.doLog(8)) Logger.error(ex);
Logger.error(ex);

String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);

Expand Down Expand Up @@ -423,7 +423,7 @@ public String queryData(String path) throws AccessRightsException, ObjectNotFoun
throw new PersistencyException("Server exception: " + ex.getClass().getName());
}

if (Logger.doLog(9)) Logger.msg(9, "ItemImplementation::queryData(" + mItemPath + ") - result:" + result);
if (Logger.doLog(8)) Logger.msg(9, "ItemImplementation::queryData(" + mItemPath + ") - result:" + result);

return result;
}
Expand Down
137 changes: 94 additions & 43 deletions src/main/java/org/cristalise/kernel/entity/proxy/ItemProxy.java

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/main/java/org/cristalise/kernel/lookup/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ protected Path(String path) {
* Create a path by appending a child string to an existing path
*/
protected Path(Path parent, String child) {
if (child.contains(delim)) throw new IllegalArgumentException("Child name '"+child+"' contains delimiter:"+delim);

mPath = Arrays.copyOf(parent.getPath(), parent.getPath().length + 1);
mPath[mPath.length - 1] = child;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@

public class ParameterException extends ScriptingEngineException {

/**
/**
*
*/
private static final long serialVersionUID = 7549607286659193866L;

/**
* Creates new <code>ParameterException</code> without detail message.
*/
public ParameterException() {
Expand All @@ -35,6 +40,12 @@ public ParameterException() {
public ParameterException(String msg) {
super(msg);
}
}

public ParameterException(Throwable throwable) {
super(throwable);
}

public ParameterException(String message, Throwable throwable) {
super(message, throwable);
}
}
60 changes: 31 additions & 29 deletions src/main/java/org/cristalise/kernel/scripting/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private void parseScriptXML(String scriptXML) throws ScriptParsingException, Par
scriptDoc = domBuilder.parse(new InputSource(new StringReader(scriptXML)));
}
catch (Exception ex) {
throw new ScriptParsingException("Error parsing Script XML : " + ex.toString());
throw new ScriptParsingException("Error parsing Script XML", ex);
}

parseScriptTag (scriptDoc.getElementsByTagName("script"));
Expand Down Expand Up @@ -353,20 +353,9 @@ private void parseIncludeTag(NodeList includeList) throws ScriptParsingException
addIncludedInputParam(includeParam.getName(), includeParam.getType());
}
}
catch (NumberFormatException e) {
throw new ScriptParsingException("Invalid version in imported script name:'"+includeName+"', version:'"+includeVersion+"'");
}
catch (ScriptingEngineException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script "+includeName+" v"+includeVersion+": "+e.getMessage());
}
catch (ObjectNotFoundException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script "+includeName+" v"+includeVersion+" not found.");
}
catch (InvalidDataException e) {
catch (NumberFormatException | ScriptingEngineException | ObjectNotFoundException | InvalidDataException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script "+includeName+" v"+includeVersion+" was invalid: "+e.getMessage());
throw new ScriptParsingException("Included script '"+includeName+" v"+includeVersion+"' parse error", e);
}
}
}
Expand All @@ -382,7 +371,7 @@ private void parseScriptTag(NodeList scriptList) throws ScriptParsingException {
setScriptEngine(scriptElem.getAttribute("language"));
}
catch (ScriptingEngineException ex) {
throw new ScriptParsingException(ex.getMessage());
throw new ScriptParsingException(ex.getMessage(), ex);
}

// get script source from CDATA
Expand Down Expand Up @@ -410,7 +399,7 @@ protected void addInputParam(String name, String type) throws ParameterException
addInputParam(name, Gateway.getResource().getClassForName(type));
}
catch (ClassNotFoundException ex) {
throw new ParameterException("Input parameter " + name + " specifies class " + type + " which was not found.");
throw new ParameterException("Input parameter " + name + " specifies class " + type + " which was not found.", ex);
}
}

Expand Down Expand Up @@ -460,7 +449,7 @@ protected void addOutput(String name, String type) throws ParameterException {
addOutput(name, Gateway.getResource().getClassForName(type));
}
catch (ClassNotFoundException ex) {
throw new ParameterException("Output parameter " + name + " specifies class " + type + " which was not found.");
throw new ParameterException("Output parameter " + name + " specifies class " + type + " which was not found.", ex);
}
}

Expand Down Expand Up @@ -493,7 +482,7 @@ public boolean setInputParamValue(String name, Object value) throws ParameterExc
if (!mAllInputParams.containsKey(name)) return false;

if (param != null) { // param is in this script
if (!param.getType().isInstance(value)) {
if (value != null && !param.getType().isInstance(value)) {
throw new ParameterException( "Parameter "+name+" in script "+mName+" v"+mVersion+" is wrong type \n"+
"Required: "+param.getType().toString()+"\n"+"Supplied: "+value.getClass().toString());
}
Expand Down Expand Up @@ -526,24 +515,30 @@ public Object evaluate(ItemPath itemPath, CastorHashMap inputProps, String actCo
}
}

if (getAllInputParams().containsKey("item"))
setInputParamValue("item", Gateway.getProxyManager().getProxy(itemPath));
if (getAllInputParams().containsKey("item") && getAllInputParams().get("item") != null) {
ItemProxy item = Gateway.getProxyManager().getProxy(itemPath);
item.setTransactionKey(locker);
setInputParamValue("item", item);
}

if (getAllInputParams().containsKey("agent"))
if (getAllInputParams().containsKey("agent") && getAllInputParams().get("agent") != null) {
setInputParamValue("agent", Gateway.getProxyManager().getProxy(Gateway.getLookup().getAgentPath("system")));
}

if (getAllInputParams().containsKey("locker") && getAllInputParams().get("locker") != null) {
setInputParamValue("locker", locker);
}

Object retVal = execute();

if (retVal == null) retVal = "";

//Logger.msg(2, "Script.evaluate("+getName()+") - Script returned:'"+retVal+"'");

return retVal;
}
catch (Exception e) {
Logger.error("Script.evaluate() - Script:" + getName());
Logger.error(e);
throw new ScriptingEngineException(e.getMessage());
throw new ScriptingEngineException(e);
}
}

Expand Down Expand Up @@ -573,7 +568,7 @@ public Object execute() throws ScriptingEngineException {

// croak if any missing
if (missingParams.length() > 0) {
throw new ScriptingEngineException("Execution aborted, the following declared parameters were not set: \n" + missingParams.toString());
throw new ScriptingEngineException("Parameters were not set: \n" + missingParams.toString());
}

initOutputParams();
Expand Down Expand Up @@ -661,7 +656,10 @@ private void initOutputParams() {
try {
emptyObject = outputParam.getType().newInstance();
}
catch (Exception e) {}
catch (Exception e) {
//This case was originally not logged
Logger.warning("Script.initOutputParams() - Failed to init output:%s error:%s", outputParam.getName(), e.getMessage());
}

context.getBindings(ScriptContext.ENGINE_SCOPE).put(outputParam.getName(), emptyObject);
}
Expand Down Expand Up @@ -757,7 +755,7 @@ public void setScriptData(String script) throws ScriptParsingException {
}
catch (ScriptException e) {
Logger.error(e);
throw new ScriptParsingException(e.getMessage());
throw new ScriptParsingException(e);
}
}
}
Expand Down Expand Up @@ -842,9 +840,13 @@ public CollectionArrayList makeDescCollections() throws InvalidDataException, Ob
for (Script script : mIncludes) {
try {
includeColl.addMember(script.getItemPath());
} catch (InvalidCollectionModification e) {
}
catch (InvalidCollectionModification e) {
Logger.error(e);
throw new InvalidDataException("Could not add "+script.getName()+" to description collection. "+e.getMessage());
} catch (ObjectAlreadyExistsException e) {
}
catch (ObjectAlreadyExistsException e) {
Logger.error(e);
throw new InvalidDataException("Script "+script.getName()+" included more than once.");
} //
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,42 @@

public class ScriptErrorException extends java.lang.Exception {

/**
/**
*
*/
private static final long serialVersionUID = -4298189043503060615L;
/**
* Creates new <code>sciptingEngineException</code> without detail message.
*/
ErrorInfo errors;
ErrorInfo errors;

public ScriptErrorException() {
}

/**
* Constructs an <code>sciptingEngineException</code> with the specified detail message.
* @param msg the detail message.
*
* @param msg
* the detail message.
*/
public ScriptErrorException(String msg) {
super(msg);
}

public ScriptErrorException(ErrorInfo errors) {
super(errors.toString());
super(errors.toString());
this.errors = errors;
}

public ErrorInfo getErrors() {
return errors;
}
}
public ErrorInfo getErrors() {
return errors;
}

public ScriptErrorException(Throwable throwable) {
super(throwable);
}

public ScriptErrorException(String message, Throwable throwable) {
super(message, throwable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
*/
package org.cristalise.kernel.scripting;

/**************************************************************************
*
* $Revision: 1.1 $
* $Date: 2003/04/06 12:32:51 $
*
* Copyright (C) 2003 CERN - European Organization for Nuclear Research
* All rights reserved.
**************************************************************************/
public class ScriptLoadingException extends ScriptingEngineException {
/**
/**
*
*/
private static final long serialVersionUID = 395106341865890224L;

/**
*
*/
public ScriptLoadingException() {
Expand All @@ -41,4 +38,12 @@ public ScriptLoadingException() {
public ScriptLoadingException(String msg) {
super(msg);
}

public ScriptLoadingException(Throwable throwable) {
super(throwable);
}

public ScriptLoadingException(String message, Throwable throwable) {
super(message, throwable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@

public class ScriptParsingException extends ScriptingEngineException {

/**
/**
*
*/
private static final long serialVersionUID = 8076468979611699004L;

/**
* Creates new <code>ScriptParsingException</code> without detail message.
*/
public ScriptParsingException() {
Expand All @@ -36,6 +41,14 @@ public ScriptParsingException() {
public ScriptParsingException(String msg) {
super(msg);
}

public ScriptParsingException(Throwable throwable) {
super(throwable);
}

public ScriptParsingException(String message, Throwable throwable) {
super(message, throwable);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
package org.cristalise.kernel.scripting;

public class ScriptingEngineException extends java.lang.Exception {

/**
*
*/
private static final long serialVersionUID = 2902580887959991152L;

/**
* Creates new <code>sciptingEngineException</code> without detail message.
*/
public ScriptingEngineException() {
Expand Down

0 comments on commit d68d711

Please sign in to comment.