mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
TemplateNode API for WebDav URL to content
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7296 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,6 +37,8 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
@@ -408,6 +410,39 @@ public abstract class BaseContentNode implements TemplateContent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The WebDav cm:name based path to the content for the default content property
|
||||||
|
* (@see ContentModel.PROP_CONTENT)
|
||||||
|
*/
|
||||||
|
public String getWebdavUrl()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<FileInfo> 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.size(); i++)
|
||||||
|
{
|
||||||
|
path.append("/")
|
||||||
|
.append(StringUtils.replace(URLEncoder.encode(paths.get(i).getName(), "UTF-8"), "+", "%20"));
|
||||||
|
}
|
||||||
|
return path.toString();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException nodeErr)
|
||||||
|
{
|
||||||
|
// cannot build path if file no longer exists
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException err)
|
||||||
|
{
|
||||||
|
throw new TemplateException("Failed to encode content WebDav URL for node: " + getNodeRef(), err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The mimetype encoding for content attached to the node from the default content property
|
* @return The mimetype encoding for content attached to the node from the default content property
|
||||||
* (@see ContentModel.PROP_CONTENT)
|
* (@see ContentModel.PROP_CONTENT)
|
||||||
|
Reference in New Issue
Block a user