Produced by Araxis Merge on 12/21/2017 6:15:12 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Genisis_2.0_v7_bld7.zip\TS\Service\bookmarking-service\src\main\java\gov\va\genisis2\bs\controller | BookmarkingServiceController.java | Thu Dec 14 19:57:16 2017 UTC |
| 2 | Genisis_2.0_v7_bld7.zip\TS\Service\bookmarking-service\src\main\java\gov\va\genisis2\bs\controller | BookmarkingServiceController.java | Thu Dec 21 21:16:57 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 566 |
| Changed | 1 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.genis is2.bs.con troller; | |
| 2 | ||
| 3 | import jav a.util.Lis t; | |
| 4 | ||
| 5 | import org .apache.lo gging.log4 j.LogManag er; | |
| 6 | import org .apache.lo gging.log4 j.Logger; | |
| 7 | import org .owasp.esa pi.ESAPI; | |
| 8 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 9 | import org .springfra mework.dat a.jpa.repo sitory.con fig.Enable JpaReposit ories; | |
| 10 | import org .springfra mework.htt p.HttpStat us; | |
| 11 | import org .springfra mework.htt p.Response Entity; | |
| 12 | import org .springfra mework.web .bind.anno tation.Cro ssOrigin; | |
| 13 | import org .springfra mework.web .bind.anno tation.Exc eptionHand ler; | |
| 14 | import org .springfra mework.web .bind.anno tation.Pat hVariable; | |
| 15 | import org .springfra mework.web .bind.anno tation.Req uestBody; | |
| 16 | import org .springfra mework.web .bind.anno tation.Req uestMappin g; | |
| 17 | import org .springfra mework.web .bind.anno tation.Req uestMethod ; | |
| 18 | import org .springfra mework.web .bind.anno tation.Req uestParam; | |
| 19 | import org .springfra mework.web .bind.anno tation.Res tControlle r; | |
| 20 | ||
| 21 | import gov .va.genisi s2.bs.serv ice.IBusin essService ; | |
| 22 | import gov .va.genisi s2.ts.comm on.dto.Boo kmarkDTO; | |
| 23 | import gov .va.genisi s2.ts.comm on.dto.Lab elDTO; | |
| 24 | import gov .va.genisi s2.ts.comm on.enums.E rrorEnum; | |
| 25 | import gov .va.genisi s2.ts.comm on.excepti on.TSDupli cateDataEx ception; | |
| 26 | import gov .va.genisi s2.ts.comm on.excepti on.TSInern alSystemEx ception; | |
| 27 | import gov .va.genisi s2.ts.comm on.excepti on.TSNoDat aFoundExce ption; | |
| 28 | ||
| 29 | /** | |
| 30 | * Booking marking Se rvice Cont roller. Ma in point t o the book marking se rvice | |
| 31 | * | |
| 32 | * @author PII | |
| 33 | * @author P II | |
| 34 | * | |
| 35 | */ | |
| 36 | @CrossOrig in(origins = "*") | |
| 37 | @RestContr oller | |
| 38 | @RequestMa pping("/") | |
| 39 | @EnableJpa Repositori es("gov.va .genisis2. bs.data.re pository") | |
| 40 | public cla ss Bookmar kingServic eControlle r { | |
| 41 | ||
| 42 | pr ivate stat ic final L ogger LOGG ER = LogMa nager.getL ogger(Book markingSer viceContro ller.class ); | |
| 43 | ||
| 44 | @A utowired | |
| 45 | pr ivate IBus inessServi ce busines sService; | |
| 46 | ||
| 47 | @R equestMapp ing(value = "/bookma rks", meth od = Reque stMethod.G ET, consum es = "appl ication/js on", produ ces = "app lication/j son") | |
| 48 | pu blic Respo nseEntity< List<Bookm arkDTO>> g etBookmark s() { | |
| 49 | if ( LOGGER.isI nfoEnabled ()) { | |
| 50 | LOGGER .info("get Bookmarks" ); | |
| 51 | } | |
| 52 | List <BookmarkD TO> bookma rkingDto = null; | |
| 53 | try { | |
| 54 | bookma rkingDto = businessS ervice.get Bookmarks( ); | |
| 55 | } ca tch (Excep tion e) { | |
| 56 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 57 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 58 | } | |
| 59 | ||
| 60 | if ( null == bo okmarkingD to) { | |
| 61 | LOGGER .error("bo okmarkingD to is null "); | |
| 62 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 63 | } el se { | |
| 64 | return new Respo nseEntity< List<Bookm arkDTO>>(b ookmarking Dto, HttpS tatus.OK); | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | // @R equestMapp ing(value = "/bookma rks/{id}", method = RequestMet hod.GET, c onsumes = "applicati on/json", produces = "applicat ion/json") | |
| 69 | // pu blic Respo nseEntity< BookmarkDT O> getBook mark(@Path Variable I nteger id) { | |
| 70 | // if ( LOGGER.isI nfoEnabled ()) { | |
| 71 | // LOGGER .info("get Bookmark") ; | |
| 72 | // } | |
| 73 | // Book markDTO bo okmarkingD to = null; | |
| 74 | // try { | |
| 75 | // bookma rkingDto = businessS ervice.get Bookmark(i d); | |
| 76 | // } ca tch (Excep tion e) { | |
| 77 | // LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 78 | // throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 79 | // } | |
| 80 | // | |
| 81 | // if ( null == bo okmarkingD to) { | |
| 82 | // LOGGER .error("bo okmarkingD to is null "); | |
| 83 | // throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 84 | // } el se { | |
| 85 | // return new Respo nseEntity< BookmarkDT O>(bookmar kingDto, H ttpStatus. OK); | |
| 86 | // } | |
| 87 | // } | |
| 88 | ||
| 89 | @R equestMapp ing(value = "/bookma rks", meth od = Reque stMethod.P OST, heade rs = "Acce pt=*/*", c onsumes = "applicati on/json", produces = "applicat ion/json") | |
| 90 | pu blic Respo nseEntity< BookmarkDT O> createB ookmark(@R equestBody BookmarkD TO bookmar kDto) { | |
| 91 | if ( LOGGER.isI nfoEnabled ()) { | |
| 92 | LOGGER .info("Cre ate Bookma rk "); | |
| 93 | } | |
| 94 | // T ODO: Look into chang ing throw new catch paradigm.. stack trac es are exp ensive | |
| 95 | Book markDTO bo okmarkingD to = null; | |
| 96 | try { | |
| 97 | bookma rkingDto = businessS ervice.cre ateBookmar k(bookmark Dto); | |
| 98 | } ca tch (TSDup licateData Exception ex) { | |
| 99 | throw ex; | |
| 100 | } ca tch (Excep tion e) { | |
| 101 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 102 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 103 | } | |
| 104 | ||
| 105 | if ( null == bo okmarkingD to) { | |
| 106 | LOGGER .error("bo okmarkingD to is null "); | |
| 107 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 108 | } el se { | |
| 109 | return new Respo nseEntity< BookmarkDT O>(bookmar kingDto, H ttpStatus. CREATED); | |
| 110 | } | |
| 111 | } | |
| 112 | ||
| 113 | @R equestMapp ing(value = "/bookma rks/{id}", method = RequestMet hod.DELETE , headers = "Accept= */*", cons umes = "ap plication/ json", pro duces = "a pplication /json") | |
| 114 | pu blic Respo nseEntity< Integer> d eleteBookm ark(@PathV ariable In teger id) { | |
| 115 | if ( LOGGER.isI nfoEnabled ()) { | |
| 116 | LOGGER .info("Del ete Bookma rk "); | |
| 117 | } | |
| 118 | ||
| 119 | try { | |
| 120 | busine ssService. deleteBook mark(id); | |
| 121 | } ca tch (TSNoD ataFoundEx ception ex ) { | |
| 122 | throw ex; | |
| 123 | } | |
| 124 | catc h (Excepti on e) { | |
| 125 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e(), e); | |
| 126 | throw new TSNoDa taFoundExc eption(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e(), e); | |
| 127 | } | |
| 128 | retu rn new Res ponseEntit y<Integer> (id, HttpS tatus.OK); | |
| 129 | } | |
| 130 | ||
| 131 | @R equestMapp ing(value = "/bookma rks/{id}/l abels", me thod = Req uestMethod .POST, con sumes = "a pplication /json", pr oduces = " applicatio n/json") | |
| 132 | pu blic Respo nseEntity< BookmarkDT O> labelBo okmarkedCo ncept(@Pat hVariable Integer id , @Request Body Label DTO labelD to) { | |
| 133 | if ( LOGGER.isI nfoEnabled ()) { | |
| 134 | LOGGER .info("Add label to bookmark") ; | |
| 135 | } | |
| 136 | Book markDTO re turnedBook mark = nul l; | |
| 137 | try { | |
| 138 | // set the bookm ark id to the label | |
| 139 | labelD to.setBook markId(id) ; // check for null here | |
| 140 | ||
| 141 | // add the label to the bo okmark | |
| 142 | return edBookmark = busines sService.l abelBookma rk(labelDt o); | |
| 143 | } ca tch (Excep tion e) { | |
| 144 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 145 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 146 | } | |
| 147 | if ( returnedBo okmark == null) { | |
| 148 | LOGGER .error("La bel could not be add ed"); | |
| 149 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 150 | } el se { | |
| 151 | return new Respo nseEntity< BookmarkDT O>(returne dBookmark, HttpStatu s.CREATED) ; | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | @R equestMapp ing(value = "/bookma rks/{id}/l abels", me thod = Req uestMethod .DELETE, c onsumes = "applicati on/json", produces = "applicat ion/json") | |
| 156 | pu blic Respo nseEntity< BookmarkDT O> unLabel Bookmarked Concept(@P athVariabl e Integer id, @Reque stParam(va lue = "lab elName", r equired = true) Stri ng labelNa me) { | |
| 157 | if ( LOGGER.isI nfoEnabled ()) { | |
| 158 | LOGGER .info("Unl abel a boo kmarked co ncept"); | |
| 159 | } | |
| 160 | Book markDTO re turnedBook markDto = null; | |
| 161 | try { | |
| 162 | // Cre ate a labe lDTO with string and id passed in | |
| 163 | LabelD TO l = new LabelDTO( ); | |
| 164 | l.setB ookmarkId( id); | |
| 165 | l.setN ame(labelN ame); | |
| 166 | ||
| 167 | // add the label to the bo okmark | |
| 168 | return edBookmark Dto = busi nessServic e.unlabelB ookmark(l) ; | |
| 169 | } ca tch (TSNoD ataFoundEx ception ex ) { | |
| 170 | throw ex; | |
| 171 | } ca tch (Excep tion e) { | |
| 172 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 173 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 174 | } | |
| 175 | if ( returnedBo okmarkDto == null) { | |
| 176 | LOGGER .error("La bel could not be add ed"); | |
| 177 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 178 | } el se { | |
| 179 | return new Respo nseEntity< BookmarkDT O>(returne dBookmarkD to, HttpSt atus.OK); | |
| 180 | } | |
| 181 | } | |
| 182 | ||
| 183 | @R equestMapp ing(value = "/bookma rks/{usern ame:.+}", method = R equestMeth od.GET, co nsumes = " applicatio n/json", p roduces = "applicati on/json") | |
| 184 | pu blic Respo nseEntity< List<Bookm arkDTO>> r etreiveBoo kmarksByUs ername(@Pa thVariable String us ername) { | |
| 185 | if ( LOGGER.isI nfoEnabled ()) { | |
| 186 | LOGGER .info("Ret reive book mared conc epts with labels for given use rname"); | |
| 187 | } | |
| 188 | ||
| 189 | List <BookmarkD TO> bookma rkDto = nu ll; | |
| 190 | try { | |
| 191 | // add the label to the bo okmark | |
| 192 | bookma rkDto = bu sinessServ ice.fetchA llBookmark sByUsernam e(username ); | |
| 193 | } ca tch (Excep tion e) { | |
| 194 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 195 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 196 | } | |
| 197 | if ( bookmarkDt o == null) { | |
| 198 | LOGGER .error("No bookmarks found"); | |
| 199 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 200 | } el se { | |
| 201 | return new Respo nseEntity< List<Bookm arkDTO>>(b ookmarkDto , HttpStat us.OK); | |
| 202 | } | |
| 203 | } | |
| 204 | ||
| 205 | @R equestMapp ing(value = "/labels /{username :.+}", met hod = Requ estMethod. GET, consu mes = "app lication/j son", prod uces = "ap plication/ json") | |
| 206 | pu blic Respo nseEntity< List<Label DTO>> retr eiveLabels ByUsername (@PathVari able Strin g username ) { | |
| 207 | if ( LOGGER.isI nfoEnabled ()) { | |
| 208 | LOGGER .info("Ret reive labe ls for giv en usernam e"); | |
| 209 | } | |
| 210 | ||
| 211 | List <LabelDTO> labelDto = null; | |
| 212 | try { | |
| 213 | labelD to = busin essService .fetchAllL abelsByUse rname(user name); | |
| 214 | } ca tch (Excep tion e) { | |
| 215 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 216 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 217 | } | |
| 218 | if ( labelDto = = null) { | |
| 219 | LOGGER .error("No bookmarks found"); | |
| 220 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 221 | } el se { | |
| 222 | return new Respo nseEntity< List<Label DTO>>(labe lDto, Http Status.OK) ; | |
| 223 | } | |
| 224 | } | |
| 225 | ||
| 226 | @R equestMapp ing(value = "/bookma rks/labels /{label}", method = RequestMet hod.GET, c onsumes = "applicati on/json", produces = "applicat ion/json") | |
| 227 | pu blic Respo nseEntity< List<Bookm arkDTO>> r etreiveBoo kmarksByLa bel(@PathV ariable St ring label ) { | |
| 228 | if ( LOGGER.isI nfoEnabled ()) { | |
| 229 | LOGGER .info("Ret reive book mared conc epts with specific l abel"); | |
| 230 | } | |
| 231 | ||
| 232 | List <BookmarkD TO> bookma rkDto = nu ll; | |
| 233 | try { | |
| 234 | bookma rkDto = bu sinessServ ice.fetchA llBookmark sByLabel(l abel); | |
| 235 | } ca tch (Excep tion e) { | |
| 236 | LOGGER .error(Err orEnum.INT ERNAL_SYS_ ERROR.getE rrorMessag e()); | |
| 237 | throw new TSIner nalSystemE xception(E rrorEnum.I NTERNAL_SY S_ERROR.ge tErrorMess age()); | |
| 238 | } | |
| 239 | ||
| 240 | if ( bookmarkDt o == null) { | |
| 241 | LOGGER .error("Bo okmarks co uld not be found"); | |
| 242 | throw new TSNoDa taFoundExc eption(Err orEnum.NO_ DATA_FOUND _ERROR.get ErrorMessa ge()); | |
| 243 | } el se { | |
| 244 | return new Respo nseEntity< List<Bookm arkDTO>>(b ookmarkDto , HttpStat us.OK); | |
| 245 | } | |
| 246 | } | |
| 247 | ||
| 248 | /* * | |
| 249 | * No data f ound excep tion. | |
| 250 | * | |
| 251 | * @param ex | |
| 252 | * the ex | |
| 253 | * @return t he respons e entity | |
| 254 | * / | |
| 255 | @E xceptionHa ndler({ TS NoDataFoun dException .class }) | |
| 256 | pu blic Respo nseEntity< Object> ex ceptionHan dler(TSNoD ataFoundEx ception ex ) { | |
| 257 | retu rn new Res ponseEntit y<Object>( | |
| 258 | ESAPI.en coder().en codeForHTM L( ex.getM essage( )) , HttpStat us.NOT_FOU ND); | |
| 259 | } | |
| 260 | ||
| 261 | /* * | |
| 262 | * Duplicate data exce ption for create API calls | |
| 263 | * | |
| 264 | * @param ex | |
| 265 | * the ex | |
| 266 | * @return t he respons e entity | |
| 267 | * / | |
| 268 | @E xceptionHa ndler({ TS DuplicateD ataExcepti on.class } ) | |
| 269 | pu blic Respo nseEntity< Object> ex ceptionHan dler(TSDup licateData Exception ex) { | |
| 270 | retu rn new Res ponseEntit y<Object>( | |
| 271 | ESAPI.en coder().en codeForHTM L( ex.getM essage( )) , HttpStat us.BAD_REQ UEST); | |
| 272 | } | |
| 273 | ||
| 274 | /* * | |
| 275 | * Internal System Err or excepti on | |
| 276 | * | |
| 277 | * @param ex | |
| 278 | * the ex | |
| 279 | * @return t he respons e entity | |
| 280 | * / | |
| 281 | @E xceptionHa ndler({ TS InernalSys temExcepti on.class } ) | |
| 282 | pu blic Respo nseEntity< Object> ex ceptionHan dler(TSIne rnalSystem Exception ex) { | |
| 283 | retu rn new Res ponseEntit y<Object>( ErrorEnum. INTERNAL_S YS_ERROR.g etErrorMes sage(), Ht tpStatus.I NTERNAL_SE RVER_ERROR ); | |
| 284 | } | |
| 285 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.