Package javax.jcr

Examples of javax.jcr.Session


        public void setValue(final PropertyId propertyId, final QValue[] values)
                throws RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Session s = sInfo.getSession();
                    Value[] jcrValues = new Value[values.length];
                    for (int i = 0; i < jcrValues.length; i++) {
                        jcrValues[i] = ValueFormat.getJCRValue(values[i],
                                sInfo.getNamePathResolver(), s.getValueFactory());
                    }
                    getProperty(propertyId, sInfo).setValue(jcrValues);
                    return null;
                }
            });
View Full Code Here


        if (Boolean.getBoolean("jackrabbit.test.integration")
                && isLitmusAvailable(litmus)) {
            final Repository repository = JcrUtils.getRepository(
                    "jcr-jackrabbit://" + dir.getCanonicalPath());
            Session session = repository.login(); // for the TransientRepository
            try {
                SocketConnector connector = new SocketConnector();
                connector.setHost("localhost");
                connector.setPort(Integer.getInteger("litmus.port", 0));

                Server server = new Server();
                server.addConnector(connector);

                ServletHolder holder = new ServletHolder(
                        new SimpleWebdavServlet() {
                            @Override
                            public Repository getRepository() {
                                return repository;
                            }
                        });
                holder.setInitParameter("resource-config", "/config.xml");

                Context context = new Context(server, "/");
                context.setResourceBase("src/test/resources");
                context.addServlet(holder, "/*");
                server.addHandler(context);

                server.start();
                try {
                    int port = connector.getLocalPort();
                    String url = "http://localhost:" + port + "/default";

                    ProcessBuilder builder =
                        new ProcessBuilder(litmus, url, "admin", "admin");
                    builder.directory(dir);
                    builder.redirectErrorStream();

                    assertLitmus(builder, "basic", 0);

                    assertLitmus(builder, "http", 0);

                    assertLitmus(builder, "props", 0);

                    // FIXME: JCR-2637: WebDAV shallow copy test failure
                    assertLitmus(builder, "copymove", 1);

                    // FIXME: JCR-2638: Litmus locks test failures
                    assertLitmus(builder, "locks", 1);
                } finally {
                    server.stop();
                }
            } finally {
                session.logout();
            }
        }
    }
View Full Code Here

        this.batchRatio = batchRatio;
        this.roundTripCount = 0;

        Map<String, Integer> opCounts = new HashMap<String, Integer>();
        Map<String, Long> opTimes = new HashMap<String, Long>();
        Session session = repository.login();

        Iterable<Callable<Long>> operations = getOperations(session, opCount);
        for (Callable<Long> operation : operations) {
            String opName = operation.toString();
            Long t = operation.call();

            if (opCounts.containsKey(opName)) {
                opCounts.put(opName, opCounts.get(opName) + 1);
                opTimes.put(opName, opTimes.get(opName) + t);
            }
            else {
                opCounts.put(opName, 1);
                opTimes.put(opName, t);
            }
        }

        System.out.println("Batch ratio: " + batchRatio);
        System.out.println("Round trips: " + roundTripCount);

        int count = 0;
        long time = 0L;
        for (String opName : opCounts.keySet()) {
            int c = opCounts.get(opName);
            count += c;
            System.out.println(opName + " count: " + c);

            long t = opTimes.get(opName);
            time += t;
            System.out.println(opName + " time: " + t);
        }

        System.out.println("Total count: " + count);
        System.out.println("Total time: " + time);

        session.logout();
    }
View Full Code Here

        this.batchReadConfig = batchReadConfig;
        this.supportsObservation = "true".equals(repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED));
        this.itemInfoCacheSize = itemInfoCacheSize;

        try {
            Session s = repository.login(new GuestCredentials());
            ValueFactory vf = s.getValueFactory();
            if (vf instanceof ValueFactoryQImpl) {
                qValueFactory = ((ValueFactoryQImpl) vf).getQValueFactory();
            }
        } catch (RepositoryException e) {
            // ignore
View Full Code Here

     * {@inheritDoc}
     */
    public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName)
            throws LoginException, NoSuchWorkspaceException, RepositoryException {
        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        Session s = repository.login(sInfo.getCredentials(), workspaceName);
        return new SessionInfoImpl(s, sInfo.getCredentials(), getNameFactory(), getPathFactory());
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public String[] getWorkspaceNames(SessionInfo sessionInfo)
            throws RepositoryException {
        Session s = getSessionInfoImpl(sessionInfo).getSession();
        return s.getWorkspace().getAccessibleWorkspaceNames();
    }
View Full Code Here

     * {@inheritDoc}
     */
    public void registerNamespace(SessionInfo sessionInfo,
                                  String prefix,
                                  String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
        Session session = getSessionInfoImpl(sessionInfo).getSession();
        NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
        nsReg.registerNamespace(prefix, uri);
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void unregisterNamespace(SessionInfo sessionInfo, String uri)
            throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
        Session session = getSessionInfoImpl(sessionInfo).getSession();
        NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
        nsReg.unregisterNamespace(nsReg.getPrefix(uri));
    }
View Full Code Here

        return destPath.toString();
    }

    private String pathForId(ItemId id, SessionInfoImpl sessionInfo)
            throws RepositoryException {
        Session session = sessionInfo.getSession();
        StringBuffer path = new StringBuffer();
        if (id.getUniqueID() != null) {
            path.append(session.getNodeByIdentifier(id.getUniqueID()).getPath());
        } else {
            path.append("/");
        }

        if (id.getPath() == null) {
View Full Code Here

            throw new InvalidItemStateException(e);
        }
    }

    private Node getNode(NodeId id, SessionInfoImpl sessionInfo) throws ItemNotFoundException, PathNotFoundException, RepositoryException {
        Session session = sessionInfo.getSession();
        Node n;
        if (id.getUniqueID() != null) {
            n = session.getNodeByIdentifier(id.getUniqueID());
        } else {
            n = session.getRootNode();
        }
        Path path = id.getPath();
        if (path == null || path.denotesRoot()) {
            return n;
        }
View Full Code Here

TOP

Related Classes of javax.jcr.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.