diff --git a/config/alfresco/remote-services-context.xml b/config/alfresco/remote-services-context.xml index 78f4249e08..9360548984 100644 --- a/config/alfresco/remote-services-context.xml +++ b/config/alfresco/remote-services-context.xml @@ -57,6 +57,31 @@ + + + + + + + + + + + + + + + + org.alfresco.service.cmr.remote.AttributeServiceTransport + + + attributes + + + ${avm.remote.port} + + + @@ -139,17 +164,4 @@ ${avm.remote.port} - - - - - - - - org.alfresco.service.cmr.attributes.AttributeService - - - ${avm.remote.port} - - \ No newline at end of file diff --git a/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java b/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java new file mode 100644 index 0000000000..c6b25be44b --- /dev/null +++ b/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java @@ -0,0 +1,210 @@ +/* + * 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.repo.attributes; + +import java.util.List; + +import org.alfresco.service.cmr.attributes.AttrQuery; +import org.alfresco.service.cmr.attributes.AttributeService; +import org.alfresco.service.cmr.remote.AttributeServiceTransport; +import org.alfresco.service.cmr.security.AuthenticationService; +import org.alfresco.util.Pair; + +/** + * Server side implementation of transport for AttributeService. + * @author britt + */ +public class AttributeServiceTransportService implements + AttributeServiceTransport +{ + private AttributeService fService; + + private AuthenticationService fAuthService; + + public AttributeServiceTransportService() + { + } + + public void setAttributeService(AttributeService service) + { + fService = service; + } + + public void setAuthenticationService(AuthenticationService service) + { + fAuthService = service; + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#addAttribute(java.lang.String, java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void addAttribute(String ticket, String path, Attribute value) + { + fAuthService.validate(ticket); + fService.addAttribute(path, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#addAttribute(java.lang.String, java.util.List, org.alfresco.repo.attributes.Attribute) + */ + public void addAttribute(String ticket, List keys, Attribute value) + { + fAuthService.validate(ticket); + fService.addAttribute(keys, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#getAttribute(java.lang.String, java.lang.String) + */ + public Attribute getAttribute(String ticket, String path) + { + fAuthService.validate(ticket); + return fService.getAttribute(path); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#getAttribute(java.lang.String, java.util.List) + */ + public Attribute getAttribute(String ticket, List keys) + { + fAuthService.validate(ticket); + return fService.getAttribute(keys); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#getKeys(java.lang.String, java.lang.String) + */ + public List getKeys(String ticket, String path) + { + fAuthService.validate(ticket); + return fService.getKeys(path); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#getKeys(java.lang.String, java.util.List) + */ + public List getKeys(String ticket, List keys) + { + fAuthService.validate(ticket); + return fService.getKeys(keys); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#query(java.lang.String, java.lang.String, org.alfresco.service.cmr.attributes.AttrQuery) + */ + public List> query(String ticket, String path, + AttrQuery query) + { + fAuthService.validate(ticket); + return fService.query(path, query); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#query(java.lang.String, java.util.List, org.alfresco.service.cmr.attributes.AttrQuery) + */ + public List> query(String ticket, + List keys, AttrQuery query) + { + fAuthService.validate(ticket); + return fService.query(keys, query); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#removeAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + public void removeAttribute(String ticket, String path, String name) + { + fAuthService.validate(ticket); + fService.removeAttribute(path, name); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#removeAttribute(java.lang.String, java.util.List, java.lang.String) + */ + public void removeAttribute(String ticket, List keys, String name) + { + fAuthService.validate(ticket); + fService.removeAttribute(keys, name); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#removeAttribute(java.lang.String, java.lang.String, int) + */ + public void removeAttribute(String ticket, String path, int index) + { + fAuthService.validate(ticket); + fService.removeAttribute(path, index); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#removeAttribute(java.lang.String, java.util.List, int) + */ + public void removeAttribute(String ticket, List keys, int index) + { + fAuthService.validate(ticket); + fService.removeAttribute(keys, index); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#setAttribute(java.lang.String, java.lang.String, java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String ticket, String path, String name, + Attribute value) + { + fAuthService.validate(ticket); + fService.setAttribute(path, name, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#setAttribute(java.lang.String, java.util.List, java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String ticket, List keys, String name, + Attribute value) + { + fAuthService.validate(ticket); + fService.setAttribute(keys, name, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#setAttribute(java.lang.String, java.lang.String, int, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String ticket, String path, int index, + Attribute value) + { + fAuthService.validate(ticket); + fService.setAttribute(path, index, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeServiceTransport#setAttribute(java.lang.String, java.util.List, int, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String ticket, List keys, int index, + Attribute value) + { + fAuthService.validate(ticket); + fService.setAttribute(keys, index, value); + } +} diff --git a/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java b/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java new file mode 100644 index 0000000000..4c50b9e9b1 --- /dev/null +++ b/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java @@ -0,0 +1,188 @@ +/* + * 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.repo.remote; + +import java.util.List; + +import org.alfresco.repo.attributes.Attribute; +import org.alfresco.service.cmr.attributes.AttrQuery; +import org.alfresco.service.cmr.attributes.AttributeService; +import org.alfresco.service.cmr.remote.AttributeServiceTransport; +import org.alfresco.util.Pair; + +/** + * Client side AttributeService implementation. + * @author britt + */ +public class AttributeServiceRemote implements AttributeService +{ + private AttributeServiceTransport fTransport; + + private ClientTicketHolder fTicketHolder; + + public AttributeServiceRemote() + { + } + + public void setAttributeServiceTransport(AttributeServiceTransport transport) + { + fTransport = transport; + } + + public void setClientTicketHolder(ClientTicketHolder holder) + { + fTicketHolder = holder; + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#addAttribute(java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void addAttribute(String path, Attribute value) + { + fTransport.addAttribute(fTicketHolder.getTicket(), path, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#addAttribute(java.util.List, org.alfresco.repo.attributes.Attribute) + */ + public void addAttribute(List keys, Attribute value) + { + fTransport.addAttribute(fTicketHolder.getTicket(), keys, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#getAttribute(java.lang.String) + */ + public Attribute getAttribute(String path) + { + return fTransport.getAttribute(fTicketHolder.getTicket(), path); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#getAttribute(java.util.List) + */ + public Attribute getAttribute(List keys) + { + return fTransport.getAttribute(fTicketHolder.getTicket(), keys); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#getKeys(java.lang.String) + */ + public List getKeys(String path) + { + return fTransport.getKeys(fTicketHolder.getTicket(), path); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#getKeys(java.util.List) + */ + public List getKeys(List keys) + { + return fTransport.getKeys(fTicketHolder.getTicket(), keys); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#query(java.lang.String, org.alfresco.service.cmr.attributes.AttrQuery) + */ + public List> query(String path, AttrQuery query) + { + return fTransport.query(fTicketHolder.getTicket(), path, query); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#query(java.util.List, org.alfresco.service.cmr.attributes.AttrQuery) + */ + public List> query(List keys, + AttrQuery query) + { + return fTransport.query(fTicketHolder.getTicket(), keys, query); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.lang.String, java.lang.String) + */ + public void removeAttribute(String path, String name) + { + fTransport.removeAttribute(fTicketHolder.getTicket(), path, name); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.util.List, java.lang.String) + */ + public void removeAttribute(List keys, String name) + { + fTransport.removeAttribute(fTicketHolder.getTicket(), keys, name); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.lang.String, int) + */ + public void removeAttribute(String path, int index) + { + fTransport.removeAttribute(fTicketHolder.getTicket(), path, index); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.util.List, int) + */ + public void removeAttribute(List keys, int index) + { + fTransport.removeAttribute(fTicketHolder.getTicket(), keys, index); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.lang.String, java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String path, String name, Attribute value) + { + fTransport.setAttribute(fTicketHolder.getTicket(), path, name, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.util.List, java.lang.String, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(List keys, String name, Attribute value) + { + fTransport.setAttribute(fTicketHolder.getTicket(), keys, name, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.lang.String, int, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(String path, int index, Attribute value) + { + fTransport.setAttribute(fTicketHolder.getTicket(), path, index, value); + } + + /* (non-Javadoc) + * @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.util.List, int, org.alfresco.repo.attributes.Attribute) + */ + public void setAttribute(List keys, int index, Attribute value) + { + fTransport.setAttribute(fTicketHolder.getTicket(), keys, index, value); + } +} diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java index 22f6297ae3..61c8e5ec3c 100644 --- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java +++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java @@ -31,6 +31,7 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.audit.AuditService; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avm.locking.AVMLockingService; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -361,4 +362,12 @@ public class ServiceDescriptorRegistry { return (AttributeService)getService(ATTRIBUTE_SERVICE); } + + /* (non-Javadoc) + * @see org.alfresco.service.ServiceRegistry#getAVMLockingService() + */ + public AVMLockingService getAVMLockingService() + { + return (AVMLockingService)getService(AVM_LOCKING_SERVICE); + } } diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java index da499a8649..a093f21e57 100644 --- a/source/java/org/alfresco/service/ServiceRegistry.java +++ b/source/java/org/alfresco/service/ServiceRegistry.java @@ -30,6 +30,7 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.audit.AuditService; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avm.locking.AVMLockingService; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -106,7 +107,8 @@ public interface ServiceRegistry static final QName AVM_SYNC_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMSyncService"); static final QName CROSS_REPO_COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CrossRepositoryCopyService"); static final QName ATTRIBUTE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AttributeService"); - + static final QName AVM_LOCKING_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingService"); + /** * Get the list of services provided by the Repository * @@ -324,4 +326,11 @@ public interface ServiceRegistry */ @NotAuditable AttributeService getAttributeService(); + + /** + * Get the AVM locking service (or null if one is not provided) + * @return + */ + @NotAuditable + AVMLockingService getAVMLockingService(); } diff --git a/source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java b/source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java index fb22d9fd27..53c7614677 100644 --- a/source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java +++ b/source/java/org/alfresco/service/cmr/avm/locking/AVMLock.java @@ -42,11 +42,11 @@ import org.alfresco.repo.attributes.StringAttributeValue; */ 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"; + public static final String PATH = "path"; + public static final String STORE = "store"; + public static final String OWNERS = "owners"; + public static final String WEBPROJECT = "webproject"; + public static final String TYPE = "type"; private static final long serialVersionUID = -8026344276097527239L; @@ -121,7 +121,6 @@ public class AVMLock implements Serializable ListAttribute owners = new ListAttributeValue(); for (String owner : fOwners) { - // The value is a dummy. owners.add(new StringAttributeValue(owner)); } lockData.put(OWNERS, owners); diff --git a/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java b/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java new file mode 100644 index 0000000000..71b9259b97 --- /dev/null +++ b/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java @@ -0,0 +1,173 @@ +/* + * 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.remote; + +import java.util.List; + +import org.alfresco.repo.attributes.Attribute; +import org.alfresco.service.cmr.attributes.AttrQuery; +import org.alfresco.util.Pair; + +/** + * The transport wrapper for remoted AttributeService. + * @author britt + */ +public interface AttributeServiceTransport +{ + /** + * Get an Attribute. + * @param ticket The authentication ticket. + * @param path The path of the Attribute. + * @return The value of the attribute or null. + */ + public Attribute getAttribute(String ticket, String path); + + /** + * Get an attribute. + * @param ticket The authentication ticket. + * @param keys The keys in the attribute path. + * @return The value of the attribute or null. + */ + public Attribute getAttribute(String ticket, List keys); + + /** + * Set an attribute. Overwrites if it exists. + * @param ticket The authentication ticket. + * @param name The name of the Attribute. + * @param value The value to set. + */ + public void setAttribute(String ticket, String path, String name, Attribute value); + + /** + * Set an attribute + * @param ticket The authentication ticket. + * @param keys List of attribute path keys. + * @param name The name of the attribute to set. + * @param value The Attribute to set. + */ + public void setAttribute(String ticket, List keys, String name, Attribute value); + + /** + * Set an attribute in a list. + * @param ticket The authentication ticket. + * @param path The path to the list. + * @param index The list index. + * @param value The Attribute to set. + */ + public void setAttribute(String ticket, String path, int index, Attribute value); + + /** + * Set an attribute in a list. + * @param ticket The authentication ticket. + * @param keys The path components to the list. + * @param index The list index. + * @param value The Attribute to set. + */ + public void setAttribute(String ticket, List keys, int index, Attribute value); + + /** + * Add an attribute to a List Attribute + * @param ticket The authentication ticket. + * @param path The path to the list. + * @param value The Attribute to add. + */ + public void addAttribute(String ticket, String path, Attribute value); + + /** + * Add an attribute to a List Attribute. + * @param ticket The authentication ticket. + * @param keys The path components to the list. + * @param value The Attribute to add. + */ + public void addAttribute(String ticket, List keys, Attribute value); + + /** + * Remove an Attribute. + * @param ticket The authentication ticket. + * @param name The name of the Attribute. + */ + public void removeAttribute(String ticket, String path, String name); + + /** + * Remove an Attribute. + * @param ticket The authentication ticket. + * @param keys List of attribute path keys. + * @param name The name of the attribute to remove. + */ + public void removeAttribute(String ticket, List keys, String name); + + /** + * Remove an attribute from a list. + * @param ticket The authentication ticket. + * @param path The path to the list. + * @param index The index to remove. + */ + public void removeAttribute(String ticket, String path, int index); + + /** + * Remove an attribute from a list. + * @param ticket The authentication ticket. + * @param keys The components of the path to the list. + * @param index The index to remove. + */ + public void removeAttribute(String ticket, List keys, int index); + + /** + * Query for a list of attributes which are contained in the map + * defined by the given path and meet the query criteria. + * @param ticket The authentication ticket. + * @param path + * @param query + * @return A List of matching attributes. + */ + public List> query(String ticket, String path, AttrQuery query); + + /** + * Query for a list of attributes which are contained in a map defined by the + * given path and meet the query criteria. + * @param ticket The authentication ticket. + * @param keys The list of attribute path keys. + * @param query + * @return A list of matching attributes. + */ + public List> query(String ticket, List keys, AttrQuery query); + + /** + * Get all the keys for a given attribute path. + * @param ticket The authentication ticket. + * @param path The attribute path. + * @return A list of all keys. + */ + public List getKeys(String ticket, String path); + + /** + * Get all the keys for a give attribute path. + * @param ticket The authentication ticket. + * @param keys The keys of the attribute path. + * @return A list of all keys. + */ + public List getKeys(String ticket, List keys); +}