Interim checkin. Attributes basically work.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5510 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-04-18 23:25:53 +00:00
parent e2329988bd
commit bdae23b768
43 changed files with 1891 additions and 658 deletions

View File

@@ -46,7 +46,6 @@ public interface Attribute extends Serializable
FLOAT,
DOUBLE,
STRING,
BLOB,
SERIALIZABLE,
MAP
};

View File

@@ -0,0 +1,143 @@
/*
* 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 org.alfresco.error.AlfrescoRuntimeException;
/**
* Handles conversions between persistent and value based Attributes.
* @author britt
*/
public class AttributeConverter
{
/**
* Convert an Attribute (recursively) to a persistent attribute. This persists
* the newly created Attribute immediately.
* @param from The Attribute to clone.
* @return The cloned persistent Attribute.
*/
public Attribute toPersistent(Attribute from)
{
switch (from.getType())
{
case BOOLEAN :
{
return new BooleanAttributeImpl((BooleanAttribute)from);
}
case BYTE :
{
return new ByteAttributeImpl((ByteAttribute)from);
}
case SHORT :
{
return new ShortAttributeImpl((ShortAttribute)from);
}
case INT :
{
return new IntAttributeImpl((IntAttribute)from);
}
case LONG :
{
return new LongAttributeImpl((LongAttribute)from);
}
case FLOAT :
{
return new FloatAttributeImpl((FloatAttribute)from);
}
case DOUBLE :
{
return new DoubleAttributeImpl((DoubleAttribute)from);
}
case STRING :
{
return new StringAttributeImpl((StringAttribute)from);
}
case SERIALIZABLE :
{
return new SerializableAttributeImpl((SerializableAttribute)from);
}
case MAP :
{
return new MapAttributeImpl((MapAttribute)from);
}
default :
{
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
}
}
}
public Attribute toValue(Attribute from)
{
switch (from.getType())
{
case BOOLEAN :
{
return new BooleanAttributeValue((BooleanAttribute)from);
}
case BYTE :
{
return new ByteAttributeValue((ByteAttribute)from);
}
case SHORT :
{
return new ShortAttributeValue((ShortAttribute)from);
}
case INT :
{
return new IntAttributeValue((IntAttribute)from);
}
case LONG :
{
return new LongAttributeValue((LongAttribute)from);
}
case FLOAT :
{
return new FloatAttributeValue((FloatAttribute)from);
}
case DOUBLE :
{
return new DoubleAttributeValue((DoubleAttribute)from);
}
case STRING :
{
return new StringAttributeValue((StringAttribute)from);
}
case SERIALIZABLE :
{
return new SerializableAttributeValue((SerializableAttribute)from);
}
case MAP :
{
return new MapAttributeValue((MapAttribute)from);
}
default :
{
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
}
}
}
}

View File

