/** * Get the ETag associated with a file.<p> * * @param item the WebDavItem * * @return the created ETag for the resource attributes */ protected String getETag(I_CmsRepositoryItem item) { return "\"" + item.getContentLength() + "-" + item.getLastModifiedDate() + "\""; }
/** * Constructor with an initialized {@link CmsObjectWrapper} and a * {@link CmsRepositoryFilter} to use.<p> * * @param cms the initialized CmsObject * @param filter the repository filter to use */ public CmsRepositorySession(CmsObjectWrapper cms, CmsRepositoryFilter filter) { m_cms = cms; setFilter(filter); }
/** * @see org.opencms.repository.A_CmsRepository#initConfiguration() */ @Override public void initConfiguration() throws CmsConfigurationException { CmsParameterConfiguration config = getConfiguration(); List<I_CmsResourceWrapper> wrapperObjects = CmsRepositoryManager.createResourceWrappersFromConfiguration( config, PARAM_WRAPPER, LOG); m_wrappers = Collections.unmodifiableList(wrapperObjects); super.initConfiguration(); }
/** * @see org.opencms.repository.I_CmsRepositorySession#getItem(java.lang.String) */ public I_CmsRepositoryItem getItem(String path) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_ITEM_1, path)); } CmsResource res = m_cms.readResource(path, CmsResourceFilter.DEFAULT); CmsRepositoryItem item = new CmsRepositoryItem(res, m_cms); return item; }
/** * @see org.opencms.repository.I_CmsRepositorySession#lock(java.lang.String, org.opencms.repository.CmsRepositoryLockInfo) */ public boolean lock(String path, CmsRepositoryLockInfo lock) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LOCK_ITEM_1, path)); } m_cms.lockResource(path); return true; }
/** * Check to see if a resource is currently write locked.<p> * * @param path the path where to find the resource to check the lock * * @return true if the resource is locked otherwise false */ private boolean isLocked(String path) { // get lock for path CmsRepositoryLockInfo lock = m_session.getLock(path); if (lock == null) { return false; } // check if found lock fits to the lock token from request // String currentToken = "<opaquelocktoken:" + generateLockToken(req, lock) + ">"; // if (currentToken.equals(parseLockTokenHeader(req))) { // return false; // } if (lock.getUsername().equals(m_username)) { return false; } return true; }
/** * @see org.opencms.repository.I_CmsRepositorySession#exists(java.lang.String) */ public boolean exists(String path) { try { path = validatePath(path); return m_cms.existsResource(path); } catch (CmsException ex) { return false; } }
/** * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration() */ public void initConfiguration() throws CmsConfigurationException { if (m_filter != null) { m_filter.initConfiguration(); } // suppress the compiler warning, this is never true if (m_configuration == null) { throw new CmsConfigurationException(null); } }
/** * Checks if a path is filtered out of the filter or not.<p> * * @param path the path of a resource to check * @return true if the name matches one of the given filter patterns */ protected boolean isFiltered(String path) { // filter all temporary files if (CmsWorkplace.isTemporaryFileName(path)) { return true; } if (m_filter == null) { return false; } return m_filter.isFiltered(path); }
/** * Print the lock discovery information associated with a path.<p> * * @param path the path to the resource * @param elem the dom element where to add the lock discovery elements * @param req the servlet request we are processing * * @return true if at least one lock was displayed */ private boolean generateLockDiscovery(String path, Element elem, HttpServletRequest req) { CmsRepositoryLockInfo lock = m_session.getLock(path); if (lock != null) { Element lockElem = addElement(elem, TAG_LOCKDISCOVERY); addLockElement(lock, lockElem, generateLockToken(req, lock)); return true; } return false; }
/** * @see org.opencms.repository.I_CmsRepositorySession#getItem(java.lang.String) */ public I_CmsRepositoryItem getItem(String path) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_ITEM_1, path)); } CmsResource res = m_cms.readResource(path, CmsResourceFilter.DEFAULT); CmsRepositoryItem item = new CmsRepositoryItem(res, m_cms); return item; }
/** * @see org.opencms.repository.I_CmsRepositorySession#lock(java.lang.String, org.opencms.repository.CmsRepositoryLockInfo) */ public boolean lock(String path, CmsRepositoryLockInfo lock) throws CmsException { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_LOCK_ITEM_1, path)); } m_cms.lockResource(path); return true; }
/** * Get the ETag associated with a file.<p> * * @param item the WebDavItem * * @return the created ETag for the resource attributes */ protected String getETag(I_CmsRepositoryItem item) { return "\"" + item.getContentLength() + "-" + item.getLastModifiedDate() + "\""; }
/** * Check to see if a resource is currently write locked.<p> * * @param path the path where to find the resource to check the lock * * @return true if the resource is locked otherwise false */ private boolean isLocked(String path) { // get lock for path CmsRepositoryLockInfo lock = m_session.getLock(path); if (lock == null) { return false; } // check if found lock fits to the lock token from request // String currentToken = "<opaquelocktoken:" + generateLockToken(req, lock) + ">"; // if (currentToken.equals(parseLockTokenHeader(req))) { // return false; // } if (lock.getUsername().equals(m_username)) { return false; } return true; }
/** * Constructor with an initialized {@link CmsObjectWrapper} and a * {@link CmsRepositoryFilter} to use.<p> * * @param cms the initialized CmsObject * @param filter the repository filter to use */ public CmsRepositorySession(CmsObjectWrapper cms, CmsRepositoryFilter filter) { m_cms = cms; setFilter(filter); }
/** * @see org.opencms.repository.I_CmsRepositorySession#exists(java.lang.String) */ public boolean exists(String path) { try { path = validatePath(path); return m_cms.existsResource(path); } catch (CmsException ex) { return false; } }
/** * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration() */ public void initConfiguration() throws CmsConfigurationException { if (m_filter != null) { m_filter.initConfiguration(); } // suppress the compiler warning, this is never true if (m_configuration == null) { throw new CmsConfigurationException(null); } }
/** * Checks if a path is filtered out of the filter or not.<p> * * @param path the path of a resource to check * @return true if the name matches one of the given filter patterns */ protected boolean isFiltered(String path) { // filter all temporary files if (CmsResource.isTemporaryFileName(path)) { return true; } if (m_filter == null) { return false; } return m_filter.isFiltered(path); }
/** * Print the lock discovery information associated with a path.<p> * * @param path the path to the resource * @param elem the dom element where to add the lock discovery elements * @param req the servlet request we are processing * * @return true if at least one lock was displayed */ private boolean generateLockDiscovery(String path, Element elem, HttpServletRequest req) { CmsRepositoryLockInfo lock = m_session.getLock(path); if (lock != null) { Element lockElem = addElement(elem, TAG_LOCKDISCOVERY); addLockElement(lock, lockElem, generateLockToken(req, lock)); return true; } return false; }
/** * @see org.opencms.repository.I_CmsRepositorySession#unlock(java.lang.String) */ public void unlock(String path) { try { path = validatePath(path); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_UNLOCK_ITEM_1, path)); } m_cms.unlockResource(path); } catch (CmsException ex) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_UNLOCK_FAILED_0), ex); } } }