Produced by Araxis Merge on 7/20/2018 12:56:41 PM Central Daylight 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 | CTT_Release_8_June_2018.zip\CTT_ISAAC\ISAAC\ochre-api\src\main\java\gov\vha\isaac\ochre\api\util | ArtifactUtilities.java | Tue Jul 17 16:28:35 2018 UTC |
| 2 | CTT_Release_8_June_2018.zip\CTT_ISAAC\ISAAC\ochre-api\src\main\java\gov\vha\isaac\ochre\api\util | ArtifactUtilities.java | Wed Jul 18 20:02:01 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 332 |
| Changed | 3 | 10 |
| 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 | /** | |
| 2 | * Copyrig ht Notice | |
| 3 | * | |
| 4 | * This is a work of the U.S. Government and is no t subject to copyrig ht | |
| 5 | * protect ion in the United St ates. Fore ign copyri ghts may a pply. | |
| 6 | * | |
| 7 | * License d under th e Apache L icense, Ve rsion 2.0 (the "Lice nse"); | |
| 8 | * you may not use t his file e xcept in c ompliance with the L icense. | |
| 9 | * You may obtain a copy of th e License at | |
| 10 | * | |
| 11 | * http:// www.apache .org/licen ses/LICENS E-2.0 | |
| 12 | * | |
| 13 | * Unless required b y applicab le law or agreed to in writing , software | |
| 14 | * distrib uted under the Licen se is dist ributed on an "AS IS " BASIS, | |
| 15 | * WITHOUT WARRANTIE S OR CONDI TIONS OF A NY KIND, e ither expr ess or imp lied. | |
| 16 | * See the License f or the spe cific lang uage gover ning permi ssions and | |
| 17 | * limitat ions under the Licen se. | |
| 18 | */ | |
| 19 | package go v.vha.isaa c.ochre.ap i.util; | |
| 20 | ||
| 21 | import jav a.io.File; | |
| 22 | import jav a.io.IOExc eption; | |
| 23 | import jav a.net.URL; | |
| 24 | import jav a.util.con current.Ex ecutionExc eption; | |
| 25 | import jav ax.xml.par sers.Docum entBuilder ; | |
| 26 | import jav ax.xml.par sers.Docum entBuilder Factory; | |
| 27 | import jav ax.xml.xpa th.XPath; | |
| 28 | import jav ax.xml.xpa th.XPathCo nstants; | |
| 29 | import jav ax.xml.xpa th.XPathFa ctory; | |
| 30 | import org .apache.co mmons.lang 3.StringUt ils; | |
| 31 | import org .w3c.dom.D ocument; | |
| 32 | import org .w3c.dom.N ode; | |
| 33 | import gov .vha.isaac .ochre.api .Get; | |
| 34 | import gov .vha.isaac .ochre.api .LookupSer vice; | |
| 35 | import jav afx.applic ation.Plat form; | |
| 36 | import jav afx.concur rent.Task; | |
| 37 | ||
| 38 | public cla ss Artifac tUtilities | |
| 39 | { | |
| 40 | pu blic stati c String m akeMavenRe lativePath (String gr oupId, Str ing artifa ctId, Stri ng version , String c lassifier, String ty pe) | |
| 41 | { | |
| 42 | if ( version.en dsWith("-S NAPSHOT")) | |
| 43 | { | |
| 44 | throw new Runtim eException ("Cannot c reate a va lid path t o a -SNAPS HOT url wi thout down loading th e correspo nding mave n-metadata .xml file. "); | |
| 45 | } | |
| 46 | try | |
| 47 | { | |
| 48 | return makeMaven RelativePa th(null, n ull, null, groupId, artifactId , version, classifie r, type); | |
| 49 | } | |
| 50 | catc h (Excepti on e) | |
| 51 | { | |
| 52 | throw new Runtim eException ("Unexpect ed", e); | |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | /* * | |
| 57 | * | |
| 58 | * @param ba seMavenURL - optiona l - but re quired if you are do wnloading a SNAPSHOT dependenc y, as this method wi ll need to download the metada ta file | |
| 59 | * from the repository server in order to determine the proper version c omponent f or the SNA PSHOT. | |
| 60 | * @param ma venUsernam e - option al - only used for a SNAPSHOT dependency | |
| 61 | * @param ma venPasswor d - option al - only used for a SNAPSHOT dependency | |
| 62 | * @param gr oupId | |
| 63 | * @param ar tifactId | |
| 64 | * @param ve rsion | |
| 65 | * @param cl assifier - optional | |
| 66 | * @param ty pe | |
| 67 | * @return | |
| 68 | * @throws E xception | |
| 69 | * / | |
| 70 | pu blic stati c String m akeMavenRe lativePath (String ba seMavenURL , String m avenUserna me, String mavenPass word, Stri ng groupId , String a rtifactId, | |
| 71 | String version, String cla ssifier, S tring type ) throws E xception | |
| 72 | { | |
| 73 | Stri ng temp = groupId.re placeAll(" \\.", "/") ; | |
| 74 | Stri ng snapsho tVersion = ""; | |
| 75 | Stri ng version WithoutSna pshot = ve rsion; | |
| 76 | if ( version.en dsWith("-S NAPSHOT")) | |
| 77 | { | |
| 78 | versio nWithoutSn apshot = v ersion.sub string(0, version.la stIndexOf( "-SNAPSHOT ")); | |
| 79 | URL me tadataUrl = new URL( baseMavenU RL + (base MavenURL.e ndsWith("/ ") ? "" : "/") + tem p + "/" + artifactId + "/" + v ersion + " /maven-met adata.xml" ); | |
| 80 | //Need to downlo ad the mav en-metadat a.xml file | |
| 81 | Task<F ile> task = new Down loadUnzipT ask(mavenU sername, m avenPasswo rd, metada taUrl, fal se, false, null); | |
| 82 | WorkEx ecutors.ge t().getExe cutor().ex ecute(task ); | |
| 83 | ||
| 84 | File m etadataFil e = task.g et(); | |
| 85 | ||
| 86 | Docume ntBuilderF actory dom Factory = DocumentBu ilderFacto ry.newInst ance(); | |
| 87 | //adde d to avoid XXE injec tions | |
| 88 | domFac tory.setFe ature("htt p://apache .org/xml/f eatures/di sallow-doc type-decl" , true); | |
| 89 | ||
| 90 | Docume ntBuilder builder; | |
| 91 | Docume nt dDoc = null; | |
| 92 | XPath xPath = XP athFactory .newInstan ce().newXP ath(); | |
| 93 | ||
| 94 | builde r = domFac tory.newDo cumentBuil der(); | |
| 95 | ||
| 96 | dDoc = builder.p arse(metad ataFile); | |
| 97 | String timestamp = ((Node) xPath.eval uate("/met adata/vers ioning/sna pshot/time stamp", dD oc, XPathC onstants.N ODE)).getT extContent (); | |
| 98 | String buildNumb er = ((Nod e)xPath.ev aluate("/m etadata/ve rsioning/s napshot/bu ildNumber" , dDoc, XP athConstan ts.NODE)). getTextCon tent(); | |
| 99 | ||
| 100 | snapsh otVersion = "-" + ti mestamp + "-" + buil dNumber; | |
| 101 | metada taFile.del ete(); | |
| 102 | //The download t ask makes a subfolde r in temp for this, delete tha t too | |
| 103 | metada taFile.get ParentFile ().delete( ); | |
| 104 | } | |
| 105 | ||
| 106 | retu rn temp + "/" + arti factId + " /" + versi on + "/" + artifactI d + "-" + versionWit houtSnapsh ot + snaps hotVersion + | |
| 107 | (StringU tils.isNot Blank(clas sifier) ? "-" + clas sifier : " ") + "." + type; | |
| 108 | } | |
| 109 | ||
| 110 | /* * | |
| 111 | * | |
| 112 | * @param ba seMavenURL | |
| 113 | * @param ma venUsernam e - option al - only used for a SNAPSHOT dependency | |
| 114 | * @param ma venPasswor d - option al - only used for a SNAPSHOT dependency | |
| 115 | * @param gr oupId | |
| 116 | * @param ar tifactId | |
| 117 | * @param ve rsion | |
| 118 | * @param cl assifier - optional | |
| 119 | * @param ty pe | |
| 120 | * @return | |
| 121 | * @throws E xception | |
| 122 | * / | |
| 123 | pu blic stati c URL make FullURL(St ring baseM avenURL, S tring mave nUsername, String ma venPasswor d, String groupId, S tring arti factId, | |
| 124 | String version, String cla ssifier, S tring type ) throws E xception | |
| 125 | { | |
| 126 | retu rn new URL (baseMaven URL + (bas eMavenURL. endsWith(" /") ? "" : "/") | |
| 127 | + make MavenRelat ivePath(ba seMavenURL , mavenUse rname, mav enPassword , groupId, artifactI d, version , classifi er, type)) ; | |
| 128 | } | |
| 129 | ||
| 130 | pu blic stati c void mai n(String[] args) thr ows Interr uptedExcep tion, Exec utionExcep tion, IOEx ception | |
| 131 | { | |
| 132 | try | |
| 133 | { | |
| 134 | String username = "foo"; | |
| 135 | String userpd = "foo"; | |
| 136 | ||
| 137 | Lookup Service.st artupWorkE xecutors() ; | |
| 138 | ||
| 139 | URL releas e = new UR L("http:// URL : PORT /nexus/con tent/repos itories/ce ntral/" | |
| 140 | + makeMave nRelativeP ath("aopal liance", " aopallianc e", "1.0", null, "ja r")); | |
| 141 | Task<F ile> task = new Down loadUnzipT ask(null, null, rele ase, false , true, nu ll); | |
| 142 | Get.wo rkExecutor s().getExe cutor().su bmit(task) ; | |
| 143 | File f oo = task. get(); | |
| 144 | System .out.print ln(foo.get CanonicalP ath()); | |
| 145 | foo.de lete(); | |
| 146 | foo.ge tParentFil e().delete (); | |
| 147 | ||
| 148 | File w here = new File(""). getAbsolut eFile(); | |
| 149 | URL snapsh ot = new U RL("http:/ / URL : PORT /nexus/con tent/repos itories/te rmdatasnap shots/" | |
| 150 | + makeMave nRelativeP ath("http: // URL : PORT /nexus/con tent/repos itories/te rmdatasnap shots/", u sername, u serpd, | |
| 151 | "gov .vha.isaac .db", "vha t", "2016. 01.07-1.0- SNAPSHOT", "all", "c radle.zip" )); | |
| 152 | task = new Downl oadUnzipTa sk(usernam e, userpd, snapshot, true, tru e, where); | |
| 153 | Get.wo rkExecutor s().getExe cutor().su bmit(task) ; | |
| 154 | foo = task.get() ; | |
| 155 | ||
| 156 | snapshot = new URL(" http:// URL : PORT /nexus/con tent/repos itories/te rmdatasnap shots/" | |
| 157 | + makeMave nRelativeP ath("http: // URL : PORT /nexus/con tent/repos itories/te rmdatasnap shots/", u sername, u serpd, | |
| 158 | "gov .vha.isaac .db", "vha t", "2016. 01.07-1.0- SNAPSHOT", "all", "l ucene.zip" )); | |
| 159 | task = new Downl oadUnzipTa sk(usernam e, userpd, snapshot, true, tru e, where); | |
| 160 | Get.wo rkExecutor s().getExe cutor().su bmit(task) ; | |
| 161 | foo = task.get() ; | |
| 162 | ||
| 163 | System .out.print ln(foo.get CanonicalP ath()); | |
| 164 | } | |
| 165 | catc h (Excepti on e) | |
| 166 | { | |
| 167 | e.prin tStackTrac e(); | |
| 168 | } | |
| 169 | Plat form.exit( ); | |
| 170 | } | |
| 171 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.