jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jackrabbit Wiki] Update of "ExamplesPage" by RobertRitchy
Date Fri, 08 Jul 2005 18:55:38 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.

The following page has been changed by RobertRitchy:

New page:
= Examples Page =

This page will be used to show solutions to common problems related to JSR 170.

'''Importing a File'''
    public Node importFile (Node folderNode, File file, String mimeType,
            String encoding) throws RepositoryException, IOException
        //create the file node - see section of the spec
        Node fileNode = folderNode.addNode (file.getName (), "nt:file");
        //create the manditory child node - jcr:content
        Node resNode = fileNode.addNode ("jcr:content", "nt:resource");
        resNode.setProperty ("jcr:mimeType", mimeType);
        resNode.setProperty ("jcr:encoding", encoding);
        resNode.setProperty ("jcr:data", new FileInputStream (file));
        Calendar lastModified = Calendar.getInstance ();
        lastModified.setTimeInMillis (file.lastModified ());
        resNode.setProperty ("jcr:lastModified", lastModified);

        return fileNode;

View raw message