/** * 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())); }
/** * 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())); }
/** * Reads all versions of the given resource.<br> * * This method returns a list with the history of the given resource, i.e. * the historical resource entries, independent of the project they were attached to.<br> * * The reading excludes the file content.<p> * * @param dbc the current database context * @param resource the resource to read the history for * * @return a list of file headers, as <code>{@link I_CmsHistoryResource}</code> objects * * @throws CmsException if something goes wrong */ public List readAllAvailableVersions(CmsDbContext dbc, CmsResource resource) throws CmsException { // read the historical resources List versions = m_historyDriver.readAllAvailableVersions(dbc, resource.getStructureId()); if ((versions.size() > OpenCms.getSystemInfo().getHistoryVersions()) && (OpenCms.getSystemInfo().getHistoryVersions() > -1)) { return versions.subList(0, OpenCms.getSystemInfo().getHistoryVersions()); } return versions; }
/** * Reads all versions of the given resource.<br> * * This method returns a list with the history of the given resource, i.e. * the historical resource entries, independent of the project they were attached to.<br> * * The reading excludes the file content.<p> * * @param dbc the current database context * @param resource the resource to read the history for * * @return a list of file headers, as <code>{@link I_CmsHistoryResource}</code> objects * * @throws CmsException if something goes wrong */ public List<I_CmsHistoryResource> readAllAvailableVersions(CmsDbContext dbc, CmsResource resource) throws CmsException { // read the historical resources List<I_CmsHistoryResource> versions = getHistoryDriver(dbc).readAllAvailableVersions( dbc, resource.getStructureId()); if ((versions.size() > OpenCms.getSystemInfo().getHistoryVersions()) && (OpenCms.getSystemInfo().getHistoryVersions() > -1)) { return versions.subList(0, OpenCms.getSystemInfo().getHistoryVersions()); } return versions; }