Hi,

I have an issue in Webdav access.Actually, when I add some document (eg. Tiff 
files) in default repository and view it in web browser using Webdav 
functionality, the file is getting opened as an folder structure instead of 
opening as a file.Please advice me on this.

My code snippet is as follows:

Session session = null;

        InitialContext ctx = new InitialContext();

        Repository repository = (Repository) ctx
                .lookup("jcr/local");

        System.out.println("jackrabbit repository found!"
                + repository);

        Credentials cred = new SimpleCredentials("user",
                new char[] { 'p', 'w', 'd' });

        session = repository.login(cred);

        System.out.println("Login Successful!"
                + session.getUserID());
        File file = new File(
                "C:\\ Original Image.tif");
        System.out.println("File Content length - "
                + file.length());
        MimeTable mt = MimeTable.getDefaultTable();
        String mimeType = mt.getContentTypeFor(file
                .getName());

        System.out.println("MIME Type - " + mimeType);
        if (mimeType == null)
            mimeType = "application/octet-stream";

        Node root = session.getRootNode();


        Node fileNode = root.addNode(file.getName(),
                "nt:file");
        Node resNode = fileNode.addNode("jcr:content",
                "nt:resource");
        resNode.setProperty("jcr:mimeType", mimeType);
        resNode.setProperty("jcr:data",
                new FileInputStream(file));
        resNode.setProperty("jcr:encoding", "");
        Calendar lastModified = Calendar.getInstance();
        lastModified.setTimeInMillis(file.lastModified());
        resNode.setProperty("jcr:lastModified",
                lastModified);

        session.save();


I had this issue previously. Even I made some necessary changes in the 
config.xml as well. But still I couldn't resolve the issue.

Please advice.

Thanks & Regards,
Gandhi Rajan.N
________________________________
| iSIGHT Development Team | iGATE Global Solutions| T: +91-80-4104 1308| M: +91 
9886834626 | [EMAIL PROTECTED] |
| 158-162 & 165-170 EPIP Phase II Whitefield Bangalore - 560 066 India | 
www.igate.com<http://www.igate.com/> |

iGATE is Ranked No. 3 in DQ-IDC best IT employer survey and Ranked No.6 
by Business Today-Mercer Human Resource Consulting-TNS  in a cross industry 
survey of Best Companies to work for in India
----------------------------------------------------------------DISCLAIMER---------------------------------------------------------
Information transmitted by this EMAIL is proprietary to iGATE Group of 
Companies and is intended for use only by the individual 
or entity to whom it is addressed and may contain information that is 
privileged, confidential, or exempt from disclosure under 
applicable law. If you are not the intended recipient of this EMAIL immediately 
notify the sender at iGATE or [EMAIL PROTECTED] 
and delete this EMAIL including any attachments

Reply via email to