diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-noauth.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-noauth.get.desc.xml
new file mode 100644
index 0000000000..8d419184a1
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-noauth.get.desc.xml
@@ -0,0 +1,19 @@
+
+ QuickShare - get some "shared" content
+
+ if QuickShare exists then gets the content stream for the specified document
+
+ TODO:
+ - do we need both options (/node/content/{shared_id} vs /node/{shared_id}/content) ?
+ ]]>
+
+
+ /api/internal/shared/node/content{property}/{shared_id}?a={attach?}
+ /api/internal/shared/node/{shared_id}/content{property}?a={attach?}
+
+ argument
+ none
+
+ internal
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-thumbnail-noauth.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-thumbnail-noauth.get.desc.xml
new file mode 100644
index 0000000000..e6766cf166
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/content-thumbnail-noauth.get.desc.xml
@@ -0,0 +1,15 @@
+
+ QuickShare - get some "shared" thumbnail content
+
+ if QuickShare exists then gets the content stream for the specified document thumbnail/rendition
+ ]]>
+
+
+ /api/internal/shared/node/{shared_id}/content{property}/thumbnails/{thumbnailname}?a={attach?}
+
+ argument
+ none
+
+ internal
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.desc.xml
new file mode 100644
index 0000000000..e8f45ae162
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.desc.xml
@@ -0,0 +1,12 @@
+
+QuickShare - get some limited metadata for "shared" content (including thumbnail defs)
+
+ if QuickShare exists then gets the limited metadata for the specified document
+ ]]>
+
+ /api/internal/shared/node/{shared_id}/metadata
+
+ none
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.json.ftl
new file mode 100644
index 0000000000..99c80e2628
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata-noauth.get.json.ftl
@@ -0,0 +1,2 @@
+<#import "metadata.lib.ftl" as metadataLib />
+<@metadataLib.resultsJSON item=item />
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.desc.xml
new file mode 100644
index 0000000000..fbce00923a
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.desc.xml
@@ -0,0 +1,12 @@
+
+Get some limited metadata for content (including thumbnail defs)
+
+
+
+ /api/node/{store_protocol}/{store_id}/{node_id}/metadata
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.json.ftl
new file mode 100644
index 0000000000..99c80e2628
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.get.json.ftl
@@ -0,0 +1,2 @@
+<#import "metadata.lib.ftl" as metadataLib />
+<@metadataLib.resultsJSON item=item />
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.lib.ftl
new file mode 100644
index 0000000000..1fe70144ce
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/metadata.lib.ftl
@@ -0,0 +1,43 @@
+<#macro resultsJSON item>
+<#escape x as jsonUtils.encodeJSONString(x)>
+{
+ "name": "${item.name}",
+ "title": "${item.title!""}",
+ "mimetype": "${item.mimetype!""}",
+ "size": ${item.size?c},
+ "modifiedOn": "${xmldate(item.modified)}",
+ "modifier":
+ {
+ "firstName": "${item.modifierFirstName!""}",
+ "lastName": "${item.modifierLastName!""}"
+ },
+ "thumbnailDefinitions":
+ [
+ <#if item.thumbnailDefinitions??>
+ <#list item.thumbnailDefinitions as thumbnailDefinition>
+ "${thumbnailDefinition}"
+ <#if thumbnailDefinition_has_next>,#if>
+ #list>
+ #if>
+ ],
+ "thumbnails":
+ [
+ <#if item.thumbnailNames??>
+ <#list item.thumbnailNames as thumbnailName>
+ "${thumbnailName}"
+ <#if thumbnailName_has_next>,#if>
+ #list>
+ #if>
+ ],
+ "lastThumbnailModificationData":
+ [
+ <#if item.lastThumbnailModificationData??>
+ <#list item.lastThumbnailModificationData as lastThumbnailMod>
+ "${lastThumbnailMod}"
+ <#if lastThumbnailMod_has_next>,#if>
+ #list>
+ #if>
+ ]
+}
+#escape>
+#macro>
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.desc.xml
new file mode 100644
index 0000000000..ed5efe3fea
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.desc.xml
@@ -0,0 +1,12 @@
+
+Get some node context (nodeRef, tenantDomain, siteId) for given shared_id
+
+
+
+ /api/internal/shared/share/{shared_id}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.json.ftl
new file mode 100644
index 0000000000..618bf81e7b
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.get.json.ftl
@@ -0,0 +1,8 @@
+<#escape x as jsonUtils.encodeJSONString(x)>
+{
+ "sharedId" : "${sharedId}",
+ "nodeRef" : "${nodeRef}",
+ "tenantDomain" : "${tenantDomain}",
+ "siteId" : "${siteId}"
+}
+#escape>
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.desc.xml
new file mode 100644
index 0000000000..23821924d0
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.desc.xml
@@ -0,0 +1,17 @@
+
+ QuickShare - "share" some content => enable public/unauthenticated access
+
+
+
+
+ /api/internal/shared/share/{store_protocol}/{store_id}/{node_id}
+
+ argument
+ user
+ internal
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.json.ftl
new file mode 100644
index 0000000000..b083e2fbe4
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/share.post.json.ftl
@@ -0,0 +1,5 @@
+<#escape x as jsonUtils.encodeJSONString(x)>
+{
+ "sharedId" : "${sharedId}"
+}
+#escape>
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.desc.xml
new file mode 100644
index 0000000000..2453ebe38d
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.desc.xml
@@ -0,0 +1,14 @@
+
+ QuickShare - "unshare" some content => disable public/unauthenticated access
+
+
+
+
+ /api/internal/shared/unshare/{shared_id}
+
+ argument
+ user
+ internal
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.json.ftl
new file mode 100644
index 0000000000..99e4ef07c6
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/unshare.delete.json.ftl
@@ -0,0 +1,5 @@
+<#escape x as jsonUtils.encodeJSONString(x)>
+{
+ "success" : ${success?string}
+}
+#escape>
\ No newline at end of file
diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml
index 3ca598456c..6979d55294 100644
--- a/config/alfresco/web-scripts-application-context.xml
+++ b/config/alfresco/web-scripts-application-context.xml
@@ -1840,4 +1840,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/web/scripts/quickshare/AbstractQuickShareContent.java b/source/java/org/alfresco/repo/web/scripts/quickshare/AbstractQuickShareContent.java
new file mode 100644
index 0000000000..fc8cb41980
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/quickshare/AbstractQuickShareContent.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2005-2012 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.quickshare;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.alfresco.repo.tenant.TenantService;
+import org.alfresco.repo.tenant.TenantUtil;
+import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
+import org.alfresco.service.cmr.attributes.AttributeService;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.util.Pair;
+import org.springframework.extensions.webscripts.DeclarativeWebScript;
+import org.springframework.extensions.webscripts.WebScriptException;
+
+
+/**
+ * QuickShare/PublicView
+ *
+ * @author janv
+ */
+public abstract class AbstractQuickShareContent extends DeclarativeWebScript
+{
+ protected NodeService nodeService;
+ protected AttributeService attributeService;
+ protected TenantService tenantService;
+
+ private boolean enabled = true;
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ public void setAttributeService(AttributeService attributeService)
+ {
+ this.attributeService = attributeService;
+ }
+
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ protected boolean isEnabled()
+ {
+ return this.enabled;
+ }
+
+
+ protected Pair getTenantNodeRefFromSharedId(final String sharedId)
+ {
+ return getTenantNodeRefFromSharedId(attributeService, tenantService, sharedId);
+ }
+
+ /* package */ static Pair getTenantNodeRefFromSharedId(final AttributeService attributeService, final TenantService tenantService, final String sharedId)
+ {
+ final NodeRef nodeRef = TenantUtil.runAsDefaultTenant(new TenantRunAsWork()
+ {
+ public NodeRef doWork() throws Exception
+ {
+ return (NodeRef)attributeService.getAttribute(ShareContentPost.ATTR_KEY_SHAREDIDS_ROOT, sharedId);
+ }
+ });
+
+ if (nodeRef == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
+ }
+
+ // note: relies on tenant-specific (ie. mangled) nodeRef
+ String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
+
+ return new Pair(tenantDomain, tenantService.getBaseName(nodeRef));
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/quickshare/MetaDataGet.java b/source/java/org/alfresco/repo/web/scripts/quickshare/MetaDataGet.java
new file mode 100644
index 0000000000..47d4d9f514
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/quickshare/MetaDataGet.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2005-2012 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.quickshare;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.repo.thumbnail.ThumbnailDefinition;
+import org.alfresco.repo.web.scripts.WebScriptUtil;
+import org.alfresco.service.cmr.repository.ContentData;
+import org.alfresco.service.cmr.repository.InvalidNodeRefException;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.security.NoSuchPersonException;
+import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.cmr.thumbnail.ThumbnailService;
+import org.alfresco.service.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * QuickShare/PublicView
+ *
+ * GET web script to get limited metadata (including thumbnail defs) => authenticated web script (using a nodeRef)
+ *
+ * Note: authenticated web script (equivalent to unauthenticated version - see QuickShareMetaDataGet)
+ *
+ * @author janv
+ */
+public class MetaDataGet extends AbstractQuickShareContent
+{
+ private static final Log logger = LogFactory.getLog(QuickShareMetaDataGet.class);
+
+ private PersonService personService;
+ private ThumbnailService thumbnailService;
+
+ public void setPersonService(PersonService personService)
+ {
+ this.personService = personService;
+ }
+
+ public void setThumbnailService(ThumbnailService thumbnailService)
+ {
+ this.thumbnailService = thumbnailService;
+ }
+
+
+ @Override
+ protected Map executeImpl(final WebScriptRequest req, Status status, Cache cache)
+ {
+ // create map of params (template vars)
+ Map params = req.getServiceMatch().getTemplateVars();
+ final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
+ if (nodeRef == null)
+ {
+ String msg = "A valid NodeRef must be specified!";
+ throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
+
+ try
+ {
+ Map model = getMetaDataModel(nodeRef);
+
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("Retrieved limited metadata: "+nodeRef+" ["+model+"]");
+ }
+
+ return model;
+ }
+ catch (InvalidNodeRefException inre)
+ {
+ logger.error("Unable to find node: "+inre.getNodeRef());
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find nodeRef: "+inre.getNodeRef());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Map getMetaDataModel(NodeRef nodeRef)
+ {
+ QName typeQName = nodeService.getType(nodeRef);
+ if (! typeQName.equals(ContentModel.TYPE_CONTENT))
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
+
+ Map nodeProps = nodeService.getProperties(nodeRef);
+ ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
+
+ String modifierUserName = (String)nodeProps.get(ContentModel.PROP_MODIFIER);
+ Map personProps = null;
+ if (modifierUserName != null)
+ {
+ try
+ {
+ NodeRef personRef = personService.getPerson(modifierUserName);
+ if (personRef != null)
+ {
+ personProps = nodeService.getProperties(personRef);
+ }
+ }
+ catch (NoSuchPersonException nspe)
+ {
+ // absorb this exception - eg. System (or maybe the user has been deleted)
+ if (logger.isInfoEnabled())
+ {
+ logger.info("MetaDataGet - no such person: "+modifierUserName);
+ }
+ }
+ }
+
+ Map metadata = new HashMap(8);
+
+ metadata.put("name", nodeProps.get(ContentModel.PROP_NAME));
+ metadata.put("title", nodeProps.get(ContentModel.PROP_TITLE));
+
+ if (contentData != null)
+ {
+ metadata.put("mimetype", contentData.getMimetype());
+ metadata.put("size", contentData.getSize());
+ }
+ else
+ {
+ metadata.put("size", 0L);
+ }
+
+ metadata.put("modified", nodeProps.get(ContentModel.PROP_MODIFIED));
+
+ if (personProps != null)
+ {
+ metadata.put("modifierFirstName", personProps.get(ContentModel.PROP_FIRSTNAME));
+ metadata.put("modifierLastName", personProps.get(ContentModel.PROP_LASTNAME));
+ }
+
+ // thumbnail defs for this nodeRef
+ List thumbnailDefs = new ArrayList(7);
+ if (contentData != null)
+ {
+ // Note: thumbnail defs only appear in this list if they can produce a thumbnail for the content
+ // found in the content property of this node. This will be determined by looking at the mimetype of the content
+ // and the destination mimetype of the thumbnail.
+ List thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(contentData.getMimetype(), contentData.getSize());
+ for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions)
+ {
+ thumbnailDefs.add(thumbnailDefinition.getName());
+ }
+ }
+ metadata.put("thumbnailDefinitions", thumbnailDefs);
+
+ // thumbnail instances for this nodeRef
+ List thumbnailRefs = thumbnailService.getThumbnails(nodeRef, ContentModel.PROP_CONTENT, null, null);
+ List thumbnailNames = new ArrayList(thumbnailRefs.size());
+ for (NodeRef thumbnailRef : thumbnailRefs)
+ {
+ thumbnailNames.add((String)nodeService.getProperty(thumbnailRef, ContentModel.PROP_NAME));
+ }
+ metadata.put("thumbnailNames", thumbnailNames);
+
+ metadata.put("lastThumbnailModificationData", (List)nodeProps.get(ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA));
+
+ Map model = new HashMap(1);
+ model.put("item", metadata);
+ return model;
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareContentGet.java b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareContentGet.java
new file mode 100644
index 0000000000..4dbed92472
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareContentGet.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2005-2012 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.quickshare;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.model.QuickShareModel;
+import org.alfresco.repo.tenant.TenantService;
+import org.alfresco.repo.tenant.TenantUtil;
+import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
+import org.alfresco.repo.web.scripts.content.ContentGet;
+import org.alfresco.service.cmr.attributes.AttributeService;
+import org.alfresco.service.cmr.repository.InvalidNodeRefException;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.Pair;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+import org.springframework.extensions.webscripts.WebScriptResponse;
+
+
+/**
+ * QuickShare/PublicView
+ *
+ * GET web script to get stream "shared" content (ie. enabled for public/unauthenticated access) from the repository
+ *
+ * WARNING: **unauthenticated** web script (equivalent to authenticated version - see ContentGet.java)
+ *
+ * @author janv
+ */
+public class QuickShareContentGet extends ContentGet
+{
+ private static final Log logger = LogFactory.getLog(QuickShareContentGet.class);
+
+ private NodeService nodeService;
+ private NamespaceService namespaceService;
+ private AttributeService attributeService;
+ private TenantService tenantService;
+
+ private boolean enabled = true;
+
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ super.setNodeService(nodeService);
+ }
+
+ public void setNamespaceService(NamespaceService namespaceService)
+ {
+ this.namespaceService = namespaceService;
+ super.setNamespaceService(namespaceService);
+ }
+
+ public void setAttributeService(AttributeService attributeService)
+ {
+ this.attributeService = attributeService;
+ }
+
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ protected boolean isEnabled()
+ {
+ return this.enabled;
+ }
+
+
+ @Override
+ public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
+ {
+ if (! isEnabled())
+ {
+ throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
+ }
+
+ // create map of template vars (params)
+ final Map params = req.getServiceMatch().getTemplateVars();
+ final String sharedId = params.get("shared_id");
+ if (sharedId == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
+ }
+
+ try
+ {
+ Pair pair = ShareContentPost.getTenantNodeRefFromSharedId(attributeService, tenantService, sharedId);
+ final String tenantDomain = pair.getFirst();
+ final NodeRef nodeRef = pair.getSecond();
+
+ TenantUtil.runAsSystemTenant(new TenantRunAsWork()
+ {
+ public Void doWork() throws Exception
+ {
+ if (! nodeService.getAspects(nodeRef).contains(QuickShareModel.ASPECT_QSHARE))
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
+
+ executeImpl(nodeRef, params, req, res, null);
+
+ return null;
+ }
+ }, tenantDomain);
+
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("QuickShare - retrieved content: "+sharedId+" ["+nodeRef+"]");
+ }
+
+ }
+ catch (InvalidNodeRefException inre)
+ {
+ logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
+ }
+ }
+
+ protected void executeImpl(NodeRef nodeRef, Map templateVars, WebScriptRequest req, WebScriptResponse res, Map model) throws IOException
+ {
+ // render content
+ QName propertyQName = ContentModel.PROP_CONTENT;
+ String contentPart = templateVars.get("property");
+ if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
+ {
+ if (contentPart.length() < 2)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
+ }
+ String propertyName = contentPart.substring(1);
+ if (propertyName.length() > 0)
+ {
+ propertyQName = QName.createQName(propertyName, namespaceService);
+ }
+ }
+
+ // determine attachment
+ boolean attach = Boolean.valueOf(req.getParameter("a"));
+
+ // Stream the content
+ streamContent(req, res, nodeRef, propertyQName, attach, model);
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareMetaDataGet.java b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareMetaDataGet.java
new file mode 100644
index 0000000000..8b0b8a1c2e
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareMetaDataGet.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2005-2012 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.quickshare;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.alfresco.model.QuickShareModel;
+import org.alfresco.repo.tenant.TenantUtil;
+import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
+import org.alfresco.service.cmr.repository.InvalidNodeRefException;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.util.Pair;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+
+/**
+ * QuickShare/PublicView
+ *
+ * GET web script to get limited metadata (including thumbnail defs) for some "shared" content
+ *
+ * WARNING: **unauthenticated** web script (equivalent to authenticated version - see MetaDataGet.java)
+ *
+ * @author janv
+ */
+public class QuickShareMetaDataGet extends MetaDataGet
+{
+ private static final Log logger = LogFactory.getLog(QuickShareMetaDataGet.class);
+
+ @Override
+ protected Map executeImpl(final WebScriptRequest req, Status status, Cache cache)
+ {
+ if (! isEnabled())
+ {
+ throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
+ }
+
+ // create map of params (template vars)
+ Map params = req.getServiceMatch().getTemplateVars();
+ final String sharedId = params.get("shared_id");
+ if (sharedId == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
+ }
+
+ try
+ {
+ Pair pair = getTenantNodeRefFromSharedId(attributeService, tenantService, sharedId);
+ final String tenantDomain = pair.getFirst();
+ final NodeRef nodeRef = pair.getSecond();
+
+ Map model = TenantUtil.runAsSystemTenant(new TenantRunAsWork