eventModel = builder.buildPublishingEvent(event, channelService);
- return WebScriptUtil.createBaseModel(eventModel);
- }
- catch (WebScriptException we)
- {
- throw we;
- }
- catch (Exception e)
- {
- String msg = "Failed to schedule publishing event. POST body: " + content;
- throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
- }
- }
-}
diff --git a/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java b/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java
deleted file mode 100644
index 5faab3db72..0000000000
--- a/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * #%L
- * Alfresco Remote API
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * 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 .
- * #L%
- */
-
-package org.alfresco.repo.web.scripts.publishing;
-
-import org.alfresco.service.cmr.publishing.PublishingQueue;
-import org.alfresco.service.cmr.publishing.PublishingService;
-import org.alfresco.service.cmr.publishing.channels.ChannelService;
-import org.springframework.extensions.webscripts.DeclarativeWebScript;
-
-/**
- * @author Nick Smith
- * @since 4.0
- */
-public abstract class PublishingWebScript extends DeclarativeWebScript
-{
- protected final PublishingJsonParser jsonParser = new PublishingJsonParser();
- protected final PublishingModelBuilder builder= new PublishingModelBuilder();
-
- protected PublishingService publishingService;
- protected ChannelService channelService;
-
- /**
- * @param publishingService the publishingService to set
- */
- public void setPublishingService(PublishingService publishingService)
- {
- this.publishingService = publishingService;
- }
-
- /**
- * @param channelService the channelService to set
- */
- public void setChannelService(ChannelService channelService)
- {
- this.channelService = channelService;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScriptConstants.java b/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScriptConstants.java
deleted file mode 100644
index 69fce994c4..0000000000
--- a/src/main/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScriptConstants.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * #%L
- * Alfresco Remote API
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * 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 .
- * #L%
- */
-
-package org.alfresco.repo.web.scripts.publishing;
-
-/**
- * @author Nick Smith
- * @since 4.0
- */
-public interface PublishingWebScriptConstants
-{
- // General Model Keys
- public static final String ID = "id";
- public static final String URL = "url";
- public static final String ICON = "icon";
- public static final String TITLE = "title";
-
- // Channel Type Model Keys
- public static final String CHANNEL_NODE_TYPE = "channelNodeType";
- public static final String CONTENT_ROOT_NODE_TYPE = "contentRootNodeType";
- public static final String SUPPORTED_CONTENT_TYPES = "supportedContentTypes";
- public static final String SUPPORTED_MIME_TYPES = "supportedMimeTypes";
- public static final String CAN_PUBLISH = "canPublish";
- public static final String CAN_PUBLISH_STATUS_UPDATES = "canPublishStatusUpdates";
- public static final String CAN_UNPUBLISH = "canUnpublish";
- public static final String MAX_STATUS_LENGTH = "maxStatusLength";
-
- // Channel Keys
- public static final String NAME = "name";
- public static final String CHANNEL_TYPE = "channelType";
- public static final String CHANNEL_AUTH_STATUS = "authorised";
-
- // Publishing Event Model Keys
- public static final String CHANNEL = "channel";
- public static final String STATUS = "status";
- public static final String COMMENT = "comment";
- public static final String SCHEDULED_TIME = "scheduledTime";
- public static final String CREATOR = "creator";
- public static final String CREATED_TIME = "createdTime";
- public static final String PUBLISH_NODES = "publishNodes";
- public static final String UNPUBLISH_NODES = "unpublishNodes";
- public static final String NODEREF = "nodeRef";
- public static final String VERSION = "version";
- public static final String STATUS_UPDATE = "statusUpdate";
- public static final String CHANNEL_NAME = "channelName";
- public static final String CHANNEL_ID = "channelId";
-
- // Status Update Model Keys
- public static final String CHANNEL_IDS = "channelIds";
- public static final String NODE_REF = "nodeRef";
- public static final String MESSAGE = "message";
-
- // Publishing Events For Node Modek Keys
- public static final String EVENT_TYPE = "eventType";
-
- // channels.get Model Keys
- public static final String URL_LENGTH = "urlLength";
- public static final String PUBLISHING_CHANNELS = "publishChannels";
- public static final String STATUS_UPDATE_CHANNELS = "statusUpdateChannels";
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/auth-response.lib.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/auth-response.lib.ftl
deleted file mode 100644
index 8cc800d333..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/auth-response.lib.ftl
+++ /dev/null
@@ -1,47 +0,0 @@
-<#-- Renders the HTML response to a completed Auth Request -->
-<#macro htmlPage>
-
-
-
-
-
-
- Alfresco » Authorisation
-
-
-
-
-
- Completing your authorisation...
-
-
-
-#macro>
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.desc.xml
deleted file mode 100644
index e832d645d1..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.desc.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
- Authorisation Callback
-
-
- /api/publishing/channels/{store_protocol}/{store_id}/{node_id}/authcallback
-
- user
- required
-
-
- store_protocol
- The protocol of the store in which the relevant publishing channel lives.
-
-
- store_id
- The identifier of the store in which the relevant publishing channel lives.
-
-
- node_id
- The identifier of the node that represents the relevant publishing channel.
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.html.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.html.ftl
deleted file mode 100644
index 09f481bcf2..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authcallback.get.html.ftl
+++ /dev/null
@@ -1,2 +0,0 @@
-<#import "auth-response.lib.ftl" as authResponse />
-<@authResponse.htmlPage />
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.desc.xml
deleted file mode 100644
index f8825f917a..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.desc.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- Channel Authorisation Form
-
- /api/publishing/channels/{store_protocol}/{store_id}/{node_id}/authform
-
- user
- required
-
-
- store_protocol
- The protocol of the store in which the relevant publishing channel lives.
-
-
- store_id
- The identifier of the store in which the relevant publishing channel lives.
-
-
- node_id
- The identifier of the node that represents the relevant publishing channel.
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.html.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.html.ftl
deleted file mode 100644
index f085b76d71..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.html.ftl
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
- ${msg("authForm.title")}
-
-
-
-
-
- ${msg("authForm.directions", channel.name)}
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.properties
deleted file mode 100644
index f6894d4738..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » Channel Authentication Details
-authForm.heading=Channel Authentication
-authForm.directions=Please enter your username and password for {0}
-authForm.user=User Name:
-authForm.password=Password:
-authForm.login=Login
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_de.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_de.properties
deleted file mode 100755
index 3040f857d6..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_de.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » Kanalauthentifizierungsdaten
-authForm.heading=Kanalauthentifizierung
-authForm.directions=Geben Sie Ihren Benutzernamen und Ihr Passwort f\u00fcr {0} ein
-authForm.user=Benutzername:
-authForm.password=Passwort:
-authForm.login=Anmelden
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_es.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_es.properties
deleted file mode 100755
index 8acc3d5240..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_es.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » Datos de autenticaci\u00f3n del canal
-authForm.heading=Autenticaci\u00f3n del canal
-authForm.directions=Introduzca su nombre de usuario y contrase\u00f1a de {0}
-authForm.user=Nombre de usuario:
-authForm.password=Contrase\u00f1a:
-authForm.login=Iniciar sesi\u00f3n
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_fr.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_fr.properties
deleted file mode 100755
index eb573a320f..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_fr.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » D\u00e9tails d'authentification de canal
-authForm.heading=Authentification de canal
-authForm.directions=Veuillez saisir votre nom d''utilisateur et votre mot de passe pour {0}
-authForm.user=Nom d'utilisateur :
-authForm.password=Mot de passe :
-authForm.login=Connexion
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_it.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_it.properties
deleted file mode 100755
index 27471a1a86..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_it.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » Dati di autenticazione canale
-authForm.heading=Autenticazione canale
-authForm.directions=Immettere nome utente e password per {0}
-authForm.user=Nome utente:
-authForm.password=Password:
-authForm.login=Login
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ja.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ja.properties
deleted file mode 100755
index 065c51f1c3..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ja.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » \u30c1\u30e3\u30cd\u30eb\u8a8d\u8a3c\u306e\u8a73\u7d30
-authForm.heading=\u30c1\u30e3\u30cd\u30eb\u8a8d\u8a3c
-authForm.directions={0}\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
-authForm.user=\u30e6\u30fc\u30b6\u30fc\u540d\uff1a
-authForm.password=\u30d1\u30b9\u30ef\u30fc\u30c9\uff1a
-authForm.login=\u30ed\u30b0\u30a4\u30f3
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nb.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nb.properties
deleted file mode 100755
index c9e20fcced..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nb.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » Detaljer om kanalgodkjenning
-authForm.heading=Kanalgodkjenning
-authForm.directions=Angi brukernavn og passord for {0}
-authForm.user=Brukernavn:
-authForm.password=Passord:
-authForm.login=Logg inn
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nl.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nl.properties
deleted file mode 100755
index cf969f06e3..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_nl.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » kanaalverificatiegegevens
-authForm.heading=Kanaalverificatie
-authForm.directions=Voer uw gebruikersnaam en wachtwoord in voor {0}
-authForm.user=Gebruikersnaam:
-authForm.password=Wachtwoord:
-authForm.login=Aanmelden
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_pt_BR.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_pt_BR.properties
deleted file mode 100644
index ce27720ca8..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_pt_BR.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Detalhes de autentica\u00e7\u00e3o de canal do Alfresco »
-authForm.heading=Autentica\u00e7\u00e3o de canal
-authForm.directions=Insira seu nome de usu\u00e1rio e senha para {0}
-authForm.user=Nome de usu\u00e1rio:
-authForm.password=Senha:
-authForm.login=Login
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ru.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ru.properties
deleted file mode 100755
index 2a3abdc493..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_ru.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=\u0421\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u0431 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 Alfresco »
-authForm.heading=\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432
-authForm.directions=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0432\u043e\u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f {0}
-authForm.user=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:
-authForm.password=\u041f\u0430\u0440\u043e\u043b\u044c:
-authForm.login=\u0412\u043e\u0439\u0442\u0438
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_zh_CN.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_zh_CN.properties
deleted file mode 100755
index d80e3377d6..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.get_zh_CN.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-authForm.title=Alfresco » \u6e20\u9053\u8eab\u4efd\u9a8c\u8bc1\u8be6\u7ec6\u4fe1\u606f
-authForm.heading=\u6e20\u9053\u8eab\u4efd\u9a8c\u8bc1
-authForm.directions=\u8bf7\u8f93\u5165\u60a8\u7684 {0} \u7528\u6237\u540d\u548c\u5bc6\u7801
-authForm.user=\u7528\u6237\u540d\uff1a
-authForm.password=\u5bc6\u7801\uff1a
-authForm.login=\u767b\u5f55
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.desc.xml
deleted file mode 100644
index ce6d42014f..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.desc.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- Channel Authorisation Form
-
- /api/publishing/channels/{store_protocol}/{store_id}/{node_id}/authform
-
- user
- required
-
-
- store_protocol
- The protocol of the store in which the relevant publishing channel lives.
-
-
- store_id
- The identifier of the store in which the relevant publishing channel lives.
-
-
- node_id
- The identifier of the node that represents the relevant publishing channel.
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.html.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.html.ftl
deleted file mode 100644
index 09f481bcf2..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/authform.post.html.ftl
+++ /dev/null
@@ -1,2 +0,0 @@
-<#import "auth-response.lib.ftl" as authResponse />
-<@authResponse.htmlPage />
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml
deleted file mode 100644
index 791b08af47..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
- Reauthorise the specified publishing channel
-
- Response status may be:
-
- - 200
- The body of the response contains the necessary information to continue the reauthorisation process
- - 400
- invalid data received from caller
- - 404
- the specified channel cannot be found
-
- Returns three pieces of informtation:
-
-
- - channelId
- the identifier of the publishing channel
- - authoriseUrl
- The URL to send the user to in order for them to authorise access to the channel
- - authCallbackUrl
- The URL to return the channel authorisation details to
- - authRedirectUrl
- The URL that the channel service provider will try to redirect the user to
-
- ]]>
- /api/publishing/channels/{store_protocol}/{store_id}/{node_id}/reauthorise
-
- user
- required
- limited_support
-
-
- store_protocol
- The protocol of the store in which the relevant publishing channel lives.
-
-
- store_id
- The identifier of the store in which the relevant publishing channel lives.
-
-
- node_id
- The identifier of the node that represents the relevant publishing channel.
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.json.ftl
deleted file mode 100644
index 15992eb63e..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.json.ftl
+++ /dev/null
@@ -1,5 +0,0 @@
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- <@publishLib.channelAuthJSON />
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-type-icon.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-type-icon.get.desc.xml
deleted file mode 100644
index 31f4f4e901..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-type-icon.get.desc.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
- Get channel type icon
-
-
- - channelType
- mandatory - the channel type for which the icon is required
- - iconSize
- mandatory - the size of the icon required. Must be either "16" or "32"
-
- Streams the requested icon if it can be found, otherwise returns a 404 status code. If either channelType or iconSize
- are missing then a 400 status code is returned.
- ]]>
-
- /api/publishing/channel-types/{channelType}/icon/{iconSize}
-
- user
- required
- limited_support
-
-
- channelType
- The identifier of the channel type whose icon is wanted.
-
-
- iconSize
- The size (in pixels) of the required icon. Must be either "16" or "32".
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.desc.xml
deleted file mode 100644
index fd25023a15..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.desc.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- Get Publishing Channels
- Get the publishing channels for a Share Site.or specified NodeRef
- /api/publishing/channel-types
-
- user
- required
- limited_support
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.json.ftl
deleted file mode 100644
index 87d85a360c..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-types.get.json.ftl
+++ /dev/null
@@ -1,13 +0,0 @@
-<#-- List Channels -->
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- [
- <#if data??>
- <#list data as type>
- <@publishLib.channelTypeJSON type=type/>
- <#if type_has_next>,#if>
- #list>
- #if>
- ]
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel.put.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel.put.desc.xml
deleted file mode 100644
index 3ff0f2655a..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel.put.desc.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
- Update Channel
- Updates an existing Channel's name.
- /api/publishing/channels/{channel_id}
-
- user
- required
- limited_support
-
-
- channel_id
- The URL-encoded id of the channel to be updated.
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.delete.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.delete.desc.xml
deleted file mode 100644
index 80ec997e86..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.delete.desc.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
- Delete specified publishing channel
-
- Response status indicates result:
-
- - 200
- deletion successful
- - 400
- invalid data received from caller
- - 401
- user doesn't have permission to delete the specified channel
- - 404
- the specified channel cannot be found
-
-
- ]]>
- /api/publishing/channels/{store_protocol}/{store_id}/{node_id}
-
- user
- required
- limited_support
-
-
- store_protocol
- The protocol of the store in which the relevant publishing channel lives.
-
-
- store_id
- The identifier of the store in which the relevant publishing channel lives.
-
-
- node_id
- The identifier of the node that represents the relevant publishing channel.
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.desc.xml
deleted file mode 100644
index 8ba9c03946..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.desc.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
- Get Publishing Channels
- Get the publishing channels for specified NodeRef or returns all Publishing Channels
- /api/publishing/channels
- /api/publishing/{store_protocol}/{store_id}/{node_id}/channels
-
- user
- required
- limited_support
-
-
- store_protocol
- The protocol used by the StoreRef to retrieve channels for.
-
-
- store_id
- The id of the StoreRef to retrieve channels for.
-
-
- node_id
- The id of the NodeRef to retrieve channels for.
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.json.ftl
deleted file mode 100644
index d9be03dc98..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.get.json.ftl
+++ /dev/null
@@ -1,12 +0,0 @@
-<#-- List Channels -->
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- {
- <#if data.urlLength??>"urlLength": ${data.urlLength},#if>
- "publishChannels":
- <@publishLib.channelsJSON channels=data.publishChannels />,
- "statusUpdateChannels":
- <@publishLib.channelsJSON channels=data.statusUpdateChannels />
- }
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml
deleted file mode 100644
index df66dc5e1a..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
- Create a publishing channel
-
-
- - channelType
- mandatory - the type of delivery channel to create
- - siteId
- mandatory - the Share site with which the new delivery channel is to be associated
- - channelName
- mandatory - the name of the new delivery channel
-
- Returns three pieces of informtation:
-
-
- - channelId
- the identifier of the new publishing channel
- - pollUrl
- The URL to poll to discover whether the channel has been authorised
- - authoriseUrl
- The URL to send the user to in order for them to authorise access to the channel
- - authCallbackUrl
- The URL to return the channel authorisation details to
- - authRedirectUrl
- The URL to which the channel service provider will redirect the user upon authorisation
-
-
- ]]>
-
- /api/publishing/channels
-
- user
- required
- limited_support
-
-
- siteId
- The id of the site to create a delivery channel on.
-
-
- channelType
- The identifier of the type of delivery channel to create.
-
-
- channelName
- The name of the channel that is to be created.
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.json.ftl
deleted file mode 100644
index 685717eabd..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.json.ftl
+++ /dev/null
@@ -1,6 +0,0 @@
-<#-- Response to a request to create a publishing channel -->
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- <@publishLib.channelAuthJSON />
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.desc.xml
deleted file mode 100644
index d01cf640c3..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.desc.xml
+++ /dev/null
@@ -1,165 +0,0 @@
-
- Get Publishing Events For Node
- Find all PublishingEvents that publish or unpublish the specified node.
- /api/publishing/{store_protocol}/{store_id}/{node_id}/events
-
- user
- required
- limited_support
-
-
- store_protocol
- The store protocol for the published/unpublished node.
-
-
- store_id
- The store id for the published/unpublished node.
-
-
- node_id
- The node id for the published/unpublished node.
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.json.ftl
deleted file mode 100644
index ab6b289ccd..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-events.get.json.ftl
+++ /dev/null
@@ -1,6 +0,0 @@
-<#-- List Channels -->
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- <@publishLib.eventsJSON events=data />
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.desc.xml
deleted file mode 100644
index a835abe025..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.desc.xml
+++ /dev/null
@@ -1,178 +0,0 @@
-
- Post Content to Publishing Queue
- Place a new Publishing Event on the Publishing Queue..
- /api/publishing/queue
-
- user
- required
- limited_support
-
-
- json
-
-
-
-
-
-
-
- json
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.json.ftl
deleted file mode 100644
index ac66e54bd6..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing-queue.post.json.ftl
+++ /dev/null
@@ -1,7 +0,0 @@
-<#-- List Channels -->
-<#import "publishing.lib.ftl" as publishLib />
-{
- "data":
- {
- }
-}
diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl
deleted file mode 100644
index 34851403fc..0000000000
--- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl
+++ /dev/null
@@ -1,160 +0,0 @@
-<#-- Renders a List of Publishing Events -->
-<#macro eventsJSON events>
-<#escape x as jsonUtils.encodeJSONString(x)>
-[
- <#if events??>
- <#list events as event>
- <@eventJSON event=event />
- <#if event_has_next>,#if>
- #list>
- #if>
-]
-#escape>
-#macro>
-
-
-<#-- Renders a Publishing Event. -->
-<#macro eventJSON event>
-{
- "id": "${event.id}",
- "url": "${event.url}",
- "status": "${event.status}",
- <#if event.comment?? >"comment": "${event.comment}",#if>
- <#if event.eventType?? >"eventType": "${event.eventType}",#if>
- <#if event.scheduledTime?? >
- "scheduledTime":
- <@calendarJSON calendar=event.scheduledTime />,
- #if>
- "creator": "${event.creator}",
- "createdTime":
- <@dateJSON date=event.createdTime/>,
- "publishNodes":
- <@publishNodesJSON nodes=event.publishNodes/>,
- "unpublishNodes":
- <@publishNodesJSON nodes=event.unpublishNodes/>,
- <#if event.channel?? >
- "channel":
- <@channelJSON channel=event.channel/>
- <#elseif event.channelId?? >
- "channelId": "${event.channelId}"
- #if>
-}
-#macro>
-
-<#-- Renders a List of Nodes to be published/unpublished. -->
-<#macro publishNodesJSON nodes>
-[
- <#if nodes??>
- <#list nodes as node>
- <@publishNodeJSON node=node/>
- <#if node_has_next>,#if>
- #list>
- #if>
-]
-#macro>
-
-<#-- Renders a Published/Unpublished Node. -->
-<#macro publishNodeJSON node>
-{
- <#if node.name?? >"name": "${node.name}",#if>
- <#if node.version?? >"version": "${node.version}",#if>
- "nodeRef": "${node.nodeRef}"
-}
-#macro>
-
-<#-- Renders a List of Channel.s -->
-<#macro channelsJSON channels>
-<#escape x as jsonUtils.encodeJSONString(x)>
-[
- <#if channels??>
- <#list channels as channel>
- <@channelJSON channel=channel />
- <#if channel_has_next>,#if>
- #list>
- #if>
-]
-#escape>
-#macro>
-
-<#-- Renders a Channel. -->
-<#macro channelJSON channel>
-{
- "url": "${channel.url}",
- "id": "${channel.id}",
- "name": "${channel.name}",
- "title": "${channel.title}",
- "authorised": ${channel.authorised},
- "canPublish": ${channel.canPublish},
- "canPublishStatusUpdates": ${channel.canPublishStatusUpdates},
- "canUnpublish": ${channel.canUnpublish},
- "channelType":
- <@channelTypeJSON type=channel.channelType />
-}
-#macro>
-
-<#-- Renders a Channel Type. -->
-<#macro channelTypeJSON type>
-{
- "id": "${type.id}",
- "title": "${type.title}",
- "url": "${type.url}",
- <#if type.channelNodeType??>"channelNodeType": "${type.channelNodeType}",#if>
- <#if type.supportedContentTypes?? >
- "supportedContentTypes":
- <@iterateStringsJSON strings=type.supportedContentTypes />,
- #if>
- <#if type.supportedMimeTypes?? >
- "supportedMimeTypes":
- <@iterateStringsJSON strings=type.supportedMimeTypes/>,
- #if>
- "canPublish": ${type.canPublish},
- "canPublishStatusUpdates": ${type.canPublishStatusUpdates},
- "canUnpublish": ${type.canUnpublish},
- <#if type.icon??>"icon": "${type.icon}",#if>
- "maxStatusLength": ${type.maxStatusLength}
-}
-#macro>
-
-<#-- Renders a List of Strings. -->
-<#macro iterateStringsJSON strings>
-<#if strings??>
-[
- <#list strings as string>
- "${string}"
- <#if string_has_next>,#if>
- #list>
-]
-<#else>
-[]
-#if>
-#macro>
-
-<#-- Renders a date. -->
-<#macro dateJSON date>
-{
- "dateTime": "${date.dateTime}",
- "format": "${date.format}"
-}
-#macro>
-
-<#-- Renders a calendar. -->
-<#macro calendarJSON calendar>
-{
- "dateTime": "${calendar.dateTime}",
- "format": "${calendar.format}",
- "timeZone": "${calendar.timeZone}"
-}
-#macro>
-
-<#-- Renders the info needed about a channel's authorisation -->
-<#macro channelAuthJSON>
-<#escape x as jsonUtils.encodeJSONString(x)>
- {
- "channelId" : "${channelId}",
- "authoriseUrl": "${authoriseUrl}",
- "authCallbackUrl": "${authCallbackUrl}",
- "authRedirectUrl": "${authRedirectUrl}"
- }
-#escape>
-#macro>
-
\ No newline at end of file
diff --git a/src/main/resources/alfresco/web-scripts-application-context.xml b/src/main/resources/alfresco/web-scripts-application-context.xml
index 292b95d170..4bf49eeb44 100644
--- a/src/main/resources/alfresco/web-scripts-application-context.xml
+++ b/src/main/resources/alfresco/web-scripts-application-context.xml
@@ -959,100 +959,6 @@
class="org.alfresco.repo.web.scripts.workflow.WorkflowInstanceDelete"
parent="abstractWorkflowWebScript">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/test/java/org/alfresco/AppContext04TestSuite.java b/src/test/java/org/alfresco/AppContext04TestSuite.java
index 95e69bcf77..7d4895f3ad 100644
--- a/src/test/java/org/alfresco/AppContext04TestSuite.java
+++ b/src/test/java/org/alfresco/AppContext04TestSuite.java
@@ -63,7 +63,6 @@ import org.junit.runners.Suite;
org.alfresco.repo.web.scripts.thumbnail.ThumbnailServiceTest.class,
org.alfresco.repo.web.scripts.transfer.TransferWebScriptTest.class,
org.alfresco.repo.web.scripts.workflow.ActivitiWorkflowRestApiTest.class,
- org.alfresco.repo.web.scripts.publishing.PublishingRestApiTest.class,
org.alfresco.repo.web.scripts.solr.SOLRWebScriptTest.class,
org.alfresco.repo.web.scripts.subscriptions.SubscriptionServiceRestApiTest.class,
org.alfresco.repo.web.scripts.facet.FacetRestApiTest.class,
diff --git a/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java b/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java
index 9ae49bc4e5..a74d4d4a57 100644
--- a/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java
+++ b/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java
@@ -48,7 +48,6 @@ import org.alfresco.repo.web.scripts.links.LinksRestApiTest;
import org.alfresco.repo.web.scripts.node.NodeWebScripTest;
import org.alfresco.repo.web.scripts.person.PersonServiceTest;
import org.alfresco.repo.web.scripts.preference.PreferenceServiceTest;
-import org.alfresco.repo.web.scripts.publishing.PublishingRestApiTest;
import org.alfresco.repo.web.scripts.quickshare.QuickShareRestApiTest;
import org.alfresco.repo.web.scripts.rating.RatingRestApiTest;
import org.alfresco.repo.web.scripts.replication.ReplicationRestApiTest;
@@ -62,8 +61,8 @@ import org.alfresco.repo.web.scripts.tagging.TaggingServiceTest;
import org.alfresco.repo.web.scripts.thumbnail.ThumbnailServiceTest;
import org.alfresco.repo.web.scripts.transfer.TransferWebScriptTest;
import org.alfresco.repo.web.scripts.workflow.ActivitiWorkflowRestApiTest;
-import org.alfresco.repo.web.scripts.workflow.WorkflowModelBuilderTest;
-import org.alfresco.repo.web.scripts.content.ContentGetTest;
+import org.alfresco.repo.web.scripts.workflow.WorkflowModelBuilderTest;
+import org.alfresco.repo.web.scripts.content.ContentGetTest;
/**
* Web Scripts test suite
@@ -105,13 +104,12 @@ public class WebScriptTestSuite extends TestSuite
suite.addTestSuite( TransferWebScriptTest.class );
suite.addTestSuite( WorkflowModelBuilderTest.class );
suite.addTestSuite( ActivitiWorkflowRestApiTest.class );
- suite.addTestSuite( PublishingRestApiTest.class );
suite.addTestSuite( SOLRWebScriptTest.class );
suite.addTestSuite( SubscriptionServiceRestApiTest.class );
suite.addTestSuite( FacetRestApiTest.class );
suite.addTestSuite( CommentsApiTest.class );
suite.addTestSuite( DeclarativeSpreadsheetWebScriptTest.class );
- suite.addTestSuite( ContentGetTest.class);
+ suite.addTestSuite( ContentGetTest.class);
suite.addTestSuite( XssVulnerabilityTest.class );
suite.addTestSuite( LinksRestApiTest.class );
suite.addTestSuite( RemoteFileFolderLoaderTest.class );
diff --git a/src/test/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java b/src/test/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java
deleted file mode 100644
index 022e73c359..0000000000
--- a/src/test/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java
+++ /dev/null
@@ -1,818 +0,0 @@
-/*
- * #%L
- * Alfresco Remote API
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * 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 .
- * #L%
- */
-
-package org.alfresco.repo.web.scripts.publishing;
-
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CAN_PUBLISH;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CAN_PUBLISH_STATUS_UPDATES;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CAN_UNPUBLISH;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_AUTH_STATUS;
-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_NODE_TYPE;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CHANNEL_TYPE;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.COMMENT;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CREATED_TIME;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.CREATOR;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.ICON;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.ID;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.MAX_STATUS_LENGTH;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.MESSAGE;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.NAME;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.NODE_REF;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISHING_CHANNELS;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.PUBLISH_NODES;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.SCHEDULED_TIME;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.STATUS;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.STATUS_UPDATE;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.STATUS_UPDATE_CHANNELS;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.SUPPORTED_CONTENT_TYPES;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.SUPPORTED_MIME_TYPES;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.TITLE;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.UNPUBLISH_NODES;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.URL;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.URL_LENGTH;
-import static org.alfresco.repo.web.scripts.publishing.PublishingWebScriptConstants.VERSION;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMap;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.repo.content.MimetypeMap;
-import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
-import org.alfresco.repo.publishing.AbstractChannelType;
-import org.alfresco.repo.publishing.ChannelHelper;
-import org.alfresco.repo.publishing.ChannelServiceImpl;
-import org.alfresco.repo.publishing.PublishServiceImpl;
-import org.alfresco.repo.publishing.PublishingTestHelper;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.person.TestPersonManager;
-import org.alfresco.repo.web.scripts.BaseWebScriptTest;
-import org.alfresco.repo.web.scripts.WebScriptUtil;
-import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.model.FileFolderService;
-import org.alfresco.service.cmr.publishing.NodeSnapshot;
-import org.alfresco.service.cmr.publishing.PublishingDetails;
-import org.alfresco.service.cmr.publishing.PublishingEvent;
-import org.alfresco.service.cmr.publishing.PublishingPackage;
-import org.alfresco.service.cmr.publishing.PublishingPackageEntry;
-import org.alfresco.service.cmr.publishing.PublishingService;
-import org.alfresco.service.cmr.publishing.Status;
-import org.alfresco.service.cmr.publishing.StatusUpdate;
-import org.alfresco.service.cmr.publishing.channels.Channel;
-import org.alfresco.service.cmr.publishing.channels.ChannelService;
-import org.alfresco.service.cmr.publishing.channels.ChannelType;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.cmr.security.MutableAuthenticationService;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.cmr.security.PersonService;
-import org.alfresco.service.cmr.site.SiteService;
-import org.alfresco.util.GUID;
-import org.alfresco.util.ISO8601DateFormat;
-import org.alfresco.util.collections.CollectionUtils;
-import org.alfresco.util.collections.Function;
-import org.alfresco.util.testing.category.LuceneTests;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.experimental.categories.Category;
-import org.mockito.ArgumentCaptor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.extensions.surf.util.URLEncoder;
-import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
-import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest;
-import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest;
-import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
-
-/**
- * @author Nick Smith
- * @since 4.0
- */
-@Category(LuceneTests.class)
-public class PublishingRestApiTest extends BaseWebScriptTest
-{
- private static final String publishPdfType = "publishPdfForTest";
- private static final String publishAnyType = "publishAnyForTest";
- private static final String statusUpdateType = "statusUpdateForTest";
- private static final int maxStatusLength = 100;
-
- private static final String CHANNELS_URL = "api/publishing/channels";
- private static final String CHANNEL_URL = "api/publishing/channels/{0}";
- private static final String CHANNELS_NODE_URL = "api/publishing/{0}/{1}/{2}/channels";
- private static final String CHANNEL_TYPES_URL = "api/publishing/channel-types";
- private static final String PUBLISHING_QUEUE_URL = "api/publishing/queue";
- private static final String PUBLISHING_EVENTS_URL = "api/publishing/{0}/{1}/{2}/events";
-
- private static final String JSON = "application/json";
-
- private NodeService nodeService;
- private PermissionService permissionService;
- private ChannelService channelService;
- private PublishingService publishingService;
- private ChannelHelper channelHelper;
- private PublishingTestHelper testHelper;
- TestPersonManager personManager;
- private String userName = GUID.generate();
-
-
- public void testGetChannels() throws Exception
- {
- Channel publishAnyChannel = testHelper.createChannel(publishAnyType);
- Channel publishPdfChannel = testHelper.createChannel(publishPdfType);
- Channel statusUpdateChannel=testHelper. createChannel(statusUpdateType);
-
- // Call channels defined.
- Response response = sendRequest(new GetRequest(CHANNELS_URL), 200);
- JSONObject data = getJsonData(response);
-
- assertEquals(21, data.getInt(URL_LENGTH));
- JSONArray publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- JSONArray statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- checkChannels(publishingChannels, publishAnyChannel, publishPdfChannel);
- checkChannels(statusChannels, statusUpdateChannel);
-
- personManager.setUser(userName);
- response = sendRequest(new GetRequest(CHANNELS_URL), 200);
- data = getJsonData(response);
- publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- checkChannels(publishingChannels, publishAnyChannel, publishPdfChannel);
- checkChannels(statusChannels, statusUpdateChannel);
- }
-
- public void testGetChannelsForNode() throws Exception
- {
- NodeRef textNode = testHelper.createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
- permissionService.setPermission(textNode, userName, PermissionService.READ, true);
-
- File pdfFile = AbstractContentTransformerTest.loadQuickTestFile("pdf");
- assertNotNull("Failed to load required test file.", pdfFile);
- NodeRef xmlNode = testHelper.createContentNode("xmlContent", pdfFile, MimetypeMap.MIMETYPE_PDF);
- StoreRef store = textNode.getStoreRef();
-
- String plainTextNodeUrl = MessageFormat.format(CHANNELS_NODE_URL, store.getProtocol(), store.getIdentifier(), textNode.getId() );
-
- Channel publishAnyChannel = testHelper.createChannel(publishAnyType);
- Channel publishPdfChannel = testHelper.createChannel(publishPdfType);
- Channel statusUpdateChannel= testHelper.createChannel(statusUpdateType);
-
- // Call with channels defined.
- Response response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
- JSONObject data = getJsonData(response);
-
- //TODO Fix hard coding.
- assertEquals(21, data.getInt(URL_LENGTH));
- JSONArray publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- JSONArray statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- checkChannels(publishingChannels, publishAnyChannel);
- checkChannels(statusChannels, statusUpdateChannel);
-
- String xmlNodeUrl = MessageFormat.format(CHANNELS_NODE_URL, store.getProtocol(), store.getIdentifier(), xmlNode.getId() );
- response = sendRequest(new GetRequest(xmlNodeUrl), 200);
- data = getJsonData(response);
-
- assertEquals(21, data.getInt(URL_LENGTH));
- publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- checkChannels(publishingChannels, publishAnyChannel, publishPdfChannel);
- checkChannels(statusChannels, statusUpdateChannel);
-
- personManager.setUser(userName);
- response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
- data = getJsonData(response);
- publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- assertEquals(0, publishingChannels.length());
- assertEquals(0, statusChannels.length());
-
- testHelper.allowChannelAccess(userName, publishAnyChannel.getId());
- testHelper.allowChannelAccess(userName, publishPdfChannel.getId());
- testHelper.allowChannelAccess(userName, statusUpdateChannel.getId());
-
- personManager.setUser(userName);
- response = sendRequest(new GetRequest(plainTextNodeUrl), 200);
- data = getJsonData(response);
- publishingChannels = data.getJSONArray(PUBLISHING_CHANNELS);
- statusChannels = data.getJSONArray(STATUS_UPDATE_CHANNELS);
-
- checkChannels(publishingChannels, publishAnyChannel);
- checkChannels(statusChannels, statusUpdateChannel);
- }
-
- public void testChannelPut() throws Exception
- {
- Channel channel1 = testHelper.createChannel(publishAnyType);
- Channel channel2 = testHelper.createChannel(publishAnyType);
-
- String name1 = channel1.getName();
- String name2 = channel2.getName();
-
- String newName = name1 + "Foo";
- JSONObject json = new JSONObject();
- json.put(NAME, newName);
-
- String jsonStr = json.toString();
-
- String channel1Url = MessageFormat.format(CHANNEL_URL, URLEncoder.encode(channel1.getId()));
- // Post JSON content.
- sendRequest(new PutRequest(channel1Url, jsonStr, JSON), 200);
-
- Channel renamedCH1 = channelService.getChannelById(channel1.getId());
- assertEquals("Channel1 was not renamed correctly!", newName, renamedCH1.getName());
-
- Channel renamedCH2 = channelService.getChannelById(channel2.getId());
- assertEquals("Channel2 name should not have changed!", name2, renamedCH2.getName());
- }
-
- public void testPublishingQueuePost() throws Exception
- {
- // Create some content.
- NodeRef textNode = testHelper.createContentNode("plainContent", "Some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
- try
- {
- checkPublishingQueuePost(textNode);
- }
- finally
- {
- // Clean up events
- List events = publishingService.getPublishEventsForNode(textNode);
- List ids = CollectionUtils.transform(events, new Function()
- {
- public String apply(PublishingEvent value)
- {
- return value.getId();
- }
- });
- testHelper.addEvents(ids);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void checkPublishingQueuePost(NodeRef textNode) throws Exception
- {
- // Create publish and status update channels.
- Channel publishChannel = testHelper.createChannel(publishAnyType);
- Channel statusChannel = testHelper.createChannel(statusUpdateType);
-
- // Post empty content.
- sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, "", JSON), 400);
-
- String comment = "The comment";
- String statusMessage = "The status message";
-
- JSONObject json = buildScheduleEventJson(textNode, publishChannel, comment, statusMessage, true, statusChannel);
-
- String jsonStr = json.toString();
-
- // Post JSON content.
- sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
-
- List publishedEvents = publishingService.getPublishEventsForNode(textNode);
-
- assertEquals(1, publishedEvents.size());
-
- PublishingEvent event = publishedEvents.get(0);
- assertEquals(publishChannel.getId(), event.getChannelId());
- assertEquals(comment, event.getComment());
- Collection expectedPubEventStatuses = Arrays.asList(Status.SCHEDULED, Status.IN_PROGRESS, Status.COMPLETED);
- assertTrue(expectedPubEventStatuses.contains(event.getStatus()));
-
- // Check Package
- PublishingPackage pckg = event.getPackage();
- Set toPublish = pckg.getNodesToPublish();
- assertEquals(1, toPublish.size());
- assertTrue(toPublish.contains(textNode));
- assertTrue(pckg.getNodesToUnpublish().isEmpty());
-
- // Check StatusUpdate
- StatusUpdate statusUpdate = event.getStatusUpdate();
- assertEquals(statusMessage, statusUpdate.getMessage());
- assertEquals(textNode, statusUpdate.getNodeToLinkTo());
- Set channelIds = statusUpdate.getChannelIds();
- assertEquals(1, channelIds.size());
- assertTrue(channelIds.contains(statusChannel.getId()));
-
- // Wait for Publishing Event to execute asynchronously
- Thread.sleep(5000);
-
- AbstractChannelType publishAnyChannelType = (AbstractChannelType) channelService.getChannelType(publishAnyType);
- AbstractChannelType statusUpdateChannelType = (AbstractChannelType) channelService.getChannelType(statusUpdateType);
-
- NodeRef mappedTextNode = channelHelper.mapSourceToEnvironment(textNode, publishChannel.getNodeRef());
-
- // Check publish is called.
- verify(publishAnyChannelType)
- .publish(eq(mappedTextNode), anyMap());
-
- // Check updateStatus is called correctly.
- ArgumentCaptor captor = ArgumentCaptor.forClass(String.class);
- verify(statusUpdateChannelType)
- .sendStatusUpdate(any(Channel.class), captor.capture());
- String actualStatusMessage = captor.getValue();
- assertTrue(actualStatusMessage.startsWith(statusMessage));
-
- verify(statusUpdateChannelType, never()).publish(any(NodeRef.class), anyMap());
- verify(publishAnyChannelType, never()).sendStatusUpdate(any(Channel.class), anyString());
-
- JSONObject status = json.optJSONObject(STATUS_UPDATE);
- status.remove(NODE_REF);
- jsonStr = json.toString();
-
- // Post JSON without NodeRef in status.
- sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
-
- json.remove(STATUS_UPDATE);
- jsonStr = json.toString();
-
- // Post JSON without Status Update.
- sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
-
- // Wait for Publishing Events to execute asynchronously
- Thread.sleep(5000);
-
- // Check published node still exists.
- assertTrue(nodeService.exists(mappedTextNode));
-
- // Check unpublish hasn't been called yet.
- verify(publishAnyChannelType, never())
- .unpublish(eq(mappedTextNode), anyMap());
-
- // Create unpublish Json
- json = buildScheduleEventJson(textNode, publishChannel, comment, null, false);
- jsonStr = json.toString();
-
- // Post Unpublish JSON.
- sendRequest(new PostRequest(PUBLISHING_QUEUE_URL, jsonStr, JSON), 200);
-
- // Wait for unpublishing Event to execute asynchronously
- Thread.sleep(5000);
-
- // Check published node has been deleted.
- assertFalse(nodeService.exists(mappedTextNode));
- NodeRef remappedTextNode = channelHelper.mapSourceToEnvironment(textNode, publishChannel.getNodeRef());
- assertNull(remappedTextNode);
-
- // Check unpublish was called
- verify(publishAnyChannelType)
- .unpublish(eq(mappedTextNode), anyMap());
-
- // Check can get unpublish event.
- String protocol = textNode.getStoreRef().getProtocol();
- String storeId = textNode.getStoreRef().getIdentifier();
- String nodeId = textNode.getId();
- String textNodeUrl = MessageFormat.format(PUBLISHING_EVENTS_URL, protocol, storeId, nodeId);
-
- // Get events on textNode1 before any events created.
- Response response = sendRequest(new GetRequest(textNodeUrl), 200);
- JSONArray data = getDataArray(response);
-
- List unpublishEvents = publishingService.getUnpublishEventsForNode(textNode);
- assertEquals(1, unpublishEvents.size());
- PublishingEvent unpublishedEvent = unpublishEvents.get(0);
-
- checkContainsEvent(data, unpublishedEvent.getId());
- }
-
- public void testPublishingEventsGet() throws Exception
- {
- Channel publishChannel = testHelper.createChannel(publishAnyType);
- NodeRef textNode1 = testHelper.createContentNode("plain1.txt", "This is some plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
- NodeRef textNode2 = testHelper.createContentNode("plain2.txt", "This is some more plain text", MimetypeMap.MIMETYPE_TEXT_PLAIN);
-
- String protocol = textNode1.getStoreRef().getProtocol();
- String storeId = textNode1.getStoreRef().getIdentifier();
- String nodeId1 = textNode1.getId();
- String textNode1Url = MessageFormat.format(PUBLISHING_EVENTS_URL, protocol, storeId, nodeId1);
-
- // Get events on textNode1 before any events created.
- Response response = sendRequest(new GetRequest(textNode1Url), 200);
- JSONArray data = getDataArray(response);
- assertEquals(0, data.length());
-
- // Create publishing event for textNode1.
- String comment = "This is a comment";
- PublishingDetails details = publishingService.createPublishingDetails()
- .setPublishChannelId(publishChannel.getId())
- .addNodesToPublish(textNode1)
- .setComment(comment);
-
- String event1Id = testHelper.scheduleEvent1Year(details);
-
- // Query for events on textNode1.
- response = sendRequest(new GetRequest(textNode1Url), 200);
- data = getDataArray(response);
- checkContainsEvents(data, event1Id);
-
- // Query for events on textNode2.
- String nodeId2 = textNode2.getId();
- String textNode2Url = MessageFormat.format(PUBLISHING_EVENTS_URL, protocol, storeId, nodeId2);
- response = sendRequest(new GetRequest(textNode2Url), 200);
- data = getDataArray(response);
- assertEquals(0, data.length());
-
- // Change to non-Admin user.
- personManager.setUser(userName);
- // Query for events on textNode1.
- response = sendRequest(new GetRequest(textNode1Url), 200);
- data = getDataArray(response);
- checkContainsEvents(data, event1Id);
-
- // Query for events on textNode2.
- response = sendRequest(new GetRequest(textNode2Url), 200);
- data = getDataArray(response);
- assertEquals(0, data.length());
-
- }
-
- public void testChannelTypesGet() throws Exception
- {
- Response response = sendRequest(new GetRequest(CHANNEL_TYPES_URL), 200);
- JSONArray data = getDataArray(response);
- checkChannelTypes(data, channelService.getChannelTypes());
- }
-
- private void checkChannelTypes(JSONArray data, List channelTypes) throws Exception
- {
- assertEquals(channelTypes.size(), data.length());
- for (ChannelType type : channelTypes)
- {
- checkContainsChannelType(data, type);
- }
- }
-
- private void checkContainsChannelType(JSONArray data, ChannelType type) throws Exception
- {
- String typeId = type.getId();
- for (int i = 0; i < data.length(); i++)
- {
- JSONObject json = data.optJSONObject(i);
- if (typeId.equals(json.optString(ID)))
- {
- checkChannelType(json, type);
- return;
- }
- }
- fail("Failed to find Channel Type: " + typeId);
- }
-
- private void checkContainsEvents(JSONArray data, String... eventIds) throws Exception
- {
- assertEquals(eventIds.length, data.length());
- for (String eventId : eventIds)
- {
- checkContainsEvent(data, eventId);
- }
- }
-
- private void checkContainsEvent(JSONArray data, String eventId) throws Exception
- {
- for (int i = 0; i < data.length(); i++)
- {
- JSONObject json = data.optJSONObject(i);
- if (eventId.equals(json.optString(ID)))
- {
- PublishingEvent event = publishingService.getPublishingEvent(eventId);
- checkJsonEvent(event, json);
- return;
- }
- }
- fail("Failed to find Publishing Event: " + eventId);
- }
-
- private void checkJsonEvent(PublishingEvent event, JSONObject json) throws Exception
- {
- String url = "api/publishing/events/" + URLEncoder.encode(event.getId());
- assertEquals(url, json.getString(URL));
-
- assertEquals(event.getStatus().name(), json.getString(STATUS));
-
- assertEquals(event.getComment(), json.optString(COMMENT));
- checkCalendar(event.getScheduledTime(), json.optJSONObject(SCHEDULED_TIME));
- assertEquals(event.getCreator(), json.getString(CREATOR));
- checkDate(event.getCreatedTime(), json.getJSONObject(CREATED_TIME));
-
- PublishingPackage pckg = event.getPackage();
- checkContainsNodes(pckg, json.getJSONArray(PUBLISH_NODES), true);
- checkContainsNodes(pckg, json.getJSONArray(UNPUBLISH_NODES), false);
-
- Channel channel = channelService.getChannelById(event.getChannelId());
- checkChannel(json.getJSONObject(CHANNEL), channel);
- }
-
- private void checkContainsNodes(PublishingPackage pckg, JSONArray json, boolean isPublish) throws JSONException
- {
- Collection nodes = isPublish ? pckg.getNodesToPublish() : pckg.getNodesToUnpublish();
- checkContainsNodes(nodes, pckg.getEntryMap(), json);
- }
-
- private void checkContainsNodes(Collection nodes, Map entryMap, JSONArray json) throws JSONException
- {
- assertEquals(nodes.size(), json.length());
- for (NodeRef node : nodes)
- {
- checkContainsNode(entryMap.get(node), json);
- }
- }
-
- private void checkContainsNode(PublishingPackageEntry entry, JSONArray jsonArray) throws JSONException
- {
- String nodeId = entry.getNodeRef().toString();
- for (int i = 0; i < jsonArray.length(); i++)
- {
- JSONObject json = jsonArray.getJSONObject(i);
- if (nodeId.equals(json.getString(NODE_REF)))
- {
- checkNode(entry, json);
- return;
- }
- }
- fail("NodeRef was not found!");
- }
-
- private void checkNode(PublishingPackageEntry entry, JSONObject json) throws JSONException
- {
- NodeSnapshot snapshot = entry.getSnapshot();
- String version = snapshot.getVersion();
- if (version != null && version.isEmpty() == false)
- {
- assertEquals(version, json.getString(VERSION));
- }
- String name = (String) snapshot.getProperties().get(ContentModel.PROP_NAME);
- if (name != null && name.isEmpty() == false)
- {
- assertEquals(name, json.getString(NAME));
- }
- }
-
- private void checkCalendar(Calendar calendar, JSONObject json) throws JSONException
- {
- checkDate(calendar.getTime(), json);
- String timeZone = calendar.getTimeZone().getID();
- assertEquals(timeZone, json.getString(WebScriptUtil.TIME_ZONE));
- }
-
- private void checkDate(Date date, JSONObject json) throws JSONException
- {
- assertEquals(WebScriptUtil.ISO8601, json.getString(WebScriptUtil.FORMAT));
- String dateStr = json.getString(WebScriptUtil.DATE_TIME);
- Date actualDate = ISO8601DateFormat.parse(dateStr);
- assertEquals(date, actualDate);
- }
-
- private JSONObject buildScheduleEventJson(NodeRef node, Channel publishChannel,
- String comment, String statusMessage,
- boolean publish, Channel... statusChannels) throws JSONException
- {
- JSONObject json = new JSONObject();
- json.put(CHANNEL_ID, publishChannel.getId());
- json.put(COMMENT, comment);
- Collection publishNodes = Collections.singleton(node.toString());
- if (publish)
- {
- json.put(PUBLISH_NODES, publishNodes);
- }
- else
- {
- json.put(UNPUBLISH_NODES, publishNodes);
- }
- if (statusMessage != null)
- {
- json.put(STATUS_UPDATE, buildStatusUpdate(statusMessage, node, statusChannels));
- }
- return json;
- }
-
- private JSONObject buildStatusUpdate(String message, NodeRef textNode, Channel... theChannels) throws JSONException
- {
- Function transformer = new Function()
- {
- public String apply(Channel channel)
- {
- return channel.getId();
- }
- };
- List ids = CollectionUtils.transform(transformer, theChannels);
-
- JSONObject statusUpdate = new JSONObject();
- statusUpdate.put(MESSAGE, message);
- statusUpdate.put(NODE_REF, textNode.toString());
- statusUpdate.put(CHANNEL_IDS, ids);
- return statusUpdate;
- }
-
- private void checkChannels(JSONArray json, Channel... theChannels)throws Exception
- {
- for (Channel channel : theChannels)
- {
- checkContainsChannel(json, channel);
- }
- }
-
- private void checkContainsChannel(JSONArray json, Channel channel) throws Exception
- {
- for (int i = 0; i < json.length(); i++)
- {
- JSONObject jsonChannel = json.getJSONObject(i);
- String name = jsonChannel.getString(NAME);
- if (channel.getName().equals(name))
- {
- checkChannel(jsonChannel, channel);
- return;
- }
- }
- fail("Json did not contain channel: " + channel.getName());
- }
-
- private void checkChannel(JSONObject jsonChannel, Channel channel) throws Exception
- {
- NodeRef node = channel.getNodeRef();
- StoreRef storeRef = node.getStoreRef();
- check(ID, jsonChannel, channel.getId());
- String expUrl = "api/publishing/channels/"
- + storeRef.getProtocol() + "/"
- + storeRef.getIdentifier() + "/"
- + node.getId();
- check(URL, jsonChannel, expUrl);
- check(TITLE, jsonChannel, channel.getName());
- check(CAN_PUBLISH, jsonChannel, channel.canPublish());
- check(CAN_UNPUBLISH, jsonChannel, channel.canUnpublish());
- check(CAN_PUBLISH_STATUS_UPDATES, jsonChannel, channel.canPublishStatusUpdates());
- check(CHANNEL_AUTH_STATUS, jsonChannel, channel.isAuthorised());
-
- JSONObject jsonType = jsonChannel.getJSONObject(CHANNEL_TYPE);
- assertNotNull("The channel type is null!", jsonType);
- checkChannelType(jsonType, channel.getChannelType());
- }
-
- private void checkChannelType(JSONObject jsonType, ChannelType channelType) throws Exception
- {
- check(ID, jsonType, channelType.getId());
- check(TITLE, jsonType, channelType.getId());
-
- String expUrl = "api/publishing/channel-types/"+URLEncoder.encode(channelType.getId());
- check(URL, jsonType, expUrl);
- check(CHANNEL_NODE_TYPE, jsonType, channelType.getChannelNodeType().toString());
-
- List contentTypes = CollectionUtils.toListOfStrings(channelType.getSupportedContentTypes());
- checkStrings(jsonType.getJSONArray(SUPPORTED_CONTENT_TYPES), contentTypes);
- checkStrings(jsonType.getJSONArray(SUPPORTED_MIME_TYPES), channelType.getSupportedMimeTypes());
-
- check(CAN_PUBLISH, jsonType, channelType.canPublish());
- check(CAN_PUBLISH_STATUS_UPDATES, jsonType, channelType.canPublishStatusUpdates());
- check(CAN_UNPUBLISH, jsonType, channelType.canUnpublish());
- check(MAX_STATUS_LENGTH, jsonType, channelType.getMaximumStatusLength());
-
- //TODO Implement Icon URL
- check(ICON, jsonType, expUrl + "/icon");
- }
-
- private void check(String key, JSONObject json, Object exp)
- {
- Object actual = json.opt(key);
- if (exp instanceof String && actual instanceof String)
- {
- exp = exp.toString().toLowerCase();
- actual = actual.toString().toLowerCase();
- }
- assertEquals("Comparing "+key, exp, actual);
- }
-
- private void checkStrings(JSONArray json, Collection strings) throws Exception
- {
- assertEquals(strings.size(), json.length());
- for (String string : strings)
- {
- checkContains(json, string);
- }
- }
-
- private void checkContains(JSONArray json, String string) throws Exception
- {
- for (int i = 0; i < json.length(); i++)
- {
- if (string.equals(json.getString(i)))
- {
- return;
- }
- }
- fail("Did not contain " + string);
- }
-
- private JSONObject getJsonData(Response response) throws Exception
- {
- JSONObject json = getJson(response);
- JSONObject data = json.getJSONObject("data");
- assertNotNull("Data was null!", data);
- return data;
- }
-
- public JSONArray getDataArray(Response response) throws Exception
- {
- JSONObject json = getJson(response);
- JSONArray data = json.getJSONArray("data");
- assertNotNull("Data was null!", data);
- return data;
- }
-
- private JSONObject getJson(Response response) throws UnsupportedEncodingException, JSONException
- {
- String jsonStr = response.getContentAsString();
- assertNotNull("The JSON is null!", jsonStr);
- return new JSONObject(jsonStr);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- ApplicationContext ctx = getServer().getApplicationContext();
- ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
- SiteService siteService = serviceRegistry.getSiteService();
- FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
- this.nodeService = serviceRegistry.getNodeService();
- this.permissionService= serviceRegistry.getPermissionService();
- this.channelService = (ChannelService) ctx.getBean(ChannelServiceImpl.NAME);
- this.publishingService= (PublishingService) ctx.getBean(PublishServiceImpl.NAME);
- this.channelHelper = (ChannelHelper) ctx.getBean(ChannelHelper.NAME);
- this.testHelper = new PublishingTestHelper(channelService, publishingService, siteService, fileFolderService, permissionService);
-
- MutableAuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
- PersonService personService = serviceRegistry.getPersonService();
- this.personManager = new TestPersonManager(authenticationService, personService, nodeService);
-
- personManager.createPerson(userName);
- AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
-
- ChannelType publishAny = testHelper.mockChannelType(publishAnyType);
- when(publishAny.canPublish()).thenReturn(true);
- when(publishAny.canUnpublish()).thenReturn(true);
-
- ChannelType publishPdf= testHelper.mockChannelType(publishPdfType);
- when(publishPdf.canPublish()).thenReturn(true);
- when(publishPdf.getSupportedMimeTypes()).thenReturn(Collections.singleton(MimetypeMap.MIMETYPE_PDF));
-
- ChannelType statusUpdate= testHelper.mockChannelType(statusUpdateType);
- when(statusUpdate.canPublishStatusUpdates()).thenReturn(true);
- when(statusUpdate.getMaximumStatusLength()).thenReturn(maxStatusLength);
- }
-
- @Override
- public void tearDown() throws Exception
- {
- try
- {
- testHelper.tearDown();
- }
- finally
- {
- super.tearDown();
- }
- }
-}