Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent 59f33f811b
commit 0847deba8f
52 changed files with 931 additions and 1127 deletions

View File

@@ -16,6 +16,8 @@
*/
package org.alfresco.repo.webservice;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,11 +37,15 @@ import org.alfresco.repo.webservice.types.CMLRemoveAspect;
import org.alfresco.repo.webservice.types.CMLRemoveAssociation;
import org.alfresco.repo.webservice.types.CMLRemoveChild;
import org.alfresco.repo.webservice.types.CMLUpdate;
import org.alfresco.repo.webservice.types.CMLWriteContent;
import org.alfresco.repo.webservice.types.ContentFormat;
import org.alfresco.repo.webservice.types.NamedValue;
import org.alfresco.repo.webservice.types.ParentReference;
import org.alfresco.repo.webservice.types.Predicate;
import org.alfresco.repo.webservice.types.Reference;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -64,12 +70,14 @@ public class CMLUtil
private static final String REMOVE_CHILD = "removeChild";
private static final String CREATE_ASSOCIATION = "createAssociation";
private static final String REMOVE_ASSOCIATION = "removeAssociation";
private static final String WRITE_CONTENT = "writeContent";
private NodeService nodeService;
private SearchService searchService;
private NamespaceService namespaceService;
private CopyService copyService;
private DictionaryService dictionaryService;
private ContentService contentService;
public void setNodeService(NodeService nodeService)
{
@@ -96,6 +104,11 @@ public class CMLUtil
this.dictionaryService = dictionaryService;
}
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
/**
* Execute a cml update query.
*
@@ -147,6 +160,15 @@ public class CMLUtil
}
}
CMLWriteContent[] writes = cml.getWriteContent();
if (writes != null)
{
for (CMLWriteContent write : writes)
{
executeCMLWriteContent(write, context, results);
}
}
// Execute delete
CMLDelete[] deletes = cml.getDelete();
if (deletes != null)
@@ -253,7 +275,7 @@ public class CMLUtil
context.addId(id, nodeRef);
}
results.add(createResult(CREATE, null, nodeRef));
results.add(createResult(CREATE, id, null, nodeRef));
}
/**
@@ -277,10 +299,14 @@ public class CMLUtil
return properties;
}
private UpdateResult createResult(String cmd, NodeRef sourceNodeRef, NodeRef destinationNodeRef)
private UpdateResult createResult(String cmd, String sourceId, NodeRef sourceNodeRef, NodeRef destinationNodeRef)
{
UpdateResult result = new UpdateResult();
result.setStatement(cmd);
if (sourceId != null)
{
result.setSourceId(sourceId);
}
if (sourceNodeRef != null)
{
result.setSource(Utils.convertToReference(sourceNodeRef));
@@ -313,7 +339,7 @@ public class CMLUtil
this.nodeService.addAspect(nodeRef, aspectQName, properties);
// Create the result
results.add(createResult(ADD_ASPECT, nodeRef, nodeRef));
results.add(createResult(ADD_ASPECT, null, nodeRef, nodeRef));
}
}
@@ -331,7 +357,7 @@ public class CMLUtil
this.nodeService.removeAspect(nodeRef, aspectQName);
// Create the result
results.add(createResult(REMOVE_ASPECT, nodeRef, nodeRef));
results.add(createResult(REMOVE_ASPECT, null, nodeRef, nodeRef));
}
}
@@ -367,10 +393,38 @@ public class CMLUtil
this.nodeService.setProperties(nodeRef, currentProps);
// Get the result
results.add(createResult(UPDATE, nodeRef, nodeRef));
results.add(createResult(UPDATE, null, nodeRef, nodeRef));
}
}
private void executeCMLWriteContent(CMLWriteContent write, ExecutionContext context, List<UpdateResult> results)
{
// Get the nodes and content property
List<NodeRef> nodeRefs = getNodeRefList(write.getWhere_id(), write.getWhere(), context);
QName property = QName.createQName(write.getProperty());
ContentFormat format = write.getFormat();
byte[] content = write.getContent();
for (NodeRef nodeRef : nodeRefs)
{
//Get the content writer
ContentWriter writer = this.contentService.getWriter(nodeRef, property, true);
// Set the content format details (if they have been specified)
if (format != null)
{
writer.setEncoding(format.getEncoding());
writer.setMimetype(format.getMimetype());
}
// Write the content
InputStream is = new ByteArrayInputStream(content);
writer.putContent(is);
results.add(createResult(WRITE_CONTENT, null, nodeRef, nodeRef));
}
}
private void executeCMLDelete(CMLDelete delete, ExecutionContext context, List<UpdateResult> results)
{
List<NodeRef> nodeRefs = Utils.resolvePredicate(delete.getWhere(), this.nodeService, this.searchService, this.namespaceService);
@@ -380,7 +434,7 @@ public class CMLUtil
this.nodeService.deleteNode(nodeRef);
// Create the result
results.add(createResult(DELETE, nodeRef, null));
results.add(createResult(DELETE, null, nodeRef, null));
}
}
@@ -408,7 +462,7 @@ public class CMLUtil
NodeRef newNodeRef = this.nodeService.moveNode(nodeToMove, destinationNodeRef, assocType, assocName).getChildRef();
// Create the result
results.add(createResult(MOVE, nodeToMove, newNodeRef));
results.add(createResult(MOVE, null, nodeToMove, newNodeRef));
}
}
}
@@ -474,7 +528,7 @@ public class CMLUtil
NodeRef newNodeRef = this.copyService.copy(nodeToCopy, destinationNodeRef, assocType, assocName, copyChildren);
// Create the result
results.add(createResult(COPY, nodeToCopy, newNodeRef));
results.add(createResult(COPY, null, nodeToCopy, newNodeRef));
}
}
@@ -504,7 +558,7 @@ public class CMLUtil
this.nodeService.addChild(nodeRef, whereNodeRef, assocType, assocName);
// Create the result
results.add(createResult(ADD_CHILD, nodeRef, whereNodeRef));
results.add(createResult(ADD_CHILD, null, nodeRef, whereNodeRef));
}
}
}
@@ -520,7 +574,7 @@ public class CMLUtil
this.nodeService.removeChild(parentNodeRef, childNodeRef);
// Create the result
results.add(createResult(REMOVE_CHILD, parentNodeRef, null));
results.add(createResult(REMOVE_CHILD, null, parentNodeRef, null));
}
}
@@ -540,7 +594,7 @@ public class CMLUtil
this.nodeService.createAssociation(fromNodeRef, toNodeRef, assocType);
// Create the result
results.add(createResult(CREATE_ASSOCIATION, fromNodeRef, toNodeRef));
results.add(createResult(CREATE_ASSOCIATION, null, fromNodeRef, toNodeRef));
}
}
}
@@ -560,7 +614,7 @@ public class CMLUtil
this.nodeService.removeAssociation(fromNodeRef, toNodeRef, assocType);
// Create the result
results.add(createResult(REMOVE_ASSOCIATION, fromNodeRef, toNodeRef));
results.add(createResult(REMOVE_ASSOCIATION, null, fromNodeRef, toNodeRef));
}
}
}
@@ -569,15 +623,22 @@ public class CMLUtil
private class ExecutionContext
{
private Map<String, NodeRef> idMap = new HashMap<String, NodeRef>();
private Map<NodeRef, String> nodeRefMap = new HashMap<NodeRef, String>();
public void addId(String id, NodeRef nodeRef)
{
this.idMap.put(id, nodeRef);
this.nodeRefMap.put(nodeRef, id);
}
public NodeRef getNodeRef(String id)
{
return this.idMap.get(id);
}
public String getId(NodeRef nodeRef)
{
return this.nodeRefMap.get(nodeRef);
}
}
}

View File

@@ -34,6 +34,8 @@ import org.alfresco.repo.webservice.types.CMLRemoveAspect;
import org.alfresco.repo.webservice.types.CMLRemoveAssociation;
import org.alfresco.repo.webservice.types.CMLRemoveChild;
import org.alfresco.repo.webservice.types.CMLUpdate;
import org.alfresco.repo.webservice.types.CMLWriteContent;
import org.alfresco.repo.webservice.types.ContentFormat;
import org.alfresco.repo.webservice.types.NamedValue;
import org.alfresco.repo.webservice.types.ParentReference;
import org.alfresco.repo.webservice.types.Predicate;
@@ -41,6 +43,8 @@ import org.alfresco.repo.webservice.types.Reference;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -57,6 +61,7 @@ public class CMLUtilTest extends BaseSpringTest
{
private static final ContentData CONTENT_DATA_TEXT_UTF8 = new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8");
private static final ContentData CONTENT_DATA_HTML_UTF16 = new ContentData(null, MimetypeMap.MIMETYPE_HTML, 0L, "UTF-16");
private static final String TEST_CONTENT = "This is some test content";
private CMLUtil cmlUtil;
private NodeService nodeService;
@@ -67,6 +72,7 @@ public class CMLUtilTest extends BaseSpringTest
private SearchService searchService;
private NodeRef folderNodeRef;
private AuthenticationComponent authenticationComponent;
private ContentService contentService;
@Override
protected String[] getConfigLocations()
@@ -82,6 +88,7 @@ public class CMLUtilTest extends BaseSpringTest
this.searchService = (SearchService)this.applicationContext.getBean("searchService");
this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService");
this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent");
this.contentService = (ContentService)this.applicationContext.getBean("contentService");
this.authenticationComponent.setSystemUserAsCurrentUser();
@@ -212,6 +219,32 @@ public class CMLUtilTest extends BaseSpringTest
assertEquals(CONTENT_DATA_HTML_UTF16, this.nodeService.getProperty(this.nodeRef, ContentModel.PROP_CONTENT));
}
public void testWriteContent()
{
CMLWriteContent write = new CMLWriteContent();
write.setWhere(createPredicate(this.nodeRef));
write.setProperty(ContentModel.PROP_CONTENT.toString());
ContentFormat format = new ContentFormat(MimetypeMap.MIMETYPE_TEXT_PLAIN, "UTF-8");
write.setFormat(format);
write.setContent(TEST_CONTENT.getBytes());
CML cml = new CML();
cml.setWriteContent(new CMLWriteContent[]{write});
UpdateResult[] result = this.cmlUtil.executeCML(cml);
assertNotNull(result);
assertEquals(1, result.length);
UpdateResult updateResult = result[0];
assertEquals("writeContent", updateResult.getStatement());
assertNotNull(updateResult.getSource());
assertNotNull(updateResult.getDestination());
ContentReader reader = this.contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT);
assertNotNull(reader);
assertEquals(reader.getContentString(), TEST_CONTENT);
}
public void testDelete()
{
CMLDelete delete = new CMLDelete();

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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());
}
}

View File

@@ -111,13 +111,16 @@ public class AssociatedQuerySession extends AbstractQuerySession
// get the data for the row and build up the columns structure
Map<QName, Serializable> props = nodeService
.getProperties(childNodeRef);
NamedValue[] columns = new NamedValue[props.size()];
NamedValue[] columns = new NamedValue[props.size()+1];
int col = 0;
for (QName propName : props.keySet())
{
columns[col] = Utils.createNamedValue(dictionaryService, propName, props.get(propName));
col++;
}
// Now add the system columns containing the association details
columns[col] = new NamedValue(SYS_COL_ASSOC_TYPE, Boolean.FALSE, assoc.getTypeQName().toString(), null);
ResultSetRow row = new ResultSetRow();
row.setRowIndex(x);

View File

@@ -97,7 +97,7 @@ public class ChildrenQuerySession extends AbstractQuerySession
// create columns for all the properties of the node
// get the data for the row and build up the columns structure
Map<QName, Serializable> props = nodeService.getProperties(childNodeRef);
NamedValue[] columns = new NamedValue[props.size()];
NamedValue[] columns = new NamedValue[props.size()+4];
int col = 0;
for (QName propName : props.keySet())
{
@@ -105,6 +105,15 @@ public class ChildrenQuerySession extends AbstractQuerySession
col++;
}
// Now add the system columns containing the association details
columns[col] = new NamedValue(SYS_COL_ASSOC_TYPE, Boolean.FALSE, assoc.getTypeQName().toString(), null);
col++;
columns[col] = new NamedValue(SYS_COL_ASSOC_NAME, Boolean.FALSE, assoc.getQName().toString(), null);
col++;
columns[col] = new NamedValue(SYS_COL_IS_PRIMARY, Boolean.FALSE, Boolean.toString(assoc.isPrimary()), null);
col++;
columns[col] = new NamedValue(SYS_COL_NTH_SIBLING, Boolean.FALSE, Integer.toString(assoc.getNthSibling()), null);
ResultSetRow row = new ResultSetRow();
row.setRowIndex(x);
row.setNode(rowNode);

View File

@@ -97,7 +97,7 @@ public class ParentsQuerySession extends AbstractQuerySession
// create columns for all the properties of the node
// get the data for the row and build up the columns structure
Map<QName, Serializable> props = nodeService.getProperties(parentNodeRef);
NamedValue[] columns = new NamedValue[props.size()];
NamedValue[] columns = new NamedValue[props.size()+4];
int col = 0;
for (QName propName : props.keySet())
{
@@ -105,6 +105,15 @@ public class ParentsQuerySession extends AbstractQuerySession
col++;
}
// Now add the system columns containing the association details
columns[col] = new NamedValue(SYS_COL_ASSOC_TYPE, Boolean.FALSE, assoc.getTypeQName().toString(), null);
col++;
columns[col] = new NamedValue(SYS_COL_ASSOC_NAME, Boolean.FALSE, assoc.getQName().toString(), null);
col++;
columns[col] = new NamedValue(SYS_COL_IS_PRIMARY, Boolean.FALSE, Boolean.toString(assoc.isPrimary()), null);
col++;
columns[col] = new NamedValue(SYS_COL_NTH_SIBLING, Boolean.FALSE, Integer.toString(assoc.getNthSibling()), null);
ResultSetRow row = new ResultSetRow();
row.setRowIndex(x);
row.setNode(rowNode);

View File

@@ -30,6 +30,12 @@ import org.alfresco.service.namespace.NamespaceService;
*/
public interface QuerySession extends Serializable
{
/** System column namess */
public static String SYS_COL_ASSOC_TYPE = "associationType";
public static String SYS_COL_ASSOC_NAME = "associationName";
public static String SYS_COL_IS_PRIMARY = "isPrimary";
public static String SYS_COL_NTH_SIBLING = "nthSibling";
/**
* Retrieves the id this query session can be identified as
*

View File

@@ -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!");
}
@@ -275,6 +265,8 @@ public class RepositoryWebService extends AbstractWebService implements
return queryResult;
} catch (Throwable e)
{
e.printStackTrace();
// rollback the transaction
try
{

View File

@@ -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();

View File

@@ -49,6 +49,9 @@
<property name="dictionaryService">
<ref bean="DictionaryService"/>
</property>
<property name="contentService">
<ref bean="ContentService"/>
</property>
</bean>
<!-- Implementations of each exposed web service -->