Merged V2.1 to HEAD

6327: Drops alfresco-deployment.zip in build/dist instead of build.
   6328:Set AVM file name requirements as lenient as possible.
   6329: Fixed DNS name restriction to allow 1-char host labels.
   6330: Setting read-only flag for start up components (AR-1621 and AR-193)
   6331: Minor formatting
   6332: Implementation of a read-only, HTTP-based ContentStore.
   6333: AR-1619: A debug message needed changing as the FileFolderService now supports adding children onto system nodes.
   6334: Build fix
   6335: Fix for AWC-1447 (Office Add-In - Create Collaboration Space)
   6337: Fixed AR-1622: WebService requests must be wrapped in retries


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6721 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-10 13:09:30 +00:00
parent 38c103e17b
commit 9e41dc105d
3 changed files with 338 additions and 494 deletions

View File

@@ -38,6 +38,7 @@ import javax.servlet.http.HttpSession;
import javax.transaction.UserTransaction;
import javax.xml.rpc.server.ServletEndpointContext;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.webservice.axis.QueryConfigHandler;
import org.alfresco.repo.webservice.types.AssociationDefinition;
import org.alfresco.repo.webservice.types.Cardinality;
@@ -511,8 +512,7 @@ public class Utils
* SOAP message context
* @return The Spring WebApplicationContext
*/
public static WebApplicationContext getSpringContext(
MessageContext msgContext)
public static WebApplicationContext getSpringContext(MessageContext msgContext)
{
// get hold of the web application context via the message context
HttpServletRequest req = (HttpServletRequest) msgContext
@@ -528,6 +528,8 @@ public class Utils
* @param msgContext
* SOAP message context
* @return a UserTransaction
*
* @deprecated Use {@link #getRetryingTransactionHelper(MessageContext)}
*/
public static UserTransaction getUserTransaction(MessageContext msgContext)
{
@@ -539,6 +541,24 @@ public class Utils
return transactionService.getUserTransaction();
}
/**
* Get the executer to wrap transactional callbacks in for better transaction behaviour.
*
* @param msgContext
* SOAP message context
* @return
* a transactional, retrying, callback executer
*/
public static RetryingTransactionHelper getRetryingTransactionHelper(MessageContext msgContext)
{
// get the service regsistry
ServiceRegistry svcReg = (ServiceRegistry) getSpringContext(msgContext)
.getBean(ServiceRegistry.SERVICE_REGISTRY);
TransactionService transactionService = svcReg.getTransactionService();
return transactionService.getRetryingTransactionHelper();
}
/**
* Gets the current http session id
*

View File

@@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.webservice.AbstractWebService;
import org.alfresco.repo.webservice.Utils;
import org.alfresco.repo.webservice.types.ContentFormat;
@@ -67,49 +68,35 @@ public class ContentWebService extends AbstractWebService implements
/**
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#read(org.alfresco.repo.webservice.types.Reference)
*/
public Content[] read(Predicate items, String property)
public Content[] read(final Predicate items, final String property)
throws RemoteException, ContentFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
RetryingTransactionCallback<Content[]> callback = new RetryingTransactionCallback<Content[]>()
{
public Content[] execute() throws Throwable
{
// resolve the predicates
List<NodeRef> nodes = Utils.resolvePredicate(items, nodeService, searchService, namespaceService);
List<Content> results = new ArrayList<Content>(nodes.size());
for (NodeRef nodeRef : nodes)
{
// Add content to the result
results.add(createContent(nodeRef, property));
}
// resolve the predicates
List<NodeRef> nodes = Utils.resolvePredicate(items, this.nodeService, this.searchService, this.namespaceService);
List<Content> results = new ArrayList<Content>(nodes.size());
for (NodeRef nodeRef : nodes)
{
// Add content to the result
results.add(createContent(nodeRef, property));
}
// commit the transaction
tx.commit();
return results.toArray(new Content[results.size()]);
return results.toArray(new Content[results.size()]);
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new ContentFault(0, e.getMessage());
}
}
@@ -193,64 +180,50 @@ public class ContentWebService extends AbstractWebService implements
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#write(org.alfresco.repo.webservice.types.Reference,
* byte[])
*/
public Content write(Reference node, String property, byte[] content, ContentFormat format)
public Content write(final Reference node, final String property, final byte[] content, final ContentFormat format)
throws RemoteException, ContentFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// create a NodeRef from the parent reference
NodeRef nodeRef = Utils.convertToNodeRef(node, this.nodeService,
this.searchService, this.namespaceService);
// Get the content writer
ContentWriter writer = this.contentService.getWriter(nodeRef, QName.createQName(property), true);
// Set the content format details (if they have been specified)
if (format != null)
RetryingTransactionCallback<Content> callback = new RetryingTransactionCallback<Content>()
{
writer.setEncoding(format.getEncoding());
writer.setMimetype(format.getMimetype());
}
// Write the content
InputStream is = new ByteArrayInputStream(content);
writer.putContent(is);
public Content execute() throws Throwable
{
// create a NodeRef from the parent reference
NodeRef nodeRef = Utils.convertToNodeRef(node, nodeService, searchService, namespaceService);
// Debug
if (logger.isDebugEnabled())
{
logger.debug("Updated content for node with id: " + nodeRef.getId());
}
// Get the content writer
ContentWriter writer = contentService.getWriter(nodeRef, QName.createQName(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);
// Commit the transaction
tx.commit();
// Return the content object
return createContent(nodeRef, property);
// Debug
if (logger.isDebugEnabled())
{
logger.debug("Updated content for node with id: " + nodeRef.getId());
}
// Return the content object
return createContent(nodeRef, property);
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// Rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new ContentFault(0, e.getMessage());
}
}
@@ -259,58 +232,43 @@ public class ContentWebService extends AbstractWebService implements
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#clear(org.alfresco.repo.webservice.types.Predicate,
* java.lang.String)
*/
public Content[] clear(Predicate items, String property)
throws RemoteException, ContentFault
public Content[] clear(final Predicate items, final String property) throws RemoteException, ContentFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
List<NodeRef> nodes = Utils.resolvePredicate(items, this.nodeService,this.searchService, this.namespaceService);
Content[] contents = new Content[nodes.size()];
// delete each node in the predicate
for (int x = 0; x < nodes.size(); x++)
RetryingTransactionCallback<Content[]> callback = new RetryingTransactionCallback<Content[]>()
{
NodeRef nodeRef = nodes.get(x);
// Clear the content
this.nodeService.setProperty(nodeRef, QName.createQName(property), null);
if (logger.isDebugEnabled())
public Content[] execute() throws Throwable
{
logger.debug("Cleared content node with id: " + nodeRef.getId());
List<NodeRef> nodes = Utils.resolvePredicate(items, nodeService, searchService, namespaceService);
Content[] contents = new Content[nodes.size()];
// delete each node in the predicate
for (int x = 0; x < nodes.size(); x++)
{
NodeRef nodeRef = nodes.get(x);
// Clear the content
nodeService.setProperty(nodeRef, QName.createQName(property), null);
if (logger.isDebugEnabled())
{
logger.debug("Cleared content node with id: " + nodeRef.getId());
}
contents[x] = createContent(nodeRef, property);
}
return contents;
}
contents[x] = createContent(nodeRef, property);
}
// commit the transaction
tx.commit();
return contents;
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new ContentFault(0, e.getMessage());
}
}

