|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Need to get the repository content (readable) within java code.Hi,
I try to figure out how to get the repository content within my java code. I tried it via HttpWagon and WebDAV, but it did not work. In both cases I only get the HTML-Code for the User-Login. The code snippet I use for HttpWagon: String id = "bosch-ei-libs-releases"; String url = "http://127.0.0.1:8081/artifactory/bosch-ei-libs-releases"; Repository repo = new Repository(id, url); //JcrWagon jcrWagon = new JcrWagon(); LightweightHttpWagon jcrWagon = new LightweightHttpWagon(); try { AuthenticationInfo ai = new AuthenticationInfo(); ai.setUserName("admin"); ai.setPassword("password"); jcrWagon.connect(repo, ai); jcrWagon.getIfNewer("Bosch2", new File("D:\\temp\\Maven\\test.pom"), -1); // List fileList = jcrWagon.getFileList("Bosch2"); // ListIterator iter = fileList.listIterator(); // while(iter.hasNext()) { // Object o = iter.next(); // if(o != null) // System.out.println("F:" + o.toString()); // } jcrWagon.disconnect(); } catch (Exception e) { e.printStackTrace(); } After executing it I get in "D:\\temp\\Maven\\test.pom": <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.sourceforge.net/"> ... <div id="wrapper"> ... <form action=";jsessionid=xaw0ztg84war?wicket:interface=:0:loginPanel:loginForm::IFormSubmitListener::" class="win_login" method="post" id="loginForm13"><div style="display:none"><input type="hidden" name="loginForm13_hf_0" id="loginForm13_hf_0" /></div> <table> <tr> <td align="right">Username:</td> <td> <input value="" type="text" class="textfield" size="30" name="username"/> </td> </tr> <tr> <td align="right">Password:</td> <td> <input value="" type="password" class="textfield" size="30" name="password"/> </td> </tr> ... Please give me some help to get the repository content. Cheers, Rob. |
|
|
Re: Need to get from java code the repository content (readable).I think the only issue here is the "/" after the name of the repository and may be the "dav:http://" protocol instead of pure Http. Sorry, but it's quite hard for Artifactory code to separate the different kind of requests without it.
Another point, it's recommended to do that on a virtual repository if you want pure read only navigation/browsing. Hope it helps. On Fri, Jun 20, 2008 at 2:39 PM, RobW <robert.weissmann@...> wrote:
-- http://freddy33.blogspot.com/ http://www.jfrog.org/ ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Artifactory-users mailing list Artifactory-users@... https://lists.sourceforge.net/lists/listinfo/artifactory-users |
|
|
Re: Need to get from java code the repository content (readable).Another thing, in the latest 1.3.0-beta version you can configure the security of anonymous to read only certain repo/path and so avoid the security login.
On Fri, Jun 20, 2008 at 5:57 PM, Frederic Simon <freds@...> wrote: I think the only issue here is the "/" after the name of the repository and may be the "dav:http://" protocol instead of pure Http. Sorry, but it's quite hard for Artifactory code to separate the different kind of requests without it. -- http://freddy33.blogspot.com/ http://www.jfrog.org/ ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Artifactory-users mailing list Artifactory-users@... https://lists.sourceforge.net/lists/listinfo/artifactory-users |
|
|
Re: Need to get from java code the repository content (readable).This works now:
... import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpURL; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.webdav.lib.WebdavResource; import org.apache.webdav.lib.WebdavResources; ... HttpURL hrl = new HttpURL("http://127.0.0.1:8081/artifactory/<REPOSITORY>/<REPO_NAME_ROOT_FOLDER>"); Credentials credentials = new UsernamePasswordCredentials(user, password); WebdavResource root = new WebdavResource(hrl, credentials, WebdavResource.DEFAULT, WebdavResource.DEFAULT); String[] li = root.list(); for(int i = 0; i < li.length; i++) System.out.println("L[" + i + "]=" + li[i]); or WebdavResources resources = wr.getChildResources(); ... Important: <REPO_NAME_ROOT_FOLDER>, don't forget it. But still other methods will return the HTML-code of the login !?!?!?! Those little things are horribly time-consuming.
|
| Free Forum Powered by Nabble | Forum Help |