diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.desc.xml new file mode 100644 index 0000000000..1a7aa30ee1 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.desc.xml @@ -0,0 +1,11 @@ + +QuickShare - indicates is enabled + + + + /quickshare/enabled + + none + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.json.ftl new file mode 100644 index 0000000000..ae4f0e5501 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/quickshare/enabled-noauth.get.json.ftl @@ -0,0 +1,3 @@ +{ + "enabled" : ${enabled?string} +} \ No newline at end of file diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index b0b49d7be7..7fb72ea487 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -1747,6 +1747,10 @@ + + + + diff --git a/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareEnabledGet.java b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareEnabledGet.java new file mode 100644 index 0000000000..2d45cdfa75 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/quickshare/QuickShareEnabledGet.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.quickshare; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * QuickShare/PublicView + * + * GET web script to get property system.quickshare.enabled value + * + * @author sergey.shcherbovich + * @since 4.2 + */ +public class QuickShareEnabledGet extends AbstractQuickShareContent +{ + @Override + protected Map executeImpl(final WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(); + + model.put("enabled", isEnabled()); + + return model; + } +} \ No newline at end of file diff --git a/source/test-java/org/alfresco/repo/web/scripts/quickshare/QuickShareTurnedOffRestApiTest.java b/source/test-java/org/alfresco/repo/web/scripts/quickshare/QuickShareTurnedOffRestApiTest.java new file mode 100644 index 0000000000..23813ff324 --- /dev/null +++ b/source/test-java/org/alfresco/repo/web/scripts/quickshare/QuickShareTurnedOffRestApiTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts.quickshare; + +import java.io.IOException; + +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.web.scripts.BaseWebScriptTest; +import org.springframework.extensions.webscripts.GUID; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; + +/** + * This class tests QuickShare REST API with disabled QuickShare feature + * + * @author sergey.shcherbovich + * @since 4.2 + */ +public class QuickShareTurnedOffRestApiTest extends BaseWebScriptTest +{ + private static final String APPLICATION_JSON = "application/json"; + private final static String SHARE_URL = "/api/internal/shared/share/{node_ref}"; + + @Override + protected void setUp() throws Exception + { + setCustomContext("classpath:alfresco/quick-share-turned-off-test-context.xml"); + + super.setUp(); + + getServer().getApplicationContext(); + } + + public void testQuickShareDisabled() throws IOException + { + String testNodeRef = "workspace://SpacesStore/" + GUID.generate(); + sendRequest(new PostRequest(SHARE_URL.replace("{node_ref}", testNodeRef), "", APPLICATION_JSON), 403, AuthenticationUtil.getAdminUserName()); + } +} diff --git a/source/test-resources/alfresco/quick-share-turned-off-test-context.xml b/source/test-resources/alfresco/quick-share-turned-off-test-context.xml new file mode 100644 index 0000000000..e3ffeaa0aa --- /dev/null +++ b/source/test-resources/alfresco/quick-share-turned-off-test-context.xml @@ -0,0 +1,8 @@ + + + + + + + +