View File

@@ -31,9 +31,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.transaction.UserTransaction;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.webservice.AbstractWebService;
import org.alfresco.repo.webservice.CMLUtil;
import org.alfresco.repo.webservice.Utils;
@@ -108,7 +107,7 @@ public class RepositoryWebService extends AbstractWebService implements
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#createStore(org.alfresco.repo.webservice.types.StoreEnum, java.lang.String)
* {@inheritDoc}
*/
public Store createStore(String scheme, String address) throws RemoteException, RepositoryFault
{
@@ -117,63 +116,50 @@ public class RepositoryWebService extends AbstractWebService implements
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#getStores()
* {@inheritDoc}
*/
public Store[] getStores() throws RemoteException, RepositoryFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
List<StoreRef> stores = this.nodeService.getStores();
Store[] returnStores = new Store[stores.size()];
for (int x = 0; x < stores.size(); x++)
RetryingTransactionCallback<Store[]> callback = new RetryingTransactionCallback<Store[]>()
{
StoreRef storeRef = stores.get(x);
if (logger.isDebugEnabled() == true)
public Store[] execute() throws Throwable
{
logger.debug("Store protocol :" + storeRef.getProtocol());
List<StoreRef> stores = nodeService.getStores();
Store[] returnStores = new Store[stores.size()];
for (int x = 0; x < stores.size(); x++)
{
StoreRef storeRef = stores.get(x);
if (logger.isDebugEnabled() == true)
{
logger.debug("Store protocol :" + storeRef.getProtocol());
}
Store store = Utils.convertToStore(storeRef);
returnStores[x] = store;
}
return returnStores;
}
Store store = Utils.convertToStore(storeRef);
returnStores[x] = store;
}
// commit the transaction
tx.commit();
return returnStores;
} catch (Throwable e)
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#query(org.alfresco.repo.webservice.types.Store,
* org.alfresco.repo.webservice.types.Query, boolean)
* {@inheritDoc}
*/
public QueryResult query(Store store, Query query, boolean includeMetaData)
public QueryResult query(final Store store, final Query query, final boolean includeMetaData)
throws RemoteException, RepositoryFault
{
String language = query.getLanguage();
@@ -184,387 +170,283 @@ public class RepositoryWebService extends AbstractWebService implements
+ "' queries are currently supported!");
}
UserTransaction tx = null;
MessageContext msgContext = MessageContext.getCurrentContext();
final MessageContext msgContext = MessageContext.getCurrentContext();
try
{
tx = Utils.getUserTransaction(msgContext);
tx.begin();
// setup a query session and get the first batch of results
QuerySession querySession = new ResultSetQuerySession(Utils
.getBatchSize(msgContext), store, query, includeMetaData);
QueryResult queryResult = querySession
.getNextResultsBatch(this.searchService, this.nodeService,
this.namespaceService, this.dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
RetryingTransactionCallback<QueryResult> callback = new RetryingTransactionCallback<QueryResult>()
{
// this.querySessionCache.putQuerySession(querySession);
this.querySessionCache.put(queryResult.getQuerySession(),
querySession);
}
// commit the transaction
tx.commit();
return queryResult;
} catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
public QueryResult execute() throws Throwable
{
tx.rollback();
}
} catch (Exception ex)
{
}
// setup a query session and get the first batch of results
QuerySession querySession = new ResultSetQuerySession(Utils
.getBatchSize(msgContext), store, query, includeMetaData);
QueryResult queryResult = querySession
.getNextResultsBatch(searchService, nodeService, namespaceService, dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
{
// this.querySessionCache.putQuerySession(querySession);
querySessionCache.put(queryResult.getQuerySession(), querySession);
}
return queryResult;
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
e.printStackTrace();
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#queryChildren(org.alfresco.repo.webservice.types.Reference)
* {@inheritDoc}
*/
public QueryResult queryChildren(Reference node) throws RemoteException,
public QueryResult queryChildren(final Reference node) throws RemoteException,
RepositoryFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// setup a query session and get the first batch of results
QuerySession querySession = new ChildrenQuerySession(Utils
.getBatchSize(MessageContext.getCurrentContext()), node);
QueryResult queryResult = querySession
.getNextResultsBatch(this.searchService, this.nodeService,
this.namespaceService, this.dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
RetryingTransactionCallback<QueryResult> callback = new RetryingTransactionCallback<QueryResult>()
{
// this.querySessionCache.putQuerySession(querySession);
this.querySessionCache.put(queryResult.getQuerySession(),
querySession);
}
if (logger.isDebugEnabled() == true)
{
logger.debug("Method end ... queryChildren");
}
public QueryResult execute() throws Throwable
{
// setup a query session and get the first batch of results
QuerySession querySession = new ChildrenQuerySession(Utils
.getBatchSize(MessageContext.getCurrentContext()), node);
QueryResult queryResult = querySession
.getNextResultsBatch(searchService, nodeService, namespaceService, dictionaryService);
// commit the transaction
tx.commit();
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
{
querySessionCache.put(queryResult.getQuerySession(), querySession);
}
if (logger.isDebugEnabled())
{
logger.debug("Method end ... queryChildren");
}
return queryResult;
} catch (Throwable e)
return queryResult;
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
e.printStackTrace();
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#queryParents(org.alfresco.repo.webservice.types.Reference)
* {@inheritDoc}
*/
public QueryResult queryParents(Reference node) throws RemoteException,
RepositoryFault
public QueryResult queryParents(final Reference node) throws RemoteException, RepositoryFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// setup a query session and get the first batch of results
QuerySession querySession = new ParentsQuerySession(Utils
.getBatchSize(MessageContext.getCurrentContext()), node);
QueryResult queryResult = querySession
.getNextResultsBatch(this.searchService, this.nodeService,
this.namespaceService, this.dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
RetryingTransactionCallback<QueryResult> callback = new RetryingTransactionCallback<QueryResult>()
{
// this.querySessionCache.putQuerySession(querySession);
this.querySessionCache.put(queryResult.getQuerySession(),
querySession);
}
// commit the transaction
tx.commit();
return queryResult;
} catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
public QueryResult execute() throws Throwable
{
tx.rollback();
}
} catch (Exception ex)
{
}
// setup a query session and get the first batch of results
QuerySession querySession = new ParentsQuerySession(Utils
.getBatchSize(MessageContext.getCurrentContext()), node);
QueryResult queryResult = querySession.getNextResultsBatch(
searchService, nodeService, namespaceService, dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
{
// this.querySessionCache.putQuerySession(querySession);
querySessionCache.put(queryResult.getQuerySession(), querySession);
}
return queryResult;
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#queryAssociated(org.alfresco.repo.webservice.types.Reference,
* org.alfresco.repo.webservice.repository.Association[])
* {@inheritDoc}
*/
public QueryResult queryAssociated(Reference node, Association association)
public QueryResult queryAssociated(final Reference node, final Association association)
throws RemoteException, RepositoryFault
{
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// setup a query session and get the first batch of results
QuerySession querySession = new AssociatedQuerySession(Utils.getBatchSize(MessageContext.getCurrentContext()), node, association);
QueryResult queryResult = querySession
.getNextResultsBatch(this.searchService, this.nodeService,
this.namespaceService, this.dictionaryService);
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
RetryingTransactionCallback<QueryResult> callback = new RetryingTransactionCallback<QueryResult>()
{
// this.querySessionCache.putQuerySession(querySession);
this.querySessionCache.put(queryResult.getQuerySession(),
querySession);
}
public QueryResult execute() throws Throwable
{
// setup a query session and get the first batch of results
QuerySession querySession = new AssociatedQuerySession(Utils.getBatchSize(MessageContext.getCurrentContext()), node, association);
QueryResult queryResult = querySession.getNextResultsBatch(searchService, nodeService, namespaceService, dictionaryService);
// commit the transaction
tx.commit();
// add the session to the cache if there are more results to come
if (queryResult.getQuerySession() != null)
{
// this.querySessionCache.putQuerySession(querySession);
querySessionCache.put(queryResult.getQuerySession(), querySession);
}
return queryResult;
return queryResult;
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#fetchMore(java.lang.String)
* {@inheritDoc}
*/
public QueryResult fetchMore(String querySession) throws RemoteException,
RepositoryFault
public QueryResult fetchMore(final String querySession) throws RemoteException, RepositoryFault
{
QueryResult queryResult = null;
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// try and get the QuerySession with the given id from the cache
QuerySession session = this.querySessionCache.get(querySession);
if (session == null)
RetryingTransactionCallback<QueryResult> callback = new RetryingTransactionCallback<QueryResult>()
{
if (logger.isDebugEnabled())
logger.debug("Invalid querySession id requested: "
+ querySession);
throw new RepositoryFault(4, "querySession with id '"
+ querySession + "' is invalid");
}
// get the next batch of results
queryResult = session.getNextResultsBatch(this.searchService,
this.nodeService, this.namespaceService, this.dictionaryService);
// remove the QuerySession from the cache if there are no more
// results to come
if (queryResult.getQuerySession() == null)
{
this.querySessionCache.remove(querySession);
}
// commit the transaction
tx.commit();
return queryResult;
} catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
public QueryResult execute() throws Throwable
{
tx.rollback();
}
} catch (Exception ex)
{
}
// try and get the QuerySession with the given id from the cache
QuerySession session = querySessionCache.get(querySession);
if (session == null)
{
if (logger.isDebugEnabled())
{
logger.debug("Invalid querySession id requested: " + querySession);
}
throw new RepositoryFault(
4,
"querySession with id '" + querySession + "' is invalid");
}
// get the next batch of results
QueryResult queryResult = session.getNextResultsBatch(
searchService,
nodeService,
namespaceService,
dictionaryService);
// remove the QuerySession from the cache if there are no more
// results to come
if (queryResult.getQuerySession() == null)
{
querySessionCache.remove(querySession);
}
return queryResult;
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (e instanceof RepositoryFault)
{
throw (RepositoryFault) e;
} else
}
else
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#update(org.alfresco.repo.webservice.types.CML)
* {@inheritDoc}
*/
public UpdateResult[] update(CML statements) throws RemoteException,
RepositoryFault
public UpdateResult[] update(final CML statements) throws RemoteException, RepositoryFault
{
UpdateResult[] result = null;
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
result = this.cmlUtil.executeCML(statements);
// commit the transaction
tx.commit();
return result;
RetryingTransactionCallback<UpdateResult[]> callback = new RetryingTransactionCallback<UpdateResult[]>()
{
public UpdateResult[] execute() throws Throwable
{
return cmlUtil.executeCML(statements);
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
} catch (Exception ex)
{
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
/**
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#describe(org.alfresco.repo.webservice.types.Predicate)
* {@inheritDoc}
*/
public NodeDefinition[] describe(Predicate items) throws RemoteException,
RepositoryFault
public NodeDefinition[] describe(final Predicate items) throws RemoteException, RepositoryFault
{
NodeDefinition[] nodeDefs = null;
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
List<NodeRef> nodes = Utils
.resolvePredicate(items, this.nodeService,
this.searchService, this.namespaceService);
nodeDefs = new NodeDefinition[nodes.size()];
for (int x = 0; x < nodes.size(); x++)
RetryingTransactionCallback<NodeDefinition[]> callback = new RetryingTransactionCallback<NodeDefinition[]>()
{
nodeDefs[x] = setupNodeDefObject(nodes.get(x));
}
// commit the transaction
tx.commit();
return nodeDefs;
} catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
public NodeDefinition[] execute() throws Throwable
{
tx.rollback();
List<NodeRef> nodes = Utils.resolvePredicate(items, nodeService, searchService, namespaceService);
NodeDefinition[] nodeDefs = new NodeDefinition[nodes.size()];
for (int x = 0; x < nodes.size(); x++)
{
nodeDefs[x] = setupNodeDefObject(nodes.get(x));
}
return nodeDefs;
}
} catch (Exception ex)
{
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
}
@@ -604,91 +486,75 @@ public class RepositoryWebService extends AbstractWebService implements
* Gets the nodes associatiated with the predicate provided. Usefull when the store and ids of the required
* nodes are known.
*
* @see org.alfresco.repo.webservice.repository.RepositoryServiceSoapPort#get(org.alfresco.repo.webservice.types.Predicate)
* {@inheritDoc}
*/
public Node[] get(Predicate where) throws RemoteException, RepositoryFault
public Node[] get(final Predicate where) throws RemoteException, RepositoryFault
{
Node[] nodes = null;
UserTransaction tx = null;
try
{
tx = Utils.getUserTransaction(MessageContext.getCurrentContext());
tx.begin();
// Resolve the predicate to a list of node references
List<NodeRef> nodeRefs = Utils.resolvePredicate(where, this.nodeService, this.searchService, this.namespaceService);
List<Node> nodeList = new ArrayList<Node>();
for (NodeRef nodeRef : nodeRefs)
RetryingTransactionCallback<Node[]> callback = new RetryingTransactionCallback<Node[]>()
{
// search can return nodes that no longer exist, so we need to ignore these
if(nodeService.exists(nodeRef) == false)
{
if(logger.isDebugEnabled())
{
logger.warn("Search returned node that doesn't exist: " + nodeRef);
}
}
// Get the nodes reference
Reference reference = Utils.convertToReference(this.nodeService, this.namespaceService, nodeRef);
// Get the nodes type
String type = this.nodeService.getType(nodeRef).toString();
// Get the nodes aspects
Set<QName> aspectQNames = this.nodeService.getAspects(nodeRef);
String[] aspects = new String[aspectQNames.size()];
int aspectIndex = 0;
for (QName aspectQName : aspectQNames)
public Node[] execute() throws Throwable
{
aspects[aspectIndex] = aspectQName.toString();
aspectIndex++;
// Resolve the predicate to a list of node references
List<NodeRef> nodeRefs = Utils.resolvePredicate(where, nodeService, searchService, namespaceService);
List<Node> nodeList = new ArrayList<Node>();
for (NodeRef nodeRef : nodeRefs)
{
// search can return nodes that no longer exist, so we need to ignore these
if(nodeService.exists(nodeRef) == false)
{
if(logger.isDebugEnabled())
{
logger.warn("Search returned node that doesn't exist: " + nodeRef);
}
}
// Get the nodes reference
Reference reference = Utils.convertToReference(nodeService, namespaceService, nodeRef);
// Get the nodes type
String type = nodeService.getType(nodeRef).toString();
// Get the nodes aspects
Set<QName> aspectQNames = nodeService.getAspects(nodeRef);
String[] aspects = new String[aspectQNames.size()];
int aspectIndex = 0;
for (QName aspectQName : aspectQNames)
{
aspects[aspectIndex] = aspectQName.toString();
aspectIndex++;
}
// Get the nodes properties
Map<QName, Serializable> propertyMap = nodeService.getProperties(nodeRef);
NamedValue[] properties = new NamedValue[propertyMap.size()];
int propertyIndex = 0;
for (Map.Entry<QName, Serializable> entry : propertyMap.entrySet())
{
properties[propertyIndex] = Utils.createNamedValue(dictionaryService, entry.getKey(), entry.getValue());
propertyIndex++;
}
// Create the node and add to the array
Node node = new Node(reference, type, aspects, properties);
nodeList.add(node);
}
Node[] nodes = nodeList.toArray(new Node[nodeList.size()]);
return nodes;
}
// Get the nodes properties
Map<QName, Serializable> propertyMap = this.nodeService.getProperties(nodeRef);
NamedValue[] properties = new NamedValue[propertyMap.size()];
int propertyIndex = 0;
for (Map.Entry<QName, Serializable> entry : propertyMap.entrySet())
{
properties[propertyIndex] = Utils.createNamedValue(this.dictionaryService, entry.getKey(), entry.getValue());
propertyIndex++;
}
// Create the node and add to the array
Node node = new Node(reference, type, aspects, properties);
nodeList.add(node);
}
nodes = nodeList.toArray(new Node[nodeList.size()]);
// commit the transaction
tx.commit();
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
// rollback the transaction
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception ex)
{
// Ignore
}
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new RepositoryFault(0, e.toString());
}
return nodes;
}
}