⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workspaceresourceimpl.java

📁 jsr170接口的java实现。是个apache的开源项目。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @see DavResource#setProperty(org.apache.jackrabbit.webdav.property.DavProperty)     */    public void setProperty(DavProperty property) throws DavException {        if (ItemResourceConstants.JCR_NAMESPACES.equals(property.getName())) {            NamespacesProperty nsp = new NamespacesProperty(property);            try {                Map changes = new HashMap(nsp.getNamespaces());                NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();                String[] registeredPrefixes = nsReg.getPrefixes();                for (int i = 0; i < registeredPrefixes.length; i++) {                    String prfx = registeredPrefixes[i];                    if (!changes.containsKey(prfx)) {                        // prefix not present amongst the new values any more > unregister                        nsReg.unregisterNamespace(prfx);                    } else if (changes.get(prfx).equals(nsReg.getURI(prfx))) {                        // present with same uri-value >> no action required                        changes.remove(prfx);                    }                }                // try to register any prefix/uri pair that has a changed uri or                // it has not been present before.                Iterator prefixIt = changes.keySet().iterator();                while (prefixIt.hasNext()) {                    String prefix = (String)prefixIt.next();                    String uri = (String)changes.get(prefix);                    nsReg.registerNamespace(prefix, uri);                }            } catch (RepositoryException e) {                throw new JcrDavException(e);            }        } else {            // only jcr:namespace can be modified            throw new DavException(DavServletResponse.SC_CONFLICT);        }    }    /**     * Handles an attempt to set {@link ItemResourceConstants#JCR_NAMESPACES}     * and forwards any other set or remove requests to the super class.     *     * @see #setProperty(DavProperty)     * @see DefaultItemCollection#alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)     */    public MultiStatusResponse alterProperties(List changeList) throws DavException {        if (changeList.size() == 1) {           Object propEntry = changeList.get(0);            // only modification of prop is allowed. removal is not possible            if (propEntry instanceof DavProperty                && ItemResourceConstants.JCR_NAMESPACES.equals(((DavProperty)propEntry).getName())) {                DavProperty namespaceProp = (DavProperty) propEntry;                setProperty(namespaceProp);            } else {                // attempt to remove the namespace property                throw new DavException(DavServletResponse.SC_CONFLICT);            }        } else {            // changelist contains more than the jcr:namespaces property            // TODO: build multistatus instead            throw new DavException(DavServletResponse.SC_CONFLICT);        }        return new MultiStatusResponse(getHref(), DavServletResponse.SC_OK);    }    //------------------------------------------------< VersionableResource >---    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public void addVersionControl() throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    //------------------------------------------< VersionControlledResource >---    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public String checkin() throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public void checkout() throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public void uncheckout() throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    /**     * While RFC 3253 does not define any version-related operations for the     * workspace resource, this implementation uses {@link VersionControlledResource#update(UpdateInfo)}     * to map {@link Workspace#restore(javax.jcr.version.Version[], boolean)} to     * a WebDAV call.     * </p>     * Limitation: note that the <code>MultiStatus</code> returned by this method     * will not list any nodes that have been removed due to an Uuid conflict.     *     * @param updateInfo     * @return     * @throws org.apache.jackrabbit.webdav.DavException     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#update(org.apache.jackrabbit.webdav.version.UpdateInfo)     */    public MultiStatus update(UpdateInfo updateInfo) throws DavException {        if (updateInfo == null) {            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid update request body required.");        }        if (!exists()) {            throw new DavException(DavServletResponse.SC_NOT_FOUND);        }        Session session = getRepositorySession();        MultiStatus ms = new MultiStatus();        try {            Element udElem = updateInfo.getUpdateElement();            boolean removeExisting = DomUtil.hasChildElement(udElem, ItemResourceConstants.XML_REMOVEEXISTING, ItemResourceConstants.NAMESPACE);            // register eventListener in order to be able to report the modified resources.            EventListener el = new EListener(updateInfo.getPropertyNameSet(), ms);            registerEventListener(el, session.getRootNode().getPath());            String[] hrefs = updateInfo.getVersionHref();            if (hrefs == null || hrefs.length < 1) {                throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid update request body: at least a single version href must be specified.");            }            // perform the update/restore according to the update info            Version[] versions = new Version[hrefs.length];            for (int i = 0; i < hrefs.length; i++) {                DavResourceLocator vLoc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), hrefs[i]);                String versionPath = vLoc.getRepositoryPath();                Item item = getRepositorySession().getItem(versionPath);                if (item instanceof Version) {                    versions[i] = (Version) item;                } else {                    throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid update request body: href does not identify a version " + hrefs[i]);                }            }            session.getWorkspace().restore(versions, removeExisting);            // unregister the event listener again            unregisterEventListener(el);        } catch (RepositoryException e) {            throw new JcrDavException(e);        }        return ms;    }    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public MultiStatus merge(MergeInfo mergeInfo) throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public void label(LabelInfo labelInfo) throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    /**     * @throws DavException (403) since workspace is not versionable. implementing     * <code>VersionControlledResource</code> only for 'update'.     */    public VersionHistoryResource getVersionHistory() throws DavException {        throw new DavException(DavServletResponse.SC_FORBIDDEN);    }    //---------------------------------------------------< AbstractResource >---    protected void initLockSupport() {        // lock not allowed    }    protected void initSupportedReports() {        super.initSupportedReports();        supportedReports.addReportType(JcrPrivilegeReport.PRIVILEGES_REPORT);    }        protected String getWorkspaceHref() {        return getHref();    }    protected void initProperties() {        super.initProperties();        try {            // init workspace specific properties            NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();            DavProperty namespacesProp = new NamespacesProperty(nsReg);            properties.add(namespacesProp);        } catch (RepositoryException e) {            log.error("Failed to access NamespaceRegistry: " + e.getMessage());        }        // TODO: required property DAV:workspace-checkout-set (computed)    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -