You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Paco Avila <pa...@git.es> on 2006/06/06 22:30:36 UTC
isCheckedOut bug?
When I add a new versionable node, the node is addes with
jcr:isCheckedout set to true. If I shutdown the repository and test it
again, now has the correct value. So the case is:
-> Create a repository
-> Add a versionable node
-> Test isCkeckedOut property (is true)
-> Shutdown repository
-> Open repository
-> get node
-> test isCheckedOut property (is false)
Is this a bug? should i set the isChekedOut property to false on node
creation?
--
Paco Avila <pa...@git.es>
Re: isCheckedOut bug?
Posted by Paco Avila <pa...@git.es>.
Here is a sample code:
---------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Hashtable;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Workspace;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.core.jndi.RegistryHelper;
public class IsCheckedOutTest {
public static void main(String[] args) throws Exception {
removeRepository();
Session session = getSession();
Node root = createRepository(session);
// Add a new node
Node child = root.addNode("prueba", "nt:file");
child.addMixin("mix:referenceable");
child.addMixin("mix:lockable");
child.addMixin("mix:versionable");
Node content = child.addNode("jcr:content", "nt:resource");
content.setProperty("jcr:mimeType", "text/plain");
content.setProperty("jcr:data", "En un lugar de La Mancha...");
content.setProperty("jcr:lastModified", Calendar.getInstance());
System.out.println("isCheckedOut: "+child.isCheckedOut());
root.save();
System.out.println("isCheckedOut: "+child.isCheckedOut());
}
/**
*
*/
public static void removeRepository() {
// Remove previous repo
try {
FileUtils.deleteDirectory(new File("repotest/repository"));
FileUtils.deleteDirectory(new File("repotest/versions"));
FileUtils.deleteDirectory(new File("repotest/workspaces"));
} catch (IOException e) {
System.err.println("No previous repo");
}
}
/**
*
*/
public static Session getSession() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
env.put(Context.PROVIDER_URL, "localhost");
InitialContext ctx = new InitialContext(env);
// Repository config
String configFile = "repotest/repository.xml";
String repHomeDir = "repotest";
RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir,
true);
// Obtain the repository through a JNDI lookup
Repository r = (Repository) ctx.lookup("repo");
// Create a new repository session, after authenticating
Session session = r.login(new SimpleCredentials("paco",
"".toCharArray()), null);
System.out.println("Session: "+session);
return session;
}
/**
*
*/
public static Node createRepository(Session session) throws Exception {
// Namespace registration
Workspace ws = session.getWorkspace();
ws.getNamespaceRegistry().registerNamespace("okm",
"http://www.pepito.org/1.0");
// Node creation
Node root = session.getRootNode();
Node okmRoot = root.addNode("okm:root", "nt:folder");
okmRoot.addMixin("mix:referenceable");
session.save();
System.out.println("Repository created.");
return okmRoot;
}
}
---------------------------------------------
--
Paco Avila <pa...@git.es>
Re: isCheckedOut bug?
Posted by Paco Avila <pa...@git.es>.
El mié, 07-06-2006 a las 17:12 +0200, Tobias Bocanegra escribió:
> > So, I need to checking() just after save(). I thinks this is a strange
> > behavior.
>
> well, if you create a new node, and it would be checked-in right away,
> you could not write anything to it....and that's how it is specified
> by jsr170.
I know, jsr170 is mandatory. It was only my own point of view :)
Thanks again.
--
Paco Avila <pa...@git.es>
Re: isCheckedOut bug?
Posted by Tobias Bocanegra <to...@day.com>.
> So, I need to checking() just after save(). I thinks this is a strange
> behavior.
well, if you create a new node, and it would be checked-in right away,
you could not write anything to it....and that's how it is specified
by jsr170.
regards, toby
On 6/7/06, Paco Avila <pa...@git.es> wrote:
> El mié, 07-06-2006 a las 11:06 +0200, Tobias Bocanegra escribió:
> > when you create a new versionable node, it is in a checked-out state,
> > until you explicitely check-in the node. so Node.isCheckedOut should
> > always return true, until you checkin the node.
>
>
> Thanks a lot :)
>
> --
> Paco Avila <pa...@git.es>
>
>
--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---
Re: isCheckedOut bug?
Posted by Paco Avila <pa...@git.es>.
El mié, 07-06-2006 a las 11:06 +0200, Tobias Bocanegra escribió:
> when you create a new versionable node, it is in a checked-out state,
> until you explicitely check-in the node. so Node.isCheckedOut should
> always return true, until you checkin the node.
So, I need to checking() just after save(). I thinks this is a strange
behavior.
Thanks a lot :)
--
Paco Avila <pa...@git.es>
Re: isCheckedOut bug?
Posted by Tobias Bocanegra <to...@day.com>.
when you create a new versionable node, it is in a checked-out state,
until you explicitely check-in the node. so Node.isCheckedOut should
always return true, until you checkin the node.
regards, toby
On 6/6/06, Paco Avila <pa...@git.es> wrote:
> When I add a new versionable node, the node is addes with
> jcr:isCheckedout set to true. If I shutdown the repository and test it
> again, now has the correct value. So the case is:
>
> -> Create a repository
> -> Add a versionable node
> -> Test isCkeckedOut property (is true)
> -> Shutdown repository
> -> Open repository
> -> get node
> -> test isCheckedOut property (is false)
>
> Is this a bug? should i set the isChekedOut property to false on node
> creation?
> --
> Paco Avila <pa...@git.es>
>
>
--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---