test123456 | 1 Jan 2010 11:31

Storing and retrieving images from jackrabbit


Hi new to jackrabbit.

I try to create a content repository to store the  images uploaded by users
from my web application.

I am having the environment
Tomcat 6.0.13 server
JDK 1.6
Jackrabbit 1.6

I am using the following code snippet for that for adding image 

			
			Node rootNode = session.getRootNode();
			String fileName = "abc.gif";
			String destinationNodeName = "attachment";
			
			// First check the type of the file to add
			MimeTable mt = MimeTable.getDefaultTable();
			String mimeType = mt.getContentTypeFor(fileName);
			if (mimeType == null)
			{
				mimeType = "application/octet-stream";
			}
			
			// Get the destinationNode to which the file to be added
			Node destinationNode = rootNode.addNode(destinationNodeName);
			Node file = destinationNode.addNode(fileName, "nt:file");
			Node contentNode = file.addNode("jcr:content", "nt:resource");
(Continue reading)

test123456 | 1 Jan 2010 13:01

Image attachment problem


I am adding a image to the jackrabbit repository.
I am using jackrabbit 1.6.0 version .

While try to retrieve the image from the repository  it is throwing the
PathNotFoundException for jcr:data

It is showing only two properties 
jcr:created
jcr:primaryType

there is no jcr:data property.

What will be the problem 
I used the following snippet for adding the image to repository

                        Node folder =
session.getRootNode().addNode("ptattachment");
			
			Node file = folder.addNode(fileName, "nt:file");
						
			MimeTable mt = MimeTable.getDefaultTable();
			String mimeType = mt.getContentTypeFor(fileName);
			if (mimeType == null) mimeType = "application/octet-stream";
			
			Node contentNode = file.addNode("jcr:content", "nt:resource");
			contentNode.setProperty("jcr:data", fileStream);
			contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
			contentNode.setProperty("jcr:mimeType", mimeType);
			
(Continue reading)

Mat Lowery | 1 Jan 2010 14:59
Favicon

Re: Image attachment problem

The storing looks fine but the retrieval looks wrong.  Try this:

Node resourceNode =
session.getRootNode().getNode("ptattachment").getNode(fileName).getNode("jcr:content");
InputStream in = resourceNode.getProperty("jcr:data").getStream();

On Fri, 2010-01-01 at 04:01 -0800, test123456 wrote:

> I am adding a image to the jackrabbit repository.
> I am using jackrabbit 1.6.0 version .
> 
> While try to retrieve the image from the repository  it is throwing the
> PathNotFoundException for jcr:data
> 
> It is showing only two properties 
> jcr:created
> jcr:primaryType
> 
> there is no jcr:data property.
> 
> What will be the problem 
> I used the following snippet for adding the image to repository
> 
>                         Node folder =
> session.getRootNode().addNode("ptattachment");
> 			
> 			Node file = folder.addNode(fileName, "nt:file");
> 						
> 			MimeTable mt = MimeTable.getDefaultTable();
> 			String mimeType = mt.getContentTypeFor(fileName);
(Continue reading)

Mat Lowery | 1 Jan 2010 16:09
Favicon

remote JCR

I'm trying to wrap my head around Deployment Model 3: Repository Server.
Can anyone confirm that my understanding is accurate?  My understanding
is that there are two ways to access a repository remotely: RMI and
WebDAV.  If you want to use the JCR API, you use RMI.  Otherwise you use
WebDAV.  But by using WebDAV, you lose access to the low level node
operations that you would otherwise have access to in the JCR API.

Let's assume that I need access to the low level node operations.  So I
opt for RMI.

However, there is a statement on
http://jackrabbit.apache.org/repository-server-howto.html that says:

"Warning: The current JCR-RMI library is designed for simplicity, not
performance. You will probably experience major performance issues if
you try running any non-trivial applications on top of JCR-RMI."

Does performance suffer because each and every node operation (e.g.
addNode and setProperty) involves a communication with the server?

In this case, it seems that the best option is to expose my own service
(backed by a local Jackrabbit) for remote access.  In this way, there is
far less communication with the remote service (i.e. my service) since
my objects would be far less granular than nodes.

This is probably obvious to most but it took me a while to figure it out
what my options were.  Can anyone comment?  Thank you.
Jere McDevitt | 2 Jan 2010 04:41
Picon

Postgres case sensitivity issue

Ran into an issue that took me a little while to track down.  This isn't a
bug with Jackrabbit, but is something to watch out for.

I had configured my repository to use Postgres as the persistence manager
and in the <DataStore> entry of the repository.xml file I was original
configured like:

  <DataStore class="org.apache.jackrabbit.core.data.db.DbDataStore">
      <param name="driver" value="org.postgresql.Driver"/>
      <param name="url" value="jdbc:postgresql://testserver/jackrabbit"/>
      <param name="user" value="testuser"/>
      <param name="password" value="**********"/>
      <param name="databaseType" value="postgresql"/>
      <param name="minRecordLength" value="1024"/>
      <param name="maxConnections" value="3"/>
      <param name="copyWhenReading" value="true"/>
      <param name="tablePrefix" value=""/>
      <param name="schemaObjectPrefix" value="DS_"/>
      <param name="schemaCheckEnabled" value="true"/>
  </DataStore>

