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 Brant Levinson <wi...@hotmail.com> on 2004/07/02 07:17:46 UTC

Can't use Put Method in command line app

Hello All - I've hit a road block and needs some help... I'm trying to use the put method from the command line client. I made sure that root is in the the root group, I logged in with root, I can see all of the files but can not use the "put method".

Here is my console:
[LOCALHOST] /storage/files/ $ put notes3.txt
put notes3.txt null
Uploading  'notes3.txt' to '/storage/files/': failed.
Forbidden (403)
[LOCALHOST] /storage/files/ $

I'm able to use the write option in DAVExplorer to put the file in there, but I need to use it in the command line.

When I do it by DAVExplorer the log file shows this:
Thread-15, 01-Jul-2004 22:09:04, root, PUT, 201 "Created", 521 ms, /files/test.doc

When I run the put test.doc from the command line, the log file shows this:

Thread-14, 01-Jul-2004 22:14:21, root, PUT, 403 "Forbidden", 10 ms, /files/

The ACL Info is this:
Subject            Action                Inheritable     Deny
/roles/root        /actions/write        true            false

      ACL Info 
      Subject Action Inheritable Deny 
      unauthenticated all true false 
      /roles/user /actions/write true false 
      owner /actions/read-acl true false 
      /roles/root /actions/write true false 
        
      Filename Size Last Modified 
         new/   Wed, 30 Jun 2004 10:47:40 GMT 


Urgent: Exception raised on Https Access

Posted by "Koundinya (Sudhakar Chavali)" <su...@yahoo.com>.
I got the WebdavException when I am trying to authenticate to the MS Exchange 2003 Server which is
configured on Https with OWS.
while accessing the following URL https://192.12.0.38/Exchnage, it should redirect to
https://192.12.0.38/exchweb/bin/auth/owalogon.asp?url=https://192.12.0.38/Exchange&reason=0 for
further authentication. But it is not happening.

Please Help me



Here is the Exception Stack Trace
Exception raised at processMailboxFolders
org.apache.webdav.lib.WebdavException
        at org.apache.webdav.lib.WebdavFile.listFiles(WebdavFile.java:379)
        at org.apache.webdav.lib.WebdavFile.listFiles(WebdavFile.java:358)
        at wefTest.processMailboxFolders(wefTest.java:143)
        at wefTest.<init>(wefTest.java:112)
        at wefTest.main(wefTest.java:234)






And here is the Sample Code

import javax.xml.parsers.*; //PRITHVI
import org.apache.webdav.lib.*;
import java.net.*;
import java.io.*;
import org.apache.commons.httpclient.HttpClient;
import org.apache.util.WebdavStatus;
import org.apache.webdav.lib.methods.*;
import org.apache.webdav.lib.properties.*;
import org.apache.commons.httpclient.HttpsURL;
import org.apache.webdav.lib.WebdavFile;




public class wefTest
{

	protected org.apache.commons.httpclient.HttpsURL url;
	
	protected org.apache.commons.httpclient.HttpsURL url99;
	
	protected org.apache.webdav.lib.WebdavResource wdfr;

	protected org.apache.webdav.lib.WebdavFile wdfile;
	//protected WebdavFile wdfile;

	protected String username;

	protected String password;

	protected String hostname;

	protected int port;

	protected String path;

	protected String mailbox;

	protected String targetPath;


	// Constructor

