diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingRestOperationsImpl.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingRestOperationsImpl.java
index 32f7aa129..1db0834b2 100644
--- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingRestOperationsImpl.java
+++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingRestOperationsImpl.java
@@ -42,7 +42,7 @@ public class ReportingRestOperationsImpl implements ReportingRestOperations {
public void hackToForceAuthentication() {
try {
URI restUri = URI
- .create(getBaseServerUrl().concat("api/protected/reporting/forceauth"));
+ .create(getBaseServerUrl().concat("api/v1/flexiblereporting/forceauth"));
this.oauthRestServiceTemplate.exchange(restUri, HttpMethod.GET, emptyRequest(), null);
} catch (HttpStatusCodeException e) {
diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.95.js b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.96.js
similarity index 99%
rename from mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.95.js
rename to mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.96.js
index 807fa3881..1d8833f2b 100644
--- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.95.js
+++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchyreporting/stretchyreporting-0.96.js
@@ -1076,10 +1076,14 @@ function getReportDataNoAuth(inParams, successFunction) {
$.ajax({
url: RESTUrl,
type:'GET',
- dataType: 'jsonp',
+ dataType: 'json',
data: inQueryParameters,
contentType: "application/json; charset=utf-8",
- crossDomain: true,
+ crossDomain: false,
+ //cache: true,
+ beforeSend: function( xhr ) {
+ xhr.setRequestHeader("Accept", "application/json");
+ },
success: successFunction,
error:function(jqXHR, textStatus, errorThrown){
showMsgE("getReportDataNoAuth: ");
diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head-stretchyreporting.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head-stretchyreporting.jsp
index f5c828a2a..46cf2f03f 100644
--- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head-stretchyreporting.jsp
+++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head-stretchyreporting.jsp
@@ -16,6 +16,6 @@
-
+
diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/reports/flexireport.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/reports/flexireport.jsp
index 3816af560..9e7e14217 100644
--- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/reports/flexireport.jsp
+++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/reports/flexireport.jsp
@@ -91,7 +91,8 @@ function selectNewThousandsSep(selectedVal) {
var reportingParams = {
rptDB: "mifosngprovider",
- RESTUrl: "${baseUrl}api/protected/reporting/flexireport",
+ //old link RESTUrl: "${baseUrl}api/protected/reporting/flexireport",
+ RESTUrl: "${baseUrl}api/v1/flexiblereporting",
pentahoUrl: "${baseUrl}pentahoreport",
exportUrl: "${rootContext}/exportcsv",
bundleDir: "${resValue}/stretchyreporting/mifosngbundle/",
@@ -103,13 +104,13 @@ var reportingParams = {
indianFormat: false,
highlightMissingXlations: "N",
loadingImg: "${resValue}/stretchyreporting/dots64.gif",
- resValue: "${resValue}/stretchyreporting/",
+ resValue: "${resValue}/stretchyreporting/"
//OAuth 1.0a parameters
- apiKey: "${consumerKey}",
- sharedSecret: "${consumerSecret}",
- accessToken: "${accessToken}",
- tokenSecret: "${tokenSecret}"
+ //apiKey: "${consumerKey}",
+ //sharedSecret: "${consumerSecret}",
+ //accessToken: "${accessToken}",
+ //tokenSecret: "${tokenSecret}"
};
jQuery.stretchyReporting.initialise(reportingParams);
diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/ReadPlatformService.java
index c2659fd0e..83dcbf2f0 100644
--- a/mifosng-provider/src/main/java/org/mifosng/platform/ReadPlatformService.java
+++ b/mifosng-provider/src/main/java/org/mifosng/platform/ReadPlatformService.java
@@ -81,7 +81,7 @@ public interface ReadPlatformService {
Collection retrieveAllPermissions();
- @PreAuthorize(value = "hasAnyRole('REPORTING_SUPER_USER_ROLE')")
+ //@PreAuthorize(value = "hasAnyRole('REPORTING_SUPER_USER_ROLE')")
GenericResultset retrieveGenericResultset(String rptDB, String name,
String type, Map extractedQueryParams);
diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResource.java
index 4caaa697a..78639cb0f 100644
--- a/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResource.java
@@ -6,8 +6,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -16,6 +19,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
@@ -24,8 +28,8 @@ import org.mifosng.data.ErrorResponseList;
import org.mifosng.data.reports.GenericResultset;
import org.mifosng.platform.ReadPlatformService;
import org.mifosng.platform.exceptions.ApplicationDomainRuleException;
-import org.mifosng.platform.exceptions.NewDataValidationException;
import org.mifosng.platform.exceptions.UnAuthenticatedUserException;
+import org.mifosng.platform.exceptions.NewDataValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,11 +47,37 @@ public class FlexibleReportingApiResource {
@Autowired
private ReadPlatformService readPlatformService;
+ private String _corsHeaders;
+
+ private Response makeCORS(ResponseBuilder req, String returnMethod) {
+ ResponseBuilder rb = req
+ .header("Access-Control-Allow-Origin", "*")
+ .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
+
+ if (!"".equals(returnMethod)) {
+ rb.header("Access-Control-Allow-Headers", returnMethod);
+ }
+
+ return rb.build();
+ }
+
+ private Response makeCORS(ResponseBuilder req) {
+ return makeCORS(req, _corsHeaders);
+ }
+
+ // This OPTIONS request/response is necessary
+ // if you consumes other format than text/plain or
+ // if you use other HTTP verbs than GET and POST
+ @OPTIONS
+ public Response corsMyResource(@HeaderParam("Access-Control-Request-Headers") String requestH) {
+ _corsHeaders = requestH;
+ return makeCORS(Response.ok(), requestH);
+ }
+
@GET
- @Path("flexireport")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response retrieveReport(@Context UriInfo uriInfo) {
+ public Response retrieveReport(@Context UriInfo uriInfo, @Context HttpServletResponse httpServletResponse) {
MultivaluedMap queryParams = uriInfo.getQueryParameters();
String rptDB = queryParams.getFirst("MRP_rptDB");
@@ -75,7 +105,7 @@ public class FlexibleReportingApiResource {
// JSONWithPadding paddedResult = new JSONWithPadding(result,
// callbackName);
- return Response.ok().entity(result).build();
+ return makeCORS(Response.ok().entity(result));
}
@GET
@@ -114,4 +144,10 @@ public class FlexibleReportingApiResource {
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
}
}
+
+ @GET
+ @Path("forceauth")
+ public Response hackToForceAuthentication() {
+ return Response.ok().build();
+ }
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResourceOLD.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResourceOLD.java
new file mode 100644
index 000000000..1048d2057
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/FlexibleReportingApiResourceOLD.java
@@ -0,0 +1,107 @@
+package org.mifosng.platform.api;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.mifosng.data.ErrorResponse;
+import org.mifosng.data.ErrorResponseList;
+import org.mifosng.data.reports.GenericResultset;
+import org.mifosng.platform.ReadPlatformService;
+import org.mifosng.platform.exceptions.ApplicationDomainRuleException;
+import org.mifosng.platform.exceptions.NewDataValidationException;
+import org.mifosng.platform.exceptions.UnAuthenticatedUserException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.stereotype.Component;
+
+@Path("/v1/flexiblereportingxxx")
+@Component
+@Scope("singleton")
+public class FlexibleReportingApiResourceOLD {
+
+ private final static Logger logger = LoggerFactory.getLogger(FlexibleReportingApiResourceOLD.class);
+
+ @Autowired
+ private ReadPlatformService readPlatformService;
+
+ @GET
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces({ MediaType.APPLICATION_JSON})
+ public Response retrieveReport(@Context UriInfo uriInfo) {
+
+ MultivaluedMap queryParams = uriInfo.getQueryParameters();
+ String rptDB = queryParams.getFirst("MRP_rptDB");
+ String name = queryParams.getFirst("MRP_Name");
+ String type = queryParams.getFirst("MRP_Type");
+
+ Map extractedQueryParams = new HashMap();
+
+ Set keys = queryParams.keySet();
+ String pKey;
+ String pValue;
+ for (String k : keys) {
+
+ if (k.startsWith("MRP_"))
+ {
+ pKey = "${" + k.substring(4) + "}";
+ pValue = queryParams.get(k).get(0);
+
+ extractedQueryParams.put(pKey, pValue);
+ }
+ }
+ logger.info("BEGINNING REQUEST FOR: " + name);
+ GenericResultset result = this.readPlatformService.retrieveGenericResultset(rptDB, name, type, extractedQueryParams);
+
+// JSONWithPadding paddedResult = new JSONWithPadding(result,
+// callbackName);
+
+ return Response.ok().entity(result).build();
+ }
+ /*
+ @GET
+ @Path("/exportcsv/{reportDb}/{reportName}/{reportType}/office/{officeId}/currency/{currencyId}")
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response exportCsvReport(
+ @PathParam("reportDb") String rptDB,
+ @PathParam("reportName") String name,
+ @PathParam("reportType") String type,
+ @PathParam("officeId") Long officeId, @PathParam("currencyId") Long currencyId) throws IOException {
+
+ try {
+ Map extractedQueryParams = new HashMap();
+
+ if (officeId != null && officeId > 0) {
+ extractedQueryParams.put("${officeId}", officeId.toString());
+ }
+
+ if (currencyId != null) {
+ extractedQueryParams.put("${currencyId}", currencyId.toString());
+ }
+
+ GenericResultset result = this.readPlatformService.retrieveGenericResultset(rptDB, name, type, extractedQueryParams);
+
+ return Response.ok().entity(result).build();
+ } catch (UnAuthenticatedUserException e) {
+ throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
+ } catch (AccessDeniedException e) {*/
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/rest/ProtectedFlexibleReportingResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/rest/ProtectedFlexibleReportingResource.java
index e09c7a021..765a8c7b1 100644
--- a/mifosng-provider/src/main/java/org/mifosng/platform/rest/ProtectedFlexibleReportingResource.java
+++ b/mifosng-provider/src/main/java/org/mifosng/platform/rest/ProtectedFlexibleReportingResource.java
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Component;
-@Path("/protected/reporting")
+@Path("/v1/flexiblereportingxxxyyy")
@Component
@Scope("singleton")
public class ProtectedFlexibleReportingResource {