/** * @see org.opencms.repository.I_CmsRepositoryItem#getLastModifiedDate() */ public long getLastModifiedDate() { return m_resource.getDateLastModified(); }
/** * @see org.opencms.repository.I_CmsRepositoryItem#getLastModifiedDate() */ public long getLastModifiedDate() { return m_resource.getDateLastModified(); }
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(CmsResource r1, CmsResource r2) { if (r1 == r2) { return 0; } long date1 = r1.getDateReleased(); if (date1 == CmsResource.DATE_RELEASED_DEFAULT) { // use creation date if release date is not set date1 = r1.getDateLastModified(); } long date2 = r2.getDateReleased(); if (date2 == CmsResource.DATE_RELEASED_DEFAULT) { // use creation date if release date is not set date2 = r2.getDateLastModified(); } return (date1 > date2) ? 1 : (date1 < date2) ? -1 : 0; } };
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) { return 0; } CmsResource r1 = (CmsResource)o1; CmsResource r2 = (CmsResource)o2; long date1 = r1.getDateReleased(); if (date1 == CmsResource.DATE_RELEASED_DEFAULT) { // use creation date if release date is not set date1 = r1.getDateLastModified(); } long date2 = r2.getDateReleased(); if (date2 == CmsResource.DATE_RELEASED_DEFAULT) { // use creation date if release date is not set date2 = r2.getDateLastModified(); } return (date1 > date2) ? 1 : (date1 < date2) ? -1 : 0; } };
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) { return 0; } CmsResource r1 = (CmsResource)o1; CmsResource r2 = (CmsResource)o2; long date1 = r1.getDateReleased(); if (date1 == CmsResource.DATE_RELEASED_DEFAULT) { // use last modification date if release date is not set date1 = r1.getDateLastModified(); } long date2 = r2.getDateReleased(); if (date2 == CmsResource.DATE_RELEASED_DEFAULT) { // use last modification date if release date is not set date2 = r2.getDateLastModified(); } return (date1 > date2) ? -1 : (date1 < date2) ? 1 : 0; } };
/** * Returns the last modified date of the current resource as localized String.<p> * * @return the date of last modification */ protected String getLastModifiedDate() { long dateLong = getCurrentResource().getDateLastModified(); return getMessages().getDateTime(dateLong); }
/** * Returns the last modified date of the current resource as localized String.<p> * * @return the date of last modification */ protected String getLastModifiedDate() { long dateLong = getCurrentResource().getDateLastModified(); return getMessages().getDateTime(dateLong); }
/** * Removes an access control entry for a given resource and principal.<p> * * @param dbc the current database context * @param resource the resource * @param principal the id of the principal to remove the the access control entry for * * @throws CmsException if something goes wrong */ public void removeAccessControlEntry(CmsDbContext dbc, CmsResource resource, CmsUUID principal) throws CmsException { // remove the ace m_userDriver.removeAccessControlEntry(dbc, dbc.currentProject(), resource.getResourceId(), principal); // update the "last modified" information setDateLastModified(dbc, resource, resource.getDateLastModified()); // clear the cache m_monitor.clearAccessControlListCache(); // fire a resource modification event HashMap data = new HashMap(2); data.put(I_CmsEventListener.KEY_RESOURCE, resource); data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_ACCESSCONTROL)); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data)); }
/** * Updates the "last modified" date for this context as well as the * "expires" date with the values from a given resource.<p> * * The "expires" date is the calculated from the given date values * of resource release and expiration and also the current time.<p> * * @param resource the resource to use for updating the context values */ public void updateFromResource(CmsResource resource) { // first set the last modification date updateDateLastModified(resource.getDateLastModified()); // now use both release and expiration date from the resource to update the expires info updateDateExpires(resource.getDateReleased()); updateDateExpires(resource.getDateExpired()); } }
/** * Updates the "last modified" date for this context as well as the * "expires" date with the values from a given resource.<p> * * The "expires" date is the calculated from the given date values * of resource release and expiration and also the current time.<p> * * @param resource the resource to use for updating the context values */ public void updateFromResource(CmsResource resource) { // first set the last modification date updateDateLastModified(resource.getDateLastModified()); // now use both release and expiration date from the resource to update the expires info updateDateExpires(resource.getDateReleased()); updateDateExpires(resource.getDateExpired()); } }
/** * Extends the given document by fields for date of creation, content and last modification.<p> * * @param document the document to extend * @param cms the OpenCms context used for building the search index * @param resource the resource that is indexed * @param extractionResult the plain text extraction result from the resource * @param properties the list of all properties directly attached to the resource (not searched) * @param propertiesSearched the list of all searched properties of the resource * * @return the document extended by fields for date of creation, content and last modification */ protected I_CmsSearchDocument appendDates( I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) { document.addDateField(CmsSearchField.FIELD_DATE_CREATED, resource.getDateCreated(), true); document.addDateField(CmsSearchField.FIELD_DATE_LASTMODIFIED, resource.getDateLastModified(), true); document.addDateField(CmsSearchField.FIELD_DATE_CONTENT, resource.getDateContent(), false); return document; }
/** * @see org.opencms.workflow.CmsDefaultPublishResourceFormatter.I_PublishResourceValidator#getInfoForResource(org.opencms.file.CmsResource) */ public CmsPublishResourceInfo getInfoForResource(CmsResource resource) throws CmsException { String info; CmsPublishResourceInfo.Type infoType; CmsPublishResourceInfo infoObj; String publishUser = getOuAwareName(m_cms, m_cms.readUser(resource.getUserLastModified()).getName()); Date publishDate = new Date(resource.getDateLastModified()); info = Messages.get().getBundle(getLocale()).key( Messages.GUI_RESOURCE_PUBLISHED_BY_2, publishUser, publishDate); infoType = CmsPublishResourceInfo.Type.PUBLISHED; infoObj = new CmsPublishResourceInfo(info, infoType); return infoObj; } }
/** * @see org.opencms.file.types.I_CmsResourceType#importResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, org.opencms.file.CmsResource, byte[], List) */ public CmsResource importResource( CmsObject cms, CmsSecurityManager securityManager, String resourcename, CmsResource resource, byte[] content, List properties) throws CmsException { // this triggers the internal "is touched" state // and prevents the security manager from inserting the current time resource.setDateLastModified(resource.getDateLastModified()); // ensure resource record is updated resource.setState(CmsResource.STATE_NEW); return securityManager.importResource( cms.getRequestContext(), cms.getRequestContext().addSiteRoot(resourcename), resource, content, properties, true); }
/** * Copies state information from the internal CmsResource object to this object.<p> */ protected void updateFromResource() { setCreationDate(m_resource.getDateCreated()); int length = m_resource.getLength(); if (m_resource.isFolder()) { length = 1; } setFileSize(length); setModifyDate(m_resource.getDateLastModified()); setAttributes(m_resource.isFile() ? FileAttribute.Normal : FileAttribute.Directory); }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * @see org.opencms.search.fields.CmsSearchFieldConfiguration#appendDates(org.opencms.search.I_CmsSearchDocument, org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List) */ @Override protected I_CmsSearchDocument appendDates( I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) { document.addDateField(CmsSearchField.FIELD_DATE_CREATED, resource.getDateCreated(), false); document.addDateField(CmsSearchField.FIELD_DATE_LASTMODIFIED, resource.getDateLastModified(), false); document.addDateField(CmsSearchField.FIELD_DATE_CONTENT, resource.getDateContent(), false); document.addDateField(CmsSearchField.FIELD_DATE_RELEASED, resource.getDateReleased(), false); document.addDateField(CmsSearchField.FIELD_DATE_EXPIRED, resource.getDateExpired(), false); return document; }
/** * @see org.opencms.gwt.shared.rpc.I_CmsCoreService#lockTempAndCheckModification(org.opencms.util.CmsUUID, long) */ public CmsLockInfo lockTempAndCheckModification(CmsUUID structureId, long modification) throws CmsRpcException { CmsObject cms = getCmsObject(); try { CmsResource resource = cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION); if (resource.getDateLastModified() != modification) { CmsUser user = cms.readUser(resource.getUserLastModified()); return CmsLockInfo.forChangedResource(user.getFullName()); } } catch (Throwable e) { error(e); } try { return getLock(structureId); } catch (CmsException e) { return CmsLockInfo.forError(e.getLocalizedMessage()); } }
/** * Adds additional info items for broken links.<p> * * @param cms the CMS context to use * @param resource the resource from which the additional infos should be read * @param result the result in which to store the additional info */ private void addBrokenLinkAdditionalInfo(CmsObject cms, CmsResource resource, CmsBrokenLinkBean result) { String dateLastModifiedLabel = org.opencms.workplace.commons.Messages.get().getBundle( OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key( org.opencms.workplace.commons.Messages.GUI_LABEL_DATE_LAST_MODIFIED_0); String dateLastModified = CmsVfsService.formatDateTime(cms, resource.getDateLastModified()); String userLastModifiedLabel = org.opencms.workplace.commons.Messages.get().getBundle( OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key( org.opencms.workplace.commons.Messages.GUI_LABEL_USER_LAST_MODIFIED_0); String userLastModified = "" + resource.getUserLastModified(); try { userLastModified = cms.readUser(resource.getUserLastModified()).getName(); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } result.addInfo(dateLastModifiedLabel, dateLastModified); result.addInfo(userLastModifiedLabel, userLastModified); }
/** * Constructor, creates a new CmsFolder Object from the given CmsResource.<p> * * @param resource the base resource object to create a folder from */ public CmsFolder(CmsResource resource) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getVersion()); }
/** * Returns the virtual resource.<p> * * @return the virtual resource */ public CmsResource getResource() { return new CmsResource( m_base.getStructureId(), m_base.getResourceId(), m_rootPath, m_typeId, m_isFolder, m_base.getFlags(), m_base.getProjectLastModified(), m_base.getState(), m_base.getDateCreated(), m_base.getUserCreated(), m_base.getDateLastModified(), m_base.getUserLastModified(), m_base.getDateReleased(), m_base.getDateExpired(), m_base.getSiblingCount(), m_length, m_base.getDateContent(), m_base.getVersion()); }