mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75134: Merged BRANCHES/DEV/KEVINR3 to BRANCHES/DEV/HEAD-BUG-FIX 71905: Merged BRANCHES/DEV/KEVINR2 to BRANCHES/DEV/KEVINR3 71779: Activities prototype - PDF Previewer link to original PDF correction 71776: Activities prototype - Slingshot download urls for Image Preview dashlet and PDF Previewer components. 71752: Activities prototype - Added activity feed items for Preview and Download actions 71913: Activities prototype - styling and UX 72000: Activities prototype - improved CSS 73462: Activities prototype - CSS tweaks 75128: Activities prototype - CSS tweaks git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77438 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -258,6 +258,8 @@
|
||||
<value>org.alfresco.documentlibrary.file-created</value>
|
||||
<value>org.alfresco.documentlibrary.file-deleted</value>
|
||||
<value>org.alfresco.documentlibrary.file-liked</value>
|
||||
<value>org.alfresco.documentlibrary.file-previewed</value>
|
||||
<value>org.alfresco.documentlibrary.file-downloaded</value>
|
||||
<value>org.alfresco.documentlibrary.inline-edit</value>
|
||||
<value>org.alfresco.documentlibrary.folder-liked</value>
|
||||
<value>org.alfresco.documentlibrary.folder-added</value>
|
||||
|
@@ -82,6 +82,8 @@ function postActivity()
|
||||
case "file-added":
|
||||
case "file-updated":
|
||||
case "file-liked":
|
||||
case "file-previewed":
|
||||
case "file-downloaded":
|
||||
case "folder-liked":
|
||||
case "google-docs-checkout":
|
||||
case "google-docs-checkin":
|
||||
|
@@ -0,0 +1,12 @@
|
||||
<webscript>
|
||||
<shortname>DownloadContent</shortname>
|
||||
<description>Slingshot download content webscript - posts an activity for Site content download then delegates to standard ContentGet implementation</description>
|
||||
<url>/slingshot/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}</url>
|
||||
<url>/slingshot/node/content{property}/{store_type}/{store_id}/{id}/{filename}?a={attach?}</url>
|
||||
<url>/slingshot/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}</url>
|
||||
<url>/slingshot/node/{store_type}/{store_id}/{id}/content{property}/{filename}?a={attach?}</url>
|
||||
<format default="">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -2060,4 +2060,10 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Share Content Download - post of an Activity before performing a Site download action -->
|
||||
<bean id="webscript.org.alfresco.slingshot.download.get" class="org.alfresco.slingshot.web.scripts.SlingshotContentGet" parent="webscript.org.alfresco.cmis.content.get">
|
||||
<property name="siteService" ref="SiteService" />
|
||||
<property name="activityService" ref="activityService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.slingshot.web.scripts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.web.scripts.content.ContentGet;
|
||||
import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.springframework.extensions.surf.util.StringBuilderWriter;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.extensions.webscripts.json.JSONWriter;
|
||||
|
||||
/**
|
||||
* Share specific ContentGet implementation.
|
||||
* <p>
|
||||
* Checks to see if:
|
||||
* a) the request is an explicit download (attachment)
|
||||
* b) the requested NodeRef within the context of a Share Site
|
||||
* <p>
|
||||
* If both tests are true then generates an Activity feed item to record the Download request.
|
||||
* All other requests and any further processing is performed by the super class.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class SlingshotContentGet extends ContentGet
|
||||
{
|
||||
protected SiteService siteService;
|
||||
protected ActivityService activityService;
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setActivityService(ActivityService activityService)
|
||||
{
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.web.scripts.content.ContentGet#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse)
|
||||
*/
|
||||
@Override
|
||||
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
|
||||
{
|
||||
// are we downloading content as an attachment?
|
||||
if (Boolean.valueOf(req.getParameter("a")))
|
||||
{
|
||||
// is this node part of a Site context?
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
String storeType = templateVars.get("store_type");
|
||||
String storeId = templateVars.get("store_id");
|
||||
String nodeId = templateVars.get("id");
|
||||
|
||||
// create the NodeRef and ensure it is valid
|
||||
if (storeType != null && storeId != null && nodeId != null)
|
||||
{
|
||||
final NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
|
||||
final SiteInfo site = this.siteService.getSite(nodeRef);
|
||||
if (site != null)
|
||||
{
|
||||
// found a valid parent Site - gather the details to post an Activity
|
||||
String filename = templateVars.get("filename");
|
||||
if (filename == null || filename.length() == 0)
|
||||
{
|
||||
filename = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
}
|
||||
StringBuilderWriter out = new StringBuilderWriter(256);
|
||||
final JSONWriter json = new JSONWriter(out);
|
||||
json.startObject();
|
||||
json.writeValue("title", filename);
|
||||
json.writeValue("nodeRef", nodeRef.toString());
|
||||
json.writeValue("page", "document-details?nodeRef=" + nodeRef.toString());
|
||||
json.endObject();
|
||||
|
||||
// post an activity - mirror the mechanism as if from the Share application
|
||||
this.activityService.postActivity(
|
||||
"org.alfresco.documentlibrary.file-downloaded",
|
||||
site.getShortName(),
|
||||
"documentlibrary",
|
||||
out.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
super.execute(req, res);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user