	public wefTest(String username, String password, String hostname, int port, String path, String
targetPath) throws Exception
	{
		this.username=username;
		this.password=password;
		this.hostname=hostname;
		this.port=port;
		this.path=path;
		this.mailbox=null;
		this.targetPath=targetPath;

		java.io.File targetFolder= new java.io.File(targetPath);

		if (!targetFolder.exists())
		{
			targetFolder.mkdir();
		}


		java.util.Vector names=new java.util.Vector();
		names.add("Administrator");

		System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
		System.setProperty("javax.net.ssl.trustStore","comp38.jks");
		
		//System.setProperty("javax.net.ssl.trustStorePassword", "irah"); 


		for(java.util.Enumeration enum=names.elements();enum.hasMoreElements();)
		{
			this.mailbox=(String)enum.nextElement();

			// Initializing target parameters
			url = new org.apache.commons.httpclient.HttpsURL(username,password,hostname, port,
path+"/"+mailbox);
			// Initializing webdave file object
			wdfile= new org.apache.webdav.lib.WebdavFile(url);

			processMailboxFolders();
		}
	}



	protected void processMailboxFolders() throws Exception
	{

		System.out.println("Processing MailBox : "+mailbox+"  ....... \n");

		java.io.File mailFolder= new java.io.File(targetPath+"/"+mailbox);

		if (!mailFolder.exists())
		{
			mailFolder.mkdir();
		}

		// Fetch all folder list

		try
		{

			java.io.File folders[] = wdfile.listFiles();

			for (int i=0;i<folders.length;i++ )
			{
				// process all objects present in this folder
					System.out.println("Processing Folder : "+folders[i].getName()+"  ... \n");
					//if(folders[i].getName().indexOf("Inbox")==-1)
					//	continue;
					processFolder(folders[i].getName());
			}

		}
		catch(Exception ee) // mailbox not created
		{
			System.out.println("Exception raised at processMailboxFolders ");
			ee.printStackTrace();
			//throw ee;
		}
	}

