Hi Olivier:
My code:
private void uploadContent(URL targetURL, InputStream bis)
throws IOException {
Authenticator.setDefault(new RepositoryAuthentication(userName,
password));
String host = targetURL.getHost();
int port = targetURL.getPort();
HttpURLConnection connection = null;
OutputStream outputStream = null;
InputStream inputStream = null;
BufferedReader bufferedReader = null;
try {
connection = (HttpURLConnection)
targetURL.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
connection.setDoInput(true);
connection.addRequestProperty("Connection",
"keep-alive");
byte[] contents = new byte[1024];
outputStream = connection.getOutputStream();
int count = -1;
while ((count = bis.read(contents)) != -1) {
outputStream.write(contents, 0, count);
}
System.out.println("response....");
inputStream = connection.getInputStream();
bufferedReader = new BufferedReader(new
InputStreamReader(
inputStream));
String s = bufferedReader.readLine();
while (s != null) {
System.out.println(s);
s = bufferedReader.readLine();
}
System.out.println("end");
} catch (IOException e) {
throw e;
} finally {
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
if (outputStream != null) {
outputStream.close();
}
if (connection != null) {
connection.disconnect();
}
}
}
-----Original Message-----
From: Olivier Lamy [mailto:[email protected]]
Sent: Monday, September 26, 2011 3:24 PM
To: [email protected]
Subject: Re: How can I easily to deploy jar into Archiva Without Maven
Hello,
Could you share the code you are using ?
2011/9/26 Gang Liu <[email protected]>:
> Hi All:
>
> Sometimes, when I'm tring to upload a jar file into repository, I'll always
> get an error message: Server redirected too many times (20)
>
> It seems it is failed to authenticate the userName and password.
>
> Is there anybody can give me some helps about this?
>
> Thanks.
> Best Regards
> Gang.Liu
> Beijing Talend
> Skype: gang.liu.talendbj
> Phone: +86 13146181923
>
>
> -----Original Message-----
> From: Gang Liu [mailto:[email protected]]
> Sent: Friday, September 16, 2011 2:51 PM
> To: [email protected]
> Subject: RE: How can I easily to deploy jar into Archiva Without Maven
>
> Hi Brett:
>
> Thanks for you reply, I have finished a very simple version of uploader.
>
> the md5, sha1 files and pom file will be created and uploaded. And also the
> metadata.xml file will be updated.
>
> It seems work fine now.
>
> Thanks.
> Best Regards
> Gang.Liu
> Beijing Talend
> Skype: gang.liu.talendbj
> Phone: +86 13146181923
>
> -----Original Message-----
> From: Brett Porter [mailto:[email protected]] On Behalf Of Brett Porter
> Sent: Friday, September 16, 2011 9:48 AM
> To: [email protected]
> Subject: Re: How can I easily to deploy jar into Archiva Without Maven
>
>
> On 15/09/2011, at 7:10 PM, Gang Liu wrote:
>
>> Hi Olivier:
>>
>> Thanks for your quickly response and Sure, I will fill the issue.
>>
>> And BTW. If I want to write an upload action by myself, I have to provider
>> all related files, for example, the pom.xml, *.sha1, *.md5, and update
>> Maven-metadata.xml, right?
>>
>> There's any way to make these can be done from Archiva side?
>
> You're able to just push those files over HTTP - there's no need for another
> "REST" action for that.
>
> Archiva will generate the .sha1, .md5 and maven-metadata.xml files if you
> have that setting turned on in the consumers page (create missing checksums
> and update metadata).
>
> To do a generated POM more like the upload form, that's where a separate
> service might be useful - though it's not very hard to come up with a
> generated POM file to push on your end either - if you do an upload on the
> Archiva form you'll see the format it expects.
>
> - Brett
>
> --
> Brett Porter
> [email protected]
> http://brettporter.wordpress.com/
> http://au.linkedin.com/in/brettporter
>
>
>
>
>
> This message and any attachment (the "message") is intended solely for the
> addressees and is confidential. If you receive this message by mistake,
> please delete it and notify the sender immediately. Any use not in accordance
> with its purpose, any out-spread or disclosure, either as a whole or
> partially, is prohibited except with formal approval. Internet cannot
> guarantee the integrity of this message, therefore Talend will not be liable
> for the message if modified.
>
>
--
Olivier Lamy
Talend : http://talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy