WCM SandboxService - add SandboxVersion (wraps AVM VersionDescriptor)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12640 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-01-08 17:38:45 +00:00
parent 799761d5e9
commit f2d23ec0c1
5 changed files with 193 additions and 15 deletions

View File

@@ -322,9 +322,9 @@ public interface SandboxService
* *
* @param sbStoreId staging sandbox store id * @param sbStoreId staging sandbox store id
* @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots
* @return List<VersionDescriptor> list of AVM version descriptors * @return List<SandboxVersion> list of sandbox versions
*/ */
public List<VersionDescriptor> listSnapshots(String sbStoreId, boolean includeSystemGenerated); public List<SandboxVersion> listSnapshots(String sbStoreId, boolean includeSystemGenerated);
/** /**
* List snapshots (sandbox versions) for the given sandbox between given dates (ie. for staging sandbox) * 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 from from date
* @param to to date * @param to to date
* @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots * @param includeSystemGenerated if false will ignore system generated snapshots else true to get all snapshots
* @return List<VersionDescriptor> list of AVM version descriptors * @return List<SandboxVersion> list of sandbox versions
*/ */
public List<VersionDescriptor> listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated); public List<SandboxVersion> listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated);
} }

View File

@@ -693,7 +693,7 @@ public class SandboxServiceImpl implements SandboxService
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, boolean) * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, boolean)
*/ */
public List<VersionDescriptor> listSnapshots(String sbStoreId, boolean includeSystemGenerated) public List<SandboxVersion> listSnapshots(String sbStoreId, boolean includeSystemGenerated)
{ {
ParameterCheck.mandatoryString("sbStoreId", sbStoreId); ParameterCheck.mandatoryString("sbStoreId", sbStoreId);
@@ -710,7 +710,7 @@ public class SandboxServiceImpl implements SandboxService
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, java.util.Date, java.util.Date, boolean) * @see org.alfresco.wcm.sandbox.SandboxService#listSnapshots(java.lang.String, java.util.Date, java.util.Date, boolean)
*/ */
public List<VersionDescriptor> listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated) public List<SandboxVersion> listSnapshots(String sbStoreId, Date from, Date to, boolean includeSystemGenerated)
{ {
ParameterCheck.mandatoryString("sbStoreId", sbStoreId); ParameterCheck.mandatoryString("sbStoreId", sbStoreId);
@@ -724,9 +724,9 @@ public class SandboxServiceImpl implements SandboxService
return listSnapshots(versionsToFilter, includeSystemGenerated); return listSnapshots(versionsToFilter, includeSystemGenerated);
} }
private List<VersionDescriptor> listSnapshots(List<VersionDescriptor> versionsToFilter, boolean includeSystemGenerated) private List<SandboxVersion> listSnapshots(List<VersionDescriptor> versionsToFilter, boolean includeSystemGenerated)
{ {
List<VersionDescriptor> versions = new ArrayList<VersionDescriptor>(versionsToFilter.size()); List<SandboxVersion> versions = new ArrayList<SandboxVersion>(versionsToFilter.size());
for (int i = versionsToFilter.size() - 1; i >= 0; i--) // reverse order 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 // only display snapshots with a valid tag - others are system generated snapshots
if ((includeSystemGenerated == true) || ((item.getTag() != null) && (item.getVersionID() != 0))) if ((includeSystemGenerated == true) || ((item.getTag() != null) && (item.getVersionID() != 0)))
{ {
versions.add(item); versions.add(new SandboxVersionImpl(item));
} }
} }

View File

@@ -38,7 +38,6 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.avm.AVMService; 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.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthenticationService;
@@ -1221,7 +1220,7 @@ public class SandboxServiceImplTest extends TestCase
String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp; String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp;
assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size()); assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size());
List<VersionDescriptor> sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); List<SandboxVersion> sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false);
assertEquals(0, sbVersions.size()); assertEquals(0, sbVersions.size());
// submit (new assets) ! // submit (new assets) !
@@ -1289,7 +1288,7 @@ public class SandboxServiceImplTest extends TestCase
String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp; String stagingSandboxPath = sbInfo.getSandboxRootPath() + "/" + webApp;
assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size()); assertEquals(0, assetService.listAssets(stagingSandboxId, -1, stagingSandboxPath, false).size());
List<VersionDescriptor> sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false); List<SandboxVersion> sbVersions = sbService.listSnapshots(stagingSandboxId, fromDate, new Date(), false);
assertEquals(0, sbVersions.size()); assertEquals(0, sbVersions.size());
// submit (new assets) ! // submit (new assets) !
@@ -1378,8 +1377,8 @@ public class SandboxServiceImplTest extends TestCase
// revert to snapshot ... // revert to snapshot ...
VersionDescriptor version = sbVersions.get(1); SandboxVersion version = sbVersions.get(1);
int versionId = version.getVersionID(); int versionId = version.getVersion();
sbService.revertSnapshot(stagingSandboxId, versionId); sbService.revertSnapshot(stagingSandboxId, versionId);

View File

@@ -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();
}

View File

@@ -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));
}
}