I was using the First Hop 3  as a sample and when I first ran it, it created
and loaded everything fine.

The second time I ran the example it failed, saying "relation ds_datastore
already exists".

When the repository starts up, the DbDataStore.java file does this call:

            ResultSet rs = meta.getTables(null, null, schemaObjectPrefix +
(Continue reading)

Vibhu Sharma | 3 Jan 2010 08:36

Re: Storing and retrieving images from jackrabbit

Hi,

I think the problem lies in retrieval.

your node addition code creates the following node structure

root <-- attachment <-- 'filename' --- prop-'jcr:data'

when you retrieve you check for

root <-- attachment --- prop-'jcr:data'

Solution:
fileNode = sourceNode.getNode(<FileName>);
fileNode.getProperty("jcr:data").getStream();

Hope this solves the problem

regards
Vibhu
projectoffguard.com

-

On Fri, Jan 1, 2010 at 4:01 PM, test123456 <sajith.pc <at> thinkcoretech.com>wrote:

>
> Hi new to jackrabbit.
>
> I try to create a content repository to store the  images uploaded by users
(Continue reading)

Alexander Klimetschek | 3 Jan 2010 17:36
Favicon

Re: Branching and workspace creation

On Thu, Dec 31, 2009 at 19:22, Robin Batra <robin.batra <at> gmail.com> wrote:
> I am working on Windows XP and xp does support creation of folders starting
> with numbers. Moreover when i try to create the workspace through my code
> the folder is created but when the persistent manager tries to create the
> database table corresponding to it an exception is thrown on the server. The
> error code returned by DB2 corresponds to "Invalid numeric literal" (i am
> using DB2 as the back-end). I think this is the problem of DDL used by the
> persistent manager but i am not at all sure.

Or maybe DB2 doesn't allow numbers in table / schema names? What are
the schemaObjectPrefix'es you have in your repository/workspace.xml?

Regards,
Alex

--

-- 
Alexander Klimetschek
alexander.klimetschek <at> day.com

Alexander Klimetschek | 3 Jan 2010 17:38
Favicon

Re: remote JCR

On Fri, Jan 1, 2010 at 16:09, Mat Lowery <mlowery <at> pentaho.com> wrote:
> In this case, it seems that the best option is to expose my own service
> (backed by a local Jackrabbit) for remote access.  In this way, there is
> far less communication with the remote service (i.e. my service) since
> my objects would be far less granular than nodes.

Did you take a look at Apache Sling? It allows you to easily access a
JCR over HTTP on a "document" level.

Regards,
Alex

--

-- 
Alexander Klimetschek
alexander.klimetschek <at> day.com

test123456 | 4 Jan 2010 05:45

Re: Storing and retrieving images from jackrabbit


Thank you very much.

I understood the problem. It create a node with the image file name.

On Sun, Jan 3, 2010 at 1:07 PM, vibhu7 [via Jackrabbit] <
ml-node+997613-1385984177 <at> n4.nabble.com<ml-node%2B997613-1385984177 <at> n4.nabble.com>
> wrote:

> Hi,
>
> I think the problem lies in retrieval.
>
> your node addition code creates the following node structure
>
> root <-- attachment <-- 'filename' --- prop-'jcr:data'
>
> when you retrieve you check for
>
> root <-- attachment --- prop-'jcr:data'
>
> Solution:
> fileNode = sourceNode.getNode(<FileName>);
> fileNode.getProperty("jcr:data").getStream();
>
> Hope this solves the problem
>
> regards
> Vibhu
> projectoffguard.com
(Continue reading)

test123456 | 4 Jan 2010 05:47

Re: Image attachment problem


Thank you very much Mat.

I got my mistake. Your code snippet explains the problem.
And it was worked fine also.

On Fri, Jan 1, 2010 at 7:30 PM, Mat Lowery-2 [via Jackrabbit] <
ml-node+991794-1824138349 <at> n4.nabble.com<ml-node%2B991794-1824138349 <at> n4.nabble.com>
> wrote:

> The storing looks fine but the retrieval looks wrong.  Try this:
>
> Node resourceNode =
> session.getRootNode().getNode("ptattachment").getNode(fileName).getNode("jcr:content");
>
> InputStream in = resourceNode.getProperty("jcr:data").getStream();
>
> On Fri, 2010-01-01 at 04:01 -0800, test123456 wrote:
>
> > I am adding a image to the jackrabbit repository.
> > I am using jackrabbit 1.6.0 version .
> >
> > While try to retrieve the image from the repository  it is throwing the
> > PathNotFoundException for jcr:data
> >
> > It is showing only two properties
> > jcr:created
> > jcr:primaryType
> >
> > there is no jcr:data property.
(Continue reading)


Gmane