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\sync-git\src\main\java\gov\va\isaac\sync\git\gitblit | GitBlitUtils.java | Tue Jul 17 16:28:25 2018 UTC |
| 2 | CTT_Release_8_June_2018.zip\CTT_ISAAC\ISAAC\sync-git\src\main\java\gov\va\isaac\sync\git\gitblit | GitBlitUtils.java | Wed Jul 18 20:24:14 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 254 |
| 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 | * htt p://www.ap ache.org/l icenses/LI CENSE-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.va.isaac .sync.git. gitblit; | |
| 20 | ||
| 21 | import jav a.io.IOExc eption; | |
| 22 | import jav a.util.Dat e; | |
| 23 | import jav a.util.Has hSet; | |
| 24 | import jav a.util.Set ; | |
| 25 | import jav a.util.reg ex.Matcher ; | |
| 26 | import jav a.util.reg ex.Pattern ; | |
| 27 | import org .slf4j.Log ger; | |
| 28 | import org .slf4j.Log gerFactory ; | |
| 29 | import gov .va.isaac. sync.git.g itblit.mod els.Reposi toryModel; | |
| 30 | import gov .va.isaac. sync.git.g itblit.uti ls.RpcUtil s; | |
| 31 | import gov .va.isaac. sync.git.g itblit.uti ls.RpcUtil s.AccessRe strictionT ype; | |
| 32 | ||
| 33 | ||
| 34 | /** | |
| 35 | * {@link GitBlitUti ls} | |
| 36 | * | |
| 37 | * This en tire packa ge exists because th e GitBlit client API is a bit painful to use, and the client libraries they prod uce | |
| 38 | * aren't available in maven c entral, an d they hav e a depend ency chain we may no t want to drag in. | |
| 39 | * | |
| 40 | * The cod e in this package, a nd below, are extrac ted from h ttp://gitb lit.github .io/gitbli t-maven/ | |
| 41 | * within the com.gi tblit:gbap i:1.8.0 mo dule. | |
| 42 | * | |
| 43 | * @author <a href=" mailto:dan iel.armbru st.list@gm ail.com">D an Armbrus t</a> | |
| 44 | */ | |
| 45 | public cla ss GitBlit Utils | |
| 46 | { | |
| 47 | pr ivate stat ic Logger log = Logg erFactory. getLogger( GitBlitUti ls.class); | |
| 48 | ||
| 49 | ||
| 50 | /* * | |
| 51 | * Create a repository on a remo te gitblit server | |
| 52 | * @param b aseRemoteA ddress - s hould be a url like https:// DNS : PORT /git/ (tho ugh {@link #adjustBa reUrlForGi tBlit(Stri ng)} is ut ilized | |
| 53 | * @param re poName a n ame such a foo or fo o.git | |
| 54 | * @param re poDesc the descripti on | |
| 55 | * @param us ername | |
| 56 | * @param pa ssword | |
| 57 | * @param al lowRead tr ue to allo w unauthen ticated us ers to rea d / clone the reposi tory. Fal se to lock down the repository | |
| 58 | * @throws I OException | |
| 59 | * / | |
| 60 | pu blic stati c void cre ateReposit ory(String baseRemot eAddress, String rep oName, Str ing repoDe sc, String username, char[] pa ssword, bo olean allo wRead) thr ows IOExce ption | |
| 61 | { | |
| 62 | try | |
| 63 | { | |
| 64 | Reposi toryModel rm = new R epositoryM odel(repoN ame, repoD esc, usern ame, new D ate()); | |
| 65 | if (al lowRead) | |
| 66 | { | |
| 67 | rm.acces sRestricti on = Acces sRestricti onType.PUS H.toString (); | |
| 68 | } | |
| 69 | ||
| 70 | boolea n status = RpcUtils .createRep ository(rm , adjustBa reUrlForGi tBlit(base RemoteAddr ess), | |
| 71 | username, password); | |
| 72 | log.in fo("Reposi tory: "+re poName +", create su ccessfully : " + stat us); | |
| 73 | if (!s tatus) | |
| 74 | { | |
| 75 | throw ne w IOExcept ion("Creat e of repo '" + repoN ame + "' f ailed"); | |
| 76 | } | |
| 77 | } | |
| 78 | catc h (Excepti on e) | |
| 79 | { | |
| 80 | log.er ror("Faile d to creat e reposito ry: "+repo Name +", U nexpected Error: ", e); | |
| 81 | throw new IOExce ption("Fai led to cre ate reposi tory: "+re poName +", Internal error", e) ; | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | pu blic stati c Set<Stri ng> readRe positories (String ba seRemoteAd dress, Str ing userna me, char[] password) throws IO Exception | |
| 86 | { | |
| 87 | Hash Set<String > results = new Hash Set<>(); | |
| 88 | RpcU tils.getRe positories (adjustBar eUrlForGit Blit(baseR emoteAddre ss), usern ame, passw ord).forEa ch((name, value) -> results.ad d((String) value.get( "name"))); | |
| 89 | retu rn results ; | |
| 90 | } | |
| 91 | ||
| 92 | /* * | |
| 93 | * Take in a URL like https:// DNS : PORT /git/r/db_ test.git | |
| 94 | * and turn it into h ttps:// DNS : PORT /git/ | |
| 95 | * @param ur l | |
| 96 | * @return | |
| 97 | * @throws I OException | |
| 98 | * / | |
| 99 | pu blic stati c String p arseBaseRe moteAddres s(String u rl) throws IOExcepti on | |
| 100 | { | |
| 101 | Patt ern p = Pa ttern.comp ile("(?i)( https?:\\/ \\/[a-zA-Z 0-9\\.\\-_ ]+:?\\d*\\ /[a-zA-Z0- 9\\-_]+\\/ )r\\/[a-zA -Z0-9\\-_] +.git$"); | |
| 102 | Matc her m = p. matcher(ur l); | |
| 103 | if ( m.find()) | |
| 104 | { | |
| 105 | return m.group(1 ); | |
| 106 | } | |
| 107 | thro w new IOEx ception("N ot a known giblit ur l pattern! "); | |
| 108 | } | |
| 109 | ||
| 110 | /* * | |
| 111 | * This hack ery is bei ng done be cause of a code-sync issue bet ween PRISM E and ISAA C-Rest, wh ere PRISME is puttin g a bare U RL into th e props fi le. | |
| 112 | * It will b e fixed on the PRISM E side, ev entually, making thi s method a noop - bu t for now, handle ei ther the o ld or new style. | |
| 113 | * | |
| 114 | * Essentia lly, if we see a bar e URL like https:// DNS : PORT we add /g it to the end of it. | |
| 115 | * If we se e a URL th at include s a locati on - like https:// DNS : PORT /gitServer - we do n othing mor e than add a trailin g forward slash | |
| 116 | * @param ur l | |
| 117 | * @return | |
| 118 | * / | |
| 119 | pu blic stati c String a djustBareU rlForGitBl it(String url) | |
| 120 | { | |
| 121 | Stri ng temp = url; | |
| 122 | if ( !temp.ends With("/")) | |
| 123 | { | |
| 124 | temp + = "/"; | |
| 125 | } | |
| 126 | if ( temp.match es("(?i)ht tps?:\\/\\ /[a-zA-Z0- 9\\.\\-_]+ :?\\d*\\/$ ")) | |
| 127 | { | |
| 128 | temp + = "git/"; | |
| 129 | } | |
| 130 | retu rn temp; | |
| 131 | } | |
| 132 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.