	protected void processFolder(String folder) throws Exception
	{
			
		//System.out.println("\r\n\r\n-------------- Folder : "+folder+"--------------");

		System.err.println(username+" "+password+" "+hostname+" "+port+" "+path+"/"+mailbox+"/"+
java.net.URLDecoder.decode(folder));
		
		org.apache.commons.httpclient.HttpsURL urlMailboxFolder = new
org.apache.commons.httpclient.HttpsURL(username,password,hostname,port,path+"/"+mailbox+"/"+
java.net.URLDecoder.decode(folder)); 

		org.apache.webdav.lib.WebdavResource wdfr= new
org.apache.webdav.lib.WebdavResource(urlMailboxFolder);


		org.apache.commons.httpclient.HttpClient client=wdfr.retrieveSessionInstance();
		java.util.Vector properties= new java.util.Vector();
		properties.addElement("DAV:displayname");

		PropFindMethod method = new
PropFindMethod(urlMailboxFolder.toString(),Integer.MAX_VALUE,properties.elements());//Integer.MAX_VALUE

			int status = client.executeMethod(method);
			java.util.Vector results = new java.util.Vector();
			java.util.Enumeration responses = method.getResponses();
			ResponseEntity response =null; 
			while (responses.hasMoreElements()) 
			{
					response = (ResponseEntity) responses.nextElement();

						java.util.Enumeration properties1 = method.getResponseProperties(response.getHref());
//response.getProperties();
			            while (properties1.hasMoreElements()) {
					    Property property = (Property) properties1.nextElement();
					    }

			}




		org.apache.webdav.lib.WebdavResource resourceList[]= wdfr.listWebdavResources();

		String rlist[]=wdfr.list();

		int mailCount=0;
		for(int i=0;i<resourceList.length;i++)
		{
			if(resourceList[i].isCollection())
			{
				System.out.println("Folder: "+java.net.URLDecoder.decode(resourceList[i].getName()));
				processFolder(folder+"/"+java.net.URLDecoder.decode(resourceList[i].getName()));
			}
			else
			{
				System.out.println(java.net.URLDecoder.decode(resourceList[i].getName()));
			
fetchMail(java.net.URLDecoder.decode(folder),java.net.URLDecoder.decode(resourceList[i].getName()));
				mailCount++;
			}
		}


		System.out.println("-------------- End of Folder: "+folder+" No of Mails:
"+mailCount+"--------------\r\n");
	}



	public static void main(String args[]) throws Exception
	{
		
		wefTest test= new wefTest("administrator","comp38","192.12.0.38",443,"/Exchange","c:/aaa");
		
		System.out.println("\nPrithvi Solutions");
	}


	protected void fetchMail(String folder, String filename) throws Exception
	{
		
			org.apache.commons.httpclient.HttpsURL urlEML = new
org.apache.commons.httpclient.HttpsURL(username,password,hostname, port,path+"/"+mailbox+"/"+
folder+"/"+filename ); 
			System.out.println(urlEML);
			org.apache.webdav.lib.WebdavResource wdfr= new org.apache.webdav.lib.WebdavResource(urlEML);

			java.io.File mailFolder= new java.io.File(targetPath+"/"+mailbox+"/"+folder);
			
			if (!mailFolder.exists())
			{
				mailFolder.mkdir();
			}

			mailFolder= new
java.io.File(targetPath+"/"+mailbox+"/"+folder+"/"+filename.replaceAll(":","%3A")+"_Dir");
			
			if (!mailFolder.exists())
			{
				mailFolder.mkdir();
			}

			java.io.FileOutputStream fos= new
java.io.FileOutputStream(targetPath+"/"+mailbox+"/"+folder+"/"+filename.replaceAll(":","%3A")+"_Dir/"+filename.replaceAll(":","%3A")+".xml");


			
			org.apache.commons.httpclient.HttpClient client=wdfr.retrieveSessionInstance();
			java.util.Vector properties= new java.util.Vector();

			properties.addElement("DAV:autoversion");
			properties.addElement("DAV:contentclass");
			properties.addElement("DAV:creationdate");
			properties.addElement("DAV:displayname");
			properties.addElement("DAV:getcontentlength");
			properties.addElement("DAV:getcontenttype");
			properties.addElement("DAV:getetag");
			properties.addElement("DAV:getlastmodified");
			properties.addElement("DAV:href");
			properties.addElement("DAV:id");
			properties.addElement("DAV:iscollection");
			properties.addElement("DAV:isfolder");
			properties.addElement("DAV:ishidden");
			properties.addElement("DAV:isreadonly");
			properties.addElement("DAV:isstructureddocument");
			properties.addElement("DAV:isversioned");
			properties.addElement("DAV:lockdiscovery");
			properties.addElement("DAV:parentname");
			properties.addElement("DAV:resourcetype");
			properties.addElement("DAV:revisionid");
			properties.addElement("DAV:revisionlabel");
			properties.addElement("DAV:revisionuri");
			properties.addElement("DAV:supportedlock");
			properties.addElement("DAV:uid");
			properties.addElement("DAV:vresourceid");
			properties.addElement("urn:schemas:httpmail:date");
			properties.addElement("urn:schemas:httpmail:datereceived");
			properties.addElement("urn:schemas:httpmail:displaycc");
			properties.addElement("urn:schemas:httpmail:displayto");
			properties.addElement("urn:schemas:httpmail:from");
			properties.addElement("urn:schemas:httpmail:fromemail");
			properties.addElement("urn:schemas:httpmail:fromname");
			properties.addElement("urn:schemas:httpmail:hasattachment");
			properties.addElement("urn:schemas:httpmail:htmldescription");
			properties.addElement("urn:schemas:httpmail:importance");
			properties.addElement("urn:schemas:httpmail:normalizedsubject");
			properties.addElement("urn:schemas:httpmail:read");
			properties.addElement("urn:schemas:httpmail:sendername");
			properties.addElement("urn:schemas:httpmail:subject");
			properties.addElement("urn:schemas:httpmail:submitted");
			properties.addElement("urn:schemas:httpmail:textdescription");
			properties.addElement("urn:schemas:httpmail:thread-topic");
			properties.addElement("urn:schemas:httpmail:to");
			properties.addElement("urn:schemas:mailheader:content-class");
			properties.addElement("urn:schemas:mailheader:date");
			properties.addElement("urn:schemas:mailheader:from");
			properties.addElement("urn:schemas:mailheader:message-id");
			properties.addElement("urn:schemas:mailheader:received");
			properties.addElement("urn:schemas:mailheader:subject");
			properties.addElement("urn:schemas:mailheader:thread-index");
			properties.addElement("urn:schemas:mailheader:thread-topic");
			properties.addElement("urn:schemas:mailheader:to");

			PropFindMethod method = new
PropFindMethod(urlEML.toString(),Integer.MAX_VALUE,properties.elements());

			int status = client.executeMethod(method);
			java.util.Vector results = new java.util.Vector();

			java.util.Enumeration responses = method.getResponses();

			if (responses.hasMoreElements()) 
			{
					ResponseEntity response = (ResponseEntity) responses.nextElement();
					//System.out.println(response.toString());
					fos.write(response.toString().getBytes());
			}

			fos.close();

			java.util.Enumeration enum=wdfr.propfindMethod("urn:schemas:httpmail:hasattachment");
			for (; enum.hasMoreElements() ;) 
			{
			  int i= Integer.parseInt((String)enum.nextElement());
			  if(i==1)
				processAttachments(folder,filename);
			}

	}

	protected void processAttachments(String folder,String filename) throws Exception
	{

		org.apache.commons.httpclient.HttpsURL urlEML = new
org.apache.commons.httpclient.HttpsURL(username,password,hostname, port,path+"/"+mailbox+"/"+
folder+"/"+filename ); 
		org.apache.webdav.lib.WebdavResource wdfr= new org.apache.webdav.lib.WebdavResource(urlEML);

		org.apache.commons.httpclient.HttpClient client=wdfr.retrieveSessionInstance();
			
		java.util.Vector properties= new java.util.Vector();

		//properties.addElement("urn:schemas:httpmail:attachmentfilename");

		AttFindMethod method = new AttFindMethod(urlEML.toString(),0,properties.elements());
		int status = client.executeMethod(method);
		
	    java.util.Enumeration responses = method.getResponses();

		if (responses.hasMoreElements()) 
		{
				ResponseEntity response = (ResponseEntity) responses.nextElement();
				java.io.FileOutputStream fos= new
java.io.FileOutputStream(targetPath+"/"+mailbox+"/"+folder+"/"+filename.replaceAll(":","%3A")+"_Dir/"+filename.replaceAll(":","%3A")+"_ATT.xml");

				fos.write(response.toString().getBytes());
				fos.close();

				//System.out.println(response.toString());
				
				ByteArrayInputStream in=new ByteArrayInputStream(response.toString().getBytes());
				
				SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance();
				factory.setNamespaceAware(true);
				SAXParser parser = factory.newSAXParser();
				// Create a handler object to implement the callbacks
				AttachmentParser handler = new AttachmentParser();
				//parse the PDF stream that contains XML info
				parser.parse(in, handler);
				java.util.Vector results = handler.getAttachmentNames();

				for(java.util.Enumeration attNames=results.elements();attNames.hasMoreElements();)
				{
					//System.out.println(attNames.nextElement());
					fetchAttachment(folder,filename,(String)attNames.nextElement());
				}
		}
	}

	protected void fetchAttachment(String folder,String filename, String attname) throws Exception
	{

		attname= URLDecoder.decode(attname);

		//System.out.println("Attachment Name :"+attname);

		org.apache.commons.httpclient.HttpsURL urlEML = new
org.apache.commons.httpclient.HttpsURL(username,password,hostname, port,path+"/"+mailbox+"/"+
folder+"/"+filename+"/"+attname+"/" ); 
		org.apache.webdav.lib.WebdavResource wdfr= new org.apache.webdav.lib.WebdavResource(urlEML);

	
//System.out.println(targetPath+"/"+mailbox+"/"+folder+"/"+filename.replaceAll(":","%3A")+"_Dir/"+attname);
		try
		{

			File f= new
File(targetPath+"/"+mailbox+"/"+folder+"/"+filename.replaceAll(":","%3A")+"_Dir/"+attname);
			boolean bool=wdfr.getMethod(f) ;

		}
		catch(Exception ex) {}
	}
};

 



Please Help as soon as possibel to close this problem

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!?
Yahoo! Mail is new and improved - Check it out!
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: Can't use Put Method in command line app

Posted by Wiley Jacobs <wi...@hotmail.com>.
Nice! That worked - thank you very much!

----- Original Message -----
From: "r d" <r_...@yahoo.com>
To: "Slide Users Mailing List" <sl...@jakarta.apache.org>
Sent: Thursday, July 01, 2004 10:31 PM
Subject: Re: Can't use Put Method in command line app


> Try
> put notes3.txt notes3.txt
> It should work.
>
> rd
>
> Brant Levinson <wi...@hotmail.com> wrote:
> Hello All - I've hit a road block and needs some help... I'm trying to use
the put method from the command line client. I made sure that root is in the
the root group, I logged in with root, I can see all of the files but can
not use the "put method".
>
> Here is my console:
> [LOCALHOST] /storage/files/ $ put notes3.txt
> put notes3.txt null
> Uploading 'notes3.txt' to '/storage/files/': failed.
> Forbidden (403)
> [LOCALHOST] /storage/files/ $
>
> I'm able to use the write option in DAVExplorer to put the file in there,
but I need to use it in the command line.
>
> When I do it by DAVExplorer the log file shows this:
> Thread-15, 01-Jul-2004 22:09:04, root, PUT, 201 "Created", 521 ms,
/files/test.doc
>
> When I run the put test.doc from the command line, the log file shows
this:
>
> Thread-14, 01-Jul-2004 22:14:21, root, PUT, 403 "Forbidden", 10 ms,
/files/
>
> The ACL Info is this:
> Subject Action Inheritable Deny
> /roles/root /actions/write true false
>
> ACL Info
> Subject Action Inheritable Deny
> unauthenticated all true false
> /roles/user /actions/write true false
> owner /actions/read-acl true false
> /roles/root /actions/write true false
>
> Filename Size Last Modified
> new/ Wed, 30 Jun 2004 10:47:40 GMT
>
>
>
> ---------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: Can't use Put Method in command line app

Posted by r d <r_...@yahoo.com>.
Try 
put notes3.txt notes3.txt
It should work.
 
rd

Brant Levinson <wi...@hotmail.com> wrote:
Hello All - I've hit a road block and needs some help... I'm trying to use the put method from the command line client. I made sure that root is in the the root group, I logged in with root, I can see all of the files but can not use the "put method".

Here is my console:
[LOCALHOST] /storage/files/ $ put notes3.txt
put notes3.txt null
Uploading 'notes3.txt' to '/storage/files/': failed.
Forbidden (403)
[LOCALHOST] /storage/files/ $

I'm able to use the write option in DAVExplorer to put the file in there, but I need to use it in the command line.

When I do it by DAVExplorer the log file shows this:
Thread-15, 01-Jul-2004 22:09:04, root, PUT, 201 "Created", 521 ms, /files/test.doc

When I run the put test.doc from the command line, the log file shows this:

Thread-14, 01-Jul-2004 22:14:21, root, PUT, 403 "Forbidden", 10 ms, /files/

The ACL Info is this:
Subject Action Inheritable Deny
/roles/root /actions/write true false

ACL Info 
Subject Action Inheritable Deny 
unauthenticated all true false 
/roles/user /actions/write true false 
owner /actions/read-acl true false 
/roles/root /actions/write true false 

Filename Size Last Modified 
new/ Wed, 30 Jun 2004 10:47:40 GMT 


		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!