Package javax.jcr

Examples of javax.jcr.RepositoryException


                    throws RepositoryException {
                OpenIdUser user = authHandler.getOpenIdUser(credentials);
                if (user != null) {
                    return user.isAssociated();
                }
                throw new RepositoryException(
                    "Can't authenticate credentials of type: "
                        + credentials.getClass());
            }

        };
View Full Code Here


        if (parentLocation.isEmpty()) {
            parentLocation = "/";
        }

        if (!session.nodeExists(parentLocation)) {
            throw new RepositoryException("No parent found at " + parentLocation + " ; it's needed to create node at "
                    + resource.getPath());
        }

        String primaryType = (String) resource.getProperties().get(JCR_PRIMARYTYPE);
View Full Code Here

                                String newPasswordConfirm,
                                List<Modification> changes)
                throws RepositoryException {

        if ("anonymous".equals(name)) {
            throw new RepositoryException(
                "Can not change the password of the anonymous user.");
        }

        User user;
        UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
        Authorizable authorizable = userManager.getAuthorizable(name);
        if (authorizable instanceof User) {
            user = (User)authorizable;
        } else {
            throw new ResourceNotFoundException(
                "User to update could not be determined");
        }

        //SLING-2069: if the current user is an administrator, then a missing oldPwd is ok,
        // otherwise the oldPwd must be supplied.
        boolean administrator = false;

        // check that the submitted parameter values have valid values.
        if (oldPassword == null || oldPassword.length() == 0) {
            try {
                UserManager um = AccessControlUtil.getUserManager(jcrSession);
                User currentUser = (User) um.getAuthorizable(jcrSession.getUserID());
                administrator = currentUser.isAdmin();

                if (!administrator) {
                    //check if the user is a member of the 'User administrator' group
                    Authorizable userAdmin = um.getAuthorizable(this.userAdminGroupName);
                    if (userAdmin instanceof Group) {
                        boolean isMember = ((Group)userAdmin).isMember(currentUser);
                        if (isMember) {
                            administrator = true;
                        }
                    }

                }
            } catch ( Exception ex ) {
                log.warn("Failed to determine if the user is an admin, assuming not. Cause: "+ex.getMessage());
                administrator = false;
            }
            if (!administrator) {
                throw new RepositoryException("Old Password was not submitted");
            }
        }
        if (newPassword == null || newPassword.length() == 0) {
            throw new RepositoryException("New Password was not submitted");
        }
        if (!newPassword.equals(newPasswordConfirm)) {
            throw new RepositoryException(
                "New Password does not match the confirmation password");
        }

        if (oldPassword != null && oldPassword.length() > 0) {
            // verify old password
            checkPassword(authorizable, oldPassword);
        }

        try {
            user.changePassword(newPassword);

            final String passwordPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX + user.getID() + "/rep:password";

            changes.add(Modification.onModified(passwordPath));
        } catch (RepositoryException re) {
            throw new RepositoryException("Failed to change user password.", re);
        }

        return user;
    }
View Full Code Here

            } catch (Throwable t) {
                // failure here, fall back to password check failure below
            }
        }

        throw new RepositoryException("Old Password does not match");
    }
View Full Code Here

                if (resourceResolver != null) {
                    resourceResolver.close();
                }
            }
        } catch (RepositoryException re) {
            throw new RepositoryException("Failed to update group.", re);
        }
        return group;
    }
View Full Code Here

            } else if ("false".equalsIgnoreCase(disabledParam)) {
                //re-enable a disabled user
                user.disable(null);
            }
        } catch (RepositoryException re) {
            throw new RepositoryException("Failed to update user.", re);
        }
        return user;
    }
View Full Code Here

    protected String removeAndValidateWorkspace(String path, Session session) throws RepositoryException {
        final int wsSepPos = path.indexOf(":/");
        if (wsSepPos != -1) {
            final String workspaceName = path.substring(0, wsSepPos);
            if (!workspaceName.equals(session.getWorkspace().getName())) {
                throw new RepositoryException("Incorrect workspace. Expecting " + workspaceName + ". Received "
                        + session.getWorkspace().getName());
            }
            return path.substring(wsSepPos + 1);
        }
        return path;
View Full Code Here

                os.close();
            }
        } catch (Exception e) {
            String msg = "failed to persist namespace registry";
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }

        FileSystemResource indexFile =
                new FileSystemResource(nsRegStore, NS_IDX_RESOURCE);
        try {
            indexFile.makeParentDirs();
            OutputStream os = indexFile.getOutputStream();
            Properties props = new Properties();

            // store mappings in properties
            Iterator iter = uriToIndex.keySet().iterator();
            while (iter.hasNext()) {
                String uri = (String) iter.next();
                String index = uriToIndex.get(uri).toString();
                props.setProperty(uri, index);
            }

            try {
                props.store(os, null);
            } finally {
                // make sure stream is closed
                os.close();
            }
        } catch (Exception e) {
            String msg = "failed to persist namespace registry index.";
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }
    }
View Full Code Here

            }
            statement = node.getProperty(NameFormat.format(QName.JCR_STATEMENT, session.getNamespaceResolver())).getString();
            language = node.getProperty(NameFormat.format(QName.JCR_LANGUAGE, session.getNamespaceResolver())).getString();
            query = handler.createExecutableQuery(session, itemMgr, statement, language);
        } catch (NoPrefixDeclaredException e) {
            throw new RepositoryException(e.getMessage(), e);
        }
        initialized = true;
    }
View Full Code Here

        checkInitialized();
        try {
            NamespaceResolver resolver = session.getNamespaceResolver();
            Path p = PathFormat.parse(absPath, resolver).getNormalizedPath();
            if (!p.isAbsolute()) {
                throw new RepositoryException(absPath + " is not an absolute path");
            }

            String relPath = PathFormat.format(p, resolver).substring(1);
            Node queryNode = session.getRootNode().addNode(relPath,
                    NameFormat.format(QName.NT_QUERY, resolver));
            // set properties
            queryNode.setProperty(NameFormat.format(QName.JCR_LANGUAGE, resolver), language);
            queryNode.setProperty(NameFormat.format(QName.JCR_STATEMENT, resolver), statement);
            node = queryNode;
            return node;
        } catch (MalformedPathException e) {
            throw new RepositoryException(e.getMessage(), e);
        } catch (NoPrefixDeclaredException e) {
            throw new RepositoryException(e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.jcr.RepositoryException

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.