@@ -41,6 +41,11 @@ public abstract class AttributeImpl implements Attribute
*/
private long fID;
/**
* The optimistic locking version.
*/
private long fVersion;
/**
* Base constructor.
*/
@@ -58,12 +63,22 @@ public abstract class AttributeImpl implements Attribute
return fID;
}
public void setVersion(long version)
{
fVersion = version;
}
public long getVersion()
{
return fVersion;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#clear()
*/
public void clear()
{
throw new AtrributeMethodNotImplemented("Not ListValue or MapValue");
throw new AttributeMethodNotImplemented("Not ListValue or MapValue");
}
/* (non-Javadoc)
@@ -71,7 +86,7 @@ public abstract class AttributeImpl implements Attribute
*/
public Set<Entry<String, Attribute>> entrySet()
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -79,7 +94,7 @@ public abstract class AttributeImpl implements Attribute
*/
public Attribute get(String key)
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -87,7 +102,7 @@ public abstract class AttributeImpl implements Attribute
*/
public byte[] getBlobValue()
{
throw new AtrributeMethodNotImplemented("Not BlobValue");
throw new AttributeMethodNotImplemented("Not BlobValue");
}
/* (non-Javadoc)
@@ -95,7 +110,7 @@ public abstract class AttributeImpl implements Attribute
*/
public double getDoubleValue()
{
throw new AtrributeMethodNotImplemented("Not DoubleValue");
throw new AttributeMethodNotImplemented("Not DoubleValue");
}
/* (non-Javadoc)
@@ -103,7 +118,7 @@ public abstract class AttributeImpl implements Attribute
*/
public int getIntValue()
{
throw new AtrributeMethodNotImplemented("Not IntValue");
throw new AttributeMethodNotImplemented("Not IntValue");
}
/* (non-Javadoc)
@@ -111,7 +126,7 @@ public abstract class AttributeImpl implements Attribute
*/
public long getLongValue()
{
throw new AtrributeMethodNotImplemented("Not LongValue");
throw new AttributeMethodNotImplemented("Not LongValue");
}
/* (non-Javadoc)
@@ -119,7 +134,7 @@ public abstract class AttributeImpl implements Attribute
*/
public Serializable getSerializableValue()
{
throw new AtrributeMethodNotImplemented("Not SerializableValue");
throw new AttributeMethodNotImplemented("Not SerializableValue");
}
/* (non-Javadoc)
@@ -127,7 +142,7 @@ public abstract class AttributeImpl implements Attribute
*/
public String getStringValue()
{
throw new AtrributeMethodNotImplemented("Not StringValue");
throw new AttributeMethodNotImplemented("Not StringValue");
}
/* (non-Javadoc)
@@ -135,7 +150,7 @@ public abstract class AttributeImpl implements Attribute
*/
public Set<String> keySet()
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -143,7 +158,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void put(String key, Attribute value)
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -151,7 +166,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void remove(String key)
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -159,7 +174,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setBlobValue(byte[] value)
{
throw new AtrributeMethodNotImplemented("Not BlobValue");
throw new AttributeMethodNotImplemented("Not BlobValue");
}
/* (non-Javadoc)
@@ -167,7 +182,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setDoubleValue(double value)
{
throw new AtrributeMethodNotImplemented("Not DoubleValue");
throw new AttributeMethodNotImplemented("Not DoubleValue");
}
/* (non-Javadoc)
@@ -175,7 +190,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setIntValue(int value)
{
throw new AtrributeMethodNotImplemented("Not IntValue");
throw new AttributeMethodNotImplemented("Not IntValue");
}
/* (non-Javadoc)
@@ -183,7 +198,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setLongValue(long value)
{
throw new AtrributeMethodNotImplemented("Not LongValue");
throw new AttributeMethodNotImplemented("Not LongValue");
}
/* (non-Javadoc)
@@ -191,7 +206,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setSerializableValue(Serializable value)
{
throw new AtrributeMethodNotImplemented("Not SerializableValue");
throw new AttributeMethodNotImplemented("Not SerializableValue");
}
/* (non-Javadoc)
@@ -199,7 +214,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setStringValue(String value)
{
throw new AtrributeMethodNotImplemented("Not StringValue");
throw new AttributeMethodNotImplemented("Not StringValue");
}
/* (non-Javadoc)
@@ -207,7 +222,7 @@ public abstract class AttributeImpl implements Attribute
*/
public Collection<Attribute> values()
{
throw new AtrributeMethodNotImplemented("Not MapValue");
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
@@ -215,7 +230,7 @@ public abstract class AttributeImpl implements Attribute
*/
public boolean getBooleanValue()
{
throw new AtrributeMethodNotImplemented("Not BooleanValue");
throw new AttributeMethodNotImplemented("Not BooleanValue");
}
/* (non-Javadoc)
@@ -223,7 +238,7 @@ public abstract class AttributeImpl implements Attribute
*/
public byte getByteValue()
{
throw new AtrributeMethodNotImplemented("Not ByteValue");
throw new AttributeMethodNotImplemented("Not ByteValue");
}
/* (non-Javadoc)
@@ -231,7 +246,7 @@ public abstract class AttributeImpl implements Attribute
*/
public float getFloatValue()
{
throw new AtrributeMethodNotImplemented("Not FloatValue");
throw new AttributeMethodNotImplemented("Not FloatValue");
}
/* (non-Javadoc)
@@ -239,7 +254,7 @@ public abstract class AttributeImpl implements Attribute
*/
public short getShortValue()
{
throw new AtrributeMethodNotImplemented("Not ShortValue");
throw new AttributeMethodNotImplemented("Not ShortValue");
}
/* (non-Javadoc)
@@ -247,7 +262,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setBooleanValue(boolean value)
{
throw new AtrributeMethodNotImplemented("Not BooleanValue");
throw new AttributeMethodNotImplemented("Not BooleanValue");
}
/* (non-Javadoc)
@@ -255,7 +270,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setByteValue(byte value)
{
throw new AtrributeMethodNotImplemented("Not ByteValue");
throw new AttributeMethodNotImplemented("Not ByteValue");
}
/* (non-Javadoc)
@@ -263,7 +278,7 @@ public abstract class AttributeImpl implements Attribute
*/
public void setFloatValue(float value)
{
throw new AtrributeMethodNotImplemented("Not FloatValue");
throw new AttributeMethodNotImplemented("Not FloatValue");
}
/* (non-Javadoc)
@@ -271,6 +286,6 @@ public abstract class AttributeImpl implements Attribute
*/
public void setShortValue(short value)
{
throw new AtrributeMethodNotImplemented("Not ShortValue");
throw new AttributeMethodNotImplemented("Not ShortValue");
}
}

View File

@@ -31,11 +31,11 @@ import org.alfresco.error.AlfrescoRuntimeException;
* For unimplemented attribute methods.
* @author britt
*/
public class ValueMethodNotImplementedException extends AlfrescoRuntimeException
public class AttributeMethodNotImplemented extends AlfrescoRuntimeException
{
private static final long serialVersionUID = -7167699355451456957L;
public ValueMethodNotImplementedException(String message)
public AttributeMethodNotImplemented(String message)
{
super(message);
}

View File

@@ -0,0 +1,230 @@
/*
* 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.ArrayList;
import java.util.List;
import org.alfresco.repo.attributes.Attribute.Type;
import org.alfresco.service.cmr.attributes.AttrQuery;
import org.alfresco.service.cmr.attributes.AttributeService;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMWrongTypeException;
/**
* Implementation of the AttributeService interface.
* @author britt
*/
public class AttributeServiceImpl implements AttributeService
{
private GlobalAttributeEntryDAO fGlobalAttributeEntryDAO;
private AttributeConverter fAttributeConverter;
public AttributeServiceImpl()
{
}
public void setGlobalAttributeEntryDao(GlobalAttributeEntryDAO dao)
{
fGlobalAttributeEntryDAO = dao;
}
public void setAttributeConverter(AttributeConverter converter)
{
fAttributeConverter = converter;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#getAttribute(java.lang.String)
*/
public Attribute getAttribute(String path)
{
if (path == null)
{
throw new AVMBadArgumentException("Null path.");
}
List<String> keys = parsePath(path);
if (keys.size() < 1)
{
throw new AVMBadArgumentException("Bad Attribute Path: " + path);
}
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
{
return null;
}
Attribute current = entry.getAttribute();
for (int i = 1; i < keys.size(); i++)
{
if (current.getType() != Type.MAP)
{
return null;
}
current = current.get(keys.get(i));
if (current == null)
{
return null;
}
}
return fAttributeConverter.toValue(current);
}
/**
* Utility to parse paths. Paths are of the form '/name/name'. '\' can
* be used to escape '/'s.
* @param path The path to parse.
* @return The components of the path.
*/
private List<String> parsePath(String path)
{
List<String> components = new ArrayList<String>();
int off = 0;
while (off < path.length())
{
while (off < path.length() && path.charAt(off) == '/')
{
off++;
}
StringBuilder builder = new StringBuilder();
while (off < path.length())
{
char c = path.charAt(off);
if (c == '/')
{
break;
}
if (c == '\\')
{
off++;
if (off >= path.length())
{
break;
}
c = path.charAt(off);
}
builder.append(c);
off++;
}
components.add(builder.toString());
}
return components;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#query(java.lang.String, org.alfresco.service.cmr.attributes.AttrQuery)
*/
public List<Attribute> query(String path, AttrQuery query)
{
return null;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.lang.String)
*/
public void removeAttribute(String path, String name)
{
if (path == null)
{
throw new AVMBadArgumentException("Null Attribute Path.");
}
List<String> keys = parsePath(path);
if (keys.size() == 0)
{
fGlobalAttributeEntryDAO.delete(name);
return;
}
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(0));
}
Attribute current = entry.getAttribute();
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(0));
}
for (int i = 1; i < keys.size(); i++)
{
current = current.get(keys.get(i));
if (current == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
}
}
current.remove(name);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.lang.String, org.alfresco.repo.attributes.Attribute)
*/
public void setAttribute(String path, String name, Attribute value)
{
List<String> keys = parsePath(path);
Attribute toSave = fAttributeConverter.toPersistent(value);
if (keys.size() == 0)
{
GlobalAttributeEntry found = fGlobalAttributeEntryDAO.get(name);
if (found == null)
{
found = new GlobalAttributeEntryImpl(name, toSave);
fGlobalAttributeEntryDAO.save(found);
return;
}
found.setAttribute(toSave);
return;
}
GlobalAttributeEntry gEntry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (gEntry == null)
{
throw new AVMNotFoundException("Global Attribute Not Found: " + keys.get(0));
}
Attribute current = gEntry.getAttribute();
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Global Attribute Not Map: " + keys.get(0));
}
for (int i = 1; i < keys.size(); i++)
{
Attribute child = current.get(keys.get(i));
if (child == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (child.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
}
current = child;
}
current.put(name, toSave);
}
}

