mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Beginning interface for AVM locking.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5531 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
156
source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java
Normal file
156
source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 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.service.cmr.avm.locking;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.attributes.Attribute;
|
||||||
|
import org.alfresco.repo.attributes.BooleanAttributeImpl;
|
||||||
|
import org.alfresco.repo.attributes.MapAttribute;
|
||||||
|
import org.alfresco.repo.attributes.MapAttributeImpl;
|
||||||
|
import org.alfresco.repo.attributes.StringAttributeImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Struct representing an AVM lock.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class AVMLock implements Serializable
|
||||||
|
{
|
||||||
|
public static String PATH = "path";
|
||||||
|
public static String STORE = "store";
|
||||||
|
public static String OWNERS = "owners";
|
||||||
|
public static String WEBPROJECT = "webproject";
|
||||||
|
public static String TYPE = "type";
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -8026344276097527239L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The store relative path of the lock.
|
||||||
|
*/
|
||||||
|
private String fPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The store of the actual locked version.
|
||||||
|
*/
|
||||||
|
private String fStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of users who can access the locked asset.
|
||||||
|
*/
|
||||||
|
private List<String> fOwners;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The web project for which this lock applies.
|
||||||
|
*/
|
||||||
|
private String fWebProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the lock.
|
||||||
|
*/
|
||||||
|
private AVMLockingService.Type fType;
|
||||||
|
|
||||||
|
public AVMLock(String webProject,
|
||||||
|
String store,
|
||||||
|
String path,
|
||||||
|
AVMLockingService.Type type,
|
||||||
|
List<String> owners)
|
||||||
|
{
|
||||||
|
fWebProject = webProject;
|
||||||
|
fStore = store;
|
||||||
|
fPath = path;
|
||||||
|
fType = type;
|
||||||
|
fOwners = owners;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AVMLock(Attribute lockData)
|
||||||
|
{
|
||||||
|
fPath = lockData.get(PATH).getStringValue();
|
||||||
|
fStore = lockData.get(STORE).getStringValue();
|
||||||
|
fOwners = new ArrayList<String>(lockData.get(OWNERS).keySet());
|
||||||
|
fType = AVMLockingService.Type.valueOf(lockData.get(TYPE).getStringValue());
|
||||||
|
fWebProject = lockData.get(WEBPROJECT).getStringValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Attribute getAttribute()
|
||||||
|
{
|
||||||
|
MapAttribute lockData = new MapAttributeImpl();
|
||||||
|
lockData.put(PATH, new StringAttributeImpl(fPath));
|
||||||
|
lockData.put(STORE, new StringAttributeImpl(fStore));
|
||||||
|
lockData.put(TYPE, new StringAttributeImpl(fType.name()));
|
||||||
|
lockData.put(WEBPROJECT, new StringAttributeImpl(fWebProject));
|
||||||
|
MapAttribute owners = new MapAttributeImpl();
|
||||||
|
for (String owner : fOwners)
|
||||||
|
{
|
||||||
|
// The value is a dummy.
|
||||||
|
owners.put(owner, new BooleanAttributeImpl(true));
|
||||||
|
}
|
||||||
|
lockData.put(OWNERS, owners);
|
||||||
|
return lockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the owners
|
||||||
|
*/
|
||||||
|
public List<String> getOwners()
|
||||||
|
{
|
||||||
|
return fOwners;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Path
|
||||||
|
*/
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return fPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Store
|
||||||
|
*/
|
||||||
|
public String getStore()
|
||||||
|
{
|
||||||
|
return fStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Type
|
||||||
|
*/
|
||||||
|
public AVMLockingService.Type getType()
|
||||||
|
{
|
||||||
|
return fType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the WebProject
|
||||||
|
*/
|
||||||
|
public String getWebProject()
|
||||||
|
{
|
||||||
|
return fWebProject;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 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.service.cmr.avm.locking;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to handle AVM locking.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public interface AVMLockingService
|
||||||
|
{
|
||||||
|
public enum Type implements Serializable
|
||||||
|
{
|
||||||
|
DISCRETIONARY
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a lock of the given type on a path.
|
||||||
|
* The lock is used to control access to all the
|
||||||
|
* corresponding paths in the given path's web project.
|
||||||
|
* @param lock The lock structure to create.
|
||||||
|
*/
|
||||||
|
public void lockPath(AVMLock lock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a lock on a given path
|
||||||
|
* @param webProject The website for which to get the lock.
|
||||||
|
* @param path The path to check for a lock.
|
||||||
|
* @return The Lock structure or null if there is no lock.
|
||||||
|
*/
|
||||||
|
public AVMLock getLock(String webProject, String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a lock.
|
||||||
|
* @param webProject The web project the lock lives in.
|
||||||
|
* @param path The store relative path of the lock.
|
||||||
|
*/
|
||||||
|
public void removeLock(String webProject, String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the locks that a user owns.
|
||||||
|
* @param user The name of the user.
|
||||||
|
* @return The (possibly empty list) of the user's locks.
|
||||||
|
*/
|
||||||
|
public List<AVMLock> getUsersLocks(String user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all locks in a webProject.
|
||||||
|
* @param webProject
|
||||||
|
* @return A List (possibly empty) of all locks in a web project.
|
||||||
|
*/
|
||||||
|
public List<AVMLock> getLocks(String webProject);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a web project.
|
||||||
|
* @param webProject The web project name.
|
||||||
|
*/
|
||||||
|
public void addWebProject(String webProject);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a web project from the locking tables.
|
||||||
|
* @param webProject The web project name.
|
||||||
|
*/
|
||||||
|
public void removeWebProject(String webProject);
|
||||||
|
}
|
Reference in New Issue
Block a user