You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Stefan Fromm <sf...@inf.tu-dresden.de> on 2004/09/06 11:41:44 UTC
Re: Slide Revision Management + Revision History
Hello Gbenga,
sorry that I answer so late. Didn't check the Slide mails :(
I tried to reproduce the error but with minor success. How do you create versions - via Slide API or with a WebDAV client?
Have you had a look into your repository directories (by default store/content, store/metadata and store/sequence in the current execution directory)? You can read the XML files there. If you configured ExtendedStore in Domain.xml then you should find a file called store/metadata/files/yourpath/yourfile.def.xml. If there is only one revision inside then maybe the problem is that you create revisions via WebDAV and try to read them via Slide API?!
I've attached a working example for versioning which uses the Slide API with the appropriate Domain.xml. Note that settings regarding versioning in Domain.xml don't affect my code since it is hacked into the WebDAV layer.
Best regards
Stefan
Am Thu, 2 Sep 2004 07:19:20 -0700 (PDT) schrieb Gbenga Bello <rg...@yahoo.com>:
> Hello Stefan,
>
> Thanks for your contribution the other time
>
> I tried the code snippet but I get only the latest revision.
> For instance I had revisions 1.0,1.1,1.2
>
> It brings out only 1.2 as the lis of revision numbers available for that resource.
> What is it that is the problem
>
> Pls I will appreciate your reply today.
>
> Thanks in advance
>
> Gbenga
>
> Stefan Fromm <sf...@inf.tu-dresden.de> wrote:
> Hello Gbenga,
>
>>> 1) I want to able to view the list of all previous revision number
>>> [revision history] for a specific document resource thru the Java
>>> application. Which class of the slide native api helps to achieve
>>> this. I have searched the api doc but couldn't get something
>>> meaningful yet. Pls I need your input
>
> Note that there might occur problems with the versions because functionality
> is implemented inconsistently in the helper-layer and WebDAV-layer as mentioned
> in these messages:
>
> http://www.mail-archive.com/slide-user@jakarta.apache.org/msg06761.html
> http://www.mail-archive.com/slide-user@jakarta.apache.org/msg03708.html
> http://www.mail-archive.com/slide-dev@jakarta.apache.org/msg10230.html
>
> So it depends on if you access versions with Slide-API or via WebDAV.
>
> For Slide-API it should work like this:
>
> NamespaceAccessToken nsat =
> Domain.accessNamespace(new SecurityToken(""), Domain.getDefaultNamespace());
> SlideToken token = new SlideTokenImpl(new CredentialsToken(slideusername));
> Content contentHelper = nsat.getContentHelper();
> NodeRevisionDescriptors revisions = contentHelper.retrieve(token, "/files/test.txt");
> for ( Enumeration e = revisions.enumerateRevisionNumbers(); e.hasMoreElements(); )
> {
> NodeRevisionNumber nrno = (NodeRevisionNumber)e.nextElement();
> // get metadata
> NodeRevisionDescriptor nrd = contentHelper.retrieve(token, revisions, nrno);
> // get content
> NodeRevisionContent nrc = contentHelper.retrieve(token, revisions, nrd);
> }
>
> For WebDAV there is defined the DAV:version-tree report in RFC3253
> (DeltaV Specification). See http://www.ietf.org/rfc.html
>
>
>
>>> 2) I want to be able to request to view content for a specific
>>> revision (from the revision history) of a document . Take for
>>> instance, if there are the following revision nos for a document
>>> resource; 1.0,1.1,1.2,1.3,1.4 where 1.4 is the latest document
>>> revision number. I should be able to programmatically and randomly
>>> pool revision 1.2 to see what is in there.
>
> NodeRevisionNumber provides some constructors where you can provide a
> version number in different ways. In connection with the above shown
> code for Helper-API you should be able to do it.
>
> For WebDAV it could be the additional Label-Header in the GET-request
> where you can provide a version label. Since version numbers are just
> server-side generated version labels this could work.
>
>
>
>>> 3) You may have observed the way slide handles numbering of revisions
>>> for a document; that instead of increamenting the whole number part of
>>> the revision no, it rather increaments the decimal part of the number.
>>> Take for instance, if previous revision number is 1.0. When Slide does
>>> the next revision, it assigns the number, 1.1
>>> At what point will it move the version numbering to 2.0?
>
> To me it seems there is never created a next major version. Good points
> to have a look at are
>
> org.apache.slide.content.ContentImpl and
> org.apache.slide.webdav.util.VersioningHelper
>
> Regards
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
Re: Slide Revision Management + Revision History
Posted by Stefan Fromm <sf...@inf.tu-dresden.de>.
Didn't work 2nd time. So here is the code as text:
import java.io.ByteArrayInputStream;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.authenticate.SecurityToken;
import org.apache.slide.common.Domain;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.SlideTokenImpl;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionContent;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.content.NodeRevisionNumber;
import org.apache.slide.security.Security;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.Structure;
import org.apache.slide.structure.SubjectNode;
public class SlideVersionsTest {
private NamespaceAccessToken namespace;
private SlideToken token;
private Structure structure;
private Content content;
private Security security;
private static final String AUTHORS_XML =
"<authors>" +
"<author>" +
"<firstname>Stefan</firstname>" +
"<lastname>Fromm</lastname>" +
"</author>" +
"</authors>";
public SlideVersionsTest(String slideuser) {
namespace = Domain.accessNamespace(new SecurityToken(""), Domain.getDefaultNamespace());
token = new SlideTokenImpl(new CredentialsToken(slideuser));
token.setForceStoreEnlistment(true);
structure = namespace.getStructureHelper();
content = namespace.getContentHelper();
security = namespace.getSecurityHelper();
}
private String computeEtag(String uri, NodeRevisionDescriptor nrd)
throws Exception {
String result =
System.currentTimeMillis()
+ "_"
+ uri.hashCode()
+ "_"
+ nrd.getLastModified()
+ "_"
+ nrd.getContentLength();
result = new String(DigestUtils.md5Hex(result));
return result;
}
public void put(String uri, String data) throws Exception {
try {
namespace.begin();
try {
byte[] dataBytes = data.getBytes();
ByteArrayInputStream fis = new ByteArrayInputStream(dataBytes);
try
{
NodeRevisionNumber lastRevision = null;
try {
structure.retrieve(token, uri);
lastRevision = content.retrieve(token, uri).getLatestRevision();
System.out.println("Found resource with latest revision number " + (lastRevision == null?"none":lastRevision.toString()));
}
catch (ObjectNotFoundException e) {
SubjectNode subject = new SubjectNode();
// create object
structure.create(token, subject, uri);
}
if ( lastRevision != null )
lastRevision = new NodeRevisionNumber(lastRevision, false);
else
lastRevision = new NodeRevisionNumber();
// create node revision descriptor
NodeRevisionDescriptor revisionDescriptor = new NodeRevisionDescriptor(lastRevision, NodeRevisionDescriptors.MAIN_BRANCH, new Vector(), new Hashtable());
revisionDescriptor.setResourceType("");
revisionDescriptor.setSource("");
revisionDescriptor.setContentLanguage("en");
revisionDescriptor.setLastModified(new Date());
revisionDescriptor.setETag(computeEtag(uri, revisionDescriptor));
revisionDescriptor.setCreationDate(new Date());
// Owner
String creator = ((SubjectNode)security.getPrincipal(token)).getPath().lastSegment();
revisionDescriptor.setCreationUser(creator);
revisionDescriptor.setOwner(creator);
String contentType = "text/plain";
revisionDescriptor.setContentType(contentType);
// properties
NodeProperty newProperty = new NodeProperty("authors", AUTHORS_XML, "stefan.fromm:");
revisionDescriptor.setProperty(newProperty);
// create content
NodeRevisionContent revisionContent = new NodeRevisionContent();
revisionContent.setContent(fis);
// important to create NodeRevisionDescriptors separately to be able to tell it to use versioning
if ( lastRevision.toString().equals("1.0") )
content.create(token, uri, true);
content.create(token, uri, revisionDescriptor, revisionContent);
}
finally
{
fis.close();
}
namespace.commit();
}
catch (Exception e ) {
namespace.rollback();
throw e;
}
}
catch (OutOfMemoryError e)
{
throw new RuntimeException(e);
}
}
public NodeRevisionDescriptors getVersions(String uri) throws Exception {
namespace.begin();
try {
return content.retrieve(token, uri);
}
finally {
namespace.rollback();
}
}
public static void main(String[] args) throws Exception {
SlideVersionsTest test = new SlideVersionsTest("root");
test.put("/files/test.txt", "Content 1");
test.put("/files/test.txt", "Content 2");
test.put("/files/test.txt", "Content 3");
NodeRevisionDescriptors revisions = test.getVersions("/files/test.txt");
for ( Enumeration e = revisions.enumerateRevisionNumbers(); e.hasMoreElements(); ) {
NodeRevisionNumber number = (NodeRevisionNumber)e.nextElement();
System.out.println("number = " + number.toString());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
Re: Slide Revision Management + Revision History
Posted by Stefan Fromm <sf...@inf.tu-dresden.de>.
Hm, where was the Java code? I send it again.
Am Mon, 06 Sep 2004 11:41:44 +0200 schrieb Stefan Fromm <sf...@inf.tu-dresden.de>:
> Hello Gbenga,
>
> sorry that I answer so late. Didn't check the Slide mails :(
>
> I tried to reproduce the error but with minor success. How do you create versions - via Slide API or with a WebDAV client?
>
> Have you had a look into your repository directories (by default store/content, store/metadata and store/sequence in the current execution directory)? You can read the XML files there. If you configured ExtendedStore in Domain.xml then you should find a file called store/metadata/files/yourpath/yourfile.def.xml. If there is only one revision inside then maybe the problem is that you create revisions via WebDAV and try to read them via Slide API?!
>
> I've attached a working example for versioning which uses the Slide API with the appropriate Domain.xml. Note that settings regarding versioning in Domain.xml don't affect my code since it is hacked into the WebDAV layer.
>
> Best regards
> Stefan
>
>
>
> Am Thu, 2 Sep 2004 07:19:20 -0700 (PDT) schrieb Gbenga Bello <rg...@yahoo.com>:
>
>> Hello Stefan,
>>
>> Thanks for your contribution the other time
>>
>> I tried the code snippet but I get only the latest revision.
>> For instance I had revisions 1.0,1.1,1.2
>>
>> It brings out only 1.2 as the lis of revision numbers available for that resource.
>> What is it that is the problem
>>
>> Pls I will appreciate your reply today.
>>
>> Thanks in advance
>>
>> Gbenga
>>
>> Stefan Fromm <sf...@inf.tu-dresden.de> wrote:
>> Hello Gbenga,
>>
>>>> 1) I want to able to view the list of all previous revision number
>>>> [revision history] for a specific document resource thru the Java
>>>> application. Which class of the slide native api helps to achieve
>>>> this. I have searched the api doc but couldn't get something
>>>> meaningful yet. Pls I need your input
>>
>> Note that there might occur problems with the versions because functionality
>> is implemented inconsistently in the helper-layer and WebDAV-layer as mentioned
>> in these messages:
>>
>> http://www.mail-archive.com/slide-user@jakarta.apache.org/msg06761.html
>> http://www.mail-archive.com/slide-user@jakarta.apache.org/msg03708.html
>> http://www.mail-archive.com/slide-dev@jakarta.apache.org/msg10230.html
>>
>> So it depends on if you access versions with Slide-API or via WebDAV.
>>
>> For Slide-API it should work like this:
>>
>> NamespaceAccessToken nsat =
>> Domain.accessNamespace(new SecurityToken(""), Domain.getDefaultNamespace());
>> SlideToken token = new SlideTokenImpl(new CredentialsToken(slideusername));
>> Content contentHelper = nsat.getContentHelper();
>> NodeRevisionDescriptors revisions = contentHelper.retrieve(token, "/files/test.txt");
>> for ( Enumeration e = revisions.enumerateRevisionNumbers(); e.hasMoreElements(); )
>> {
>> NodeRevisionNumber nrno = (NodeRevisionNumber)e.nextElement();
>> // get metadata
>> NodeRevisionDescriptor nrd = contentHelper.retrieve(token, revisions, nrno);
>> // get content
>> NodeRevisionContent nrc = contentHelper.retrieve(token, revisions, nrd);
>> }
>>
>> For WebDAV there is defined the DAV:version-tree report in RFC3253
>> (DeltaV Specification). See http://www.ietf.org/rfc.html
>>
>>
>>
>>>> 2) I want to be able to request to view content for a specific
>>>> revision (from the revision history) of a document . Take for
>>>> instance, if there are the following revision nos for a document
>>>> resource; 1.0,1.1,1.2,1.3,1.4 where 1.4 is the latest document
>>>> revision number. I should be able to programmatically and randomly
>>>> pool revision 1.2 to see what is in there.
>>
>> NodeRevisionNumber provides some constructors where you can provide a
>> version number in different ways. In connection with the above shown
>> code for Helper-API you should be able to do it.
>>
>> For WebDAV it could be the additional Label-Header in the GET-request
>> where you can provide a version label. Since version numbers are just
>> server-side generated version labels this could work.
>>
>>
>>
>>>> 3) You may have observed the way slide handles numbering of revisions
>>>> for a document; that instead of increamenting the whole number part of
>>>> the revision no, it rather increaments the decimal part of the number.
>>>> Take for instance, if previous revision number is 1.0. When Slide does
>>>> the next revision, it assigns the number, 1.1
>>>> At what point will it move the version numbering to 2.0?
>>
>> To me it seems there is never created a next major version. Good points
>> to have a look at are
>>
>> org.apache.slide.content.ContentImpl and
>> org.apache.slide.webdav.util.VersioningHelper
>>
>> Regards
>> Stefan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>>
>>
>>
>> ---------------------------------
>> Do you Yahoo!?
>> Read only the mail you want - Yahoo! Mail SpamGuard.
>
Re: URLGetMethod.executeMethod is hanging under multi threaded environment
Posted by "Koundinya (Sudhakar Chavali)" <su...@yahoo.com>.
Thankyou Ingo,
this solved my problem.
if (manager == null) {
manager = new MultiThreadedHttpConnectionManager();
manager.setMaxTotalConnections(30);
manager.setMaxConnectionsPerHost(10);
}
client = new HttpClient(manager);
--- Ingo Brunberg <ib...@fiz-chemie.de> wrote:
> > This is how I am getting the Client Instance.
> >
> > org.apache.commons.httpclient.HttpURL url = (org.apache.commons.
> > httpclient.HttpURL) getURL(path + "/" + user);
> >
> > org.prithvi.docparser.microsoft.msexchange.apache.OwaWebdavResource
> > webDavResourceFile = getWebResource(
> > url);
> >
> > //get the client session
> > client = webDavResourceFile.retrieveSessionInstance();
> >
> > Is this instance comes from SimpleConnectionManager ??
>
> Simple answer, yes.
>
> Two notes:
> - Don't use UrlGetMethod. It's deprecated. Just use GetMethod.
> - As a first solution try to surround the following two lines of your
> code given below with a synchronized(client) {} block:
>
> int status = client.executeMethod(getMethod);
> byte attachmentBytes[] = getMethod.getResponseBody();
>
> Regards,
> Ingo
>
>
> >
> > thanks for trying to helping me
> >
> > Sudhakar
> >
> >
> >
> >
> >
> > --- Ingo Brunberg <ib...@fiz-chemie.de> wrote:
> >
> > > First, this is not quite the right list for asking this question. It
> > > would have better been asked on the commons-httpclient-dev list.
> > >
> > > But anyway, your code snippet does not show how you create the
> > > HttpClient instance that you use. Be aware that by default you get one
> > > that uses the so called SimpleConnectionManager. You cannot use that
> > > one to access the same connection concurrently from more than one
> > > thread. If you want HttpClient to manage the connections for you in a
> > > multithreaded environment, you should use the
> > > MutliThreadedConnectionManager.
> > >
> > > Ingo
> > >
> > > > Hello Guys,
> > > >
> > > > Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
> > > >
> > > > Please see the folloiwng code. I am trying to download the mails of MS Exchange Server
> using
> > > > URLGetMethod.executeMethod. But when execution pointer comes to the thread area
> > > > (URLGetMethod.executemethod),
> > > >
> > > > URLGetMethod.executemethod is not coming out of it's loop. Could you please explain what
> is
> > > the
> > > > problem with this code??
> > > >
> > > >
> > > > class SaveAttachmentThread
> > > > extends Thread
> > > > implements Runnable {
> > > > static int threadCount = 0;
> > > > String uri = "";
> > > > String strAttachmentName = "";
> > > > private org.apache.commons.httpclient.HttpClient client = null;
> > > > org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
> > > >
> > > > public SaveAttachmentThread(String uri, String strAttachmentName,
> > > > org.apache.commons.httpclient.HttpClient client) {
> > > > this.uri = uri;
> > > > this.strAttachmentName = strAttachmentName;
> > > > this.client = client;
> > > >
> > > > }
> > > >
> > > > public SaveAttachmentThread(org.apache.commons.httpclient.methods.
> > > > UrlGetMethod _getMethod, String attachment) {
> > > > attachmentMethod = _getMethod;
> > > > this.strAttachmentName = attachment;
> > > > }
> > > >
> > > > public void run() {
> > > > //strAttachmentName = URLDecoder.decode(strAttachmentName);
> > > > System.err.println("Saved to " + strAttachmentName);
> > > > System.err.println("URL :" + uri);
> > > > try {
> > > >
> > > >
> > > > System.err.println("Saving the URL :" + strAttachmentName);
> > > > org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
> > > > apache.commons.httpclient.methods.UrlGetMethod(uri);
> > > > int status = client.executeMethod(getMethod);
> > > >
> > > >
> > > > byte attachmentBytes[] = getMethod.getResponseBody();
> > > > FileOutputStream fout = new FileOutputStream(strAttachmentName);
> > > > fout.write(attachmentBytes);
> > > > fout.close();
> > > > fout = null;
> > > >
> > > > threadCount++;
> > > > System.err.println(threadCount);
> > > >
> > > > }
> > > > catch (Throwable e) {
> > > > System.err.println("Error raised while saving the URI : " +
> > > > strAttachmentName);
> > > > e.printStackTrace();
> > > > }
> > > > }
> > > > }
> > > >
> > > >
> > > > Thanks
> > > > Sudhakar
> > > >
> > > >
> > > >
> > > > =====
> > > > "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
> > > >
> > > > "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
> > > >
> > > > "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw
> (1856-1950)
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Do you Yahoo!?
> > > > New and Improved Yahoo! Mail - Send 10MB messages!
> > > > http://promotions.yahoo.com/new_mail
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: slide-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > =====
> > "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
> >
> > "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
> >
> > "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other providers!
> > http://promotions.yahoo.com/new_mail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>
>
=====
"No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
"Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
"It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
Re: URLGetMethod.executeMethod is hanging under multi threaded environment
Posted by Ingo Brunberg <ib...@fiz-chemie.de>.
> This is how I am getting the Client Instance.
>
> org.apache.commons.httpclient.HttpURL url = (org.apache.commons.
> httpclient.HttpURL) getURL(path + "/" + user);
>
> org.prithvi.docparser.microsoft.msexchange.apache.OwaWebdavResource
> webDavResourceFile = getWebResource(
> url);
>
> //get the client session
> client = webDavResourceFile.retrieveSessionInstance();
>
> Is this instance comes from SimpleConnectionManager ??
Simple answer, yes.
Two notes:
- Don't use UrlGetMethod. It's deprecated. Just use GetMethod.
- As a first solution try to surround the following two lines of your
code given below with a synchronized(client) {} block:
int status = client.executeMethod(getMethod);
byte attachmentBytes[] = getMethod.getResponseBody();
Regards,
Ingo
>
> thanks for trying to helping me
>
> Sudhakar
>
>
>
>
>
> --- Ingo Brunberg <ib...@fiz-chemie.de> wrote:
>
> > First, this is not quite the right list for asking this question. It
> > would have better been asked on the commons-httpclient-dev list.
> >
> > But anyway, your code snippet does not show how you create the
> > HttpClient instance that you use. Be aware that by default you get one
> > that uses the so called SimpleConnectionManager. You cannot use that
> > one to access the same connection concurrently from more than one
> > thread. If you want HttpClient to manage the connections for you in a
> > multithreaded environment, you should use the
> > MutliThreadedConnectionManager.
> >
> > Ingo
> >
> > > Hello Guys,
> > >
> > > Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
> > >
> > > Please see the folloiwng code. I am trying to download the mails of MS Exchange Server using
> > > URLGetMethod.executeMethod. But when execution pointer comes to the thread area
> > > (URLGetMethod.executemethod),
> > >
> > > URLGetMethod.executemethod is not coming out of it's loop. Could you please explain what is
> > the
> > > problem with this code??
> > >
> > >
> > > class SaveAttachmentThread
> > > extends Thread
> > > implements Runnable {
> > > static int threadCount = 0;
> > > String uri = "";
> > > String strAttachmentName = "";
> > > private org.apache.commons.httpclient.HttpClient client = null;
> > > org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
> > >
> > > public SaveAttachmentThread(String uri, String strAttachmentName,
> > > org.apache.commons.httpclient.HttpClient client) {
> > > this.uri = uri;
> > > this.strAttachmentName = strAttachmentName;
> > > this.client = client;
> > >
> > > }
> > >
> > > public SaveAttachmentThread(org.apache.commons.httpclient.methods.
> > > UrlGetMethod _getMethod, String attachment) {
> > > attachmentMethod = _getMethod;
> > > this.strAttachmentName = attachment;
> > > }
> > >
> > > public void run() {
> > > //strAttachmentName = URLDecoder.decode(strAttachmentName);
> > > System.err.println("Saved to " + strAttachmentName);
> > > System.err.println("URL :" + uri);
> > > try {
> > >
> > >
> > > System.err.println("Saving the URL :" + strAttachmentName);
> > > org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
> > > apache.commons.httpclient.methods.UrlGetMethod(uri);
> > > int status = client.executeMethod(getMethod);
> > >
> > >
> > > byte attachmentBytes[] = getMethod.getResponseBody();
> > > FileOutputStream fout = new FileOutputStream(strAttachmentName);
> > > fout.write(attachmentBytes);
> > > fout.close();
> > > fout = null;
> > >
> > > threadCount++;
> > > System.err.println(threadCount);
> > >
> > > }
> > > catch (Throwable e) {
> > > System.err.println("Error raised while saving the URI : " +
> > > strAttachmentName);
> > > e.printStackTrace();
> > > }
> > > }
> > > }
> > >
> > >
> > > Thanks
> > > Sudhakar
> > >
> > >
> > >
> > > =====
> > > "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
> > >
> > > "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
> > >
> > > "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
> > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > New and Improved Yahoo! Mail - Send 10MB messages!
> > > http://promotions.yahoo.com/new_mail
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: slide-user-help@jakarta.apache.org
> >
> >
>
>
> =====
> "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
>
> "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
>
> "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
Re: URLGetMethod.executeMethod is hanging under multi threaded environment
Posted by "Koundinya (Sudhakar Chavali)" <su...@yahoo.com>.
This is how I am getting the Client Instance.
org.apache.commons.httpclient.HttpURL url = (org.apache.commons.
httpclient.HttpURL) getURL(path + "/" + user);
org.prithvi.docparser.microsoft.msexchange.apache.OwaWebdavResource
webDavResourceFile = getWebResource(
url);
//get the client session
client = webDavResourceFile.retrieveSessionInstance();
Is this instance comes from SimpleConnectionManager ??
thanks for trying to helping me
Sudhakar
--- Ingo Brunberg <ib...@fiz-chemie.de> wrote:
> First, this is not quite the right list for asking this question. It
> would have better been asked on the commons-httpclient-dev list.
>
> But anyway, your code snippet does not show how you create the
> HttpClient instance that you use. Be aware that by default you get one
> that uses the so called SimpleConnectionManager. You cannot use that
> one to access the same connection concurrently from more than one
> thread. If you want HttpClient to manage the connections for you in a
> multithreaded environment, you should use the
> MutliThreadedConnectionManager.
>
> Ingo
>
> > Hello Guys,
> >
> > Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
> >
> > Please see the folloiwng code. I am trying to download the mails of MS Exchange Server using
> > URLGetMethod.executeMethod. But when execution pointer comes to the thread area
> > (URLGetMethod.executemethod),
> >
> > URLGetMethod.executemethod is not coming out of it's loop. Could you please explain what is
> the
> > problem with this code??
> >
> >
> > class SaveAttachmentThread
> > extends Thread
> > implements Runnable {
> > static int threadCount = 0;
> > String uri = "";
> > String strAttachmentName = "";
> > private org.apache.commons.httpclient.HttpClient client = null;
> > org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
> >
> > public SaveAttachmentThread(String uri, String strAttachmentName,
> > org.apache.commons.httpclient.HttpClient client) {
> > this.uri = uri;
> > this.strAttachmentName = strAttachmentName;
> > this.client = client;
> >
> > }
> >
> > public SaveAttachmentThread(org.apache.commons.httpclient.methods.
> > UrlGetMethod _getMethod, String attachment) {
> > attachmentMethod = _getMethod;
> > this.strAttachmentName = attachment;
> > }
> >
> > public void run() {
> > //strAttachmentName = URLDecoder.decode(strAttachmentName);
> > System.err.println("Saved to " + strAttachmentName);
> > System.err.println("URL :" + uri);
> > try {
> >
> >
> > System.err.println("Saving the URL :" + strAttachmentName);
> > org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
> > apache.commons.httpclient.methods.UrlGetMethod(uri);
> > int status = client.executeMethod(getMethod);
> >
> >
> > byte attachmentBytes[] = getMethod.getResponseBody();
> > FileOutputStream fout = new FileOutputStream(strAttachmentName);
> > fout.write(attachmentBytes);
> > fout.close();
> > fout = null;
> >
> > threadCount++;
> > System.err.println(threadCount);
> >
> > }
> > catch (Throwable e) {
> > System.err.println("Error raised while saving the URI : " +
> > strAttachmentName);
> > e.printStackTrace();
> > }
> > }
> > }
> >
> >
> > Thanks
> > Sudhakar
> >
> >
> >
> > =====
> > "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
> >
> > "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
> >
> > "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > New and Improved Yahoo! Mail - Send 10MB messages!
> > http://promotions.yahoo.com/new_mail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>
>
=====
"No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
"Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
"It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
Re: URLGetMethod.executeMethod is hanging under multi threaded environment
Posted by Ingo Brunberg <ib...@fiz-chemie.de>.
First, this is not quite the right list for asking this question. It
would have better been asked on the commons-httpclient-dev list.
But anyway, your code snippet does not show how you create the
HttpClient instance that you use. Be aware that by default you get one
that uses the so called SimpleConnectionManager. You cannot use that
one to access the same connection concurrently from more than one
thread. If you want HttpClient to manage the connections for you in a
multithreaded environment, you should use the
MutliThreadedConnectionManager.
Ingo
> Hello Guys,
>
> Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
>
> Please see the folloiwng code. I am trying to download the mails of MS Exchange Server using
> URLGetMethod.executeMethod. But when execution pointer comes to the thread area
> (URLGetMethod.executemethod),
>
> URLGetMethod.executemethod is not coming out of it's loop. Could you please explain what is the
> problem with this code??
>
>
> class SaveAttachmentThread
> extends Thread
> implements Runnable {
> static int threadCount = 0;
> String uri = "";
> String strAttachmentName = "";
> private org.apache.commons.httpclient.HttpClient client = null;
> org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
>
> public SaveAttachmentThread(String uri, String strAttachmentName,
> org.apache.commons.httpclient.HttpClient client) {
> this.uri = uri;
> this.strAttachmentName = strAttachmentName;
> this.client = client;
>
> }
>
> public SaveAttachmentThread(org.apache.commons.httpclient.methods.
> UrlGetMethod _getMethod, String attachment) {
> attachmentMethod = _getMethod;
> this.strAttachmentName = attachment;
> }
>
> public void run() {
> //strAttachmentName = URLDecoder.decode(strAttachmentName);
> System.err.println("Saved to " + strAttachmentName);
> System.err.println("URL :" + uri);
> try {
>
>
> System.err.println("Saving the URL :" + strAttachmentName);
> org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
> apache.commons.httpclient.methods.UrlGetMethod(uri);
> int status = client.executeMethod(getMethod);
>
>
> byte attachmentBytes[] = getMethod.getResponseBody();
> FileOutputStream fout = new FileOutputStream(strAttachmentName);
> fout.write(attachmentBytes);
> fout.close();
> fout = null;
>
> threadCount++;
> System.err.println(threadCount);
>
> }
> catch (Throwable e) {
> System.err.println("Error raised while saving the URI : " +
> strAttachmentName);
> e.printStackTrace();
> }
> }
> }
>
>
> Thanks
> Sudhakar
>
>
>
> =====
> "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
>
> "Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
>
> "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
>
>
>
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
URLGetMethod.executeMethod is hanging under multi threaded environment
Posted by "Koundinya (Sudhakar Chavali)" <su...@yahoo.com>.
Hello Guys,
Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
Please see the folloiwng code. I am trying to download the mails of MS Exchange Server using
URLGetMethod.executeMethod. But when execution pointer comes to the thread area
(URLGetMethod.executemethod),
URLGetMethod.executemethod is not coming out of it's loop. Could you please explain what is the
problem with this code??
class SaveAttachmentThread
extends Thread
implements Runnable {
static int threadCount = 0;
String uri = "";
String strAttachmentName = "";
private org.apache.commons.httpclient.HttpClient client = null;
org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
public SaveAttachmentThread(String uri, String strAttachmentName,
org.apache.commons.httpclient.HttpClient client) {
this.uri = uri;
this.strAttachmentName = strAttachmentName;
this.client = client;
}
public SaveAttachmentThread(org.apache.commons.httpclient.methods.
UrlGetMethod _getMethod, String attachment) {
attachmentMethod = _getMethod;
this.strAttachmentName = attachment;
}
public void run() {
//strAttachmentName = URLDecoder.decode(strAttachmentName);
System.err.println("Saved to " + strAttachmentName);
System.err.println("URL :" + uri);
try {
System.err.println("Saving the URL :" + strAttachmentName);
org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
apache.commons.httpclient.methods.UrlGetMethod(uri);
int status = client.executeMethod(getMethod);
byte attachmentBytes[] = getMethod.getResponseBody();
FileOutputStream fout = new FileOutputStream(strAttachmentName);
fout.write(attachmentBytes);
fout.close();
fout = null;
threadCount++;
System.err.println(threadCount);
}
catch (Throwable e) {
System.err.println("Error raised while saving the URI : " +
strAttachmentName);
e.printStackTrace();
}
}
}
Thanks
Sudhakar
=====
"No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925)
"Make everything as simple as possible, but not simpler."- Albert Einstein (1879-1955)
"It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw (1856-1950)
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org