View File

@@ -0,0 +1,99 @@
/*
* 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 org.alfresco.service.cmr.attributes.AttributeService;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import junit.framework.TestCase;
/**
* Basic tests for AttributeService.
* @author britt
*/
public class AttributeServiceTest extends TestCase
{
private FileSystemXmlApplicationContext fContext = null;
private AttributeService fService;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception
{
if (fContext == null)
{
fContext = new FileSystemXmlApplicationContext("config/alfresco/application-context.xml");
fService = (AttributeService)fContext.getBean("AttributeService");
}
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception
{
fContext.close();
fContext = null;
}
public void testBasic()
{
try
{
fService.setAttribute("", "boolean", new BooleanAttributeValue(true));
fService.setAttribute("", "byte", new ByteAttributeValue((byte)0x20));
fService.setAttribute("", "short", new ShortAttributeValue((short)42));
fService.setAttribute("", "int", new IntAttributeValue(43));
fService.setAttribute("", "long", new LongAttributeValue(1000000000000L));
fService.setAttribute("", "float", new FloatAttributeValue(1.414f));
fService.setAttribute("", "double", new DoubleAttributeValue(3.1415926));
fService.setAttribute("", "string", new StringAttributeValue("This is a string."));
fService.setAttribute("", "serializable", new SerializableAttributeValue(new Long(1010101L)));
MapAttribute map = new MapAttributeValue();
map.put("foo", new StringAttributeValue("I walk."));
map.put("bar", new StringAttributeValue("I talk."));
map.put("baz", new StringAttributeValue("I shop."));
map.put("funky", new StringAttributeValue("I sneeze."));
map.put("monkey",
new StringAttributeValue("I'm going to be a fireman when the floods roll back."));
fService.setAttribute("", "map", map);
assertNotNull(fService.getAttribute("boolean"));
assertEquals(42, (int)fService.getAttribute("short").getShortValue());
assertEquals("I sneeze.", fService.getAttribute("map/funky").getStringValue());
Attribute found = fService.getAttribute("map");
System.out.println(found);
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
}

View File

@@ -0,0 +1,254 @@
/*
* 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.io.Serializable;
import java.util.Collection;
import java.util.Set;
import java.util.Map.Entry;
/**
* Value based non-persistent implementation of Attribute.
* @author britt
*/
public abstract class AttributeValue implements Attribute
{
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#clear()
*/
public void clear()
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#entrySet()
*/
public Set<Entry<String, Attribute>> entrySet()
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#get(java.lang.String)
*/
public Attribute get(String key)
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getBlobValue()
*/
public byte[] getBlobValue()
{
throw new AttributeMethodNotImplemented("Not a Blob.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getBooleanValue()
*/
public boolean getBooleanValue()
{
throw new AttributeMethodNotImplemented("Not a boolean.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getByteValue()
*/
public byte getByteValue()
{
throw new AttributeMethodNotImplemented("Not a byte.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getDoubleValue()
*/
public double getDoubleValue()
{
throw new AttributeMethodNotImplemented("Not a double.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getFloatValue()
*/
public float getFloatValue()
{
throw new AttributeMethodNotImplemented("Not a float.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getIntValue()
*/
public int getIntValue()
{
throw new AttributeMethodNotImplemented("Not an int.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getLongValue()
*/
public long getLongValue()
{
throw new AttributeMethodNotImplemented("Not a long.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getSerializableValue()
*/
public Serializable getSerializableValue()
{
throw new AttributeMethodNotImplemented("Not a Serializable.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getShortValue()
*/
public short getShortValue()
{
throw new AttributeMethodNotImplemented("Not a short.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getStringValue()
*/
public String getStringValue()
{
throw new AttributeMethodNotImplemented("Not a String.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#keySet()
*/
public Set<String> keySet()
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#put(java.lang.String, org.alfresco.repo.attributes.Attribute)
*/
public void put(String key, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#remove(java.lang.String)
*/
public void remove(String key)
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setBlobValue(byte[])
*/
public void setBlobValue(byte[] value)
{
throw new AttributeMethodNotImplemented("Not a Blob.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setBooleanValue(boolean)
*/
public void setBooleanValue(boolean value)
{
throw new AttributeMethodNotImplemented("Not a boolean.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setByteValue(byte)
*/
public void setByteValue(byte value)
{
throw new AttributeMethodNotImplemented("Not a byte.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setDoubleValue(double)
*/
public void setDoubleValue(double value)
{
throw new AttributeMethodNotImplemented("Not a double.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setFloatValue(float)
*/
public void setFloatValue(float value)
{
throw new AttributeMethodNotImplemented("Not a float.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setIntValue(int)
*/
public void setIntValue(int value)
{
throw new AttributeMethodNotImplemented("Not an int.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setLongValue(long)
*/
public void setLongValue(long value)
{
throw new AttributeMethodNotImplemented("Not a long.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setSerializableValue(java.io.Serializable)
*/
public void setSerializableValue(Serializable value)
{
throw new AttributeMethodNotImplemented("Not a Serializable.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setShortValue(short)
*/
public void setShortValue(short value)
{
throw new AttributeMethodNotImplemented("Not a short.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setStringValue(java.lang.String)
*/
public void setStringValue(String value)
{
throw new AttributeMethodNotImplemented("Not a String.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#values()
*/
public Collection<Attribute> values()
{
throw new AttributeMethodNotImplemented("Not a map.");
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* @author britt
*
@@ -35,6 +37,22 @@ public class BooleanAttributeImpl extends AttributeImpl implements
private static final long serialVersionUID = 8483440613101900682L;
private boolean fValue;
public BooleanAttributeImpl()
{
}
public BooleanAttributeImpl(boolean value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public BooleanAttributeImpl(BooleanAttribute attr)
{
fValue = attr.getBooleanValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getBooleanValue()
@@ -44,7 +62,7 @@ public class BooleanAttributeImpl extends AttributeImpl implements
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setBooleanValue(boolean)
*/

View File

@@ -0,0 +1,74 @@
/*
* 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;
/**
* Value based implementation of a boolean attribute.
* @author britt
*/
public class BooleanAttributeValue extends AttributeValue implements
BooleanAttribute
{
private static final long serialVersionUID = 4019402783943642209L;
private boolean fData;
public BooleanAttributeValue(boolean value)
{
fData = value;
}
public BooleanAttributeValue(BooleanAttribute attr)
{
fData = attr.getBooleanValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.BOOLEAN;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getBooleanValue()
*/
@Override
public boolean getBooleanValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setBooleanValue(boolean)
*/
@Override
public void setBooleanValue(boolean value)
{
fData = value;
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* A Byte Attribute.
* @author britt
@@ -35,11 +37,22 @@ public class ByteAttributeImpl extends AttributeImpl implements ByteAttribute
private byte fValue;
public ByteAttributeImpl()
{
}
public ByteAttributeImpl(byte value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public ByteAttributeImpl(ByteAttribute attr)
{
fValue = attr.getByteValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/

View File

@@ -26,9 +26,48 @@
package org.alfresco.repo.attributes;
/**
* Placeholder interface for Blob attributes.
* Value based implementation of byte attribute.
* @author britt
*/
public interface BlobAttribute extends Attribute
public class ByteAttributeValue extends AttributeValue implements ByteAttribute
{
private static final long serialVersionUID = -5011945743563985072L;
private byte fData;
public ByteAttributeValue(byte value)
{
fData = value;
}
public ByteAttributeValue(ByteAttribute attr)
{
fData = attr.getByteValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.BYTE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getByteValue()
*/
@Override
public byte getByteValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setByteValue(byte)
*/
@Override
public void setByteValue(byte value)
{
fData = value;
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* @author britt
*
@@ -35,9 +37,20 @@ public class DoubleAttributeImpl extends AttributeImpl implements Attribute
private double fValue;
public DoubleAttributeImpl()
{
}
public DoubleAttributeImpl(double value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public DoubleAttributeImpl(DoubleAttribute attr)
{
fValue = attr.getDoubleValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,74 @@
/*
* 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;
/**
* Value based implementation of a double attribute.
* @author britt
*/
public class DoubleAttributeValue extends AttributeValue implements
DoubleAttribute
{
private static final long serialVersionUID = 1710813761810342910L;
private double fData;
public DoubleAttributeValue(double value)
{
fData = value;
}
public DoubleAttributeValue(DoubleAttribute attr)
{
fData = attr.getDoubleValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.DOUBLE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getDoubleValue()
*/
@Override
public double getDoubleValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setDoubleValue(double)
*/
@Override
public void setDoubleValue(double value)
{
fData = value;
}
}

View File

@@ -25,9 +25,11 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* Persistent implementation of float attribute.
* @author britt
*
*/
public class FloatAttributeImpl extends AttributeImpl implements FloatAttribute
{
@@ -35,9 +37,20 @@ public class FloatAttributeImpl extends AttributeImpl implements FloatAttribute
private float fValue;
public FloatAttributeImpl()
{
}
public FloatAttributeImpl(float value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public FloatAttributeImpl(FloatAttribute attr)
{
fValue = attr.getFloatValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,74 @@
/*
* 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;
/**
* Value based implementation of float attribute
* @author britt
*/
public class FloatAttributeValue extends AttributeValue implements
FloatAttribute
{
private static final long serialVersionUID = -1645099708530314562L;
private float fData;
public FloatAttributeValue(float value)
{
fData = value;
}
public FloatAttributeValue(FloatAttribute attr)
{
fData = attr.getFloatValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.FLOAT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getFloatValue()
*/
@Override
public float getFloatValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setFloatValue(float)
*/
@Override
public void setFloatValue(float value)
{
fData = value;
}
}

View File

@@ -40,4 +40,9 @@ public interface GlobalAttributeEntry
* Get the Attribute.
*/
public Attribute getAttribute();
/**
* Set the Attribute.
*/
public void setAttribute(Attribute attr);
}

View File

@@ -27,7 +27,7 @@ public interface GlobalAttributeEntryDAO
/**
* Get an attribute by name.
* @param name The name of the attribute.
* @return The attribute or null.
* @return The entry or null.
*/
public Attribute get(String name);
public GlobalAttributeEntry get(String name);
}

View File

@@ -35,6 +35,10 @@ public class GlobalAttributeEntryImpl implements GlobalAttributeEntry
private Attribute fAttribute;
public GlobalAttributeEntryImpl()
{
}
public GlobalAttributeEntryImpl(String name, Attribute attr)
{
fName = name;

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* An integer attribute.
* @author britt
@@ -35,9 +37,20 @@ public class IntAttributeImpl extends AttributeImpl implements IntAttribute
private int fValue;
public IntAttributeImpl()
{
}
public IntAttributeImpl(int value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public IntAttributeImpl(IntAttribute attr)
{
fValue = attr.getIntValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -26,18 +26,23 @@
package org.alfresco.repo.attributes;
/**
* Persistent implementation of Blob attribute.
* Value based implementation of int attribute.
* @author britt
*/
public class BlobAttributeImpl extends AttributeImpl implements BlobAttribute
public class IntAttributeValue extends AttributeValue implements IntAttribute
{
private static final long serialVersionUID = 53323685626921588L;
private static final long serialVersionUID = -7547112946658496030L;
private byte[] fValue;
public BlobAttributeImpl(byte[] value)
private int fData;
public IntAttributeValue(int value)
{
fValue = value;
fData = value;
}
public IntAttributeValue(IntAttribute attr)
{
fData = attr.getIntValue();
}
/* (non-Javadoc)
@@ -45,24 +50,24 @@ public class BlobAttributeImpl extends AttributeImpl implements BlobAttribute
*/
public Type getType()
{
return Type.BLOB;
return Type.INT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getBlobValue()
* @see org.alfresco.repo.attributes.AttributeValue#getIntValue()
*/
@Override
public byte[] getBlobValue()
public int getIntValue()
{
return fValue;
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setBlobValue(byte[])
* @see org.alfresco.repo.attributes.AttributeValue#setIntValue(int)
*/
@Override
public void setBlobValue(byte[] value)
public void setIntValue(int value)
{
fValue = value;
fData = value;
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* Long valued attribute.
* @author britt
@@ -35,9 +37,20 @@ public class LongAttributeImpl extends AttributeImpl implements LongAttribute
private long fValue;
public LongAttributeImpl()
{
}
public LongAttributeImpl(long value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public LongAttributeImpl(LongAttribute attr)
{
fValue = attr.getLongValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,73 @@
/*
* 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;
/**
* Value based implementation of a long attribute.
* @author britt
*/
public class LongAttributeValue extends AttributeValue implements LongAttribute
{
private static final long serialVersionUID = 3978001405238962585L;
private long fData;
public LongAttributeValue(long value)
{
fData = value;
}
public LongAttributeValue(LongAttribute attr)
{
fData = attr.getLongValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.LONG;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getLongValue()
*/
@Override
public long getLongValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setLongValue(long)
*/
@Override
public void setLongValue(long value)
{
fData = value;
}
}

View File

@@ -34,18 +34,91 @@ import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
/**
* Persistent map attribute implementation.
* @author britt
*
*/
public class MapAttributeImpl extends AttributeImpl implements MapAttribute
{
private static final long serialVersionUID = -2627849542488029248L;
public MapAttributeImpl()
{
}
public MapAttributeImpl(MapAttribute attr)
{
AVMDAOs.Instance().fAttributeDAO.save(this);
for (Map.Entry<String, Attribute> entry : attr.entrySet())
{
Attribute value = entry.getValue();
Attribute newAttr = null;
switch (value.getType())
{
case BOOLEAN :
{
newAttr = new BooleanAttributeImpl(value.getBooleanValue());
break;
}
case BYTE :
{
newAttr = new ByteAttributeImpl(value.getByteValue());
break;
}
case SHORT :
{
newAttr = new ShortAttributeImpl(value.getShortValue());
break;
}
case INT :
{
newAttr = new IntAttributeImpl(value.getIntValue());
break;
}
case LONG :
{
newAttr = new LongAttributeImpl(value.getLongValue());
break;
}
case FLOAT :
{
newAttr = new FloatAttributeImpl(value.getFloatValue());
break;
}
case DOUBLE :
{
newAttr = new DoubleAttributeImpl(value.getDoubleValue());
break;
}
case STRING :
{
newAttr = new StringAttributeImpl(value.getStringValue());
break;
}
case SERIALIZABLE :
{
newAttr = new SerializableAttributeImpl(value.getSerializableValue());
break;
}
case MAP :
{
newAttr = new MapAttributeImpl((MapAttribute)value);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
}
}
MapEntry mapEntry = new MapEntryImpl(this, entry.getKey(), newAttr);
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
@@ -108,7 +181,15 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
@Override
public void put(String key, Attribute value)
{
MapEntry entry = new MapEntryImpl(this, key, value);
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(this, key);
if (entry == null)
{
Attribute oldAttr = entry.getAttribute();
entry.setAttribute(value);
AVMDAOs.Instance().fAttributeDAO.delete(oldAttr);
return;
}
entry = new MapEntryImpl(this, key, value);
AVMDAOs.Instance().fMapEntryDAO.save(entry);
}
@@ -119,10 +200,13 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
public void remove(String key)
{
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(this, key);
if (entry != null)
if (entry == null)
{
AVMDAOs.Instance().fMapEntryDAO.delete(entry);
throw new AVMNotFoundException("Attribute Not Found: " + key);
}
Attribute attr = entry.getAttribute();
AVMDAOs.Instance().fMapEntryDAO.delete(entry);
AVMDAOs.Instance().fAttributeDAO.delete(attr);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,189 @@
/*
* 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.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Value based implementation of a map attribute.
* @author britt
*/
public class MapAttributeValue extends AttributeValue implements MapAttribute
{
private static final long serialVersionUID = -5090943744202078113L;
private Map<String, Attribute> fData;
public MapAttributeValue()
{
fData = new HashMap<String, Attribute>();
}
public MapAttributeValue(MapAttribute attr)
{
fData = new HashMap<String, Attribute>();
for (Map.Entry<String, Attribute> entry : attr.entrySet())
{
Attribute value = entry.getValue();
Attribute newAttr = null;
switch (value.getType())
{
case BOOLEAN :
{
newAttr = new BooleanAttributeValue((BooleanAttribute)value);
break;
}
case BYTE :
{
newAttr = new ByteAttributeValue((ByteAttribute)value);
break;
}
case SHORT :
{
newAttr = new ShortAttributeValue((ShortAttribute)value);
break;
}
case INT :
{
newAttr = new IntAttributeValue((IntAttribute)value);
break;
}
case LONG :
{
newAttr = new LongAttributeValue((LongAttribute)value);
break;
}
case FLOAT :
{
newAttr = new FloatAttributeValue((FloatAttribute)value);
break;
}
case DOUBLE :
{
newAttr = new DoubleAttributeValue((DoubleAttribute)value);
break;
}
case STRING :
{
newAttr = new StringAttributeValue((StringAttribute)value);
break;
}
case SERIALIZABLE :
{
newAttr = new SerializableAttributeValue((SerializableAttribute)value);
break;
}
case MAP :
{
newAttr = new MapAttributeValue((MapAttribute)value);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
}
}
fData.put(entry.getKey(), newAttr);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.MAP;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#clear()
*/
@Override
public void clear()
{
fData.clear();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#entrySet()
*/
@Override
public Set<Entry<String, Attribute>> entrySet()
{
return fData.entrySet();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#get(java.lang.String)
*/
@Override
public Attribute get(String key)
{
return fData.get(key);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#keySet()
*/
@Override
public Set<String> keySet()
{
return fData.keySet();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#put(java.lang.String, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void put(String key, Attribute value)
{
fData.put(key, value);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#remove(java.lang.String)
*/
@Override
public void remove(String key)
{
fData.remove(key);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#values()
*/
@Override
public Collection<Attribute> values()
{
return fData.values();
}
}

View File

@@ -54,4 +54,10 @@ public interface MapEntry
* @return The value attribute.
*/
public Attribute getAttribute();
/**
* Set the value of this attribute.
* @param attr
*/
public void setAttribute(Attribute attr);
}

View File

@@ -39,6 +39,10 @@ public class MapEntryImpl implements MapEntry
private Attribute fAttribute;
public MapEntryImpl()
{
}
public MapEntryImpl(MapAttribute map,
String key,
Attribute attribute)

View File

@@ -27,6 +27,8 @@ package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
* Persistent implemantation of a Serializable attribute.
* @author britt
@@ -38,9 +40,20 @@ public class SerializableAttributeImpl extends AttributeImpl implements
private Serializable fValue;
public SerializableAttributeImpl()
{
}
public SerializableAttributeImpl(Serializable value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public SerializableAttributeImpl(SerializableAttribute attr)
{
fValue = attr.getSerializableValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,76 @@
/*
* 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.io.Serializable;
/**
* Value based implemenation of a Serializable attribute.
* @author britt
*/
public class SerializableAttributeValue extends AttributeValue implements
SerializableAttribute
{
private static final long serialVersionUID = 7899458940760116171L;
private Serializable fData;
public SerializableAttributeValue(Serializable value)
{
fData = value;
}
public SerializableAttributeValue(SerializableAttribute attr)
{
fData = attr.getSerializableValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.SERIALIZABLE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getSerializableValue()
*/
@Override
public Serializable getSerializableValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setSerializableValue(java.io.Serializable)
*/
@Override
public void setSerializableValue(Serializable value)
{
fData = value;
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* A short attribute.
* @author britt
@@ -35,9 +37,20 @@ public class ShortAttributeImpl extends AttributeImpl implements ShortAttribute
private short fValue;
public ShortAttributeImpl()
{
}
public ShortAttributeImpl(short value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public ShortAttributeImpl(ShortAttribute attr)
{
fValue = attr.getShortValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,74 @@
/*
* 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;
/**
* Value based implementation of a short attribute.
* @author britt
*/
public class ShortAttributeValue extends AttributeValue implements
ShortAttribute
{
private static final long serialVersionUID = -2224950695651369979L;
private short fData;
public ShortAttributeValue(short value)
{
fData = value;
}
public ShortAttributeValue(ShortAttribute attr)
{
fData = attr.getShortValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.SHORT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getShortValue()
*/
@Override
public short getShortValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setShortValue(short)
*/
@Override
public void setShortValue(short value)
{
fData = value;
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import org.alfresco.repo.avm.AVMDAOs;
/**
* Persistent implementation of String valued attribute.
* @author britt
@@ -36,9 +38,20 @@ public class StringAttributeImpl extends AttributeImpl implements
private String fValue;
public StringAttributeImpl()
{
}
public StringAttributeImpl(String value)
{
fValue = value;
AVMDAOs.Instance().fAttributeDAO.save(this);
}
public StringAttributeImpl(StringAttribute attr)
{
fValue = attr.getStringValue();
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)

View File

@@ -0,0 +1,74 @@
/*
* 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;
/**
* Value based implementation of a String attribute.
* @author britt
*/
public class StringAttributeValue extends AttributeValue implements
StringAttribute
{
private static final long serialVersionUID = -5702787670770131672L;
private String fData;
public StringAttributeValue(String value)
{
fData = value;
}
public StringAttributeValue(StringAttribute attr)
{
fData = attr.getStringValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.STRING;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getStringValue()
*/
@Override
public String getStringValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setStringValue(java.lang.String)
*/
@Override
public void setStringValue(String value)
{
fData = value;
}
}

View File

@@ -1,256 +0,0 @@
/*
* 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.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
* Interface for polymorphic attributes.
* @author britt
*/
public interface Value extends Iterable<Value>
{
public static enum Type implements Serializable
{
BYTE,
SHORT,
INT,
LONG,
FLOAT,
DOUBLE,
STRING,
BLOB,
SERIALIZABLE,
LIST,
MAP
};
/**
* Get the value type for this node.
* @return
*/
public Type getType();
/**
* Set a boolean value.
* @param value The value.
*/
public void setBooleanValue(boolean value);
/**
* Get the value of a BooleanValue.
* @return The value.
*/
public boolean getBooleanValue();
/**
* Set a byte value.
* @param value The value to set.
*/
public void setByteValue(byte value);
/**
* Get the value of a ByteValue.
* @return The value.
*/
public byte getByteValue();
/**
* Set a short value.
* @param value The value to set.
*/
public void setShortValue(short value);
/**
* Get the value of a ShortValue.
* @return The value.
*/
public short getShortValue();
/**
* Set an integer value.
* @param value The value to set.
*/
public void setIntValue(int value);
/**
* Get the integer value of an IntValue.
* @return The value.
*/
public int getIntValue();
/**
* Set a long value.
* @param value The value to set.
*/
public void setLongValue(long value);
/**
* Get the long value of a LongValue.
* @return The value.
*/
public long getLongValue();
/**
* Set a float value.
* @param value The value to set.
*/
public void setFloatValue(float value);
/**
* Get the value of a FloatValue.
* @return The value.
*/
public float getFloatValue();
/**
* Set a double value.
* @param value The value to set.
*/
public void setDoubleValue(double value);
/**
* Get a double value from a DoubleValue.
* @return The value.
*/
public double getDoubleValue();
/**
* Set a String value.
* @param value The value to set.
*/
public void setStringValue(String value);
/**
* Get a String value from a StringValue.
* @return The value.
*/
public String getStringValue();
/**
* Set a Blob value.
* @param value The value to set.
*/
public void setBlobValue(byte[] value);
/**
* Get a Blob value from a BlobValue
* @return The value.
*/
public byte[] getBlobValue();
/**
* Set a Serializable value.
* @param value
*/
public void setSerializableValue(Serializable value);
/**
* Get a Seriailizable value from a SerializableValue
* @return The value.
*/
public Serializable getSerializableValue();
/**
* Add a Value to a list.
* @param value The value to add.
*/
public void add(Value value);
/**
* Add a Value to a list at the given index.
* @param index The offset.
* @param value The value to add.
*/
public void add(int index, Value value);
/**
* Get the value at the given index of a list.
* @param index The offset.
* @return The value.
*/
public Value get(int index);
/**
* Remove the given entry from a list.
* @param index The offset to remove.
*/
public void remove(int index);
/**
* Clear a list or a map.
*/
public void clear();
/**
* Add an entry to a map.
* @param key The key to the entry.
* @param value The Value of the entry.
*/
public void put(String key, Value value);
/**
* Get the Value for a key in a map.
* @param key The key.
* @return The value.
*/
public Value get(String key);
/**
* Remove an entry by key from a map.
* @param key The key of the entry to remove.
*/
public void remove(String key);
/**
* Get the entry set for a map.
* @return The entry set.
*/
public Set<Map.Entry<String, Value>> entrySet();
/**
* Get the key set for a map.
* @return The key set.
*/
public Set<String> keySet();
/**
* Get the collection of values of a map.
* @return The values.
*/
public Collection<Value> values();
/**
* Get (possibly recursively) the Value as an Object. The returned
* value is a copy of the Value using standard java Integers, Longs, Doubles, Strings,
* byte[]s, Maps, and Lists.
* @return The Object value.
*/
public Object getAsObject();
}

View File

@@ -1,325 +0,0 @@
/*
* 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.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;
/**
* The base class of the implementation of Values.
* @author britt
*/
public abstract class ValueImpl implements Value
{
/**
* The primary key.
*/
private long fID;
/**
* Base constructor.
*/
protected ValueImpl()
{
}
public void setId(long id)
{
fID = id;
}
public long getId()
{
return fID;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#add(org.alfresco.repo.attributes.Value)
*/
public void add(Value value)
{
throw new ValueMethodNotImplementedException("Not ListValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#add(int, org.alfresco.repo.attributes.Value)
*/
public void add(int index, Value value)
{
throw new ValueMethodNotImplementedException("Not ListValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#clear()
*/
public void clear()
{
throw new ValueMethodNotImplementedException("Not ListValue or MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#entrySet()
*/
public Set<Entry<String, Value>> entrySet()
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#get(int)
*/
public Value get(int index)
{
throw new ValueMethodNotImplementedException("Not ListValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#get(java.lang.String)
*/
public Value get(String key)
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getAsObject()
*/
public Object getAsObject()
{
throw new ValueMethodNotImplementedException("Not implemented in base class");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getBlobValue()
*/
public byte[] getBlobValue()
{
throw new ValueMethodNotImplementedException("Not BlobValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getDoubleValue()
*/
public double getDoubleValue()
{
throw new ValueMethodNotImplementedException("Not DoubleValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getIntValue()
*/
public int getIntValue()
{
throw new ValueMethodNotImplementedException("Not IntValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getLongValue()
*/
public long getLongValue()
{
throw new ValueMethodNotImplementedException("Not LongValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getSerializableValue()
*/
public Serializable getSerializableValue()
{
throw new ValueMethodNotImplementedException("Not SerializableValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getStringValue()
*/
public String getStringValue()
{
throw new ValueMethodNotImplementedException("Not StringValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#keySet()
*/
public Set<String> keySet()
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#put(java.lang.String, org.alfresco.repo.attributes.Value)
*/
public void put(String key, Value value)
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#remove(int)
*/
public void remove(int index)
{
throw new ValueMethodNotImplementedException("Not ListValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#remove(java.lang.String)
*/
public void remove(String key)
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setBlobValue(byte[])
*/
public void setBlobValue(byte[] value)
{
throw new ValueMethodNotImplementedException("Not BlobValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setDoubleValue(double)
*/
public void setDoubleValue(double value)
{
throw new ValueMethodNotImplementedException("Not DoubleValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setIntValue(int)
*/
public void setIntValue(int value)
{
throw new ValueMethodNotImplementedException("Not IntValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setLongValue(long)
*/
public void setLongValue(long value)
{
throw new ValueMethodNotImplementedException("Not LongValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setSerializableValue(java.io.Serializable)
*/
public void setSerializableValue(Serializable value)
{
throw new ValueMethodNotImplementedException("Not SerializableValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setStringValue(java.lang.String)
*/
public void setStringValue(String value)
{
throw new ValueMethodNotImplementedException("Not StringValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#values()
*/
public Collection<Value> values()
{
throw new ValueMethodNotImplementedException("Not MapValue");
}
/* (non-Javadoc)
* @see java.lang.Iterable#iterator()
*/
public Iterator<Value> iterator()
{
throw new ValueMethodNotImplementedException("Not ListValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getBooleanValue()
*/
public boolean getBooleanValue()
{
throw new ValueMethodNotImplementedException("Not BooleanValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getByteValue()
*/
public byte getByteValue()
{
throw new ValueMethodNotImplementedException("Not ByteValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getFloatValue()
*/
public float getFloatValue()
{
throw new ValueMethodNotImplementedException("Not FloatValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getShortValue()
*/
public short getShortValue()
{
throw new ValueMethodNotImplementedException("Not ShortValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setBooleanValue(boolean)
*/
public void setBooleanValue(boolean value)
{
throw new ValueMethodNotImplementedException("Not BooleanValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setByteValue(byte)
*/
public void setByteValue(byte value)
{
throw new ValueMethodNotImplementedException("Not ByteValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setFloatValue(float)
*/
public void setFloatValue(float value)
{
throw new ValueMethodNotImplementedException("Not FloatValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setShortValue(short)
*/
public void setShortValue(short value)
{
throw new ValueMethodNotImplementedException("Not ShortValue");
}
}

View File

@@ -25,10 +25,14 @@
package org.alfresco.repo.attributes.hibernate;
import java.util.Collection;
import java.util.List;
import org.alfresco.repo.attributes.Attribute;
import org.alfresco.repo.attributes.AttributeDAO;
import org.alfresco.repo.attributes.MapAttribute;
import org.alfresco.repo.attributes.MapEntryDAO;
import org.alfresco.repo.attributes.Attribute.Type;
import org.alfresco.service.cmr.attributes.AttrQuery;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -39,11 +43,23 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class AttributeDAOHibernate extends HibernateDaoSupport implements
AttributeDAO
{
private MapEntryDAO fMapEntryDAO;
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeDAO#delete(org.alfresco.repo.attributes.Attribute)
*/
public void delete(Attribute attr)
{
if (attr.getType() == Type.MAP)
{
MapAttribute map = (MapAttribute)attr;
Collection<Attribute> attrs = map.values();
fMapEntryDAO.delete(map);
for (Attribute subAttr : attrs)
{
delete(subAttr);
}
}
getSession().delete(attr);
}

View File

@@ -17,49 +17,43 @@
<!-- A boolean valued attribute -->
<subclass name="BooleanAttributeImpl" proxy="BooleanAttribute" lazy="true"
discriminator-value="O">
<property name="booleanValue" column="bool_value" type="boolean" index="attribute_bool_index"/>
<property name="booleanValue" column="bool_value" type="boolean"/>
</subclass>
<!-- A byte valued attribute -->
<subclass name="ByteAttributeImpl" proxy="ByteAttribute" lazy="true"
discriminator-value="Y">
<property name="byteValue" column="byte_value" type="byte" index="attribute_byte_index"/>
<property name="byteValue" column="byte_value" type="byte"/>
</subclass>
<!-- A short valued attribute -->
<subclass name="ShortAttributeImpl" proxy="ShortAttribute" lazy="true"
discriminator-value="H">
<property name="shortValue" column="short_value" type="short" index="attribute_short_index"/>
<property name="shortValue" column="short_value" type="short"/>
</subclass>
<!-- An integer valued attribute. -->
<subclass name="IntAttributeImpl" proxy="IntAttribute" lazy="true"
discriminator-value="I">
<property name="intValue" column="int_value" type="int" index="attribute_int_index"/>
<property name="intValue" column="int_value" type="int"/>
</subclass>
<!-- A long valued attribute -->
<subclass name="LongAttributeImpl" proxy="LongAttribute" lazy="true"
discriminator-value="L">
<property name="longValue" column="long_value" type="long" index="attribute_long_index"/>
<property name="longValue" column="long_value" type="long"/>
</subclass>
<!-- A float valued attribute -->
<subclass name="FloatAttributeImpl" proxy="FloatAttribute" lazy="true"
discriminator-value="F">
<property name="floatValue" column="float_value" type="float" index="attribute_float_index"/>
<property name="floatValue" column="float_value" type="float"/>
</subclass>
<!-- A double valued attribute -->
<subclass name="DoubleAttributeImpl" proxy="DoubleAttribute" lazy="true"
discriminator-value="D">
<property name="doubleValue" column="double_value" type="double" index="attribute_double_index"/>
<property name="doubleValue" column="double_value" type="double"/>
</subclass>
<!-- A string valued attribute -->
<subclass name="StringAttributeImpl" proxy="StringAttribute" lazy="true"
discriminator-value="S">
<property name="stringValue" column="string_value" type="string"
length="512" index="attribute_string_index(64)"/>
</subclass>
<!-- A blob valued attribute -->
<subclass name="BlobAttributeImpl" proxy="BlobAttribute" lazy="true"
discriminator-value="B">
<property name="blobValue" column="blob_value" type="blob"
length="8192"/>
length="512"/>
</subclass>
<!-- A serializable attribute -->
<subclass name="SerializableAttributeImpl" proxy="SerializableAttribute" lazy="true"
@@ -72,19 +66,19 @@
discriminator-value="M">
</subclass>
</class>
<class name="GlobalAttributeEntryImpl" proxy="GlobalAttributeEntry">
<class name="GlobalAttributeEntryImpl" proxy="GlobalAttributeEntry" table="alf_global_attributes">
<cache usage="read-write"/>
<id name="name" type="string" length="160"/>
<many-to-one class="AttributeImpl" name="attribute" unique="true"/>
</class>
<class name="MapEntryImpl" proxy="MapEntry" lazy="false">
<class name="MapEntryImpl" proxy="MapEntry" lazy="false" table="alf_map_attribute_entries">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<natural-id>
<many-to-one class="MapAttributeImpl" name="map" column="map_id"/>
<property name="key" type="string" length="160" column="key" index="map_key_index"/>
<property name="key" type="string" length="160" column="mkey" index="map_key_index"/>
</natural-id>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
</class>

View File

@@ -57,11 +57,9 @@ public class GlobalAttributeEntryDAOHibernate extends HibernateDaoSupport
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.GlobalAttributeEntryDAO#get(java.lang.String)
*/
public Attribute get(String name)
public GlobalAttributeEntry get(String name)
{
GlobalAttributeEntry entry =
(GlobalAttributeEntry)getSession().get(GlobalAttributeEntryImpl.class, name);
return entry.getAttribute();
return (GlobalAttributeEntry)getSession().get(GlobalAttributeEntryImpl.class, name);
}
/* (non-Javadoc)

View File

@@ -47,13 +47,13 @@ public interface AttributeService
* @param name The name of the Attribute.
* @param value The value to set.
*/
public void setAttribute(String path, Attribute value);
public void setAttribute(String path, String name, Attribute value);
/**
* Remove an Attribute.
* @param name The name of the Attribute.
*/
public void removeAttribute(String path);
public void removeAttribute(String path, String name);
/**
* Query for a list of attributes which are contained in the container