dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32783
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16702: add new method to contextService: getApiPath
------------------------------------------------------------
revno: 16702
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-12 16:14:40 +0700
message:
add new method to contextService: getApiPath
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/ContextService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultContextService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-09-11 06:03:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-09-12 09:14:40 +0000
@@ -338,7 +338,7 @@
if ( summary.getImportCount().getImported() == 1 && summary.getLastImported() != null )
{
- response.setHeader( "Location", contextService.getContextPath() + "/api" + getSchema().getApiEndpoint()
+ response.setHeader( "Location", contextService.getApiPath() + getSchema().getApiEndpoint()
+ "/" + summary.getLastImported() );
}
}
@@ -363,7 +363,7 @@
if ( summary.getImportCount().getImported() == 1 && summary.getLastImported() != null )
{
- response.setHeader( "Location", contextService.getContextPath() + "/api" + getSchema().getApiEndpoint()
+ response.setHeader( "Location", contextService.getApiPath() + getSchema().getApiEndpoint()
+ "/" + summary.getLastImported() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java 2014-08-26 10:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java 2014-09-12 09:14:40 +0000
@@ -102,7 +102,7 @@
complexNode.addChild( new SimpleNode( "displayName", beautify( schema.getPlural() ) ) );
complexNode.addChild( new SimpleNode( "singular", schema.getSingular() ) );
complexNode.addChild( new SimpleNode( "plural", schema.getPlural() ) );
- complexNode.addChild( new SimpleNode( "href", contextService.getContextPath() + "/api" + schema.getApiEndpoint() ) );
+ complexNode.addChild( new SimpleNode( "href", contextService.getApiPath() + schema.getApiEndpoint() ) );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/ContextService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/ContextService.java 2014-06-18 07:15:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/ContextService.java 2014-09-12 09:14:40 +0000
@@ -53,6 +53,14 @@
String getContextPath();
/**
+ * Get HREF to Web-API.
+ *
+ * @return Full HREF to Web-API
+ * @see javax.servlet.http.HttpServletRequest
+ */
+ String getApiPath();
+
+ /**
* Get active HttpServletRequest
*
* @return HttpServletRequest
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultContextService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultContextService.java 2014-06-18 07:15:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultContextService.java 2014-09-12 09:14:40 +0000
@@ -46,8 +46,7 @@
@Override
public String getServletPath()
{
- HttpServletRequest request = getRequest();
- return getContextPath() + request.getServletPath();
+ return getContextPath() + getRequest().getServletPath();
}
@Override
@@ -91,6 +90,12 @@
}
@Override
+ public String getApiPath()
+ {
+ return getContextPath() + "/api";
+ }
+
+ @Override
public HttpServletRequest getRequest()
{
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();