diff --git a/source/java/org/alfresco/repo/avm/Issuer.java b/source/java/org/alfresco/repo/avm/Issuer.java index 8acdabc5ca..8ef2f72d56 100644 --- a/source/java/org/alfresco/repo/avm/Issuer.java +++ b/source/java/org/alfresco/repo/avm/Issuer.java @@ -87,9 +87,9 @@ public class Issuer public Object execute() { IssuerID issuerID = fIDDAO.get(fName); - if (issuerID == null) + Long id = fIssuerDAO.getIssuerValue(fName); + if (issuerID == null || id == null || id >= issuerID.getNext()) { - Long id = fIssuerDAO.getIssuerValue(fName); if (id == null) { id = 0L; @@ -98,8 +98,15 @@ public class Issuer { id = id + 1L; } - issuerID = new IssuerIDImpl(fName, id); - fIDDAO.save(issuerID); + if (issuerID == null) + { + issuerID = new IssuerIDImpl(fName, id); + fIDDAO.save(issuerID); + } + else + { + issuerID.setNext(id); + } } return null; } @@ -123,11 +130,46 @@ public class Issuer { if (fNext >= fLast) { - IssuerID isID = fIDDAO.get(fName); - fNext = isID.getNext(); - fLast = fNext + BLOCK_SIZE; - isID.setNext(fLast); + BlockGetter getter = new BlockGetter(); + Thread thread = new Thread(getter); + thread.start(); + try + { + thread.join(); + } + catch (InterruptedException e) + { + // Do nothing. + } + fNext = getter.fNext; + fLast = getter.fLast; } return fNext++; } + + private class BlockGetter implements Runnable + { + public long fNext; + + public long fLast; + + /* (non-Javadoc) + * @see java.lang.Runnable#run() + */ + public void run() + { + fTxnService.getRetryingTransactionHelper().doInTransaction( + new RetryingTransactionCallback() + { + public Object execute() + { + IssuerID isID = fIDDAO.get(fName); + fNext = isID.getNext(); + fLast = fNext + BLOCK_SIZE; + isID.setNext(fLast); + return null; + } + }); + } + } } diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 73f3dd5c65..51c93a1bb8 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -24,8 +24,6 @@ */ package org.alfresco.repo.jscript; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.text.MessageFormat; @@ -53,7 +51,6 @@ import org.alfresco.service.cmr.model.FileNotFoundException; 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.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; @@ -81,7 +78,6 @@ import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.UniqueTag; import org.mozilla.javascript.Wrapper; -import org.springframework.util.FileCopyUtils; /** * Node class implementation, specific for use by ScriptService as part of the object model. @@ -834,6 +830,40 @@ public class ScriptNode implements Serializable, Scopeable } } + public String jsGet_downloadUrl() + { + return getDownloadUrl(); + } + + /** + * @return The WebDav cm:name based path to the content for the default content property + * (@see ContentModel.PROP_CONTENT) + */ + public String getWebdavUrl() + { + try + { + List paths = this.services.getFileFolderService().getNamePath(null, getNodeRef()); + + // build up the webdav url + StringBuilder path = new StringBuilder(128); + path.append("/webdav"); + + // build up the path skipping the first path as it is the root folder + for (int i=1; i paths = this.services.getFileFolderService().getNamePath(null, getNodeRef()); + + // build up the webdav url + StringBuilder path = new StringBuilder(128); + path.append("/webdav"); + + // build up the path skipping the first path as it is the root folder + for (int i=1; i