mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126434 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 121906 jvonka: Nodes (File/Folder) API - hopefully fix CMIS test fallout (from noAuth changes) RA-750, RA-755 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126780 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -65,6 +65,12 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author steveglover
|
||||
* @author janv
|
||||
* @since PublicApi1.0
|
||||
*/
|
||||
public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
|
||||
{
|
||||
private WebScript getNetworksWebScript;
|
||||
@@ -99,36 +105,37 @@ public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
|
||||
*/
|
||||
public Match findWebScript(String method, String uri)
|
||||
{
|
||||
if(method.equalsIgnoreCase("get") && uri.equals(PublicApiTenantWebScriptServletRequest.NETWORKS_PATH))
|
||||
Match match = null;
|
||||
|
||||
HttpMethod httpMethod = HttpMethod.valueOf(method);
|
||||
if (httpMethod.equals(HttpMethod.GET))
|
||||
{
|
||||
if (uri.equals(PublicApiTenantWebScriptServletRequest.NETWORKS_PATH))
|
||||
{
|
||||
Map<String, String> templateVars = new HashMap<String, String>();
|
||||
templateVars.put("apiScope", "public");
|
||||
templateVars.put("apiVersion", "1");
|
||||
templateVars.put("apiName", "networks");
|
||||
Match match = new Match("", templateVars, "", getNetworksWebScript);
|
||||
return match;
|
||||
match = new Match("", templateVars, "", getNetworksWebScript);
|
||||
}
|
||||
else if(method.equalsIgnoreCase("get") && uri.equals(PublicApiTenantWebScriptServletRequest.NETWORK_PATH))
|
||||
else if (uri.equals(PublicApiTenantWebScriptServletRequest.NETWORK_PATH))
|
||||
{
|
||||
Map<String, String> templateVars = new HashMap<String, String>();
|
||||
templateVars.put("apiScope", "public");
|
||||
templateVars.put("apiVersion", "1");
|
||||
templateVars.put("apiName", "network");
|
||||
Match match = new Match("", templateVars, "", getNetworkWebScript);
|
||||
return match;
|
||||
match = new Match("", templateVars, "", getNetworkWebScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
Match match = super.findWebScript(method, uri);
|
||||
|
||||
HttpMethod httpMethod = HttpMethod.valueOf(method);
|
||||
|
||||
if (httpMethod.equals(HttpMethod.GET))
|
||||
{
|
||||
// TODO - review (experimental)
|
||||
match = super.findWebScript(method, uri);
|
||||
|
||||
// noAuth currently only exposed for GET
|
||||
Map<String, String> templateVars = match.getTemplateVars();
|
||||
|
||||
if (templateVars.get("apiName") != null)
|
||||
{
|
||||
// NOTE: noAuth currently only exposed for GET
|
||||
Api api = determineApi(templateVars);
|
||||
|
||||
// TODO can we avoid locating resource more than once ?
|
||||
@@ -162,7 +169,7 @@ public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
|
||||
{
|
||||
final WebScript webScript = match.getWebScript();
|
||||
|
||||
// hack ! - is there a better way (to dynamically override "requiredAuthentication") or handle noAuth check earlier ?
|
||||
// TODO is there a better way (to dynamically override "requiredAuthentication") or handle noAuth check earlier ?
|
||||
WebScript noAuthWebScriptWrapper = new WebScript()
|
||||
{
|
||||
@Override
|
||||
@@ -360,16 +367,21 @@ public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
|
||||
}
|
||||
};
|
||||
|
||||
// override match with noAuth
|
||||
match = new Match(match.getTemplate(), match.getTemplateVars(), match.getPath(), noAuthWebScriptWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
match = super.findWebScript(method, uri);
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
// note: same as ApiWebscript
|
||||
// note: same as ApiWebscript (apiName must not be null)
|
||||
private Api determineApi(Map<String, String> templateVars)
|
||||
{
|
||||
String apiScope = templateVars.get("apiScope");
|
||||
|
Reference in New Issue
Block a user