/** * Reads an historical resource entry for the given resource and with the given version number.<p> * * @param dbc the current db context * @param resource the resource to be read * @param version the version number to retrieve * * @return the resource that was read * * @throws CmsException if the resource could not be read for any reason * * @see CmsObject#restoreResourceVersion(CmsUUID, int) * @see CmsObject#readResource(CmsUUID, int) */ public I_CmsHistoryResource readResource(CmsDbContext dbc, CmsResource resource, int version) throws CmsException { Iterator itVersions = m_historyDriver.readAllAvailableVersions(dbc, resource.getStructureId()).iterator(); while (itVersions.hasNext()) { I_CmsHistoryResource histRes = (I_CmsHistoryResource)itVersions.next(); if (histRes.getVersion() == version) { return histRes; } } throw new CmsVfsResourceNotFoundException(org.opencms.db.generic.Messages.get().container( org.opencms.db.generic.Messages.ERR_HISTORY_FILE_NOT_FOUND_1, resource.getStructureId())); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); List<I_CmsHistoryResource> list = getCms().readDeletedResources(m_resourcename, m_readTree); Iterator<I_CmsHistoryResource> iter = list.iterator(); while (iter.hasNext()) { I_CmsHistoryResource res = iter.next(); CmsListItem item = getList().newItem(res.getStructureId().toString()); String resourcePath = getCms().getSitePath((CmsResource)res); item.set(LIST_COLUMN_NAME, m_resourcename + "|" + resourcePath); LOG.info("deleted resource list, name = " + m_resourcename + "|" + resourcePath); item.set(LIST_COLUMN_DELETION_DATE, new Date(res.getDateLastModified())); item.set(LIST_COLUMN_VERSION, String.valueOf(res.getVersion())); item.set(LIST_COLUMN_TYPEID, String.valueOf(res.getTypeId())); ret.add(item); } return ret; }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List getListItems() throws CmsException { List ret = new ArrayList(); List list = getCms().readDeletedResources(m_resourcename, m_readTree); Iterator iter = list.iterator(); while (iter.hasNext()) { I_CmsHistoryResource res = (I_CmsHistoryResource)iter.next(); CmsListItem item = getList().newItem(res.getStructureId().toString()); String resourcePath = getCms().getSitePath((CmsResource)res); item.set(LIST_COLUMN_NAME, m_resourcename + "|" + resourcePath); item.set(LIST_COLUMN_DELETION_DATE, new Date(res.getDateLastModified())); item.set(LIST_COLUMN_VERSION, String.valueOf(res.getVersion())); item.set(LIST_COLUMN_TYPEID, String.valueOf(res.getTypeId())); ret.add(item); } return ret; }
/** * Reads an historical resource entry for the given resource and with the given version number.<p> * * @param dbc the current db context * @param resource the resource to be read * @param version the version number to retrieve * * @return the resource that was read * * @throws CmsException if the resource could not be read for any reason * * @see CmsObject#restoreResourceVersion(CmsUUID, int) * @see CmsObject#readResource(CmsUUID, int) */ public I_CmsHistoryResource readResource(CmsDbContext dbc, CmsResource resource, int version) throws CmsException { Iterator<I_CmsHistoryResource> itVersions = getHistoryDriver(dbc).readAllAvailableVersions( dbc, resource.getStructureId()).iterator(); while (itVersions.hasNext()) { I_CmsHistoryResource histRes = itVersions.next(); if (histRes.getVersion() == version) { return histRes; } } throw new CmsVfsResourceNotFoundException( org.opencms.db.generic.Messages.get().container( org.opencms.db.generic.Messages.ERR_HISTORY_FILE_NOT_FOUND_1, resource.getStructureId())); }
if (histRes.getVersion() > 1) {
/** * Restores a file in the current project with a version from the backup archive.<p> * * @param resourcename the name of the resource to restore from the archive (full current site relative path) * @param publishTag the desired tag ID of the resource * * @throws CmsException if something goes wrong * * @deprecated use {@link #restoreResourceVersion(CmsUUID, int)} instead, * but notice that the <code>publishTag != version</code> * and there is no possibility to access to an historical entry with just the filename. */ public void restoreResourceBackup(String resourcename, int publishTag) throws CmsException { CmsResource resource = readResource(resourcename, CmsResourceFilter.IGNORE_EXPIRATION); I_CmsHistoryResource history = readResourceByPublishTag(resource.getStructureId(), publishTag); restoreResourceVersion(resource.getStructureId(), history.getVersion()); }
if (histRes.getVersion() > 1) {
if (histRes.getVersion() > 1) {
maxVersion = Math.max(maxVersion, historyRes.getVersion());
histRes.getDateReleased(), histRes.getDateExpired(), histRes.getVersion(), parentId, histRes.getResourceVersion(),
histRes.getDateReleased(), histRes.getDateExpired(), histRes.getVersion(), parentId, histRes.getResourceVersion(), histRes.getLength(), histRes.getDateContent(), histRes.getVersion(), parentId, null,
String imageLink = null; if (resource instanceof I_CmsHistoryResource) { int version = ((I_CmsHistoryResource)resource).getVersion(); imageLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, String link = ""; if (resource instanceof I_CmsHistoryResource) { int version = ((I_CmsHistoryResource)resource).getVersion(); link = OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms,
long publishDate = project.getPublishingDate(); result.setDatePublished(formatDate(publishDate, locale)); int version = ((I_CmsHistoryResource)historyRes).getVersion(); result.setVersion( new CmsHistoryVersion(
histRes.getLength(), histRes.getDateContent(), histRes.getVersion());
/** * Constructor from a history resource.<p> * * @param resource the base history resource */ public CmsHistoryFolder(I_CmsHistoryResource resource) { this( resource.getPublishTag(), 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(), resource.getParentId(), resource.getResourceVersion(), resource.getStructureVersion()); }
CmsResource resource = (CmsResource)getCms().readResource( getCms().readResource(histRes.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION).getStructureId(), histRes.getVersion()); String datePublished = getMessages().getDateTime(project.getPublishingDate()); CmsListItem item = getList().newItem("" + histRes.getVersion()); factor = -1; CmsVersionWrapper version = new CmsVersionWrapper(factor * histRes.getVersion());
String datePublished = getMessages().getDateTime(project.getPublishingDate()); CmsListItem item = getList().newItem("" + histRes.getVersion()); factor = -1; CmsVersionWrapper version = new CmsVersionWrapper(factor * histRes.getVersion());
org.opencms.ui.Messages.GUI_RESTOREDELETED_DATE_VERSION_2, CmsVfsService.formatDateTime(cms, deleted.getDateLastModified()), "" + deleted.getVersion()); String iconPath = OpenCms.getWorkplaceManager().getExplorerTypeSetting( deleted.isFile() ? "unknown_file" : "unknown_folder").getBigIconIfAvailable();
/** * Constructor from a history resource.<p> * * @param resource the base history resource */ public CmsHistoryFile(I_CmsHistoryResource resource) { this( resource.getPublishTag(), 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.getLength(), resource.getDateContent(), resource.getVersion(), resource.getParentId(), resource.isFile() ? ((CmsFile)resource).getContents() : null, resource.getResourceVersion(), resource.getStructureVersion()); }