mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Action/Rule decoupling work
- Updated web services, SDK and web client where appropraite - Patch added to migrate existing rules - Entire rule service can now be disabled programmatically - Rule service is now disabled during the patching process - StoreEnum and languageEnum types removed from web service interfaces - Multiple rule types now supported in the repo (but not in the UI) - Removed owning node ref from action and rule .. now calculated from methods on the rule service git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3464 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,11 +37,9 @@ import org.alfresco.repo.webservice.types.ParentReference;
|
||||
import org.alfresco.repo.webservice.types.Predicate;
|
||||
import org.alfresco.repo.webservice.types.PropertyDefinition;
|
||||
import org.alfresco.repo.webservice.types.Query;
|
||||
import org.alfresco.repo.webservice.types.QueryLanguageEnum;
|
||||
import org.alfresco.repo.webservice.types.Reference;
|
||||
import org.alfresco.repo.webservice.types.RoleDefinition;
|
||||
import org.alfresco.repo.webservice.types.Store;
|
||||
import org.alfresco.repo.webservice.types.StoreEnum;
|
||||
import org.alfresco.repo.webservice.types.Version;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -80,6 +78,12 @@ public class Utils
|
||||
// don't allow construction
|
||||
}
|
||||
|
||||
/** Query language names */
|
||||
public static final String QUERY_LANG_LUCENE = "lucene";
|
||||
public static final String QUERY_LANG_XPATH = "xpath";
|
||||
public static final String QUERY_LANG_CQL = "cql";
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to convert from a string representation of a property value into the correct object representation.
|
||||
*
|
||||
@@ -222,7 +226,7 @@ public class Utils
|
||||
*/
|
||||
public static StoreRef convertToStoreRef(Store store)
|
||||
{
|
||||
return new StoreRef(store.getScheme().getValue(), store.getAddress());
|
||||
return new StoreRef(store.getScheme(), store.getAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +238,7 @@ public class Utils
|
||||
*/
|
||||
public static Store convertToStore(StoreRef ref)
|
||||
{
|
||||
return new Store(StoreEnum.fromValue(ref.getProtocol()), ref
|
||||
return new Store(ref.getProtocol(), ref
|
||||
.getIdentifier());
|
||||
}
|
||||
|
||||
@@ -284,8 +288,7 @@ public class Utils
|
||||
public static Reference convertToReference(NodeRef node)
|
||||
{
|
||||
Reference ref = new Reference();
|
||||
Store store = new Store(StoreEnum.fromValue(node.getStoreRef()
|
||||
.getProtocol()), node.getStoreRef().getIdentifier());
|
||||
Store store = new Store(node.getStoreRef().getProtocol(), node.getStoreRef().getIdentifier());
|
||||
ref.setStore(store);
|
||||
ref.setUuid(node.getId());
|
||||
return ref;
|
||||
@@ -351,7 +354,7 @@ public class Utils
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(
|
||||
"Failed to resolve to a single NodeRef with parameters (store=");
|
||||
builder.append(store.getScheme().getValue()).append(":")
|
||||
builder.append(store.getScheme()).append(":")
|
||||
.append(store.getAddress());
|
||||
builder.append(" uuid=").append(uuid);
|
||||
builder.append(" path=").append(path).append("), found ");
|
||||
@@ -425,13 +428,11 @@ public class Utils
|
||||
"A Store has to be supplied to in order to execute a query.");
|
||||
}
|
||||
|
||||
QueryLanguageEnum langEnum = query.getLanguage();
|
||||
|
||||
if (langEnum.equals(QueryLanguageEnum.cql)
|
||||
|| langEnum.equals(QueryLanguageEnum.xpath))
|
||||
String language = query.getLanguage();
|
||||
if (language.equals(QUERY_LANG_LUCENE) != true)
|
||||
{
|
||||
throw new IllegalArgumentException("Only '"
|
||||
+ QueryLanguageEnum.lucene.getValue()
|
||||
+ QUERY_LANG_LUCENE
|
||||
+ "' queries are currently supported!");
|
||||
}
|
||||
|
||||
@@ -440,8 +441,7 @@ public class Utils
|
||||
try
|
||||
{
|
||||
searchResults = searchService.query(Utils
|
||||
.convertToStoreRef(predicate.getStore()), langEnum
|
||||
.getValue(), query.getStatement());
|
||||
.convertToStoreRef(predicate.getStore()), language, query.getStatement());
|
||||
// get hold of all the NodeRef's from the results
|
||||
nodeRefs = searchResults.getNodeRefs();
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import org.alfresco.repo.action.ActionConditionImpl;
|
||||
import org.alfresco.repo.action.ActionImpl;
|
||||
import org.alfresco.repo.action.CompositeActionImpl;
|
||||
import org.alfresco.repo.action.executer.CompositeActionExecuter;
|
||||
import org.alfresco.repo.rule.RuleImpl;
|
||||
import org.alfresco.repo.transaction.TransactionComponent;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
@@ -482,26 +481,17 @@ public class ActionWebService extends AbstractWebService implements ActionServic
|
||||
}
|
||||
}
|
||||
|
||||
// Get the reference to the 'owning' node
|
||||
NodeRef owningNodeRef = action.getOwningNodeRef();
|
||||
Reference reference = null;
|
||||
if (owningNodeRef != null)
|
||||
{
|
||||
reference = Utils.convertToReference(owningNodeRef);
|
||||
}
|
||||
|
||||
// Create the web service action object
|
||||
org.alfresco.repo.webservice.action.Action webServiceAction = new org.alfresco.repo.webservice.action.Action(
|
||||
Utils.convertToReference(action.getNodeRef()),
|
||||
action.getId(),
|
||||
action.getActionDefinitionName(),
|
||||
action.getTitle(),
|
||||
action.getDescription(),
|
||||
action.getExecuteAsychronously(),
|
||||
namedValues,
|
||||
webServiceConditions,
|
||||
webServiceCompensatingAction,
|
||||
childWebServiceActions,
|
||||
reference);
|
||||
childWebServiceActions);
|
||||
|
||||
return webServiceAction;
|
||||
}
|
||||
@@ -638,15 +628,12 @@ public class ActionWebService extends AbstractWebService implements ActionServic
|
||||
id = GUID.generate();
|
||||
}
|
||||
|
||||
// Get the owning node ref
|
||||
NodeRef owningNodeRef = null;
|
||||
if (webServiceAction.getReference() != null)
|
||||
// Try and get the action node reference
|
||||
NodeRef actionNodeRef = null;
|
||||
Reference actionReference = webServiceAction.getActionReference();
|
||||
if (actionReference != null)
|
||||
{
|
||||
owningNodeRef = Utils.convertToNodeRef(
|
||||
webServiceAction.getReference(),
|
||||
this.nodeService,
|
||||
this.searchService,
|
||||
this.namespaceService);
|
||||
actionNodeRef = Utils.convertToNodeRef(actionReference, this.nodeService, this.searchService, this.namespaceService);
|
||||
}
|
||||
|
||||
// Create the action (or composite action)
|
||||
@@ -654,20 +641,16 @@ public class ActionWebService extends AbstractWebService implements ActionServic
|
||||
String actionDefinitionName = webServiceAction.getActionName();
|
||||
if (CompositeActionExecuter.NAME.equals(actionDefinitionName) == true)
|
||||
{
|
||||
action = new CompositeActionImpl(id, owningNodeRef);
|
||||
action = new CompositeActionImpl(actionNodeRef, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
action = new ActionImpl(id, actionDefinitionName, owningNodeRef);
|
||||
action = new ActionImpl(actionNodeRef, id, actionDefinitionName);
|
||||
}
|
||||
|
||||
// Set some of the action's details
|
||||
action.setTitle(webServiceAction.getTitle());
|
||||
action.setDescription(webServiceAction.getDescription());
|
||||
if (webServiceAction.isExecuteAsynchronously() == true)
|
||||
{
|
||||
action.setExecuteAsynchronously(true);
|
||||
}
|
||||
|
||||
// Set the parameters
|
||||
NamedValue[] namedValues = webServiceAction.getParameters();
|
||||
@@ -958,51 +941,23 @@ public class ActionWebService extends AbstractWebService implements ActionServic
|
||||
}
|
||||
|
||||
private org.alfresco.repo.webservice.action.Rule convertToWebServiceRule(Rule rule)
|
||||
{
|
||||
// Get the run as user
|
||||
// TODO for now set to null since this has no effect yet
|
||||
String runAsUserName = null;
|
||||
|
||||
// Get the conditions
|
||||
List<ActionCondition> conditions = rule.getActionConditions();
|
||||
Condition[] webServiceConditions = new Condition[conditions.size()];
|
||||
int index2 = 0;
|
||||
for (ActionCondition condition : conditions)
|
||||
{
|
||||
webServiceConditions[index2] = convertToWebServiceCondition(condition);
|
||||
index2++;
|
||||
}
|
||||
|
||||
// Sort out any sub-actions
|
||||
org.alfresco.repo.webservice.action.Action[] childWebServiceActions = null;
|
||||
List<Action> childActions = rule.getActions();
|
||||
childWebServiceActions = new org.alfresco.repo.webservice.action.Action[childActions.size()];
|
||||
int index3 = 0;
|
||||
for (Action childAction : childActions)
|
||||
{
|
||||
childWebServiceActions[index3] = convertToWebServiceAction(childAction);
|
||||
index3 ++;
|
||||
}
|
||||
|
||||
// Get the reference to the 'owning' node
|
||||
NodeRef owningNodeRef = rule.getOwningNodeRef();
|
||||
Reference reference = null;
|
||||
{
|
||||
Reference owningReference = null;
|
||||
NodeRef owningNodeRef = this.ruleService.getOwningNodeRef(rule);
|
||||
if (owningNodeRef != null)
|
||||
{
|
||||
reference = Utils.convertToReference(owningNodeRef);
|
||||
owningReference = Utils.convertToReference(owningNodeRef);
|
||||
}
|
||||
|
||||
// Create the web service rule object
|
||||
org.alfresco.repo.webservice.action.Rule webServiceRule = new org.alfresco.repo.webservice.action.Rule(
|
||||
rule.getId(),
|
||||
rule.getRuleTypeName(),
|
||||
Utils.convertToReference(rule.getNodeRef()),
|
||||
owningReference,
|
||||
rule.getRuleTypes().toArray(new String[rule.getRuleTypes().size()]),
|
||||
rule.getTitle(),
|
||||
rule.getDescription(),
|
||||
rule.getExecuteAsychronously(),
|
||||
webServiceConditions,
|
||||
childWebServiceActions,
|
||||
runAsUserName,
|
||||
reference);
|
||||
rule.getExecuteAsynchronously(),
|
||||
convertToWebServiceAction(rule.getAction()));
|
||||
|
||||
return webServiceRule;
|
||||
}
|
||||
@@ -1123,56 +1078,38 @@ public class ActionWebService extends AbstractWebService implements ActionServic
|
||||
* @return
|
||||
*/
|
||||
private Rule convertToRule(org.alfresco.repo.webservice.action.Rule webServiceRule)
|
||||
{
|
||||
// If the id is null then generate one
|
||||
String id = webServiceRule.getId();
|
||||
if (id == null || id.length() == 0)
|
||||
{
|
||||
NodeRef ruleNodeRef = null;
|
||||
if (webServiceRule.getRuleReference() != null)
|
||||
{
|
||||
id = GUID.generate();
|
||||
}
|
||||
|
||||
// Get the owning node ref
|
||||
NodeRef owningNodeRef = null;
|
||||
if (webServiceRule.getReference() != null)
|
||||
{
|
||||
owningNodeRef = Utils.convertToNodeRef(
|
||||
webServiceRule.getReference(),
|
||||
this.nodeService,
|
||||
this.searchService,
|
||||
this.namespaceService);
|
||||
ruleNodeRef = Utils.convertToNodeRef(
|
||||
webServiceRule.getRuleReference(),
|
||||
this.nodeService,
|
||||
this.searchService,
|
||||
this.namespaceService);
|
||||
}
|
||||
|
||||
// Get the rule type name
|
||||
String ruleTypeName = webServiceRule.getRuleType();
|
||||
String[] ruleTypes = webServiceRule.getRuleTypes();
|
||||
|
||||
// Create the rule
|
||||
RuleImpl rule = new RuleImpl(id, ruleTypeName, owningNodeRef);
|
||||
Rule rule = new Rule();
|
||||
List<String> ruleTypesList = new ArrayList<String>(ruleTypes.length);
|
||||
for (String ruleType : ruleTypes)
|
||||
{
|
||||
ruleTypesList.add(ruleType);
|
||||
}
|
||||
rule.setRuleTypes(ruleTypesList);
|
||||
rule.setNodeRef(ruleNodeRef);
|
||||
|
||||
// Set some of the rules details
|
||||
rule.setTitle(webServiceRule.getTitle());
|
||||
rule.setDescription(webServiceRule.getDescription());
|
||||
rule.setExecuteAsynchronously(webServiceRule.isExecuteAsynchronously());
|
||||
rule.setExecuteAsynchronously(webServiceRule.isExecuteAsynchronously());
|
||||
|
||||
// Set the conditions
|
||||
Condition[] webServiceConditions = webServiceRule.getConditions();
|
||||
if (webServiceConditions != null)
|
||||
{
|
||||
for (Condition webServiceCondition : webServiceConditions)
|
||||
{
|
||||
rule.addActionCondition(convertToActionCondition(webServiceCondition));
|
||||
}
|
||||
}
|
||||
|
||||
// Set the child actions
|
||||
org.alfresco.repo.webservice.action.Action[] webServiceChildActions = webServiceRule.getActions();
|
||||
if (webServiceChildActions != null)
|
||||
{
|
||||
for (org.alfresco.repo.webservice.action.Action webServiceChildAction : webServiceChildActions)
|
||||
{
|
||||
Action childAction = convertToAction(webServiceChildAction);
|
||||
rule.addAction(childAction);
|
||||
}
|
||||
}
|
||||
// Set the action
|
||||
Action action = convertToAction(webServiceRule.getAction());
|
||||
rule.setAction(action);
|
||||
|
||||
return rule;
|
||||
}
|
||||
|
@@ -68,10 +68,12 @@ public class AuthenticationWebService implements AuthenticationServiceSoapPort
|
||||
}
|
||||
catch (AuthenticationException ae)
|
||||
{
|
||||
ae.printStackTrace();
|
||||
throw new AuthenticationFault(100, ae.getMessage());
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new AuthenticationFault(0, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -35,10 +35,8 @@ import org.alfresco.repo.webservice.types.Node;
|
||||
import org.alfresco.repo.webservice.types.NodeDefinition;
|
||||
import org.alfresco.repo.webservice.types.Predicate;
|
||||
import org.alfresco.repo.webservice.types.Query;
|
||||
import org.alfresco.repo.webservice.types.QueryLanguageEnum;
|
||||
import org.alfresco.repo.webservice.types.Reference;
|
||||
import org.alfresco.repo.webservice.types.Store;
|
||||
import org.alfresco.repo.webservice.types.StoreEnum;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
@@ -103,14 +101,10 @@ public class RepositoryWebService extends AbstractWebService implements
|
||||
/**
|
||||
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#createStore(org.alfresco.repo.webservice.types.StoreEnum, java.lang.String)
|
||||
*/
|
||||
public Store createStore(StoreEnum scheme, String address) throws RemoteException, RepositoryFault
|
||||
public Store createStore(String scheme, String address) throws RemoteException, RepositoryFault
|
||||
{
|
||||
String protocol = scheme.getValue();
|
||||
StoreRef storeRef = this.nodeService.createStore(protocol, address);
|
||||
|
||||
StoreEnum storeEnum = StoreEnum.fromString(storeRef
|
||||
.getProtocol());
|
||||
return new Store(storeEnum, storeRef.getIdentifier());
|
||||
StoreRef storeRef = this.nodeService.createStore(scheme, address);
|
||||
return Utils.convertToStore(storeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,9 +130,7 @@ public class RepositoryWebService extends AbstractWebService implements
|
||||
logger.debug("Store protocol :" + storeRef.getProtocol());
|
||||
}
|
||||
|
||||
StoreEnum storeEnum = StoreEnum.fromString(storeRef
|
||||
.getProtocol());
|
||||
Store store = new Store(storeEnum, storeRef.getIdentifier());
|
||||
Store store = Utils.convertToStore(storeRef);
|
||||
returnStores[x] = store;
|
||||
}
|
||||
|
||||
@@ -175,13 +167,11 @@ public class RepositoryWebService extends AbstractWebService implements
|
||||
public QueryResult query(Store store, Query query, boolean includeMetaData)
|
||||
throws RemoteException, RepositoryFault
|
||||
{
|
||||
QueryLanguageEnum langEnum = query.getLanguage();
|
||||
|
||||
if (langEnum.equals(QueryLanguageEnum.cql)
|
||||
|| langEnum.equals(QueryLanguageEnum.xpath))
|
||||
String language = query.getLanguage();
|
||||
if (language.equals(Utils.QUERY_LANG_LUCENE) == false)
|
||||
{
|
||||
throw new RepositoryFault(110, "Only '"
|
||||
+ QueryLanguageEnum.lucene.getValue()
|
||||
+ Utils.QUERY_LANG_LUCENE
|
||||
+ "' queries are currently supported!");
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ public class ResultSetQuerySession extends AbstractQuerySession
|
||||
try
|
||||
{
|
||||
searchResults = searchService.query(Utils.convertToStoreRef(this.store),
|
||||
this.query.getLanguage().getValue(), statement);
|
||||
this.query.getLanguage(), statement);
|
||||
|
||||
int totalRows = searchResults.length();
|
||||
int lastRow = calculateLastRowIndex(totalRows);
|
||||
@@ -174,8 +174,8 @@ public class ResultSetQuerySession extends AbstractQuerySession
|
||||
builder.append(" (id=").append(getId());
|
||||
builder.append(" batchSize=").append(this.batchSize);
|
||||
builder.append(" position=").append(this.position);
|
||||
builder.append(" store=").append(this.store.getScheme().getValue()).append(":").append(this.store.getAddress());
|
||||
builder.append(" language=").append(this.query.getLanguage().getValue());
|
||||
builder.append(" store=").append(this.store.getScheme()).append(":").append(this.store.getAddress());
|
||||
builder.append(" language=").append(this.query.getLanguage());
|
||||
builder.append(" statement=").append(this.query.getStatement());
|
||||
builder.append(")");
|
||||
return builder.toString();
|
||||
|
Reference in New Issue
Block a user