From ec246ec1da7f87cc1aecb9739908d2b1d8d23074 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 6 Jan 2010 17:09:10 +0000 Subject: [PATCH] Merged DEV/TEMPORARY to HEAD 17804: Branch for SpringSurf integration 2 to RemoteAPI - from HEAD r17789 17808: Part 3 of SpringSurf integration - RemoteAPI, Web-Client, Mobile and DOD5015 java code refactored to use SpringSurf Webscripts libraries, removed dependancies on existing WebScriptFramework project. 17812: Removed web-framework and webscript-framework projects. Updated build scripts to use SpringSurf dependencies for remote API and client projects and also removal of wf and wsf projects from builds. 17818: Various Spring app context and config changes to integration SpringSurf at the RemoteAPI and Web-Client project level. - Build scripts fixed up - Temporary web.xml changes until spring mvc dispatcher is hooked into /service urls - The server starts up! No nothing else works yet, you know how this goes... 17819: Fix to incremental-webclient-tomcat-exploded build target to work on first deploy to a clean tomcat (affects HEAD also, not SpringSurf related). 17872: Refactor Web-Client web.xml to use Spring WebScripts Dispatcher Servlet - servlet is configured to use the existing Spring application context instance as loaded by the ContextLoaderListener Share web.xml TODOs for JBoss app-server support (currently missing from SpringSurf extraction) 17892: Upgraded Repository Spring dependant libraries to 3.0.0 release. Upgraded to latest SpringSurf release (also running against Spring 3.0.0) Various related fixes. 17893: Additional Spring3.0.0 migration fixes and libraries. 17899: Integrated another SpringSurf bug fix - to correctly add ClassPathStore instances to SearchPath objects. 17901: Fixes to handling of merging of models returned from the new Script Processors. Share now works against a Repository that is running SpringSurf WebScripts and Spring 3.0.0. 17904: Latest SpringSurf libraries after latest changes. TODO: - NTLM filter needs moving to Share (not present in SpringSurf) - MessagesWebScript - community tracking image needs adding to Share specific version (not present in SpringSurf) - feedController - for rss feed service urls - needs testing - Clustering config overrides - no longer work in SpringSurf, needs a rethink - Mobile project is not working - PHP module project - JBossEnabledWebApplicationContext required for Share - currently missing from SpringSurf git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17906 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .classpath | 37 +-- .../repository/thumbnail/thumbnail.get.js | 74 +++--- .../web-scripts-application-context.xml | 83 ++++-- .../repo/cmis/rest/CMISQueryReader.java | 8 +- .../rest/test/CMISTestRunnerWebScript.java | 6 +- .../imap/scripts/ServerStatusWebScript.java | 6 +- .../scripts/AlfrescoRhinoScriptDebugger.java | 4 +- .../repo/web/scripts/BaseWebScriptTest.java | 6 +- .../alfresco/repo/web/scripts/LoginTest.java | 10 +- .../alfresco/repo/web/scripts/RepoStore.java | 24 +- .../repo/web/scripts/RepositoryContainer.java | 32 +-- .../web/scripts/RepositoryContainerTest.java | 4 +- .../scripts/RepositoryScriptProcessor.java | 14 +- .../RepositoryScriptProcessorFactory.java | 53 ++++ .../web/scripts/RepositoryServerModel.java | 2 +- .../scripts/RepositoryTemplateProcessor.java | 8 +- .../RepositoryTemplateProcessorFactory.java | 53 ++++ .../web/scripts/TestWebScriptRepoServer.java | 2 +- .../scripts/activities/TemplateWebScript.java | 8 +- .../activities/TemplatesWebScript.java | 12 +- .../feed/SiteFeedRetrieverWebScript.java | 6 +- .../feed/UserFeedRetrieverWebScript.java | 6 +- .../feed/control/FeedControlTest.java | 8 +- .../repo/web/scripts/bean/AVMRemoteStore.java | 6 +- .../web/scripts/bean/AbstractLoginBean.java | 8 +- .../web/scripts/bean/BaseRemoteStore.java | 10 +- .../repo/web/scripts/bean/KeywordSearch.java | 8 +- .../alfresco/repo/web/scripts/bean/Login.java | 8 +- .../repo/web/scripts/bean/LoginPost.java | 6 +- .../repo/web/scripts/bean/LoginTicket.java | 8 +- .../web/scripts/bean/LoginTicketDelete.java | 8 +- .../repo/web/scripts/bean/SearchEngines.java | 6 +- .../repo/web/scripts/bean/SearchProxy.java | 18 +- .../alfresco/repo/web/scripts/bean/Touch.java | 8 +- .../web/scripts/blog/BlogServiceTest.java | 10 +- .../web/scripts/content/ContentDelete.java | 8 +- .../repo/web/scripts/content/ContentGet.java | 6 +- .../repo/web/scripts/content/ContentSet.java | 8 +- .../repo/web/scripts/content/StreamACP.java | 8 +- .../web/scripts/content/StreamContent.java | 42 +-- .../scripts/dictionary/DictionaryHelper.java | 4 +- .../dictionary/DictionaryServiceTest.java | 4 +- .../scripts/dictionary/GetAssociationDef.java | 10 +- .../dictionary/GetAssociationDefs.java | 10 +- .../scripts/dictionary/GetClassDetail.java | 10 +- .../scripts/dictionary/GetClassDetails.java | 8 +- .../scripts/dictionary/GetPropertyDef.java | 10 +- .../scripts/dictionary/GetPropertyDefs.java | 10 +- .../scripts/dictionary/GetSubClassesDef.java | 10 +- .../discussion/DiscussionServiceTest.java | 10 +- .../scripts/facebook/FacebookAPIRuntime.java | 97 +++++++ .../scripts/facebook/FacebookAPIServlet.java | 65 +++++ .../scripts/facebook/FacebookAppModel.java | 89 +++++++ .../FacebookAuthenticatorFactory.java | 13 +- .../web/scripts/facebook/FacebookError.java | 54 ++++ .../web/scripts/facebook/FacebookModel.java | 249 ++++++++++++++++++ .../web/scripts/facebook/FacebookService.java | 169 ++++++++++++ .../web/scripts/facebook/FacebookServlet.java | 76 ++++++ .../facebook/FacebookServletRequest.java | 174 ++++++++++++ .../facebook/FacebookServletRuntime.java | 121 +++++++++ .../forms/AbstractTestFormRestApi.java | 4 +- .../scripts/forms/FormRestApiGet_Test.java | 6 +- .../forms/FormRestApiJsonPost_Test.java | 4 +- .../repo/web/scripts/groups/GroupsTest.java | 12 +- .../scripts/invitation/InvitationTest.java | 12 +- .../repo/web/scripts/invite/Invite.java | 10 +- .../web/scripts/invite/InviteByTicket.java | 8 +- .../web/scripts/invite/InviteResponse.java | 8 +- .../web/scripts/invite/InviteServiceTest.java | 8 +- .../repo/web/scripts/invite/Invites.java | 8 +- .../scripts/person/ChangePasswordPost.java | 8 +- .../web/scripts/person/PersonServiceTest.java | 12 +- .../JSR168PortletAuthenticatorFactory.java | 10 +- .../preference/PreferenceServiceTest.java | 8 +- .../repo/web/scripts/rule/ActionDefGet.java | 8 +- .../repo/web/scripts/rule/ActionDefsGet.java | 6 +- .../web/scripts/rule/ActionQueuePost.java | 8 +- .../web/scripts/rule/ConditionDefGet.java | 8 +- .../web/scripts/rule/ConditionDefsGet.java | 6 +- .../repo/web/scripts/rule/RuleDelete.java | 8 +- .../repo/web/scripts/rule/RuleGet.java | 8 +- .../repo/web/scripts/rule/RulePut.java | 8 +- .../web/scripts/rule/RuleServiceTest.java | 12 +- .../repo/web/scripts/rule/RulesDelete.java | 8 +- .../repo/web/scripts/rule/RulesGet.java | 8 +- .../repo/web/scripts/rule/RulesHelper.java | 6 +- .../repo/web/scripts/rule/RulesPost.java | 8 +- .../web/scripts/search/PersonSearchTest.java | 6 +- .../BasicHttpAuthenticatorFactory.java | 12 +- .../web/scripts/site/SiteServiceTest.java | 12 +- .../scripts/tagging/TaggingServiceTest.java | 4 +- .../thumbnail/ThumbnailServiceTest.java | 6 +- .../repo/web/scripts/wcm/WebProjectTest.java | 12 +- .../membership/WebProjectMembershipTest.java | 10 +- .../web/scripts/wcm/sandbox/AssetTest.java | 12 +- .../web/scripts/wcm/sandbox/SandboxTest.java | 10 +- .../alfresco/web/app/servlet/HTTPProxy.java | 144 ++++++++++ .../web/app/servlet/HTTPProxyServlet.java | 134 ++++++++++ 98 files changed, 1977 insertions(+), 440 deletions(-) create mode 100644 source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessorFactory.java create mode 100644 source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessorFactory.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIRuntime.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIServlet.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookAppModel.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookError.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookModel.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookService.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookServlet.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRequest.java create mode 100644 source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRuntime.java create mode 100644 source/java/org/alfresco/web/app/servlet/HTTPProxy.java create mode 100644 source/java/org/alfresco/web/app/servlet/HTTPProxyServlet.java diff --git a/.classpath b/.classpath index 6531e71adb..00a5283dce 100644 --- a/.classpath +++ b/.classpath @@ -1,15 +1,22 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js index f3dcff1d5f..4e7866fd5a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js @@ -27,14 +27,14 @@ function main() var fc = false; if (args.c != null) { - if (args.c == "queue") - { - qc = true; - } - else if (args.c == "force") - { - fc = true; - } + if (args.c == "queue") + { + qc = true; + } + else if (args.c == "force") + { + fc = true; + } } // Get the place holder flag @@ -58,42 +58,42 @@ function main() // Queue the creation of the thumbnail if appropriate if (fc) { - model.contentNode = node.createThumbnail(thumbnailName, false); + model.contentNode = node.createThumbnail(thumbnailName, false); } else { - if (qc) - { - node.createThumbnail(thumbnailName, true); - } - - if (ph == true) - { - // Try and get the place holder resource - var phPath = thumbnailService.getPlaceHolderResourcePath(thumbnailName); - if (phPath == null) - { - // 404 since no thumbnail was found - status.setCode(status.STATUS_NOT_FOUND, "Thumbnail was not found and no place holde resource set for '" + thumbnailName + "'"); - return; - } - else - { - // Set the resouce path in the model ready for the content stream to send back to the client - model.contentPath = phPath; - } - } - else - { - // 404 since no thumbnail was found - status.setCode(status.STATUS_NOT_FOUND, "Thumbnail was not found"); - return; - } + if (qc) + { + node.createThumbnail(thumbnailName, true); + } + + if (ph == true) + { + // Try and get the place holder resource + var phPath = thumbnailService.getPlaceHolderResourcePath(thumbnailName); + if (phPath == null) + { + // 404 since no thumbnail was found + status.setCode(status.STATUS_NOT_FOUND, "Thumbnail was not found and no place holde resource set for '" + thumbnailName + "'"); + return; + } + else + { + // Set the resouce path in the model ready for the content stream to send back to the client + model.contentPath = phPath; + } + } + else + { + // 404 since no thumbnail was found + status.setCode(status.STATUS_NOT_FOUND, "Thumbnail was not found"); + return; + } } } else { - // Place the details of the thumbnail into the model, this will be used to stream the content to the client + // Place the details of the thumbnail into the model, this will be used to stream the content to the client model.contentNode = thumbnail; } } diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 0844450b77..33d4b4f60f 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -2,11 +2,10 @@ - - + - + @@ -29,7 +28,7 @@ - + @@ -60,7 +59,7 @@ alfresco/templates/webscripts - + @@ -68,6 +67,8 @@ + + @@ -79,16 +80,41 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + + + + Repository Template Processor + ftl + + + + + + Repository Script Processor + js @@ -139,14 +165,14 @@ - - + + - + @@ -174,12 +200,21 @@ + + + + + + + + + - + @@ -266,10 +301,10 @@ - + - + @@ -395,7 +430,7 @@ - + alfresco/extension/templates/activities @@ -406,7 +441,7 @@ alfresco/templates/activities - + @@ -649,11 +684,9 @@ - + - - ${imap.server.enabled} - + ${imap.server.enabled} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java b/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java index 8b0a8d6bca..c74356e468 100644 --- a/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java +++ b/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java @@ -34,10 +34,10 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.springframework.extensions.surf.util.Content; -import org.alfresco.web.scripts.FormatReader; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.FormatReader; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.chemistry.abdera.ext.CMISConstants; diff --git a/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java index 288d287157..f46e641a67 100644 --- a/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java +++ b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java @@ -28,9 +28,9 @@ import java.io.IOException; import java.io.PrintStream; import java.util.Properties; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.chemistry.tck.atompub.TCKMessageWriter; import org.apache.chemistry.tck.atompub.tools.TCKRunner; import org.apache.chemistry.tck.atompub.tools.TCKRunnerOptions; diff --git a/source/java/org/alfresco/repo/imap/scripts/ServerStatusWebScript.java b/source/java/org/alfresco/repo/imap/scripts/ServerStatusWebScript.java index b897456d55..7b6062345f 100755 --- a/source/java/org/alfresco/repo/imap/scripts/ServerStatusWebScript.java +++ b/source/java/org/alfresco/repo/imap/scripts/ServerStatusWebScript.java @@ -2,9 +2,9 @@ package org.alfresco.repo.imap.scripts; import java.io.IOException; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; public class ServerStatusWebScript extends AbstractWebScript { diff --git a/source/java/org/alfresco/repo/web/scripts/AlfrescoRhinoScriptDebugger.java b/source/java/org/alfresco/repo/web/scripts/AlfrescoRhinoScriptDebugger.java index 33d210789d..2cbd9dc634 100644 --- a/source/java/org/alfresco/repo/web/scripts/AlfrescoRhinoScriptDebugger.java +++ b/source/java/org/alfresco/repo/web/scripts/AlfrescoRhinoScriptDebugger.java @@ -26,12 +26,12 @@ package org.alfresco.repo.web.scripts; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.web.scripts.AlfrescoScriptDebugger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.tools.debugger.Dim; import org.mozilla.javascript.tools.debugger.SwingGui; +import org.springframework.extensions.webscripts.ScriptDebugger; /** @@ -41,7 +41,7 @@ import org.mozilla.javascript.tools.debugger.SwingGui; * * @author davidc */ -public class AlfrescoRhinoScriptDebugger extends AlfrescoScriptDebugger +public class AlfrescoRhinoScriptDebugger extends ScriptDebugger { private static final Log logger = LogFactory.getLog(AlfrescoRhinoScriptDebugger.class); diff --git a/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java b/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java index b03ea41f44..91e57ffb6d 100644 --- a/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java +++ b/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java @@ -38,9 +38,6 @@ import junit.textui.ResultPrinter; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.web.scripts.TestWebScriptServer; -import org.alfresco.web.scripts.TestWebScriptServer.Request; -import org.alfresco.web.scripts.TestWebScriptServer.Response; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; @@ -53,6 +50,9 @@ import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.params.HttpClientParams; +import org.springframework.extensions.webscripts.TestWebScriptServer; +import org.springframework.extensions.webscripts.TestWebScriptServer.Request; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * Base unit test class for web scripts. diff --git a/source/java/org/alfresco/repo/web/scripts/LoginTest.java b/source/java/org/alfresco/repo/web/scripts/LoginTest.java index 70c7fc02ee..8ec9484e10 100644 --- a/source/java/org/alfresco/repo/web/scripts/LoginTest.java +++ b/source/java/org/alfresco/repo/web/scripts/LoginTest.java @@ -30,11 +30,11 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONObject; /** diff --git a/source/java/org/alfresco/repo/web/scripts/RepoStore.java b/source/java/org/alfresco/repo/web/scripts/RepoStore.java index 64fd39f019..8573c4a165 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepoStore.java +++ b/source/java/org/alfresco/repo/web/scripts/RepoStore.java @@ -60,11 +60,12 @@ import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.util.ISO9075; -import org.alfresco.web.scripts.ScriptContent; -import org.alfresco.web.scripts.ScriptLoader; -import org.alfresco.web.scripts.Store; -import org.alfresco.web.scripts.WebScript; -import org.alfresco.web.scripts.WebScriptException; +import org.springframework.extensions.webscripts.AbstractStore; +import org.springframework.extensions.webscripts.ScriptContent; +import org.springframework.extensions.webscripts.ScriptLoader; +import org.springframework.extensions.webscripts.Store; +import org.springframework.extensions.webscripts.WebScript; +import org.springframework.extensions.webscripts.WebScriptException; import freemarker.cache.TemplateLoader; @@ -74,7 +75,7 @@ import freemarker.cache.TemplateLoader; * * @author davidc */ -public class RepoStore implements Store, TenantDeployer +public class RepoStore extends AbstractStore implements TenantDeployer { protected boolean mustExist = false; protected StoreRef repoStore; @@ -460,7 +461,7 @@ public class RepoStore implements Store, TenantDeployer */ public String[] getDescriptionDocumentPaths() { - return getDocumentPaths("/", true, "*.desc.xml"); + return getDocumentPaths("/", true, DESC_PATH_PATTERN); } /* (non-Javadoc) @@ -683,6 +684,15 @@ public class RepoStore implements Store, TenantDeployer destroy(); } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return repoPath; + } + /** * Repository path based template loader * diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java index 33548d224a..a3eb60d233 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java @@ -51,22 +51,22 @@ import org.alfresco.service.cmr.repository.TemplateService; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.descriptor.DescriptorService; import org.springframework.extensions.surf.util.StringBuilderWriter; -import org.alfresco.web.scripts.AbstractRuntimeContainer; -import org.alfresco.web.scripts.Authenticator; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.Description; -import org.alfresco.web.scripts.Registry; -import org.alfresco.web.scripts.Runtime; -import org.alfresco.web.scripts.ServerModel; -import org.alfresco.web.scripts.WebScript; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; -import org.alfresco.web.scripts.WrappingWebScriptResponse; -import org.alfresco.web.scripts.Description.RequiredAuthentication; -import org.alfresco.web.scripts.Description.RequiredTransaction; -import org.alfresco.web.scripts.Description.RequiredTransactionParameters; -import org.alfresco.web.scripts.Description.TransactionCapability; +import org.springframework.extensions.webscripts.AbstractRuntimeContainer; +import org.springframework.extensions.webscripts.Authenticator; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Description; +import org.springframework.extensions.webscripts.Registry; +import org.springframework.extensions.webscripts.Runtime; +import org.springframework.extensions.webscripts.ServerModel; +import org.springframework.extensions.webscripts.WebScript; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.WrappingWebScriptResponse; +import org.springframework.extensions.webscripts.Description.RequiredAuthentication; +import org.springframework.extensions.webscripts.Description.RequiredTransaction; +import org.springframework.extensions.webscripts.Description.RequiredTransactionParameters; +import org.springframework.extensions.webscripts.Description.TransactionCapability; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.ObjectFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java index 1608780734..69c3650ba4 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java @@ -29,8 +29,8 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * Unit test to test runas function diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessor.java b/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessor.java index 93bfe5807c..abb7c1d2cb 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessor.java @@ -35,13 +35,13 @@ import org.alfresco.repo.jscript.ValueConverter; import org.alfresco.scripts.ScriptException; import org.alfresco.service.cmr.repository.ScriptLocation; import org.alfresco.service.cmr.repository.ScriptService; -import org.alfresco.web.scripts.MultiScriptLoader; -import org.alfresco.web.scripts.ScriptContent; -import org.alfresco.web.scripts.ScriptLoader; -import org.alfresco.web.scripts.ScriptProcessor; -import org.alfresco.web.scripts.SearchPath; -import org.alfresco.web.scripts.Store; -import org.alfresco.web.scripts.WebScriptException; +import org.springframework.extensions.webscripts.MultiScriptLoader; +import org.springframework.extensions.webscripts.ScriptContent; +import org.springframework.extensions.webscripts.ScriptLoader; +import org.springframework.extensions.webscripts.ScriptProcessor; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.Store; +import org.springframework.extensions.webscripts.WebScriptException; /** diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessorFactory.java b/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessorFactory.java new file mode 100644 index 0000000000..04ea72400d --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryScriptProcessorFactory.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.repo.web.scripts; + +import org.springframework.extensions.webscripts.ScriptProcessor; +import org.springframework.extensions.webscripts.ScriptProcessorFactory; + +/** + * @author Kevin Roast + */ +public class RepositoryScriptProcessorFactory implements ScriptProcessorFactory +{ + private ScriptProcessor scriptProcessor; + + + /** + * @param scriptProcessor the ScriptProcessor to set + */ + public void setScriptProcessor(ScriptProcessor scriptProcessor) + { + this.scriptProcessor = scriptProcessor; + } + + /* (non-Javadoc) + * @see org.springframework.extensions.webscripts.ScriptProcessorFactory#newInstance() + */ + public ScriptProcessor newInstance() + { + return scriptProcessor; + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryServerModel.java b/source/java/org/alfresco/repo/web/scripts/RepositoryServerModel.java index d1884207ff..e4fcfb3d25 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryServerModel.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryServerModel.java @@ -25,7 +25,7 @@ package org.alfresco.repo.web.scripts; import org.alfresco.service.descriptor.Descriptor; -import org.alfresco.web.scripts.ServerModel; +import org.springframework.extensions.webscripts.ServerModel; /** diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java index 2a69086c8d..9ad4d350b2 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java @@ -33,10 +33,10 @@ import org.alfresco.processor.ProcessorExtension; import org.alfresco.repo.template.FreeMarkerProcessor; import org.alfresco.repo.template.QNameAwareObjectWrapper; import org.springframework.extensions.surf.util.AbstractLifecycleBean; -import org.alfresco.web.scripts.SearchPath; -import org.alfresco.web.scripts.Store; -import org.alfresco.web.scripts.TemplateProcessor; -import org.alfresco.web.scripts.WebScriptException; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.Store; +import org.springframework.extensions.webscripts.TemplateProcessor; +import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessorFactory.java b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessorFactory.java new file mode 100644 index 0000000000..48972c130d --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessorFactory.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.repo.web.scripts; + +import org.springframework.extensions.webscripts.TemplateProcessor; +import org.springframework.extensions.webscripts.TemplateProcessorFactory; + +/** + * @author Kevin Roast + */ +public class RepositoryTemplateProcessorFactory implements TemplateProcessorFactory +{ + private TemplateProcessor templateProcessor; + + + /** + * @param templateProcessor the TemplateProcessor to set + */ + public void setTemplateProcessor(TemplateProcessor templateProcessor) + { + this.templateProcessor = templateProcessor; + } + + /* (non-Javadoc) + * @see org.springframework.extensions.webscripts.TemplateProcessorFactory#newInstance() + */ + public TemplateProcessor newInstance() + { + return templateProcessor; + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java index a34d5e9ccc..c612d1ea29 100644 --- a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java +++ b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java @@ -35,7 +35,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.util.EqualsHelper; -import org.alfresco.web.scripts.TestWebScriptServer; +import org.springframework.extensions.webscripts.TestWebScriptServer; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/source/java/org/alfresco/repo/web/scripts/activities/TemplateWebScript.java b/source/java/org/alfresco/repo/web/scripts/activities/TemplateWebScript.java index e699d9674b..f56e75cf00 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/TemplateWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/TemplateWebScript.java @@ -32,10 +32,10 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.SearchPath; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/activities/TemplatesWebScript.java b/source/java/org/alfresco/repo/web/scripts/activities/TemplatesWebScript.java index 657f1a6309..69786cbb09 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/TemplatesWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/TemplatesWebScript.java @@ -30,12 +30,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.SearchPath; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.Store; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.Store; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Java-backed WebScript to get list of Activity Templates from a Template Store diff --git a/source/java/org/alfresco/repo/web/scripts/activities/feed/SiteFeedRetrieverWebScript.java b/source/java/org/alfresco/repo/web/scripts/activities/feed/SiteFeedRetrieverWebScript.java index f8315a650b..b90ca7613d 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/feed/SiteFeedRetrieverWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/feed/SiteFeedRetrieverWebScript.java @@ -34,9 +34,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.activities.ActivityService; import org.alfresco.util.JSONtoFmModel; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; diff --git a/source/java/org/alfresco/repo/web/scripts/activities/feed/UserFeedRetrieverWebScript.java b/source/java/org/alfresco/repo/web/scripts/activities/feed/UserFeedRetrieverWebScript.java index 2e10272f52..3688200024 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/feed/UserFeedRetrieverWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/feed/UserFeedRetrieverWebScript.java @@ -35,9 +35,9 @@ import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.activities.ActivityService; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.util.JSONtoFmModel; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; diff --git a/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java b/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java index 4bbf007a2c..0ca95fa626 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java @@ -31,10 +31,10 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/AVMRemoteStore.java b/source/java/org/alfresco/repo/web/scripts/bean/AVMRemoteStore.java index 865e9f2b26..6ca95ee27e 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/AVMRemoteStore.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/AVMRemoteStore.java @@ -43,9 +43,9 @@ import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java b/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java index fcf4e28454..ea8b8e6b0b 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java @@ -32,10 +32,10 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/source/java/org/alfresco/repo/web/scripts/bean/BaseRemoteStore.java b/source/java/org/alfresco/repo/web/scripts/bean/BaseRemoteStore.java index 688a3cce76..b2fedeab5f 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/BaseRemoteStore.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/BaseRemoteStore.java @@ -34,11 +34,11 @@ import javax.servlet.http.HttpServletRequest; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; -import org.alfresco.web.scripts.servlet.WebScriptServletRequest; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/KeywordSearch.java b/source/java/org/alfresco/repo/web/scripts/bean/KeywordSearch.java index f9c3a6ce66..1e1ec8c78f 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/KeywordSearch.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/KeywordSearch.java @@ -44,10 +44,10 @@ import org.alfresco.service.cmr.search.SearchService; import org.alfresco.util.GUID; import org.springframework.extensions.surf.util.ParameterCheck; import org.springframework.extensions.surf.util.URLEncoder; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.util.StringUtils; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/Login.java b/source/java/org/alfresco/repo/web/scripts/bean/Login.java index 678532d069..e69794589b 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/Login.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/Login.java @@ -31,10 +31,10 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java b/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java index 404f42bb94..0a0a5f282f 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java @@ -32,9 +32,9 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; import org.springframework.extensions.surf.util.Content; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/LoginTicket.java b/source/java/org/alfresco/repo/web/scripts/bean/LoginTicket.java index 458d62d289..9620d956f1 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/LoginTicket.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/LoginTicket.java @@ -32,10 +32,10 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.TicketComponent; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/source/java/org/alfresco/repo/web/scripts/bean/LoginTicketDelete.java b/source/java/org/alfresco/repo/web/scripts/bean/LoginTicketDelete.java index b9570ecd59..d3049e9412 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/LoginTicketDelete.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/LoginTicketDelete.java @@ -33,10 +33,10 @@ import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.TicketComponent; import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** diff --git a/source/java/org/alfresco/repo/web/scripts/bean/SearchEngines.java b/source/java/org/alfresco/repo/web/scripts/bean/SearchEngines.java index 943038aaec..d9dbe5ecad 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/SearchEngines.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/SearchEngines.java @@ -34,9 +34,9 @@ import org.springframework.extensions.config.ConfigService; import org.springframework.extensions.surf.util.I18NUtil; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/SearchProxy.java b/source/java/org/alfresco/repo/web/scripts/bean/SearchProxy.java index 3c9e83cfcd..301a29e3ad 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/SearchProxy.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/SearchProxy.java @@ -35,19 +35,11 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; -import org.springframework.extensions.config.Config; -import org.springframework.extensions.config.ConfigService; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement; import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.EngineConfig; import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.ProxyConfig; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.FormatRegistry; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; -import org.alfresco.web.scripts.servlet.HTTPProxy; -import org.alfresco.web.scripts.servlet.WebScriptServletRuntime; +import org.alfresco.web.app.servlet.HTTPProxy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Attribute; @@ -58,6 +50,14 @@ import org.dom4j.XPath; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; +import org.springframework.extensions.config.Config; +import org.springframework.extensions.config.ConfigService; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.FormatRegistry; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRuntime; import org.springframework.beans.factory.InitializingBean; diff --git a/source/java/org/alfresco/repo/web/scripts/bean/Touch.java b/source/java/org/alfresco/repo/web/scripts/bean/Touch.java index f415d79d66..4e0f73745e 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/Touch.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/Touch.java @@ -26,10 +26,10 @@ package org.alfresco.repo.web.scripts.bean; import java.io.IOException; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; /** * WebScript java backed bean implementation - to simple return a STATUS_OK message diff --git a/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java b/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java index 4795020b6f..1dc85c08b5 100644 --- a/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java @@ -39,11 +39,11 @@ import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java b/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java index e571e21311..a26ff20bbf 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java @@ -38,10 +38,10 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; /** diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java b/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java index f17b4b2390..b40996050a 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java @@ -36,9 +36,9 @@ import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java b/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java index e63f84344a..8a4fd0a86c 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java @@ -48,10 +48,10 @@ import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/content/StreamACP.java b/source/java/org/alfresco/repo/web/scripts/content/StreamACP.java index 345945ac8d..7068a6fe33 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/StreamACP.java +++ b/source/java/org/alfresco/repo/web/scripts/content/StreamACP.java @@ -41,10 +41,10 @@ import org.alfresco.service.cmr.view.ExporterService; import org.alfresco.service.cmr.view.Location; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; diff --git a/source/java/org/alfresco/repo/web/scripts/content/StreamContent.java b/source/java/org/alfresco/repo/web/scripts/content/StreamContent.java index 25b70ff1a5..9460507dc8 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/StreamContent.java +++ b/source/java/org/alfresco/repo/web/scripts/content/StreamContent.java @@ -48,19 +48,19 @@ import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.alfresco.util.TempFileProvider; -import org.alfresco.web.scripts.AbstractWebScript; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; -import org.alfresco.web.scripts.WebScriptResponse; -import org.alfresco.web.scripts.WebScriptStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.AbstractWebScript; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.ScriptProcessor; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.WebScriptStatus; import org.springframework.util.FileCopyUtils; import de.schlichtherle.io.FileOutputStream; @@ -155,7 +155,7 @@ public class StreamContent extends AbstractWebScript Map returnModel = new HashMap(8, 1.0f); scriptModel.put("model", returnModel); executeScript(executeScript.getContent(), scriptModel); - mergeScriptModelIntoTemplateModel(returnModel, model); + mergeScriptModelIntoTemplateModel(executeScript.getContent().getPath(), returnModel, model); } // is a redirect to a status specific template required? @@ -214,18 +214,28 @@ public class StreamContent extends AbstractWebScript /** * Merge script generated model into template-ready model - * + * + * @param scriptPath path to script * @param scriptModel script model * @param templateModel template model */ - final private void mergeScriptModelIntoTemplateModel(Map scriptModel, Map templateModel) + final private void mergeScriptModelIntoTemplateModel(String scriptPath, Map scriptModel, Map templateModel) { - for (Map.Entry entry : scriptModel.entrySet()) + int i = scriptPath.lastIndexOf("."); + if (i != -1) { - // retrieve script model value - Object value = entry.getValue(); - Object templateValue = getContainer().getScriptProcessor().unwrapValue(value); - templateModel.put(entry.getKey(), templateValue); + String extension = scriptPath.substring(i+1); + ScriptProcessor processor = getContainer().getScriptProcessorRegistry().getScriptProcessorByExtension(extension); + if (processor != null) + { + for (Map.Entry entry : scriptModel.entrySet()) + { + // retrieve script model value + Object value = entry.getValue(); + Object templateValue = processor.unwrapValue(value); + templateModel.put(entry.getKey(), templateValue); + } + } } } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryHelper.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryHelper.java index 397fa173b9..0c95833b41 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryHelper.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryHelper.java @@ -25,8 +25,8 @@ package org.alfresco.repo.web.scripts.dictionary; import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.InvalidQNameException; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryServiceTest.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryServiceTest.java index 53e674c386..bb288abfad 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryServiceTest.java @@ -25,8 +25,8 @@ package org.alfresco.repo.web.scripts.dictionary; import org.alfresco.repo.web.scripts.BaseWebScriptTest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import java.util.HashMap; import java.util.Map; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDef.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDef.java index 66ea35d397..76ea01ebca 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDef.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDef.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDefs.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDefs.java index 20abdd8ffe..dbcf73443d 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDefs.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetAssociationDefs.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.AssociationDefinition; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetail.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetail.java index e0c6bc61a7..083a1688bf 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetail.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetail.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.ClassDefinition; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetails.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetails.java index 37cf31ff8b..626b266da2 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetails.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetClassDetails.java @@ -24,10 +24,10 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDef.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDef.java index 32748dcc89..75cfadfee4 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDef.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDef.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDefs.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDefs.java index 8bd14eee69..728811eefd 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDefs.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetPropertyDefs.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/GetSubClassesDef.java b/source/java/org/alfresco/repo/web/scripts/dictionary/GetSubClassesDef.java index 0a3ffa8230..2ad67c3edd 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/GetSubClassesDef.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/GetSubClassesDef.java @@ -24,11 +24,11 @@ */ package org.alfresco.repo.web.scripts.dictionary; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.alfresco.service.namespace.QName; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.ClassDefinition; diff --git a/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java b/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java index 90e907e5ba..a7c2ddf057 100644 --- a/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java @@ -37,11 +37,11 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIRuntime.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIRuntime.java new file mode 100644 index 0000000000..2b0265dfe6 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIRuntime.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.extensions.config.ServerProperties; +import org.springframework.extensions.webscripts.Match; +import org.springframework.extensions.webscripts.RuntimeContainer; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRuntime; + + +/** + * Runtime to support requests from Facebook + * + * @author davidc + */ +public class FacebookAPIRuntime extends WebScriptServletRuntime +{ + + /** + * Construct + * + * @param container + * @param authFactory + * @param req + * @param res + * @param serverProperties + */ + public FacebookAPIRuntime(RuntimeContainer container, ServletAuthenticatorFactory authFactory, HttpServletRequest req, HttpServletResponse res, ServerProperties serverProperties) + { + super(container, authFactory, req, res, serverProperties); + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.servlet.WebScriptServletRuntime#createRequest(org.alfresco.web.scripts.Match) + */ + @Override + protected WebScriptRequest createRequest(Match match) + { + servletReq = new FacebookServletRequest(this, req, match, serverProperties, getScriptUrl()); + return servletReq; + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.servlet.WebScriptServletRuntime#getScriptParameters() + */ + @Override + public Map getScriptParameters() + { + Map model = new HashMap(); + model.putAll(super.getScriptParameters()); + model.put("facebook", new FacebookModel((FacebookServletRequest)servletReq)); + return model; + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.AbstractRuntime#getTemplateParameters() + */ + @Override + public Map getTemplateParameters() + { + Map model = new HashMap(); + model.putAll(super.getTemplateParameters()); + model.put("facebook", new FacebookModel((FacebookServletRequest)servletReq)); + return model; + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIServlet.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIServlet.java new file mode 100644 index 0000000000..4978739954 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAPIServlet.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.servlet.WebScriptServlet; + + +/** + * Web Script API entry point (with Facebook authentication) + * + * @author davidc + */ +public class FacebookAPIServlet extends WebScriptServlet +{ + private static final long serialVersionUID = 4209892938069597860L; + + // Logger + private static final Log logger = LogFactory.getLog(FacebookAPIServlet.class); + + + /* (non-Javadoc) + * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) + */ + @Override + protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException + { + if (logger.isDebugEnabled()) + logger.debug("Processing facebook api request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); + + FacebookAPIRuntime runtime = new FacebookAPIRuntime(container, authenticatorFactory, req, res, serverProperties); + runtime.executeScript(); + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAppModel.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAppModel.java new file mode 100644 index 0000000000..e52c5dd0e3 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAppModel.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + + +/** + * Facebook Application + * + * @author davidc + */ +public class FacebookAppModel +{ + String appId; + String apiKey; + String secretKey; + + /** + * Construct + * + * @param apiKey + */ + public FacebookAppModel(String apiKey) + { + this.apiKey = apiKey; + } + + /** + * @return application apiKey + */ + public String getApiKey() + { + return apiKey; + } + + /** + * @return application secret + */ + public String getSecret() + { + return secretKey; + } + + /** + * @param secretKey application secret + */ + public void setSecret(String secretKey) + { + this.secretKey = secretKey; + } + + /** + * @return application id + */ + public String getId() + { + return appId; + } + + /** + * @param appId application id + */ + public void setId(String appId) + { + this.appId = appId; + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAuthenticatorFactory.java index 30f509d9cd..43318a6c37 100644 --- a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAuthenticatorFactory.java +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookAuthenticatorFactory.java @@ -27,15 +27,14 @@ package org.alfresco.repo.web.scripts.facebook; import java.io.IOException; import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.web.scripts.Authenticator; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.Description.RequiredAuthentication; -import org.alfresco.web.scripts.facebook.FacebookServletRequest; -import org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory; -import org.alfresco.web.scripts.servlet.WebScriptServletRequest; -import org.alfresco.web.scripts.servlet.WebScriptServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Authenticator; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.Description.RequiredAuthentication; +import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; +import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse; /** * Web Script Authenticator that supports Facebook authentication diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookError.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookError.java new file mode 100644 index 0000000000..cfcfa38691 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookError.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +/** + * Facebook Error. + * + * @author David Caruana + */ +public class FacebookError extends RuntimeException +{ + private static final long serialVersionUID = -7338963365877285084L; + + private int code = -1; + + public FacebookError(String msg) + { + super(msg); + } + + public FacebookError(int code, String msg) + { + super(msg); + this.code = code; + } + + public int getCode() + { + return code; + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookModel.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookModel.java new file mode 100644 index 0000000000..704da6b3a6 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookModel.java @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; + +import com.facebook.api.FacebookException; +import com.facebook.api.FacebookRestClient; + + +/** + * Facebook Javascript API + * + * @author davidc + */ +public class FacebookModel +{ + // Logger + private static final Log logger = LogFactory.getLog(FacebookModel.class); + + private FacebookServletRequest req; + private FacebookRestClient client; + private String[] friends; + private String[] appFriends; + + + /** + * Construct + * + * @param req + */ + public FacebookModel(FacebookServletRequest req) + { + this.req = req; + } + + /** + * @return the facebook rest client + */ + private FacebookRestClient getClient() + { + if (client == null) + { + String apiKey = req.getApiKey(); + String secretKey = req.getSecretKey(); + String sessionKey = req.getSessionKey(); + if (sessionKey == null) + { + client = new FacebookRestClient(apiKey, secretKey); + } + else + { + client = new FacebookRestClient(apiKey, secretKey, sessionKey); + } + + if (logger.isDebugEnabled()) + client.setDebug(true); + } + return client; + } + + /** + * @return all friends of the logged in facebook user + */ + public String[] getFriends() + { + if (friends == null) + { + friends = req.getFriends(); + if (friends == null) + { + try + { + Document response = getClient().friends_get(); + NodeList uids = response.getElementsByTagName("uid"); + String[] uidsArray = new String[uids.getLength()]; + for (int i = 0; i < uids.getLength(); i++) + { + uidsArray[i] = uids.item(i).getTextContent(); + } + friends = uidsArray; + } + catch(FacebookException e) + { + throw new FacebookError(e.getCode(), e.getMessage()); + } + catch(IOException e) + { + throw new FacebookError(e.getMessage()); + } + } + } + return friends; + } + + /** + * @return friends who are users of the current application + */ + public String[] getAppFriends() + { + if (appFriends == null) + { + try + { + Document response = getClient().friends_getAppUsers(); + NodeList uids = response.getElementsByTagName("uid"); + String[] uidsArray = new String[uids.getLength()]; + for (int i = 0; i < uids.getLength(); i++) + { + uidsArray[i] = uids.item(i).getTextContent(); + } + appFriends = uidsArray; + } + catch(FacebookException e) + { + throw new FacebookError(e.getCode(), e.getMessage()); + } + catch(IOException e) + { + throw new FacebookError(e.getMessage()); + } + } + return appFriends; + } + + /** + * Post User Action + * + * For details see: + * http://wiki.developers.facebook.com/index.php/Feed.publishActionOfUser + * + * @param title + * @param body + * @return + */ + public int postUserAction(String title, String body) + { + try + { + Document response = getClient().feed_publishActionOfUser(title, body); + int status = Integer.parseInt(response.getDocumentElement().getTextContent()); + return status; + } + catch (FacebookException e) + { + if (logger.isErrorEnabled()) + logger.error("Failed to post user action [title=" + title + ", body=" + body + "] due to " + e.toString()); + throw new FacebookError(e.getCode(), e.getMessage()); + } + catch (IOException e) + { + if (logger.isErrorEnabled()) + logger.error("Failed to post user action [title=" + title + ", body=" + body + "] due to " + e.toString()); + throw new FacebookError(e.getMessage()); + } + } + + /** + * @return user id of logged in facebook user + */ + public String getUser() + { + return req.getUserId(); + } + + /** + * @return application id of current application + */ + public String getAppId() + { + return req.getAppId(); + } + + /** + * @return session key of current facebook session + */ + public String getSessionKey() + { + return req.getSessionKey(); + } + + /** + * @return application api key + */ + public String getApiKey() + { + return req.getApiKey(); + } + + /** + * @return application secret key + */ + public String getSecret() + { + return req.getSecretKey(); + } + + /** + * @return facebook canvas path (as entered into 'Create Application' dialog) + */ + public String getCanvasPath() + { + return req.getCanvasPath(); + } + + /** + * @return facebook canvas url (http://apps.facebook.com/canvasPath) + */ + public String getCanvasURL() + { + return "http://apps.facebook.com/" + getCanvasPath(); + } + + /** + * @return facebook page url (http://apps.facebook.com/canvasPath/page) + */ + public String getPageURL() + { + return "http://apps.facebook.com" + req.getPagePath(); + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookService.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookService.java new file mode 100644 index 0000000000..a0ef5dfb74 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookService.java @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.webscripts.Container; +import org.springframework.extensions.webscripts.ScriptContent; +import org.springframework.extensions.webscripts.ScriptProcessor; +import org.springframework.extensions.webscripts.WebScriptException; + + +/** + * Facebook Service + * + * @author davidc + */ +public class FacebookService +{ + // Logger + private static final Log logger = LogFactory.getLog(FacebookService.class); + + // Facebook Application Cache + private Map apps = new HashMap(); + private ReentrantReadWriteLock appsLock = new ReentrantReadWriteLock(); + + // Component dependencies + private Container container; + + + /** + * @param registry Web Script Registry + */ + public void setContainer(Container container) + { + this.container = container; + } + + /** + * Gets the application model for the given application api key + * + * @param apiKey api key + * @return application model + */ + FacebookAppModel getAppModel(String apiKey) + { + FacebookAppModel facebookApp = null; + appsLock.readLock().lock(); + + try + { + facebookApp = apps.get(apiKey); + if (facebookApp == null) + { + // Upgrade read lock to write lock + appsLock.readLock().unlock(); + appsLock.writeLock().lock(); + + try + { + // Check again + facebookApp = apps.get(apiKey); + if (facebookApp == null) + { + if (logger.isDebugEnabled()) + logger.debug("Initialising Facebook Application '" + apiKey + "'"); + + // Locate app initialisation script in web script store + String appPath = "com/facebook/_apps/app." + apiKey + ".js"; + String validScriptPath = container.getScriptProcessorRegistry().findValidScriptPath(appPath); + if (validScriptPath == null) + { + throw new WebScriptException("Unable to locate application initialisation script '" + appPath + "'"); + } + ScriptProcessor scriptProcessor = container.getScriptProcessorRegistry().getScriptProcessor(validScriptPath); + ScriptContent appScript = scriptProcessor.findScript(validScriptPath); + if (appScript == null) + { + throw new WebScriptException("Unable to locate application initialisation script '" + appPath + "'"); + } + + // Execute app initialisation script + Map model = new HashMap(); + FacebookAppModel app = new FacebookAppModel(apiKey); + model.put("app", app); + scriptProcessor.executeScript(appScript, model); + + // Validate initialisation + if (app.getSecret() == null) + { + throw new WebScriptException("Secret key for application '" + apiKey + "' has not been specified."); + } + if (app.getApiKey() == null) + { + throw new WebScriptException("Application Id for application '" + apiKey + "' has not been specified."); + } + + apps.put(apiKey, app); + facebookApp = app; + } + } + finally + { + // Downgrade lock to read + appsLock.readLock().lock(); + appsLock.writeLock().unlock(); + } + } + return facebookApp; + } + finally + { + appsLock.readLock().unlock(); + } + } + + /** + * Gets currently known Facebook Applications + * + * @return map (name, application) of known applications + */ + public Map getAppModels() + { + return apps; + } + + /** + * Reset Facebook Service + */ + public void reset() + { + appsLock.writeLock().lock(); + try + { + apps.clear(); + } + finally + { + appsLock.writeLock().unlock(); + } + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServlet.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServlet.java new file mode 100644 index 0000000000..082856d862 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServlet.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.context.ApplicationContext; + + +/** + * Facebook Canvas Page Requests + * + * @author davidc + */ +public class FacebookServlet extends FacebookAPIServlet +{ + private static final long serialVersionUID = 2276870692940598426L; + + // Logger + private static final Log logger = LogFactory.getLog(FacebookServlet.class); + + // Component Dependencies + protected FacebookService facebookService; + + + /* (non-Javadoc) + * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException + { + if (logger.isDebugEnabled()) + logger.debug("Processing facebook canvas (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); + + FacebookServletRuntime runtime = new FacebookServletRuntime(container, authenticatorFactory, req, res, serverProperties, facebookService); + runtime.executeScript(); + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.WebScriptServlet#initServlet(org.springframework.context.ApplicationContext) + */ + @Override + protected void initServlet(ApplicationContext context) + { + facebookService = (FacebookService)context.getBean("facebook.service"); + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRequest.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRequest.java new file mode 100644 index 0000000000..2f8a88d185 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRequest.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.extensions.config.ServerProperties; +import org.springframework.extensions.webscripts.Match; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; +import org.springframework.extensions.webscripts.Runtime; + +/** + * Facebook Servlet Request + * + * @author davidc + */ +@SuppressWarnings("deprecation") +public class FacebookServletRequest extends WebScriptServletRequest +{ + private String appId; + private String secretKey; + private String pathInfo; + + + /** + * Construct + * + * @param serverConfig + * @param req + * @param serviceMatch + */ + public FacebookServletRequest(Runtime container, HttpServletRequest req, Match serviceMatch, ServerProperties serverProperties, String pathInfo) + { + super(container, req, serviceMatch, serverProperties); + this.pathInfo = pathInfo; + } + + + /** + * @param secretKey application secret + */ + /*package*/ void setSecretKey(String secretKey) + { + this.secretKey = secretKey; + } + + /** + * @param appId application id + */ + /*package*/ void setAppId(String appId) + { + this.appId = appId; + } + + /** + * @return application api key + */ + public String getApiKey() + { + return getParameter("fb_sig_api_key"); + } + + /** + * @return Facebook user id + */ + public String getUserId() + { + return getParameter("fb_sig_user"); + } + + /** + * @return session key + */ + public String getSessionKey() + { + return getParameter("fb_sig_session_key"); + } + + /** + * @return true => within Facebook canvas + */ + public boolean isInCanvas() + { + String canvas = getParameter("fb_sig_api_key"); + return (canvas == null || canvas.equals("1")); + } + + /** + * @return application secret + */ + public String getSecretKey() + { + return secretKey; + } + + /** + * @return application id + */ + public String getAppId() + { + return appId; + } + + /** + * @return application canvas path + */ + public String getCanvasPath() + { + String pathInfo = getPathInfo(); + String[] pathSegments = pathInfo.split("/"); + if (pathSegments.length < 3) + { + throw new WebScriptException("Cannot establish Facebook Canvas Page URL from request " + getURL()); + } + return pathSegments[2]; + } + + /** + * @return application page path + */ + public String getPagePath() + { + String pagePath = getPathInfo(); + if (pagePath.startsWith("/facebook")) + { + pagePath = pathInfo.substring("/facebook".length()); + } + return pagePath; + } + + /** + * @return friends of authenticated Facebook user + */ + public String[] getFriends() + { + String[] friends; + String friendsStr = getParameter("fb_sig_friends"); + friends = (friendsStr == null) ? new String[0] : friendsStr.split(","); + return friends; + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.servlet.WebScriptServletRequest#getPathInfo() + */ + @Override + public String getPathInfo() + { + return pathInfo; + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRuntime.java b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRuntime.java new file mode 100644 index 0000000000..c88533637b --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/facebook/FacebookServletRuntime.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.facebook; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.config.ServerProperties; +import org.springframework.extensions.webscripts.Match; +import org.springframework.extensions.webscripts.RuntimeContainer; +import org.springframework.extensions.webscripts.StatusTemplate; +import org.springframework.extensions.webscripts.WebScriptRequest; +import org.springframework.extensions.webscripts.WebScriptResponse; +import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory; + + +/** + * Facebook Canvas Page Servlet. + * + * @author davidc + */ +public class FacebookServletRuntime extends FacebookAPIRuntime +{ + // Logger + private static final Log logger = LogFactory.getLog(FacebookServletRuntime.class); + + // Component dependencies + protected FacebookService facebookService; + + + /** + * Construct + * + * @param container + * @param authFactory + * @param req + * @param res + * @param serverProperties + * @param facebookService + */ + public FacebookServletRuntime(RuntimeContainer container, ServletAuthenticatorFactory authFactory, HttpServletRequest req, HttpServletResponse res, + ServerProperties serverProperties, FacebookService facebookService) + { + super(container, authFactory, req, res, serverProperties); + this.facebookService = facebookService; + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.WebScriptRuntime#createRequest(org.alfresco.web.scripts.WebScriptMatch) + */ + @Override + protected WebScriptRequest createRequest(Match match) + { + FacebookServletRequest fbreq = new FacebookServletRequest(this, req, match, serverProperties, getScriptUrl()); + + if (match != null) + { + FacebookAppModel appModel = facebookService.getAppModel(fbreq.getApiKey()); + fbreq.setSecretKey(appModel.getSecret()); + fbreq.setAppId(appModel.getId()); + } + + if (logger.isDebugEnabled()) + logger.debug("Facebook request [apiKey=" + fbreq.getApiKey() + ", user=" + fbreq.getUserId() + ", session=" + fbreq.getSessionKey() + ", secret=" + fbreq.getSecretKey() + "]"); + + servletReq = fbreq; + return servletReq; + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.WebScriptServletRuntime#getScriptUrl() + */ + @Override + protected String getScriptUrl() + { + return "/facebook" + super.getScriptUrl(); + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.WebScriptRuntime#getStatusCodeTemplate(int) + */ + @Override + protected StatusTemplate getStatusCodeTemplate(int statusCode) + { + return new StatusTemplate("/fbml." + statusCode + ".ftl", WebScriptResponse.HTML_FORMAT); + } + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.WebScriptRuntime#getStatusTemplate() + */ + @Override + protected StatusTemplate getStatusTemplate() + { + return new StatusTemplate("/fbml.status.ftl", WebScriptResponse.HTML_FORMAT); + } + +} diff --git a/source/java/org/alfresco/repo/web/scripts/forms/AbstractTestFormRestApi.java b/source/java/org/alfresco/repo/web/scripts/forms/AbstractTestFormRestApi.java index 73d5526030..09e7ce5887 100644 --- a/source/java/org/alfresco/repo/web/scripts/forms/AbstractTestFormRestApi.java +++ b/source/java/org/alfresco/repo/web/scripts/forms/AbstractTestFormRestApi.java @@ -44,8 +44,8 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; public abstract class AbstractTestFormRestApi extends BaseWebScriptTest { diff --git a/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiGet_Test.java b/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiGet_Test.java index ccd051441b..5e261194f2 100644 --- a/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiGet_Test.java +++ b/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiGet_Test.java @@ -30,9 +30,9 @@ import java.util.List; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; -import org.alfresco.web.scripts.json.JSONUtils; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.json.JSONUtils; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener; diff --git a/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiJsonPost_Test.java b/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiJsonPost_Test.java index 19d524d69c..c38531a6e6 100644 --- a/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiJsonPost_Test.java +++ b/source/java/org/alfresco/repo/web/scripts/forms/FormRestApiJsonPost_Test.java @@ -36,8 +36,8 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java b/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java index b26020ad94..fa43c91ace 100644 --- a/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java +++ b/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java @@ -37,12 +37,12 @@ import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONArray; diff --git a/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java b/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java index 0c3dfe85ea..144d4b6fb0 100644 --- a/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java +++ b/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java @@ -47,12 +47,12 @@ import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/invite/Invite.java b/source/java/org/alfresco/repo/web/scripts/invite/Invite.java index 33e2f5dcc8..c3de1dd935 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/Invite.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/Invite.java @@ -61,11 +61,11 @@ import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; -import org.alfresco.web.scripts.Cache; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/invite/InviteByTicket.java b/source/java/org/alfresco/repo/web/scripts/invite/InviteByTicket.java index 918782504f..75571210cd 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/InviteByTicket.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/InviteByTicket.java @@ -43,10 +43,10 @@ import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script which returns invite information given an inviteId and inviteTicket. diff --git a/source/java/org/alfresco/repo/web/scripts/invite/InviteResponse.java b/source/java/org/alfresco/repo/web/scripts/invite/InviteResponse.java index c3d8a230fe..28118f73fe 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/InviteResponse.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/InviteResponse.java @@ -37,10 +37,10 @@ import org.alfresco.service.cmr.invitation.InvitationExceptionUserError; import org.alfresco.service.cmr.invitation.InvitationService; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script invoked by Invitee to either accept (response='accept') an diff --git a/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java b/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java index 9c4b0dc433..69b58018bb 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java @@ -57,10 +57,10 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.springframework.extensions.surf.util.URLEncoder; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.apache.commons.lang.RandomStringUtils; import org.json.JSONObject; import org.springframework.core.io.ClassPathResource; diff --git a/source/java/org/alfresco/repo/web/scripts/invite/Invites.java b/source/java/org/alfresco/repo/web/scripts/invite/Invites.java index 3019d38386..a85d27dd9a 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/Invites.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/Invites.java @@ -49,10 +49,10 @@ import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskQuery; import org.alfresco.service.cmr.workflow.WorkflowTaskState; import org.alfresco.service.namespace.QName; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script which returns pending Site invitations matching at least one of diff --git a/source/java/org/alfresco/repo/web/scripts/person/ChangePasswordPost.java b/source/java/org/alfresco/repo/web/scripts/person/ChangePasswordPost.java index 0f7c9125e6..5b43983115 100644 --- a/source/java/org/alfresco/repo/web/scripts/person/ChangePasswordPost.java +++ b/source/java/org/alfresco/repo/web/scripts/person/ChangePasswordPost.java @@ -32,10 +32,10 @@ import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthorityService; import org.springframework.extensions.surf.util.Content; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/person/PersonServiceTest.java b/source/java/org/alfresco/repo/web/scripts/person/PersonServiceTest.java index 9cc349b420..64fa51dd6c 100644 --- a/source/java/org/alfresco/repo/web/scripts/person/PersonServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/person/PersonServiceTest.java @@ -33,12 +33,12 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.apache.commons.lang.RandomStringUtils; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java index 0ecd518a18..0edd10079f 100644 --- a/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java +++ b/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java @@ -33,11 +33,11 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.web.scripts.Authenticator; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.Description.RequiredAuthentication; -import org.alfresco.web.scripts.portlet.PortletAuthenticatorFactory; -import org.alfresco.web.scripts.portlet.WebScriptPortletRequest; +import org.springframework.extensions.webscripts.Authenticator; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.Description.RequiredAuthentication; +import org.springframework.extensions.webscripts.portlet.PortletAuthenticatorFactory; +import org.springframework.extensions.webscripts.portlet.WebScriptPortletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java b/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java index 7ef0310980..e158806ba4 100644 --- a/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java @@ -31,10 +31,10 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java index 6c66f92aaa..b16731311d 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefGet.java @@ -29,10 +29,10 @@ import java.util.Map; import org.alfresco.service.cmr.action.ActionDefinition; import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET an action definition given its name diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ActionDefsGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefsGet.java index 79812ce312..9b2c8c672a 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/ActionDefsGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/ActionDefsGet.java @@ -31,9 +31,9 @@ import java.util.Map; import org.alfresco.service.cmr.action.ActionDefinition; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET the action definition collection diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ActionQueuePost.java b/source/java/org/alfresco/repo/web/scripts/rule/ActionQueuePost.java index 16df3d7c76..9d31aa7d70 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/ActionQueuePost.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/ActionQueuePost.java @@ -30,10 +30,10 @@ import java.util.Map; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java index e57e8da2e2..16f73bb321 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefGet.java @@ -29,10 +29,10 @@ import java.util.Map; import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET a condition definition given its name diff --git a/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefsGet.java b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefsGet.java index 21331bd689..7b43cb6217 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefsGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/ConditionDefsGet.java @@ -30,9 +30,9 @@ import java.util.Map; import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET the condition definition collection diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java b/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java index 8e54d320f4..a488c908c8 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RuleDelete.java @@ -29,10 +29,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to DELETE the rule identified by the given rule node id. diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RuleGet.java b/source/java/org/alfresco/repo/web/scripts/rule/RuleGet.java index 8b58dbec77..cebbb91b93 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RuleGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RuleGet.java @@ -30,10 +30,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET the rule identified by the given rule node reference. diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java b/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java index b9ed81d24f..b0b7faa108 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java @@ -30,10 +30,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONObject; /** diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java b/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java index 028d670aa2..999c63f793 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java @@ -46,12 +46,12 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java b/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java index 7cf3e6d4dc..5302c63559 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulesDelete.java @@ -28,10 +28,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to DELETE the rule collection associated with the given rule owning node. diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulesGet.java b/source/java/org/alfresco/repo/web/scripts/rule/RulesGet.java index f347e12fe7..43eb7098b8 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulesGet.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulesGet.java @@ -31,10 +31,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Web Script to GET the rule collection associated with the given rule owning node. diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulesHelper.java b/source/java/org/alfresco/repo/web/scripts/rule/RulesHelper.java index 4967cce28f..3b598e83e8 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulesHelper.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulesHelper.java @@ -48,9 +48,9 @@ import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleType; import org.alfresco.service.namespace.QName; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulesPost.java b/source/java/org/alfresco/repo/web/scripts/rule/RulesPost.java index f2b243dac4..4d5bf6720f 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulesPost.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulesPost.java @@ -30,10 +30,10 @@ import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.web.scripts.DeclarativeWebScript; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.WebScriptRequest; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; import org.json.JSONObject; /** diff --git a/source/java/org/alfresco/repo/web/scripts/search/PersonSearchTest.java b/source/java/org/alfresco/repo/web/scripts/search/PersonSearchTest.java index 8491536c6c..fd69672e2b 100644 --- a/source/java/org/alfresco/repo/web/scripts/search/PersonSearchTest.java +++ b/source/java/org/alfresco/repo/web/scripts/search/PersonSearchTest.java @@ -32,9 +32,9 @@ import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * Unit test for PersonSearch Web Script. diff --git a/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java index cdaf09eb93..ce3286c7c5 100644 --- a/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java +++ b/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java @@ -30,12 +30,12 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.service.cmr.security.AuthenticationService; import org.springframework.extensions.surf.util.Base64; -import org.alfresco.web.scripts.Authenticator; -import org.alfresco.web.scripts.WebScriptException; -import org.alfresco.web.scripts.Description.RequiredAuthentication; -import org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory; -import org.alfresco.web.scripts.servlet.WebScriptServletRequest; -import org.alfresco.web.scripts.servlet.WebScriptServletResponse; +import org.springframework.extensions.webscripts.Authenticator; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.Description.RequiredAuthentication; +import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; +import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java index ecab6b43a4..f48631ad66 100644 --- a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java @@ -49,12 +49,12 @@ import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java b/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java index b11fa00084..18938207c0 100644 --- a/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java @@ -38,8 +38,8 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.tagging.TaggingService; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONArray; /** diff --git a/source/java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java b/source/java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java index a6a75b5827..93d0c1fbf4 100644 --- a/source/java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java @@ -38,9 +38,9 @@ import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.util.GUID; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java index 8cccb8357e..503825b9e0 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java @@ -34,12 +34,12 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java index dd36a1d59d..567313213c 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java @@ -34,11 +34,11 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java index 2dc6643a96..a2dc1a6da1 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java @@ -36,14 +36,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; import org.json.JSONArray; import org.json.JSONObject; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +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; /** * Junit tests of the REST bindings for WCM Assets diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java index 053db98f64..397cf2ab0d 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java @@ -37,11 +37,11 @@ import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.springframework.extensions.surf.util.ISO8601DateFormat; import org.alfresco.util.PropertyMap; -import org.alfresco.web.scripts.Status; -import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; -import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; -import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; -import org.alfresco.web.scripts.TestWebScriptServer.Response; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; import org.json.JSONArray; import org.json.JSONObject; diff --git a/source/java/org/alfresco/web/app/servlet/HTTPProxy.java b/source/java/org/alfresco/web/app/servlet/HTTPProxy.java new file mode 100644 index 0000000000..9842d86441 --- /dev/null +++ b/source/java/org/alfresco/web/app/servlet/HTTPProxy.java @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.web.app.servlet; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +import javax.servlet.http.HttpServletResponse; + + +/** + * Simple server-side HTTP Request / Response + * + * @author davidc + */ +public class HTTPProxy +{ + protected URL url; + protected HttpServletResponse response; + + + /** + * Construct + * + * @param requestUrl url to request + * @param response response to write request back to + * @throws MalformedURLException + */ + public HTTPProxy(String requestUrl, HttpServletResponse response) + throws MalformedURLException + { + this.url = new URL(requestUrl); + this.response = response; + } + + /** + * Perform request + * + * @throws IOException + */ + public void service() + throws IOException + { + HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + initialiseResponse(connection); + InputStream input = connection.getInputStream(); + OutputStream output = response.getOutputStream(); + try + { + writeResponse(input, output); + } + finally + { + try + { + if (input != null) + { + input.close(); + } + if (output != null) + { + output.flush(); + output.close(); + } + // TODO: required? + connection.disconnect(); + } + catch(IOException e) + { + // TODO: log io exceptions? + } + } + } + + /** + * Initialise response + * + * @param urlConnection url connection + */ + protected void initialiseResponse(URLConnection urlConnection) + { + String type = urlConnection.getContentType(); + if (type != null) + { + int encodingIdx = type.lastIndexOf("charset="); + if (encodingIdx == -1) + { + String encoding = urlConnection.getContentEncoding(); + if (encoding != null && encoding.length() > 0) + { + type += ";charset=" + encoding; + } + } + + response.setContentType(type); + } + } + + /** + * Write response + * + * @param input input stream of request + * @param output output stream of response + * @throws IOException + */ + protected void writeResponse(InputStream input, OutputStream output) + throws IOException + { + byte[] buffer = new byte[4096]; + int read = input.read(buffer); + while (read != -1) + { + output.write(buffer, 0, read); + read = input.read(buffer); + } + } +} diff --git a/source/java/org/alfresco/web/app/servlet/HTTPProxyServlet.java b/source/java/org/alfresco/web/app/servlet/HTTPProxyServlet.java new file mode 100644 index 0000000000..4986365190 --- /dev/null +++ b/source/java/org/alfresco/web/app/servlet/HTTPProxyServlet.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.web.app.servlet; + +import java.io.IOException; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.extensions.surf.util.URLEncoder; + + +/** + * HTTP Proxy Servlet + * + * Provides the ability to submit a URL request via the Alfresco Server i.e. + * the Alfresco server acts as a proxy. + * + * This servlet accepts: + * + * /proxy?endpoint=[&=]* + * + * Where: + * + * - endpointUrl is the URL to make a request against + * - argName is the name of a URL argument to append to the request + * - argValue is the value of URL argument + * + * E.g.: + * + * /proxy?endpoint=http://www.alfresco.com&arg1=value1&arg2=value2 + * + * @author davidc + */ +public class HTTPProxyServlet extends HttpServlet +{ + private static final long serialVersionUID = -576405943603122206L; + + private static final String PARAM_ENDPOINT = "endpoint"; + + + /** + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + protected void doGet(HttpServletRequest req, HttpServletResponse res) + throws ServletException, IOException + { + String endpoint = null; + StringBuilder args = new StringBuilder(32); + + Map parameters = req.getParameterMap(); + for (Map.Entry parameter : parameters.entrySet()) + { + String[] values = parameter.getValue(); + int startIdx = 0; + + if (parameter.getKey().equals(PARAM_ENDPOINT) && values.length != 0) + { + endpoint = values[0]; + startIdx++; + } + + for (int i = startIdx; i < values.length; i++) + { + if (args.length() != 0) + { + args.append("&"); + } + args.append(parameter.getKey()).append('=').append(URLEncoder.encode(values[i])); + } + } + + if (endpoint == null || endpoint.length() == 0) + { + throw new IllegalArgumentException("endpoint argument not specified"); + } + + String url = endpoint + ((args.length() == 0) ? "" : "?" + args.toString()); + HTTPProxy proxy = new HTTPProxy(url, res); + proxy.service(); + } + + /** + * Construct a "proxied" URL + * + * Note: the "proxied" URL is a relative url - it is assumed that the servlet path is /proxy + * + * @param url the URL to proxy + * @return the "proxied" url + */ + public static String createProxyUrl(String url) + { + String proxy = "/proxy"; + if (url != null && url.length() > 0) + { + int argIndex = url.lastIndexOf("?"); + if (argIndex == -1) + { + proxy += "?endpoint=" + url; + } + else + { + proxy += "?endpoint=" + url.substring(0, argIndex) + "&" + url.substring(argIndex + 1); + } + } + + return proxy; + } +}