From 87122cf4cc15f23742f0d00dcc38fc7d6258334a Mon Sep 17 00:00:00 2001 From: shakjaf110 Date: Wed, 7 Sep 2016 15:06:43 +0500 Subject: [PATCH 1/3] SR: #43 . Improved and simplified interface and workflow and data services. fixed few issues in build --- .../java/org/opensrp/domain/ErrorTrace.java | 21 +- .../org/opensrp/repository/AllErrorTrace.java | 31 +- .../opensrp/service/ErrorTraceService.java | 53 +- .../service/XlsFormDownloaderService.java | 10 +- .../it/AllClientsIntegrationTest.java | 6 +- .../it/AllErrorTraceIntegrationTest.java | 19 +- .../form/service/FormAttributeParser.java | 8 +- .../web/controller/ErrorTraceController.java | 150 ++--- .../web/rest/rapid/RapidClientResource.java | 5 +- .../src/main/webapp/WEB-INF/home_error.jsp | 575 ++++++++---------- .../src/main/webapp/WEB-INF/solvederrors.jsp | 8 +- .../main/webapp/WEB-INF/unsolvederrors.jsp | 6 +- .../src/main/webapp/WEB-INF/view_error.jsp | 23 +- .../web/it/AllErrorTraceIntegrationTest.java | 54 ++ .../web/rest/it/ClientResourceTest.java | 3 +- 15 files changed, 442 insertions(+), 530 deletions(-) create mode 100644 opensrp-web/src/test/java/org/opensrp/web/it/AllErrorTraceIntegrationTest.java diff --git a/opensrp-core/src/main/java/org/opensrp/domain/ErrorTrace.java b/opensrp-core/src/main/java/org/opensrp/domain/ErrorTrace.java index 1af44454ca..31452e9b29 100644 --- a/opensrp-core/src/main/java/org/opensrp/domain/ErrorTrace.java +++ b/opensrp-core/src/main/java/org/opensrp/domain/ErrorTrace.java @@ -1,6 +1,8 @@ package org.opensrp.domain; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import org.codehaus.jackson.annotate.JsonProperty; import org.ektorp.support.TypeDiscriminator; @@ -9,7 +11,7 @@ /** * @author muhammad.ahmed@ihsinformatics.com Created on May 25, 2015 */ -@TypeDiscriminator("doc.type == 'Error'") +@TypeDiscriminator("doc.type == 'ErrorTrace'") public class ErrorTrace extends MotechBaseDataObject { /* @@ -36,7 +38,8 @@ public class ErrorTrace extends MotechBaseDataObject { private String documentType; @JsonProperty private String retryUrl; - + @JsonProperty + private Map details; // dateoccured , dateclosed , errortype =name, documenttype , submiturl public ErrorTrace() { @@ -110,7 +113,21 @@ public void setRetryUrl(String retryUrl) { this.retryUrl = retryUrl; } + public Map getDetails() { + return details; + } + public void setDetails(Map details) { + this.details = details; + } + + public void addDetails(String key, String val) { + if(details == null){ + details = new HashMap<>(); + } + details.put(key, val); + } + public String getRecordId() { return recordId; diff --git a/opensrp-core/src/main/java/org/opensrp/repository/AllErrorTrace.java b/opensrp-core/src/main/java/org/opensrp/repository/AllErrorTrace.java index 1249e1f922..874d7e04fa 100644 --- a/opensrp-core/src/main/java/org/opensrp/repository/AllErrorTrace.java +++ b/opensrp-core/src/main/java/org/opensrp/repository/AllErrorTrace.java @@ -5,14 +5,18 @@ import org.ektorp.CouchDbConnector; import org.ektorp.DocumentNotFoundException; +import org.ektorp.support.GenerateView; import org.ektorp.support.View; import org.motechproject.dao.MotechBaseRepository; import org.opensrp.common.AllConstants; +import org.opensrp.domain.Client; import org.opensrp.domain.ErrorTrace; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; +import com.mysql.jdbc.StringUtils; + /** * @author muhammad.ahmed@ihsinformatics.com * Created on May 25, 2015 @@ -27,41 +31,30 @@ protected AllErrorTrace( super(ErrorTrace.class, db); } - //@GenerateView public ErrorTrace findById(String _id) throws DocumentNotFoundException{ - - /*db.queryView(createQuery("_id").keys(_id) - .includeDocs(true), ErrorTrace.class);*/ - ErrorTrace errors= (ErrorTrace)get(_id); - //List errors = queryView("_id", _id); - if (errors == null ) { - System.out.println("Error by id : = found nothing !"); - return null; - } - System.out.println("Error by id : = "+errors); - return errors; + return get(_id); } public boolean exists(String id) { return findById(id) != null; } - @View(name = "all_errors", map = "function(doc) { emit(doc.id); }") + @View(name = "all_errors", map = "function(doc) { if (doc.type === 'ErrorTrace') { emit(doc.id); } }") public List findAllErrors() throws DocumentNotFoundException{ return db.queryView(createQuery("all_errors").includeDocs(true), ErrorTrace.class); } - @View(name = "all_unsolved_errors", map = "function(doc) { if (doc.status === 'unsolved') { emit(doc.id); } }") - public List findAllUnSolvedErrors() throws DocumentNotFoundException { - return db.queryView(createQuery("all_unsolved_errors").includeDocs(true), - ErrorTrace.class); + @View(name = "all_errors_by_status", map = "function(doc) { if (doc.type === 'ErrorTrace') { emit(doc.status); } }") + public List findErrorsByStatus(String status) throws DocumentNotFoundException { + return db.queryView(createQuery("all_errors_by_status"). + key(status).includeDocs(true), ErrorTrace.class); } - @View(name = "all_solved_errors", map = "function(doc) { if (doc.status === 'solved') { emit(doc.id); } }") + /*@View(name = "all_solved_errors", map = "function(doc) { if (doc.status === 'solved') { emit(doc.id); } }") public List findAllSolvedErrors() throws DocumentNotFoundException { return db.queryView(createQuery("all_solved__errors").includeDocs(true), ErrorTrace.class); - } + }*/ } diff --git a/opensrp-core/src/main/java/org/opensrp/service/ErrorTraceService.java b/opensrp-core/src/main/java/org/opensrp/service/ErrorTraceService.java index 6f9e65f794..aa57498f2c 100644 --- a/opensrp-core/src/main/java/org/opensrp/service/ErrorTraceService.java +++ b/opensrp-core/src/main/java/org/opensrp/service/ErrorTraceService.java @@ -20,7 +20,6 @@ public class ErrorTraceService { private final AllErrorTrace allErrorTrace; - @Autowired public ErrorTraceService(AllErrorTrace allErrorTrace) { this.allErrorTrace=allErrorTrace; @@ -50,63 +49,21 @@ public void log(String errorType , String documentType, String recordId ,String error.setRetryUrl(retryURL); error.setDateOccurred(new Date()); addError(error); - } public void updateError(ErrorTrace entity){ allErrorTrace.update(entity); } - public List getAllErrors() throws DocumentNotFoundException{ - - - ArrayList allErrorList= (ArrayList) allErrorTrace.findAllErrors(); - if(null==allErrorList || allErrorList.isEmpty()){ - return null; - - } - - - return allErrorList; - + public List getAllError() throws DocumentNotFoundException{ + return allErrorTrace.findAllErrors(); } - public List getAllSolvedErrors() throws DocumentNotFoundException{ - - - ArrayList allErrorList= (ArrayList) allErrorTrace.findAllSolvedErrors(); - if(null==allErrorList || allErrorList.isEmpty()){ - return null; - - } - - - return allErrorList; - + public List getErrorsByStatus(String errorStatus) throws DocumentNotFoundException{ + return allErrorTrace.findErrorsByStatus(errorStatus); } - - public List getAllUnsolvedErrors() throws DocumentNotFoundException{ - - ArrayList allErrorList= (ArrayList) allErrorTrace.findAllUnSolvedErrors(); - if(null==allErrorList || allErrorList.isEmpty()){ - return null; - - } - - - return allErrorList; - - } - public ErrorTrace getError(String id) throws DocumentNotFoundException{ - - return allErrorTrace.findById(id); - - + return allErrorTrace.findById(id); } - - - - } diff --git a/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java b/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java index b39b1c7cd7..00e9a1a5f3 100644 --- a/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java +++ b/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java @@ -2,8 +2,8 @@ -import httpdowload.JustForFun; - +/*import httpdowload.JustForFun; +*/ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; @@ -55,7 +55,7 @@ public XlsFormDownloaderService() { public static void main(String[] args) { try { - new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", + /*new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "child_vaccination_enrollment", "135187"); //------------------------- new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", @@ -66,7 +66,7 @@ public static void main(String[] args) { //---------------------------- new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "woman_tt_followup_form", "135203"); - +*/ /*new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "vaccine_stock_position", "115142"); @@ -77,7 +77,7 @@ public static void main(String[] args) { new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "offsite_woman_followup_form", "115135");*/ - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/opensrp-core/src/test/java/org/opensrp/repository/it/AllClientsIntegrationTest.java b/opensrp-core/src/test/java/org/opensrp/repository/it/AllClientsIntegrationTest.java index 8c541d76b7..e3cd1b4c00 100644 --- a/opensrp-core/src/test/java/org/opensrp/repository/it/AllClientsIntegrationTest.java +++ b/opensrp-core/src/test/java/org/opensrp/repository/it/AllClientsIntegrationTest.java @@ -112,7 +112,7 @@ public static void main(String[] args) { System.out.println(new DateTime("2016-01-23").toString("MMMM (yyyy)")); } - @Test + @Ignore @Test public void shouldSearchFullDataClientsIn10Sec() throws MalformedURLException { /*org.ektorp.http.HttpClient httpClient = new StdHttpClient.Builder().url("http://202.141.249.106:6808").build(); @@ -151,7 +151,7 @@ void addClient(int i, boolean direct, CouchDbConnector db){ int ageInWeeks = new Random().nextInt(2860);// assuming average age of people is 55 years DateTime birthdate = new DateTime().minusWeeks(ageInWeeks); DateTime deathdate = i%7==0?new DateTime():null;// every 7th person died today - Client c = new Client("entityId"+i, "firstName"+i, "middleName"+i, "lastName"+i, birthdate, deathdate, false, false, i%2==0?"FEMALE":"MALE"); + Client c = new Client("entityId"+i, "firstName"+i, "middleName"+i, "lastName"+i, birthdate, deathdate, false, false, i%2==0?"FEMALE":"MALE",""); Map am = new HashMap<>(); Address ab = new Address("birthplace", null, null, am , null, null, null, "Sindh", "Pakistan"); @@ -183,7 +183,7 @@ else if(direct){ } } - @Test + @Ignore @Test public void shouldGetByDynamicView() { addClients(); List l2 = clientService.findByCriteria(null, "MALE", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); diff --git a/opensrp-core/src/test/java/org/opensrp/repository/it/AllErrorTraceIntegrationTest.java b/opensrp-core/src/test/java/org/opensrp/repository/it/AllErrorTraceIntegrationTest.java index 16d58a8060..812e7e3b3e 100644 --- a/opensrp-core/src/test/java/org/opensrp/repository/it/AllErrorTraceIntegrationTest.java +++ b/opensrp-core/src/test/java/org/opensrp/repository/it/AllErrorTraceIntegrationTest.java @@ -1,8 +1,10 @@ package org.opensrp.repository.it; import static org.mockito.MockitoAnnotations.initMocks; +import static org.junit.Assert.*; import java.util.Date; +import java.util.Random; import org.junit.Before; import org.junit.Test; @@ -20,24 +22,39 @@ public class AllErrorTraceIntegrationTest { @Autowired private AllErrorTrace allErrorTrace; + @Before public void setUp() throws Exception { initMocks(this); + allErrorTrace.removeAll(); } @Test public void shouldAddError()throws Exception { //ErrorTrace error=new ErrorTrace(new Date(), "Error Testing" , "not availalbe","this is an Testing Error", "unsolved"); + Random ran=new Random(); + try + { + throw new RuntimeException("My Test Msg"); + } + catch(Exception e){ + for(int i=0;i<15;i++) + { ErrorTrace error=new ErrorTrace(); error.setErrorType("error loggging test"); error.setDate(new Date()); error.setStackTrace("Complete Stack Trace :"); error.setStatus("unsolved"); error.setDocumentType("Test Document"); - // error.setErrorType("test Error"); + error.setRecordId(String.valueOf(ran.nextInt(100000)+ran.nextInt(1002))); allErrorTrace.add(error); + } + assertTrue(allErrorTrace.findErrorsByStatus("unsolved").size() == 15); + assertTrue(allErrorTrace.findErrorsByStatus("solved").size() <15); + + } } diff --git a/opensrp-form/src/main/java/org/opensrp/form/service/FormAttributeParser.java b/opensrp-form/src/main/java/org/opensrp/form/service/FormAttributeParser.java index 2b3925c42e..19b6ef3011 100644 --- a/opensrp-form/src/main/java/org/opensrp/form/service/FormAttributeParser.java +++ b/opensrp-form/src/main/java/org/opensrp/form/service/FormAttributeParser.java @@ -22,6 +22,7 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.apache.commons.lang.StringUtils; import org.opensrp.form.domain.FormField; import org.opensrp.form.domain.FormSubmission; import org.opensrp.form.domain.SubFormData; @@ -42,7 +43,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; -import com.mysql.jdbc.StringUtils; /** * The class is the bridge that allows parsing and mapping of formSubmission fields with @@ -76,7 +76,7 @@ public FormSubmissionMap createFormSubmissionMap(FormSubmission fs) throws JsonI Map fieldAttributes = bindPath==null?new HashMap():getAttributesForBindPath(bindPath, modelXml); boolean ismultiselect = bindPath==null?false:isMultiselect(bindPath, jsonForm); - if(!StringUtils.isEmptyOrWhitespaceOnly(fsf.value())){ + if(!StringUtils.isBlank(fsf.value())){ if(ismultiselect){ String[] vals = fsf.value().split(" "); Map> valCods = new HashMap<>(); @@ -539,7 +539,7 @@ public Map getAttributesForSubform (String subformName, FormSubm public Map getInstanceAttributesForFormFieldAndValue(String fieldName, String fieldVal, String subform, String formName, JsonObject formDefinition, JsonObject jsonForm) throws JsonSyntaxException, IOException { String bindPath = null; - if(StringUtils.isEmptyOrWhitespaceOnly(subform)){ + if(StringUtils.isBlank(subform)){ bindPath = getPropertyBindFromFormDefinition(fieldName, formName, formDefinition); } else { @@ -552,7 +552,7 @@ public Map getInstanceAttributesForFormFieldAndValue(String fiel public Map getInstanceAttributesForFormFieldAndValue(String fieldName, String fieldVal, String subform, FormSubmission fs) throws JsonSyntaxException, IOException { String bindPath = null; - if(StringUtils.isEmptyOrWhitespaceOnly(subform)){ + if(StringUtils.isBlank(subform)){ bindPath = getPropertyBindFromFormDefinition(fieldName, fs.formName(), getFormDefinitionData(fs.formName())); } else { diff --git a/opensrp-web/src/main/java/org/opensrp/web/controller/ErrorTraceController.java b/opensrp-web/src/main/java/org/opensrp/web/controller/ErrorTraceController.java index 4585753444..7139a6f505 100644 --- a/opensrp-web/src/main/java/org/opensrp/web/controller/ErrorTraceController.java +++ b/opensrp-web/src/main/java/org/opensrp/web/controller/ErrorTraceController.java @@ -1,10 +1,10 @@ /** * @author muhammad.ahmed@ihsinformatics@gmail.com + * and Shakeeb.raza@ihsinformatics.com */ package org.opensrp.web.controller; import java.text.SimpleDateFormat; - import java.util.Date; import java.util.HashMap; import java.util.List; @@ -14,11 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.CustomDateEditor; - import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; - import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -32,9 +30,9 @@ import static org.springframework.http.HttpStatus.OK; import static org.springframework.web.bind.annotation.RequestMethod.*; +import org.apache.commons.lang3.StringUtils; import org.opensrp.domain.ErrorTrace; import org.opensrp.domain.ErrorTraceForm; - import org.opensrp.service.ErrorTraceService; import com.google.gson.Gson; @@ -53,7 +51,13 @@ public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(Date.class, new CustomDateEditor( dateFormat, false)); } - + + @RequestMapping("/errorhandler") + public String Redirecting(HttpServletRequest request, + ErrorTraceForm errorTraceForm, BindingResult errors) { + return "redirect:/errorhandler/index"; + } + @Autowired public ErrorTraceController(ErrorTraceService errorTraceService) { @@ -62,86 +66,39 @@ public ErrorTraceController(ErrorTraceService errorTraceService) { @RequestMapping(method = GET, value = "/index") public ModelAndView showPage() { - - Map model = new HashMap(); - ErrorTraceForm errorForm=new ErrorTraceForm(); - - Gson gson = new Gson(); - - // - // Convert numbers array into JSON string. - // - String optionsJson = gson.toJson(errorForm.getStatusOptions()); + Gson gson = new Gson(); + // Convert numbers array into JSON string. + String optionsJson = gson.toJson(errorForm.getStatusOptions()); model.put("statusOptions",optionsJson); - model.put("type", "all"); - return new ModelAndView("home_error", model); - } - - @RequestMapping(method = GET, value = "/errortrace") @ResponseBody - public ResponseEntity> allErrors() { - - try { - Map model = new HashMap(); - List list = errorTraceService.getAllErrors(); - model.put("errors", list); - model.put("type", "all"); - - - - return new ResponseEntity<>(list, HttpStatus.OK); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity<>(INTERNAL_SERVER_ERROR); - } - - } - - @RequestMapping(method = GET, value = "/unsolvederrors") - @ResponseBody - public ResponseEntity> showUnsolved() { - - try { - Map model = new HashMap(); - List list = errorTraceService.getAllUnsolvedErrors(); - model.put("errors", list); - model.put("type", "unsolved"); - - - return new ResponseEntity<>(list, HttpStatus.OK); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity<>(INTERNAL_SERVER_ERROR); - } - } - - @RequestMapping(method = GET, value = "/solvederrors") - @ResponseBody - public ResponseEntity> showSolved() { - + public ResponseEntity> allErrors(@RequestParam("status") String status) { + List list=null; try { Map model = new HashMap(); - - List list = errorTraceService.getAllSolvedErrors(); + if(StringUtils.isBlank(status)) + { + list = errorTraceService.getAllError(); + } + else + { + list = errorTraceService.getErrorsByStatus(status); + } model.put("errors", list); - model.put("type", "solved"); - return new ResponseEntity<>(list, HttpStatus.OK); - - } catch (Exception e) { + } catch (Exception e) + { e.printStackTrace(); return new ResponseEntity<>(INTERNAL_SERVER_ERROR); - } + } } - @RequestMapping(method=GET,value="/viewerror") @ResponseBody @@ -150,18 +107,17 @@ public ResponseEntity showError(@RequestParam("id") String id){ ErrorTrace error=errorTraceService.getError(id); - ErrorTraceForm errorTraceForm=new ErrorTraceForm(); + ErrorTraceForm errorTraceForm=new ErrorTraceForm(); errorTraceForm.setErrorTrace(error); System.out.println("error ID :" + errorTraceForm.getErrorTrace().getId()); return new ResponseEntity<>(errorTraceForm, HttpStatus.OK); - - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity<>(INTERNAL_SERVER_ERROR); - } - + }catch (Exception e) + { + e.printStackTrace(); + return new ResponseEntity<>(INTERNAL_SERVER_ERROR); + } } @@ -169,25 +125,16 @@ public ResponseEntity showError(@RequestParam("id") String id){ @ResponseBody public ResponseEntity> statusOptions(){ try{ - - - - ErrorTraceForm errorTraceForm=new ErrorTraceForm(); - - + ErrorTraceForm errorTraceForm=new ErrorTraceForm(); return new ResponseEntity<>(errorTraceForm.getStatusOptions(), HttpStatus.OK); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity<>(INTERNAL_SERVER_ERROR); - } - + }catch (Exception e) + { + e.printStackTrace(); + return new ResponseEntity<>(INTERNAL_SERVER_ERROR); + } } - - - - - /**@author engrmahmed14@gmail.com + /**@authors engrmahmed14@gmail.com and shakeeb.raza@ihsinformatics.com * @return String , value of the view error page * @param ErrorTraceForm * this method uses spring binding for form update . @@ -197,13 +144,9 @@ public ResponseEntity> statusOptions(){ @RequestMapping(value = "/update_errortrace", method = POST) public String updateErrorTrace(HttpServletRequest request, ErrorTraceForm errorTraceForm, BindingResult errors) { - if (errors.hasErrors()) { - - } - + if (errors.hasErrors()) {} System.out.println(errorTraceForm.getErrorTrace().getId()); - ErrorTrace errorTrace = errorTraceService.getError(errorTraceForm - .getErrorTrace().getId()); + ErrorTrace errorTrace = errorTraceService.getError(errorTraceForm.getErrorTrace().getId()); errorTrace.setStatus(errorTraceForm.getErrorTrace().getStatus()); errorTraceService.updateError(errorTrace); // System.out.println("page context :: "+request.getContextPath()); @@ -212,11 +155,9 @@ public String updateErrorTrace(HttpServletRequest request, @RequestMapping(value="/update_status", method=GET) public String UpdateStatus(@RequestParam("id") String id, @RequestParam("status") String status){ - ErrorTrace errorTrace = errorTraceService.getError(id); errorTrace.setStatus(status); errorTraceService.updateError(errorTrace); - return "redirect:/errorhandler/index"; } @@ -224,16 +165,11 @@ public String UpdateStatus(@RequestParam("id") String id, @RequestParam("status" @RequestMapping(method = GET, value = "/allerrors") @ResponseBody public ResponseEntity getAllErrors() { - - List list = errorTraceService.getAllErrors(); + List list = errorTraceService.getAllError(); if (list == null) { - return (ResponseEntity) new ResponseEntity<>( - "No Record(s) Found .", allowOrigin(opensrpSiteUrl), OK); - + return (ResponseEntity) new ResponseEntity<>("No Record(s) Found .", allowOrigin(opensrpSiteUrl), OK); } - return (ResponseEntity) new ResponseEntity<>(list, - allowOrigin(opensrpSiteUrl), OK); - + return (ResponseEntity) new ResponseEntity<>(list,allowOrigin(opensrpSiteUrl), OK); } } diff --git a/opensrp-web/src/main/java/org/opensrp/web/rest/rapid/RapidClientResource.java b/opensrp-web/src/main/java/org/opensrp/web/rest/rapid/RapidClientResource.java index 9c34adee67..ae2bf8515e 100644 --- a/opensrp-web/src/main/java/org/opensrp/web/rest/rapid/RapidClientResource.java +++ b/opensrp-web/src/main/java/org/opensrp/web/rest/rapid/RapidClientResource.java @@ -14,6 +14,9 @@ import javax.servlet.http.HttpServletRequest; + + + import org.apache.commons.codec.binary.Base64; import org.joda.time.DateTime; import org.joda.time.Weeks; @@ -341,7 +344,7 @@ public String usernameWithBasicAuthentication(HttpServletRequest req) { if (basic.equalsIgnoreCase("Basic")) { try { - String credentials = new String(Base64.decodeBase64(st.nextToken()), "UTF-8"); + String credentials = new String(Base64.decodeBase64(st.nextToken().getBytes()), "UTF-8"); System.out.println("Credentials: " + credentials); int p = credentials.indexOf(":"); if (p != -1) { diff --git a/opensrp-web/src/main/webapp/WEB-INF/home_error.jsp b/opensrp-web/src/main/webapp/WEB-INF/home_error.jsp index db32443b36..b087df6edc 100644 --- a/opensrp-web/src/main/webapp/WEB-INF/home_error.jsp +++ b/opensrp-web/src/main/webapp/WEB-INF/home_error.jsp @@ -1,4 +1,5 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> @@ -25,15 +26,13 @@ rel="stylesheet"> - + - - - -
- OPENSRP +
-

Error Handling -

+

Error Handling

- - - + + +
- - - -
+