mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Removed all references to Site from publishing REST API. Replaced publishing-events-query.post with publishing-events-for-node.get.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29301 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,17 +1,13 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>Get Publishing Channels</shortname>
|
<shortname>Get Publishing Channels</shortname>
|
||||||
<description>Get the publishing channels for a Share Site.or specified NodeRef</description>
|
<description>Get the publishing channels for specified NodeRef or returns all Publishing Channels</description>
|
||||||
<url>/api/publishing/site/{site_id}/channels</url>
|
<url>/api/publishing/channels</url>
|
||||||
<url>/api/publishing/{store_protocol}/{store_id}/{node_id}/channels</url>
|
<url>/api/publishing/{store_protocol}/{store_id}/{node_id}/channels</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
<lifecycle>public_api</lifecycle>
|
<lifecycle>public_api</lifecycle>
|
||||||
<args>
|
<args>
|
||||||
<arg>
|
|
||||||
<shortname>site_id</shortname>
|
|
||||||
<description>The id of the site to retrieve channels for.</description>
|
|
||||||
</arg>
|
|
||||||
<arg>
|
<arg>
|
||||||
<shortname>store_protocol</shortname>
|
<shortname>store_protocol</shortname>
|
||||||
<description>The protocol used by the StoreRef to retrieve channels for.</description>
|
<description>The protocol used by the StoreRef to retrieve channels for.</description>
|
||||||
|
@@ -0,0 +1,160 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Get Publishing Events For Node</shortname>
|
||||||
|
<description>Find all PublishingEvents that publish or unpublish the specified node.</description>
|
||||||
|
<url>/api/publishing/{store_protocol}/{store_id}/{node_id}/events</url>
|
||||||
|
<format default="json"/>
|
||||||
|
<authentication>user</authentication>
|
||||||
|
<transaction allow="readonly">required</transaction>
|
||||||
|
<lifecycle>public_api</lifecycle>
|
||||||
|
<args>
|
||||||
|
<arg>
|
||||||
|
<shortname>store_protocol</shortname>
|
||||||
|
<description>The store protocol for the published/unpublished node.</description>
|
||||||
|
</arg>
|
||||||
|
<arg>
|
||||||
|
<shortname>store_id</shortname>
|
||||||
|
<description>The store id for the published/unpublished node.</description>
|
||||||
|
</arg>
|
||||||
|
<arg>
|
||||||
|
<shortname>node_id</shortname>
|
||||||
|
<description>The node id for the published/unpublished node.</description>
|
||||||
|
</arg>
|
||||||
|
</args>
|
||||||
|
<responses>
|
||||||
|
<response>
|
||||||
|
<format>json</format>
|
||||||
|
<type>
|
||||||
|
<![CDATA[
|
||||||
|
{
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
"publishingEvents":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": string,
|
||||||
|
"url": string,
|
||||||
|
"status": string,
|
||||||
|
"comment": string,
|
||||||
|
"eventType": string,
|
||||||
|
"scheduledTime":
|
||||||
|
{
|
||||||
|
"dateTime": string,
|
||||||
|
"format": string,
|
||||||
|
"timeZone": string
|
||||||
|
}
|
||||||
|
"creator": string,
|
||||||
|
"createdTime":
|
||||||
|
{
|
||||||
|
"dateTime": string,
|
||||||
|
"format": string
|
||||||
|
},
|
||||||
|
"publishNodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"nodeRef": string,
|
||||||
|
"name": string,
|
||||||
|
"version": string
|
||||||
|
},
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"unpublishNodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"nodeRef": string,
|
||||||
|
"name": string,
|
||||||
|
"version": string
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"channel":
|
||||||
|
{
|
||||||
|
"url": string,
|
||||||
|
"name": string,
|
||||||
|
"title": string,
|
||||||
|
"channelType":
|
||||||
|
{
|
||||||
|
"id": string,
|
||||||
|
"title": string,
|
||||||
|
"url": string,
|
||||||
|
"channelNodeType": string,
|
||||||
|
"contentRootNodeType": string,
|
||||||
|
"supportedContentTypes": [string, ...],
|
||||||
|
"supportedMimeTypes": [string, ...],
|
||||||
|
"canPublish": boolean,
|
||||||
|
"canPublishStatusUpdates": boolean,
|
||||||
|
"canUnpublish": boolean,
|
||||||
|
"maxStatusLength": number,
|
||||||
|
"icon": string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
unpublishingEvents:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": string,
|
||||||
|
"url": string,
|
||||||
|
"status": string,
|
||||||
|
"comment": string,
|
||||||
|
"scheduledTime":
|
||||||
|
{
|
||||||
|
"dateTime": string,
|
||||||
|
"format": string,
|
||||||
|
"timeZone": string
|
||||||
|
}
|
||||||
|
"creator": string,
|
||||||
|
"createdTime":
|
||||||
|
{
|
||||||
|
"dateTime": string,
|
||||||
|
"format": string
|
||||||
|
},
|
||||||
|
"publishNodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"nodeRef": string,
|
||||||
|
"name": string,
|
||||||
|
"version": string
|
||||||
|
},
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"unpublishNodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"nodeRef": string,
|
||||||
|
"name": string,
|
||||||
|
"version": string
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"channel":
|
||||||
|
{
|
||||||
|
"url": string,
|
||||||
|
"name": string,
|
||||||
|
"title": string,
|
||||||
|
"channelType":
|
||||||
|
{
|
||||||
|
"id": string,
|
||||||
|
"title": string,
|
||||||
|
"url": string,
|
||||||
|
"channelNodeType": string,
|
||||||
|
"contentRootNodeType": string,
|
||||||
|
"supportedContentTypes": [string, ...],
|
||||||
|
"supportedMimeTypes": [string, ...],
|
||||||
|
"canPublish": boolean,
|
||||||
|
"canPublishStatusUpdates": boolean,
|
||||||
|
"canUnpublish": boolean,
|
||||||
|
"maxStatusLength": number,
|
||||||
|
"icon": string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</type>
|
||||||
|
</response>
|
||||||
|
</responses>
|
||||||
|
</webscript>
|
@@ -1,100 +0,0 @@
|
|||||||
<webscript>
|
|
||||||
<shortname>Query Publishing Events</shortname>
|
|
||||||
<description>Queries for Publishing Events on an Environment.</description>
|
|
||||||
<url>/api/publishing/{site_id}/events/query</url>
|
|
||||||
<format default="json"/>
|
|
||||||
<authentication>user</authentication>
|
|
||||||
<transaction>required</transaction>
|
|
||||||
<lifecycle>public_api</lifecycle>
|
|
||||||
<args>
|
|
||||||
<arg>
|
|
||||||
<shortname>site_id</shortname>
|
|
||||||
<description>The id of the site to query.</description>
|
|
||||||
</arg>
|
|
||||||
</args>
|
|
||||||
<requests>
|
|
||||||
<request>
|
|
||||||
<format>json</format>
|
|
||||||
<type>
|
|
||||||
<![CDATA[
|
|
||||||
{
|
|
||||||
"publishNodes": [string, ... ]
|
|
||||||
"unpublishNodes": [string, ... ]
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</type>
|
|
||||||
</request>
|
|
||||||
</requests>
|
|
||||||
<responses>
|
|
||||||
<response>
|
|
||||||
<format>json</format>
|
|
||||||
<type>
|
|
||||||
<![CDATA[
|
|
||||||
{
|
|
||||||
"data":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": string,
|
|
||||||
"url": string,
|
|
||||||
"status": string,
|
|
||||||
"comment": string,
|
|
||||||
"scheduledTime":
|
|
||||||
{
|
|
||||||
"dateTime": string,
|
|
||||||
"format": string,
|
|
||||||
"timeZone": string
|
|
||||||
}
|
|
||||||
"creator": string,
|
|
||||||
"createdTime":
|
|
||||||
{
|
|
||||||
"dateTime": string,
|
|
||||||
"format": string
|
|
||||||
},
|
|
||||||
"publishNodes":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"nodeRef": string,
|
|
||||||
"name": string,
|
|
||||||
"version": string
|
|
||||||
},
|
|
||||||
...
|
|
||||||
],
|
|
||||||
"unpublishNodes":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"nodeRef": string,
|
|
||||||
"name": string,
|
|
||||||
"version": string
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"channel":
|
|
||||||
{
|
|
||||||
"url": string,
|
|
||||||
"name": string,
|
|
||||||
"title": string,
|
|
||||||
"channelType":
|
|
||||||
{
|
|
||||||
"id": string,
|
|
||||||
"title": string,
|
|
||||||
"url": string,
|
|
||||||
"channelNodeType": string,
|
|
||||||
"contentRootNodeType": string,
|
|
||||||
"supportedContentTypes": [string, ...],
|
|
||||||
"supportedMimeTypes": [string, ...],
|
|
||||||
"canPublish": boolean,
|
|
||||||
"canPublishStatusUpdates": boolean,
|
|
||||||
"canUnpublish": boolean,
|
|
||||||
"maxStatusLength": number,
|
|
||||||
"icon": string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</type>
|
|
||||||
</response>
|
|
||||||
</responses>
|
|
||||||
</webscript>
|
|
@@ -1,17 +1,11 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>Post Content to Publishing Queue</shortname>
|
<shortname>Post Content to Publishing Queue</shortname>
|
||||||
<description>Place a new Publishing Event on the Publishing Queue for the specified Environment.</description>
|
<description>Place a new Publishing Event on the Publishing Queue..</description>
|
||||||
<url>/api/publishing/{site_id}/queue</url>
|
<url>/api/publishing/queue</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
<lifecycle>public_api</lifecycle>
|
<lifecycle>public_api</lifecycle>
|
||||||
<args>
|
|
||||||
<arg>
|
|
||||||
<shortname>site_id</shortname>
|
|
||||||
<description>The id of the site to publish to.</description>
|
|
||||||
</arg>
|
|
||||||
</args>
|
|
||||||
<requests>
|
<requests>
|
||||||
<request>
|
<request>
|
||||||
<format>json</format>
|
<format>json</format>
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"url": "${event.url}",
|
"url": "${event.url}",
|
||||||
"status": "${event.status}",
|
"status": "${event.status}",
|
||||||
<#if event.comment?? >"comment": "${event.comment}",</#if>
|
<#if event.comment?? >"comment": "${event.comment}",</#if>
|
||||||
|
<#if event.eventType?? >"eventType": "${event.eventType}",</#if>
|
||||||
<#if event.scheduledTime?? >
|
<#if event.scheduledTime?? >
|
||||||
"scheduledTime":
|
"scheduledTime":
|
||||||
<@calendarJSON calendar=event.scheduledTime />,
|
<@calendarJSON calendar=event.scheduledTime />,
|
||||||
|
@@ -1146,9 +1146,9 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<!-- Post Publishing Events Query web script -->
|
<!-- Get Publishing Events For Node web script -->
|
||||||
<bean id="webscript.org.alfresco.repository.publishing.publishing-events-query.post"
|
<bean id="webscript.org.alfresco.repository.publishing.publishing-events-for-node.get"
|
||||||
class="org.alfresco.repo.web.scripts.publishing.PUblishingEventsQueryPost"
|
class="org.alfresco.repo.web.scripts.publishing.PUblishingEventsForNodeGet"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="publishingService" ref="publishingService" />
|
<property name="publishingService" ref="publishingService" />
|
||||||
<property name="channelService" ref="channelService" />
|
<property name="channelService" ref="channelService" />
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
package org.alfresco.repo.web.scripts.publishing;
|
package org.alfresco.repo.web.scripts.publishing;
|
||||||
|
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISHING_CHANNELS;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISHING_CHANNELS;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.SITE_ID;
|
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.STATUS_UPDATE_CHANNELS;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.STATUS_UPDATE_CHANNELS;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.URL_LENGTH;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.URL_LENGTH;
|
||||||
|
|
||||||
@@ -28,8 +27,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
||||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||||
@@ -38,7 +35,6 @@ import org.alfresco.service.cmr.urlshortening.UrlShortener;
|
|||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,23 +55,17 @@ public class ChannelsGet extends DeclarativeWebScript
|
|||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, String> params = req.getServiceMatch().getTemplateVars();
|
Map<String, String> params = req.getServiceMatch().getTemplateVars();
|
||||||
String siteId = params.get(SITE_ID);
|
NodeRef node = WebScriptUtil.getNodeRef(params);
|
||||||
|
|
||||||
List<Channel> publishingChannels;
|
List<Channel> publishingChannels;
|
||||||
List<Channel> statusUpdateChannels;
|
List<Channel> statusUpdateChannels;
|
||||||
if (siteId!= null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
publishingChannels = channelService.getPublishingChannels();
|
publishingChannels = channelService.getPublishingChannels();
|
||||||
statusUpdateChannels = channelService.getStatusUpdateChannels();
|
statusUpdateChannels = channelService.getStatusUpdateChannels();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NodeRef node = WebScriptUtil.getNodeRef(params);
|
|
||||||
if(node == null)
|
|
||||||
{
|
|
||||||
String msg = "Either a Site ID or valid NodeRef must be specified!";
|
|
||||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
|
|
||||||
}
|
|
||||||
publishingChannels = channelService.getRelevantPublishingChannels(node);
|
publishingChannels = channelService.getRelevantPublishingChannels(node);
|
||||||
statusUpdateChannels = channelService.getStatusUpdateChannels();
|
statusUpdateChannels = channelService.getStatusUpdateChannels();
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.web.scripts.publishing;
|
package org.alfresco.repo.web.scripts.publishing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
@@ -37,7 +39,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
* @since 4.0
|
* @since 4.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PUblishingEventsQueryPost extends PublishingEnvironmentWebScript
|
public class PUblishingEventsForNodeGet extends PublishingWebScript
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
@@ -45,20 +47,33 @@ public class PUblishingEventsQueryPost extends PublishingEnvironmentWebScript
|
|||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
String siteId = getSiteId(req);
|
Map<String, String> params = req.getServiceMatch().getTemplateVars();
|
||||||
PublishingQueue queue = getQueue(siteId);
|
NodeRef node = WebScriptUtil.getNodeRef(params);
|
||||||
String content = null;
|
if(node == null)
|
||||||
|
{
|
||||||
|
String msg = "A valid NodeRef must be specified!";
|
||||||
|
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
content = WebScriptUtil.getContent(req);
|
ArrayList<PublishingEvent> events = getSortedPublishingEvents(node);
|
||||||
List<PublishingEvent> events = jsonParser.query(queue, content);
|
List<Map<String, Object>> model = builder.buildPublishingEventsForNode(events, node, channelService);
|
||||||
List<Map<String, Object>> model = builder.buildPublishingEvents(events, channelService);
|
|
||||||
return WebScriptUtil.createBaseModel(model);
|
return WebScriptUtil.createBaseModel(model);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
String msg = "Failed to query for publishing events. POST body: " + content;
|
String msg = "Failed to query for publishing events for node: " + node;
|
||||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
|
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<PublishingEvent> getSortedPublishingEvents(NodeRef node)
|
||||||
|
{
|
||||||
|
List<PublishingEvent> publishedEvents = publishingService.getEventsForPublishedNode(node);
|
||||||
|
List<PublishingEvent> unpublishedEvents = publishingService.getEventsForUnpublishedNode(node);
|
||||||
|
ArrayList<PublishingEvent> allEvents = new ArrayList<PublishingEvent>(publishedEvents);
|
||||||
|
allEvents.addAll(unpublishedEvents);
|
||||||
|
Collections.sort(allEvents);
|
||||||
|
return allEvents;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -23,7 +23,6 @@ import static org.alfresco.repo.web.scripts.WebScriptUtil.getCalendar;
|
|||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_ID;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_ID;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_IDS;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_IDS;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.COMMENT;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.COMMENT;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.IDS;
|
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.MESSAGE;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.MESSAGE;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.NODE_REF;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.NODE_REF;
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISH_NODES;
|
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISH_NODES;
|
||||||
@@ -40,8 +39,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.alfresco.repo.node.NodeUtils;
|
import org.alfresco.repo.node.NodeUtils;
|
||||||
import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
|
import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEventFilter;
|
|
||||||
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
||||||
import org.alfresco.service.cmr.publishing.StatusUpdate;
|
import org.alfresco.service.cmr.publishing.StatusUpdate;
|
||||||
@@ -70,26 +67,6 @@ public class PublishingJsonParser
|
|||||||
return new JSONObject();
|
return new JSONObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PublishingEvent> query(PublishingQueue queue, String content) throws JSONException
|
|
||||||
{
|
|
||||||
JSONObject json = getJson(content);
|
|
||||||
PublishingEventFilter filter = buildFilter(queue, json);
|
|
||||||
return queue.getPublishingEvents(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PublishingEventFilter buildFilter(PublishingQueue queue, JSONObject json)
|
|
||||||
{
|
|
||||||
List<NodeRef> publishNodes = toNodes(json.optJSONArray(PUBLISH_NODES));
|
|
||||||
List<NodeRef> unpublishNodes = toNodes(json.optJSONArray(UNPUBLISH_NODES));
|
|
||||||
List<String> ids = JsonUtils.toListOfStrings(json.optJSONArray(IDS));
|
|
||||||
|
|
||||||
PublishingEventFilter filter = queue.createPublishingEventFilter()
|
|
||||||
.setIds(ids)
|
|
||||||
.setPublishedNodes(publishNodes)
|
|
||||||
.setUnpublishedNodes(unpublishNodes);
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String schedulePublishingEvent(PublishingQueue queue, String jsonStr) throws ParseException, JSONException
|
public String schedulePublishingEvent(PublishingQueue queue, String jsonStr) throws ParseException, JSONException
|
||||||
{
|
{
|
||||||
JSONObject json = getJson(jsonStr);
|
JSONObject json = getJson(jsonStr);
|
||||||
|
@@ -50,6 +50,26 @@ import org.springframework.extensions.surf.util.URLEncoder;
|
|||||||
*/
|
*/
|
||||||
public class PublishingModelBuilder implements PublishingWebScriptConstants
|
public class PublishingModelBuilder implements PublishingWebScriptConstants
|
||||||
{
|
{
|
||||||
|
public Map<String, Object> buildPublishingEventForNode(PublishingEvent event, NodeRef node, ChannelService channelService)
|
||||||
|
{
|
||||||
|
Map<String, Object> model = buildPublishingEvent(event, channelService);
|
||||||
|
boolean isPublish = event.getPackage().getNodesToPublish().contains(node);
|
||||||
|
String type = isPublish ? "published" : "unpublished";
|
||||||
|
model.put(EVENT_TYPE, type);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> buildPublishingEventsForNode(List<PublishingEvent> events,
|
||||||
|
final NodeRef node, final ChannelService channelService)
|
||||||
|
{
|
||||||
|
return transform(events, new Function<PublishingEvent, Map<String, Object>>()
|
||||||
|
{
|
||||||
|
public Map<String, Object> apply(PublishingEvent event)
|
||||||
|
{
|
||||||
|
return buildPublishingEventForNode(event, node, channelService);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> buildPublishingEvent(PublishingEvent event, ChannelService channelService)
|
public Map<String, Object> buildPublishingEvent(PublishingEvent event, ChannelService channelService)
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
@@ -36,7 +35,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
* @since 4.0
|
* @since 4.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PublishingQueuePost extends PublishingEnvironmentWebScript
|
public class PublishingQueuePost extends PublishingWebScript
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
@@ -44,9 +43,6 @@ public class PublishingQueuePost extends PublishingEnvironmentWebScript
|
|||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
String siteId = getSiteId(req);
|
|
||||||
PublishingQueue queue = getQueue(siteId);
|
|
||||||
|
|
||||||
String content = null;
|
String content = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -55,7 +51,7 @@ public class PublishingQueuePost extends PublishingEnvironmentWebScript
|
|||||||
{
|
{
|
||||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "No publishing event was posted!");
|
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "No publishing event was posted!");
|
||||||
}
|
}
|
||||||
String eventId = jsonParser.schedulePublishingEvent(queue, content);
|
String eventId = jsonParser.schedulePublishingEvent(getQueue(), content);
|
||||||
PublishingEvent event = publishingService.getPublishingEvent(eventId);
|
PublishingEvent event = publishingService.getPublishingEvent(eventId);
|
||||||
Map<String, Object> eventModel = builder.buildPublishingEvent(event, channelService);
|
Map<String, Object> eventModel = builder.buildPublishingEvent(event, channelService);
|
||||||
return WebScriptUtil.createBaseModel(eventModel);
|
return WebScriptUtil.createBaseModel(eventModel);
|
||||||
|
@@ -64,7 +64,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -88,8 +88,6 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
|||||||
import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
|
import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
|
||||||
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent.Status;
|
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEventFilter;
|
|
||||||
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingPackageEntry;
|
import org.alfresco.service.cmr.publishing.PublishingPackageEntry;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
||||||
@@ -129,11 +127,11 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
private static final String statusUpdateType = "statusUpdateForTest";
|
private static final String statusUpdateType = "statusUpdateForTest";
|
||||||
private static final int maxStatusLength = 100;
|
private static final int maxStatusLength = 100;
|
||||||
|
|
||||||
private static final String CHANNELS_SITE_URL = "api/publishing/site/{0}/channels";
|
private static final String CHANNELS_URL = "api/publishing/channels";
|
||||||
private static final String CHANNEL_TYPES_URL = "api/publishing/channel-types";
|
|
||||||
private static final String CHANNELS_NODE_URL = "api/publishing/{0}/{1}/{2}/channels";
|
private static final String CHANNELS_NODE_URL = "api/publishing/{0}/{1}/{2}/channels";
|
||||||
private static final String PUBLISHING_QUEUE_URL = "api/publishing/{0}/queue";
|
private static final String CHANNEL_TYPES_URL = "api/publishing/channel-types";
|
||||||
private static final String PUBLISHING_EVENT_QUERY_URL = "api/publishing/{0}/events/query";
|
private static final String PUBLISHING_QUEUE_URL = "api/publishing/queue";
|
||||||
|
private static final String PUBLISHING_EVENTS_FOR_NODE_url = "api/publishing/{0}/{1}/{2}/events";
|
||||||
|
|
||||||
private static final String JSON = "application/json";
|
private static final String JSON = "application/json";
|
||||||
|
|
||||||
@@ -147,6 +145,9 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
private NodeRef docLib;
|
private NodeRef docLib;
|
||||||
private String siteId;
|
private String siteId;
|
||||||
|
|
||||||
|
private List<PublishingEvent> events = new ArrayList<PublishingEvent>();
|
||||||
|
private List<Channel> channels = new ArrayList<Channel>();
|
||||||
|
|
||||||
public void testGetChannelsForNode() throws Exception
|
public void testGetChannelsForNode() throws Exception
|
||||||
{
|
{
|
||||||
NodeRef textNode = createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
NodeRef textNode = createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
@@ -158,22 +159,14 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
assertEquals(MimetypeMap.MIMETYPE_PDF, fileFolderService.getReader(xmlNode).getMimetype());
|
assertEquals(MimetypeMap.MIMETYPE_PDF, fileFolderService.getReader(xmlNode).getMimetype());
|
||||||
String plainTextNodeUrl = MessageFormat.format(CHANNELS_NODE_URL, store.getProtocol(), store.getIdentifier(), textNode.getId() );
|
String plainTextNodeUrl = MessageFormat.format(CHANNELS_NODE_URL, store.getProtocol(), store.getIdentifier(), textNode.getId() );
|
||||||
Response response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
|
|
||||||
|
|
||||||
// Call with no channels defined on site.
|
|
||||||
response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
|
|
||||||
JSONObject data = getJsonData(response);
|
|
||||||
|
|
||||||
//TODO Fix hard coding.
|
|
||||||
assertEquals(20, data.getInt(URL_LENGTH));
|
|
||||||
|
|
||||||
Channel publishAnyChannel = createChannel(publishAnyType);
|
Channel publishAnyChannel = createChannel(publishAnyType);
|
||||||
Channel publishPdfChannel = createChannel(publishPdfType);
|
Channel publishPdfChannel = createChannel(publishPdfType);
|
||||||
Channel statusUpdateChannel= createChannel(statusUpdateType);
|
Channel statusUpdateChannel= createChannel(statusUpdateType);
|
||||||
|
|
||||||
// Call with channels defined.
|
// Call with channels defined.
|
||||||
response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
|
Response response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
|
||||||
data = getJsonData(response);
|
JSONObject data = getJsonData(response);
|
||||||
|
|
||||||
//TODO Fix hard coding.
|
//TODO Fix hard coding.
|
||||||
assertEquals(20, data.getInt(URL_LENGTH));
|
assertEquals(20, data.getInt(URL_LENGTH));
|
||||||
@@ -196,33 +189,20 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
checkChannels(statusChannels, statusUpdateChannel);
|
checkChannels(statusChannels, statusUpdateChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetChannelsForSite() throws Exception
|
public void testGetChannels() throws Exception
|
||||||
{
|
{
|
||||||
// Call with no channels defined on site.
|
|
||||||
String siteUrl = MessageFormat.format(CHANNELS_SITE_URL, siteId);
|
|
||||||
Response response = sendRequest(new GetRequest(siteUrl), 200);
|
|
||||||
JSONObject data = getJsonData(response);
|
|
||||||
|
|
||||||
//TODO Fix hard coding.
|
|
||||||
assertEquals(20, data.getInt(URL_LENGTH));
|
|
||||||
JSONArray publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
|
|
||||||
int startPublishChannelsSize = publishingChannels.length();
|
|
||||||
|
|
||||||
JSONArray statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
|
|
||||||
int startStatusChannelsSize = statusChannels.length();
|
|
||||||
|
|
||||||
Channel publishAnyChannel = createChannel(publishAnyType);
|
Channel publishAnyChannel = createChannel(publishAnyType);
|
||||||
Channel publishPdfChannel = createChannel(publishPdfType);
|
Channel publishPdfChannel = createChannel(publishPdfType);
|
||||||
Channel statusUpdateChannel= createChannel(statusUpdateType);
|
Channel statusUpdateChannel= createChannel(statusUpdateType);
|
||||||
|
|
||||||
// Call channels defined.
|
// Call channels defined.
|
||||||
response = sendRequest(new GetRequest(siteUrl), 200);
|
Response response = sendRequest(new GetRequest(CHANNELS_URL), 200);
|
||||||
data = getJsonData(response);
|
JSONObject data = getJsonData(response);
|
||||||
|
|
||||||
//TODO Fix hard coding.
|
//TODO Fix hard coding.
|
||||||
assertEquals(20, data.getInt(URL_LENGTH));
|
assertEquals(20, data.getInt(URL_LENGTH));
|
||||||
publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
|
JSONArray publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
|
||||||
statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
|
JSONArray statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
|
||||||
|
|
||||||
checkChannels(publishingChannels, publishAnyChannel, publishPdfChannel);
|
checkChannels(publishingChannels, publishAnyChannel, publishPdfChannel);
|
||||||
checkChannels(statusChannels, statusUpdateChannel);
|
checkChannels(statusChannels, statusUpdateChannel);
|
||||||
@@ -232,16 +212,14 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
public void testPublishingQueuePost() throws Exception
|
public void testPublishingQueuePost() throws Exception
|
||||||
{
|
{
|
||||||
// Create publish and status update channels.
|
// Create publish and status update channels.
|
||||||
Channel publishChannel = channelService.createChannel(publishAnyType, GUID.generate(), null);
|
Channel publishChannel = createChannel(publishAnyType);
|
||||||
Channel statusChannel = channelService.createChannel(statusUpdateType, GUID.generate(), null);
|
Channel statusChannel = createChannel(statusUpdateType);
|
||||||
|
|
||||||
// Create some content.
|
// Create some content.
|
||||||
NodeRef textNode = createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
NodeRef textNode = createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
|
|
||||||
String pubQueueUrl = MessageFormat.format(PUBLISHING_QUEUE_URL, siteId);
|
|
||||||
|
|
||||||
// Post empty content.
|
// Post empty content.
|
||||||
sendRequest(new PostRequest(pubQueueUrl, "", JSON), 400);
|
sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, "", JSON), 400);
|
||||||
|
|
||||||
String comment = "The comment";
|
String comment = "The comment";
|
||||||
String statusMessage = "The status message";
|
String statusMessage = "The status message";
|
||||||
@@ -251,17 +229,16 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
String jsonStr = json.toString();
|
String jsonStr = json.toString();
|
||||||
|
|
||||||
// Post JSON content.
|
// Post JSON content.
|
||||||
sendRequest(new PostRequest(pubQueueUrl, jsonStr, JSON), 200);
|
sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
|
||||||
|
|
||||||
PublishingEventFilter filter = queue.createPublishingEventFilter();
|
List<PublishingEvent> publishedEvents = publishingService.getEventsForPublishedNode(textNode);
|
||||||
filter.setPublishedNodes(textNode);
|
|
||||||
List<PublishingEvent> events = queue.getPublishingEvents(filter);
|
|
||||||
assertEquals(1, events.size());
|
|
||||||
|
|
||||||
PublishingEvent event = events.get(0);
|
assertEquals(1, publishedEvents.size());
|
||||||
|
|
||||||
|
PublishingEvent event = publishedEvents.get(0);
|
||||||
assertEquals(publishChannel.getId(), event.getChannelId());
|
assertEquals(publishChannel.getId(), event.getChannelId());
|
||||||
assertEquals(comment, event.getComment());
|
assertEquals(comment, event.getComment());
|
||||||
assertEquals(Status.SCHEDULED, event.getStatus());
|
assertEquals(PublishingEvent.Status.SCHEDULED, event.getStatus());
|
||||||
|
|
||||||
// Check Package
|
// Check Package
|
||||||
PublishingPackage pckg = event.getPackage();
|
PublishingPackage pckg = event.getPackage();
|
||||||
@@ -305,28 +282,32 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
jsonStr = json.toString();
|
jsonStr = json.toString();
|
||||||
|
|
||||||
// Post JSON without NodeRef in status.
|
// Post JSON without NodeRef in status.
|
||||||
sendRequest(new PostRequest(pubQueueUrl, jsonStr, JSON), 200);
|
sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
|
||||||
|
|
||||||
json.remove(STATUS_UPDATE);
|
json.remove(STATUS_UPDATE);
|
||||||
jsonStr = json.toString();
|
jsonStr = json.toString();
|
||||||
|
|
||||||
// Post JSON without Status Update.
|
// Post JSON without Status Update.
|
||||||
sendRequest(new PostRequest(pubQueueUrl, jsonStr, JSON), 200);
|
sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
|
||||||
|
|
||||||
|
events.addAll(publishingService.getEventsForPublishedNode(textNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPublishingEventsQueryPostPublishedNode() throws Exception
|
public void testPublishingEventsForNodeGet() throws Exception
|
||||||
{
|
{
|
||||||
Channel publishChannel = createChannel(publishAnyType);
|
Channel publishChannel = createChannel(publishAnyType);
|
||||||
NodeRef textNode1 = createContentNode("plain1.txt", "This is some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
NodeRef textNode1 = createContentNode("plain1.txt", "This is some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
NodeRef textNode2 = createContentNode("plain2.txt", "This is some more plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
NodeRef textNode2 = createContentNode("plain2.txt", "This is some more plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
|
|
||||||
String queryUrl = MessageFormat.format(PUBLISHING_EVENT_QUERY_URL, siteId);
|
String protocol = textNode1.getStoreRef().getProtocol();
|
||||||
|
String storeId = textNode1.getStoreRef().getIdentifier();
|
||||||
// Post empty string with correct site name.
|
String nodeId1 = textNode1.getId();
|
||||||
Response response = sendRequest(new PostRequest(queryUrl, "", JSON), 200);
|
String textNode1Url = MessageFormat.format(PUBLISHING_EVENTS_FOR_NODE_url, protocol, storeId, nodeId1);
|
||||||
|
|
||||||
|
// Get events on textNode1 before any events created.
|
||||||
|
Response response = sendRequest(new GetRequest(textNode1Url), 200);
|
||||||
JSONArray data = getDataArray(response);
|
JSONArray data = getDataArray(response);
|
||||||
int startingSize = data.length();
|
assertEquals(0, data.length());
|
||||||
|
|
||||||
// Create publishing event for textNode1.
|
// Create publishing event for textNode1.
|
||||||
MutablePublishingPackage pckg1 = queue.createPublishingPackage();
|
MutablePublishingPackage pckg1 = queue.createPublishingPackage();
|
||||||
@@ -337,35 +318,20 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
schedule.add(Calendar.YEAR, 1);
|
schedule.add(Calendar.YEAR, 1);
|
||||||
|
|
||||||
String event1Id = queue.scheduleNewEvent(pckg1, publishChannel.getId(), schedule, comment, statusUpdate);
|
String event1Id = queue.scheduleNewEvent(pckg1, publishChannel.getId(), schedule, comment, statusUpdate);
|
||||||
|
PublishingEvent event1 = publishingService.getPublishingEvent(event1Id);
|
||||||
// Query for all events.
|
events.add(event1);
|
||||||
response = sendRequest(new PostRequest(queryUrl, "", JSON), 200);
|
|
||||||
data = getDataArray(response);
|
|
||||||
checkContainsEvents(data, startingSize, event1Id);
|
|
||||||
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put(PUBLISH_NODES, Arrays.asList(textNode1.toString()));
|
|
||||||
|
|
||||||
// Query for events on textNode1.
|
// Query for events on textNode1.
|
||||||
response = sendRequest(new PostRequest(queryUrl, json.toString(), JSON), 200);
|
response = sendRequest(new GetRequest(textNode1Url), 200);
|
||||||
data = getDataArray(response);
|
data = getDataArray(response);
|
||||||
checkContainsEvents(data, 0, event1Id);
|
checkContainsEvents(data, event1Id);
|
||||||
|
|
||||||
json = new JSONObject();
|
|
||||||
json.put(PUBLISH_NODES, Arrays.asList(textNode2.toString()));
|
|
||||||
|
|
||||||
// Query for events on textNode2.
|
// Query for events on textNode2.
|
||||||
response = sendRequest(new PostRequest(queryUrl, json.toString(), JSON), 200);
|
String nodeId2 = textNode2.getId();
|
||||||
|
String textNode2Url = MessageFormat.format(PUBLISHING_EVENTS_FOR_NODE_url, protocol, storeId, nodeId2);
|
||||||
|
response = sendRequest(new GetRequest(textNode2Url), 200);
|
||||||
data = getDataArray(response);
|
data = getDataArray(response);
|
||||||
assertEquals(0, data.length());
|
assertEquals(0, data.length());
|
||||||
|
|
||||||
json = new JSONObject();
|
|
||||||
json.put(PUBLISH_NODES, Arrays.asList(textNode1.toString(), textNode2.toString()));
|
|
||||||
|
|
||||||
// Query for events on both textNode1 and textNode2.
|
|
||||||
response = sendRequest(new PostRequest(queryUrl, json.toString(), JSON), 200);
|
|
||||||
data = getDataArray(response);
|
|
||||||
checkContainsEvent(data, event1Id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChannelTypesGet() throws Exception
|
public void testChannelTypesGet() throws Exception
|
||||||
@@ -399,9 +365,9 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
fail("Failed to find Channel Type: " + typeId);
|
fail("Failed to find Channel Type: " + typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkContainsEvents(JSONArray data, int startSize, String... eventIds) throws Exception
|
private void checkContainsEvents(JSONArray data, String... eventIds) throws Exception
|
||||||
{
|
{
|
||||||
assertEquals(eventIds.length + startSize, data.length());
|
assertEquals(eventIds.length, data.length());
|
||||||
for (String eventId : eventIds)
|
for (String eventId : eventIds)
|
||||||
{
|
{
|
||||||
checkContainsEvent(data, eventId);
|
checkContainsEvent(data, eventId);
|
||||||
@@ -519,7 +485,7 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject buildStatusUpdate(String message, NodeRef textNode, Channel... channels) throws JSONException
|
private JSONObject buildStatusUpdate(String message, NodeRef textNode, Channel... theChannels) throws JSONException
|
||||||
{
|
{
|
||||||
Function<Channel, String> transformer = new Function<Channel, String>()
|
Function<Channel, String> transformer = new Function<Channel, String>()
|
||||||
{
|
{
|
||||||
@@ -528,7 +494,7 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
return channel.getId();
|
return channel.getId();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
List<String> ids = CollectionUtils.transform(transformer, channels);
|
List<String> ids = CollectionUtils.transform(transformer, theChannels);
|
||||||
|
|
||||||
JSONObject statusUpdate = new JSONObject();
|
JSONObject statusUpdate = new JSONObject();
|
||||||
statusUpdate.put(MESSAGE, message);
|
statusUpdate.put(MESSAGE, message);
|
||||||
@@ -537,9 +503,9 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
return statusUpdate;
|
return statusUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkChannels(JSONArray json, Channel... channels)throws Exception
|
private void checkChannels(JSONArray json, Channel... theChannels)throws Exception
|
||||||
{
|
{
|
||||||
for (Channel channel : channels)
|
for (Channel channel : theChannels)
|
||||||
{
|
{
|
||||||
checkContainsChannel(json, channel);
|
checkContainsChannel(json, channel);
|
||||||
}
|
}
|
||||||
@@ -625,7 +591,9 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
private Channel createChannel(String typeId)
|
private Channel createChannel(String typeId)
|
||||||
{
|
{
|
||||||
return channelService.createChannel(typeId, GUID.generate(), null);
|
Channel channel = channelService.createChannel(typeId, GUID.generate(), null);
|
||||||
|
channels.add(channel);
|
||||||
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject getJsonData(Response response) throws Exception
|
private JSONObject getJsonData(Response response) throws Exception
|
||||||
@@ -737,9 +705,6 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
@Override
|
@Override
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
//FInd all events
|
|
||||||
PublishingEventFilter filter = queue.createPublishingEventFilter();
|
|
||||||
List<PublishingEvent> events = queue.getPublishingEvents(filter);
|
|
||||||
for (PublishingEvent event : events)
|
for (PublishingEvent event : events)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -751,6 +716,17 @@ public class PublishingRestApiTest extends BaseWebScriptTest
|
|||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Channel channel : channels)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
channelService.deleteChannel(channel);
|
||||||
|
}
|
||||||
|
catch(Throwable t)
|
||||||
|
{
|
||||||
|
//NOOP
|
||||||
|
}
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
siteService.deleteSite(siteId);
|
siteService.deleteSite(siteId);
|
||||||
|
@@ -19,25 +19,17 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.web.scripts.publishing;
|
package org.alfresco.repo.web.scripts.publishing;
|
||||||
|
|
||||||
import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.SITE_ID;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingService;
|
import org.alfresco.service.cmr.publishing.PublishingService;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class PublishingEnvironmentWebScript extends DeclarativeWebScript
|
public abstract class PublishingWebScript extends DeclarativeWebScript
|
||||||
{
|
{
|
||||||
protected final PublishingJsonParser jsonParser = new PublishingJsonParser();
|
protected final PublishingJsonParser jsonParser = new PublishingJsonParser();
|
||||||
protected final PublishingModelBuilder builder= new PublishingModelBuilder();
|
protected final PublishingModelBuilder builder= new PublishingModelBuilder();
|
||||||
@@ -45,28 +37,9 @@ public abstract class PublishingEnvironmentWebScript extends DeclarativeWebScrip
|
|||||||
protected PublishingService publishingService;
|
protected PublishingService publishingService;
|
||||||
protected ChannelService channelService;
|
protected ChannelService channelService;
|
||||||
|
|
||||||
protected String getSiteId(WebScriptRequest req)
|
protected PublishingQueue getQueue()
|
||||||
{
|
{
|
||||||
Map<String, String> params = req.getServiceMatch().getTemplateVars();
|
return publishingService.getPublishingQueue();
|
||||||
String siteId = params.get(SITE_ID);
|
|
||||||
|
|
||||||
if(siteId == null)
|
|
||||||
{
|
|
||||||
String msg = "A Site ID must be specified!";
|
|
||||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
|
|
||||||
}
|
|
||||||
return siteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PublishingQueue getQueue(WebScriptRequest req)
|
|
||||||
{
|
|
||||||
String siteId = getSiteId(req);
|
|
||||||
return getQueue(siteId);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PublishingQueue getQueue(String siteId)
|
|
||||||
{
|
|
||||||
return publishingService.getPublishingQueue(siteId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@@ -26,9 +26,6 @@ package org.alfresco.repo.web.scripts.publishing;
|
|||||||
*/
|
*/
|
||||||
public interface PublishingWebScriptConstants
|
public interface PublishingWebScriptConstants
|
||||||
{
|
{
|
||||||
// URL Template Keys.
|
|
||||||
public static final String SITE_ID = "site_id";
|
|
||||||
|
|
||||||
// General Model Keys
|
// General Model Keys
|
||||||
public static final String ID = "id";
|
public static final String ID = "id";
|
||||||
public static final String URL = "url";
|
public static final String URL = "url";
|
||||||
@@ -70,8 +67,8 @@ public interface PublishingWebScriptConstants
|
|||||||
public static final String NODE_REF = "nodeRef";
|
public static final String NODE_REF = "nodeRef";
|
||||||
public static final String MESSAGE = "message";
|
public static final String MESSAGE = "message";
|
||||||
|
|
||||||
// Publishing Event Filter Modek Keys
|
// Publishing Events For Node Modek Keys
|
||||||
public static final String IDS = "ids";
|
public static final String EVENT_TYPE = "eventType";
|
||||||
|
|
||||||
// channels.get Model Keys
|
// channels.get Model Keys
|
||||||
public static final String URL_LENGTH = "urlLength";
|
public static final String URL_LENGTH = "urlLength";
|
||||||
|
Reference in New Issue
Block a user