diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxService.java b/source/java/org/alfresco/wcm/sandbox/SandboxService.java index 678fc28974..d3824a2f76 100644 --- a/source/java/org/alfresco/wcm/sandbox/SandboxService.java +++ b/source/java/org/alfresco/wcm/sandbox/SandboxService.java @@ -322,9 +322,9 @@ public interface SandboxService * * @param sbStoreId staging sandbox store id * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots - * @return List list of AVM version descriptors + * @return List list of sandbox versions */ - public List listSnapshots(String sbStoreId, boolean includeSystemGenerated); + public List listSnapshots(String sbStoreId, boolean includeSystemGenerated); /** * List snapshots (sandbox versions) for the given sandbox between given dates (ie. for staging sandbox) @@ -335,8 +335,7 @@ public interface SandboxService * @param from from date * @param to to date * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots - * @return List list of AVM version descriptors + * @return List list of sandbox versions */ - public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated); - + public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated); } diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java b/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java index e1166f2763..c0ae51a72d 100644 --- a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java +++ b/source/java/org/alfresco/wcm/sandbox/SandboxServiceImpl.java @@ -693,7 +693,7 @@ public class SandboxServiceImpl implements SandboxService /* (non-Javadoc) * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, boolean) */ - public List listSnapshots(String sbStoreId, boolean includeSystemGenerated) + public List listSnapshots(String sbStoreId, boolean includeSystemGenerated) { ParameterCheck.mandatoryString("sbStoreId", sbStoreId); @@ -710,7 +710,7 @@ public class SandboxServiceImpl implements SandboxService /* (non-Javadoc) * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, java.util.Date, java.util.Date, boolean) */ - public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated) + public List listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated) { ParameterCheck.mandatoryString("sbStoreId", sbStoreId); @@ -724,9 +724,9 @@ public class SandboxServiceImpl implements SandboxService return listSnapshots(versionsToFilter, includeSystemGenerated); } - private List listSnapshots(List versionsToFilter, boolean includeSystemGenerated) + private List listSnapshots(List versionsToFilter, boolean includeSystemGenerated) { - List versions = new ArrayList(versionsToFilter.size()); + List versions = new ArrayList(versionsToFilter.size()); for (int i = versionsToFilter.size() - 1; i >= 0; i--) // reverse order { @@ -735,7 +735,7 @@ public class SandboxServiceImpl implements SandboxService // only display snapshots with a valid tag - others are system generated snapshots if ((includeSystemGenerated == true) || ((item.getTag() != null) && (item.getVersionID() != 0))) { - versions.add(item); + versions.add(new SandboxVersionImpl(item)); } } diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImplTest.java b/source/java/org/alfresco/wcm/sandbox/SandboxServiceImplTest.java index b151eb57a0..f0d51459aa 100644 --- a/source/java/org/alfresco/wcm/sandbox/SandboxServiceImplTest.java +++ b/source/java/org/alfresco/wcm/sandbox/SandboxServiceImplTest.java @@ -38,7 +38,6 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.VersionDescriptor; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.security.AuthenticationService; @@ -1221,7 +1220,7 @@ public class SandboxServiceImplTest extends TestCase String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp; assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size()); - List sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); + List sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); assertEquals(0, sbVersions.size()); // submit (new assets) ! @@ -1289,7 +1288,7 @@ public class SandboxServiceImplTest extends TestCase String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp; assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size()); - List sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); + List sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); assertEquals(0, sbVersions.size()); // submit (new assets) ! @@ -1378,8 +1377,8 @@ public class SandboxServiceImplTest extends TestCase // revert to snapshot ... - VersionDescriptor version = sbVersions.get(1); - int versionId = version.getVersionID(); + SandboxVersion version = sbVersions.get(1); + int versionId = version.getVersion(); sbService.revertSnapshot(stagingSandboxId, versionId); diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java b/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java new file mode 100644 index 0000000000..b796e606b1 --- /dev/null +++ b/source/java/org/alfresco/wcm/sandbox/SandboxVersion.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2005-2008 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.wcm.sandbox; + +import java.util.Date; + +/** +* Provides information about a WCM sandbox version (snapshot). +*/ +public interface SandboxVersion +{ + /** + * Get the sandbox id + * + * @return String sandbox id + */ + public String getSandboxId(); + + /** + * Get the sandbox version ID + * + * @return The version + */ + public int getVersion(); + + /** + * Get the creator of this version + * + * @return The creator + */ + public String getCreator(); + + /** + * Get the creation date + * + * @return The creation date + */ + public Date getCreatedDate(); + + /** + * Get the short description + * + * @return The short description + */ + public String getTag(); + + /** + * Get the long description + * + * @return The long description + */ + public String getDescription(); + + /** + * Return true if system generated snapshot + * + * @return TRUE if system (implicit) snapshot + */ + boolean isSystemGenerated(); +} diff --git a/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java b/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java new file mode 100644 index 0000000000..bb961cee53 --- /dev/null +++ b/source/java/org/alfresco/wcm/sandbox/SandboxVersionImpl.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2005-2008 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.wcm.sandbox; + +import java.util.Date; + +import org.alfresco.service.cmr.avm.VersionDescriptor; + +/** +* Provides information about a WCM sandbox version (snapshot). +*/ +public class SandboxVersionImpl implements SandboxVersion +{ + private VersionDescriptor vDesc; + + /* package */ SandboxVersionImpl(VersionDescriptor vDesc) + { + this.vDesc = vDesc; + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getSandboxId() + */ + public String getSandboxId() + { + return vDesc.getAVMStoreName(); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getVersion() + */ + public int getVersion() + { + return vDesc.getVersionID(); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getCreator() + */ + public String getCreator() + { + return vDesc.getCreator(); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getCreatedDate() + */ + public Date getCreatedDate() + { + return new Date(vDesc.getCreateDate()); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getTag() + */ + public String getTag() + { + return vDesc.getTag(); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#getDescription() + */ + public String getDescription() + { + return vDesc.getDescription(); + } + + /* (non-Javadoc) + * @see org.alfresco.wcm.sandbox.SandboxVersion#isSystemGenerated() + */ + public boolean isSystemGenerated() + { + return ((vDesc.getTag() == null) || (vDesc.getVersionID() == 0)); + } +}