mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Switch the Links fetching webscript to be Java backed using the new service
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30101 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
|
|
||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js">
|
|
||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
|
|
||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/links/links.lib.js">
|
|
||||||
|
|
||||||
|
|
||||||
function main()
|
|
||||||
{
|
|
||||||
// get requested node
|
|
||||||
var node = getRequestNode();
|
|
||||||
if (status.getCode() != status.STATUS_OK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign data
|
|
||||||
model.item = getLinksData(node);
|
|
||||||
|
|
||||||
// fetch the contentLength param
|
|
||||||
var contentLength = args["contentLength"] != undefined ? parseInt(args["contentLength"]) : -1;
|
|
||||||
model.contentLength = isNaN(contentLength) ? -1 : contentLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
@@ -1519,6 +1519,12 @@
|
|||||||
<property name="activityService" ref="activityService"/>
|
<property name="activityService" ref="activityService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- Fetches the details of one link -->
|
||||||
|
<bean id="webscript.org.alfresco.repository.links.link.link.get"
|
||||||
|
class="org.alfresco.repo.web.scripts.links.LinkGet"
|
||||||
|
parent="abstractLinksWebScript">
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Lists the Links for a site -->
|
<!-- Lists the Links for a site -->
|
||||||
<bean id="webscript.org.alfresco.repository.links.links.get"
|
<bean id="webscript.org.alfresco.repository.links.links.get"
|
||||||
class="org.alfresco.repo.web.scripts.links.LinksListGet"
|
class="org.alfresco.repo.web.scripts.links.LinksListGet"
|
||||||
|
62
source/java/org/alfresco/repo/web/scripts/links/LinkGet.java
Normal file
62
source/java/org/alfresco/repo/web/scripts/links/LinkGet.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 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.repo.web.scripts.links;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.links.LinkInfo;
|
||||||
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the controller for the link fetching link.get webscript.
|
||||||
|
*
|
||||||
|
* @author Nick Burch
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public class LinkGet extends AbstractLinksWebScript
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Map<String, Object> executeImpl(SiteInfo site, String linkName,
|
||||||
|
WebScriptRequest req, JSONObject json, Status status, Cache cache) {
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
// Try to find the link
|
||||||
|
LinkInfo link = linksService.getLink(site.getShortName(), linkName);
|
||||||
|
if(link == null)
|
||||||
|
{
|
||||||
|
String message = "No link found with that name";
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the model
|
||||||
|
model.put("item", renderLink(link));
|
||||||
|
model.put("node", link.getNodeRef());
|
||||||
|
model.put("siteId", site.getShortName());
|
||||||
|
model.put("site", site);
|
||||||
|
|
||||||
|
// All done
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user