jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: ConstraintViolationException
Date Mon, 30 Jan 2006 09:56:02 GMT
On 1/29/06, sirène vip <sirene_vip@hotmail.com> wrote:
> Hello Everyone,
>
> This becoming really annoying!
>
> I have verified my program thousands of time and made all possible changes
> but keep having the exception "ConstraintViolationException:[other
> application_specific information]  mandatory property
> {http://www.jcp.org/jcr/1.0}created does not exist"
>
> My code consists in the following:
>
> public void store(String feName, String document) {
>
>   Node root = session.getRootNode();
>   Node n = root.addNode(feName, "nt:file");
>   Node content = expNode.addNode("jcr:content", "nt:resource");
>   content.setProperty("jcr:mimeType", "text/xml");
>   content.setProperty("jcr:encoding", "");
>   content.setProperty("jcr:data", document);
>
>   Calendar lastModified = Calendar.getInstance ();
>   long currentTime = System.currentTimeMillis();
>   final long duration = currentTime - start;
>   lastModified.setTimeInMillis(duration);
>   content.setProperty("jcr:lastModified", lastModified);
>    session.save();
> }


>   Node content = expNode.addNode("jcr:content", "nt:resource");

where does 'expNode' come from?

here's a code fragment that i works perfectly
(tested with the latest svn rev.):

            // file to be stored in repository
            File file = new File("repository.xml");

            Node fileNode = root.addNode(file.getName(), "nt:file");
            Node content = fileNode.addNode("jcr:content", "nt:resource");
            FileInputStream fin = new FileInputStream(file);
            try {
                content.setProperty("jcr:data", fin);
            } finally {
                fin.close();
            }
            content.setProperty("jcr:lastModified", Calendar.getInstance());
            content.setProperty("jcr:mimeType", "text/plain");

            session.save();


btw: who is it? sirène? celina? susanne? it would be nice to know
who we're talking to...

cheers
stefan

>
> Any help is truly appreciated. Thank you!
> Best Regards.
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>

Mime
View raw message