Search in sources :

Example 36 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class VersionHistoryImpl method getVersionByLabel.

/**
     * @see javax.jcr.version.VersionHistory#getVersionByLabel(String)
     */
public javax.jcr.version.Version getVersionByLabel(String label) throws RepositoryException {
    try {
        Name qLabel = sessionContext.getQName(label);
        InternalVersion v = getInternalVersionHistory().getVersionByLabel(qLabel);
        if (v == null) {
            throw new VersionException("No version with label '" + label + "' exists in this version history.");
        }
        return (Version) sessionContext.getSessionImpl().getNodeById(v.getId());
    } catch (NameException e) {
        throw new VersionException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) Version(javax.jcr.version.Version) Name(org.apache.jackrabbit.spi.Name) VersionException(javax.jcr.version.VersionException)

Example 37 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class VersionHistoryImpl method removeVersionLabel.

/**
     * @see javax.jcr.version.VersionHistory#removeVersionLabel(String)
     */
public void removeVersionLabel(String label) throws RepositoryException {
    try {
        // check permissions
        checkVersionManagementPermission();
        InternalVersion existing = sessionContext.getSessionImpl().getInternalVersionManager().setVersionLabel(getSession(), getInternalVersionHistory(), null, sessionContext.getQName(label), true);
        if (existing == null) {
            throw new VersionException("No version with label '" + label + "' exists in this version history.");
        }
    } catch (NameException e) {
        throw new VersionException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) VersionException(javax.jcr.version.VersionException)

Example 38 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class VersionHistoryImpl method getVersion.

/**
     * @see javax.jcr.version.VersionHistory#getVersion(String)
     */
public javax.jcr.version.Version getVersion(String versionName) throws VersionException, RepositoryException {
    try {
        Name name = sessionContext.getQName(versionName);
        InternalVersion v = getInternalVersionHistory().getVersion(name);
        if (v == null) {
            throw new VersionException("No version with name '" + versionName + "' exists in this version history.");
        }
        return (Version) sessionContext.getSessionImpl().getNodeById(v.getId());
    } catch (NameException e) {
        throw new VersionException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) Version(javax.jcr.version.Version) Name(org.apache.jackrabbit.spi.Name) VersionException(javax.jcr.version.VersionException)

Example 39 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class VersionHistoryImpl method addVersionLabel.

/**
     * @see javax.jcr.version.VersionHistory#addVersionLabel(String, String, boolean)
     */
public void addVersionLabel(String versionName, String label, boolean move) throws VersionException, RepositoryException {
    try {
        // check permissions
        checkVersionManagementPermission();
        sessionContext.getSessionImpl().getInternalVersionManager().setVersionLabel(getSession(), getInternalVersionHistory(), sessionContext.getQName(versionName), sessionContext.getQName(label), move);
    } catch (NameException e) {
        throw new VersionException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) VersionException(javax.jcr.version.VersionException)

Example 40 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class ObservationManagerImpl method createEventFilter.

/**
     * Creates a new event filter with the given restrictions.
     *
     * @param eventTypes A combination of one or more event type constants encoded as a bitmask.
     * @param absPaths absolute paths.
     * @param isDeep a <code>boolean</code>.
     * @param uuid array of UUIDs.
     * @param nodeTypeName array of node type names.
     * @param noLocal a <code>boolean</code>.
     * @param noExternal a <code>boolean</code>.
     * @param noInternal a <code>boolean</code>.
     * @return the event filter with the given restrictions.
     * @throws RepositoryException if an error occurs.
     */
public EventFilter createEventFilter(int eventTypes, List<String> absPaths, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal, boolean noExternal, boolean noInternal) throws RepositoryException {
    // create NodeType instances from names
    NodeTypeImpl[] nodeTypes;
    if (nodeTypeName == null) {
        nodeTypes = null;
    } else {
        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
        nodeTypes = new NodeTypeImpl[nodeTypeName.length];
        for (int i = 0; i < nodeTypes.length; i++) {
            nodeTypes[i] = (NodeTypeImpl) ntMgr.getNodeType(nodeTypeName[i]);
        }
    }
    List<Path> paths = new ArrayList<Path>();
    for (String absPath : absPaths) {
        try {
            Path normalizedPath = session.getQPath(absPath).getNormalizedPath();
            if (!normalizedPath.isAbsolute()) {
                throw new RepositoryException("absPath must be absolute");
            }
            paths.add(normalizedPath);
        } catch (NameException e) {
            String msg = "invalid path syntax: " + absPath;
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }
    }
    NodeId[] ids = null;
    if (uuid != null) {
        ids = new NodeId[uuid.length];
        for (int i = 0; i < uuid.length; i++) {
            ids[i] = NodeId.valueOf(uuid[i]);
        }
    }
    // create filter
    return new EventFilter(session, eventTypes, paths, isDeep, ids, nodeTypes, noLocal, noExternal, noInternal);
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeTypeImpl(org.apache.jackrabbit.core.nodetype.NodeTypeImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) JackrabbitEventFilter(org.apache.jackrabbit.api.observation.JackrabbitEventFilter) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) NodeId(org.apache.jackrabbit.core.id.NodeId) NodeTypeManagerImpl(org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl)

Aggregations

NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)65 RepositoryException (javax.jcr.RepositoryException)44 Name (org.apache.jackrabbit.spi.Name)38 Path (org.apache.jackrabbit.spi.Path)20 NamespaceException (javax.jcr.NamespaceException)17 ArrayList (java.util.ArrayList)16 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)9 SAXException (org.xml.sax.SAXException)8 Node (javax.jcr.Node)6 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)6 InvalidQueryException (javax.jcr.query.InvalidQueryException)6 NodeId (org.apache.jackrabbit.core.id.NodeId)6 IOException (java.io.IOException)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 PathNotFoundException (javax.jcr.PathNotFoundException)5 Value (javax.jcr.Value)5 LocationStepQueryNode (org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode)5 AccessDeniedException (javax.jcr.AccessDeniedException)4 NodeType (javax.jcr.nodetype.NodeType)4 VersionException (javax.jcr.version.VersionException)4