Merged V2.2 to HEAD

8371: Merged V2.1 to V2.2
      8307: Next round of fixes for session management.
      8309: Fixed AR-1891: Long MLText strings fail in Oracle
      8313: Fix for case where existing MLText entry is null
      8319: Follow-up fix for NPE where StringValue is null when persisting
      8331: Fix for AR-1696: Long text in an aspect property causes an exception


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8496 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-03-11 06:03:17 +00:00
parent 78c695fc0a
commit ceed05d26f
40 changed files with 1276 additions and 1445 deletions

View File

@@ -0,0 +1,373 @@
/*
* 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.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
/**
* Base class for handling basic type conversions.
*
* @author Derek Hulley
* @since V2.1.2
*/
public abstract class AbstractAttribute implements Attribute
{
public final AttributeImpl getAttributeImpl()
{
if (this instanceof AttributeImpl)
{
// No conversion necessary
return (AttributeImpl) this;
}
else
{
// Use Type's factory method
return getType().getAttributeImpl(this);
}
}
public final AttributeValue getAttributeValue()
{
if (this instanceof AttributeValue)
{
// No conversion necessary
return (AttributeValue) this;
}
else
{
// Use Type's factory method
return getType().getAttributeValue(this);
}
}
/**
* {@link ListAttributeValue}-specific method.
*/
public void add(Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link ListAttributeValue}-specific method.
*/
public void add(int index, Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link ListAttributeValue}-specific method.
*/
public Iterator<Attribute> iterator()
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link ListAttributeValue} or {@link MapAttributeValue}-specific method.
*/
public int size()
{
throw new AttributeMethodNotImplemented("Not a List or Map.");
}
/**
* {@link ListAttributeValue}-specific method.
*/
public Attribute get(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link ListAttributeValue}-specific method.
*/
public void remove(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link ListAttributeValue}-specific method.
*/
public void set(int index, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public void clear()
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public Set<Entry<String, Attribute>> entrySet()
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public Set<String> keySet()
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public Collection<Attribute> values()
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public void put(String key, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public void remove(String key)
{
throw new AttributeMethodNotImplemented("Not a map.");
}
/**
* {@link MapAttributeValue}-specific method.
*/
public Attribute get(String key)
{
throw new AttributeMethodNotImplemented("Not a Map.");
}
public byte[] getBlobValue()
{
Serializable raw = getRawValue();
// Just serialize it
try
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(raw);
byte[] bytes = bos.toByteArray();
return bytes;
}
catch (IOException e)
{
throw new TypeConversionException("Unable to get blob value: " + this);
}
}
public boolean getBooleanValue()
{
Serializable raw = getRawValue();
try
{
Boolean obj = DefaultTypeConverter.INSTANCE.convert(Boolean.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Boolean value: " + this);
}
}
public byte getByteValue()
{
Serializable raw = getRawValue();
try
{
Byte obj = DefaultTypeConverter.INSTANCE.convert(Byte.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Byte value: " + this);
}
}
public short getShortValue()
{
Serializable raw = getRawValue();
try
{
Short obj = DefaultTypeConverter.INSTANCE.convert(Short.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Short value: " + this);
}
}
public int getIntValue()
{
Serializable raw = getRawValue();
try
{
Integer obj = DefaultTypeConverter.INSTANCE.convert(Integer.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Integer value: " + this);
}
}
public long getLongValue()
{
Serializable raw = getRawValue();
try
{
Long obj = DefaultTypeConverter.INSTANCE.convert(Long.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Long value: " + this);
}
}
public double getDoubleValue()
{
Serializable raw = getRawValue();
try
{
Double obj = DefaultTypeConverter.INSTANCE.convert(Double.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Double value: " + this);
}
}
public float getFloatValue()
{
Serializable raw = getRawValue();
try
{
Float obj = DefaultTypeConverter.INSTANCE.convert(Float.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to Float value: " + this);
}
}
public String getStringValue()
{
Serializable raw = getRawValue();
try
{
String obj = DefaultTypeConverter.INSTANCE.convert(String.class, raw);
return obj;
}
catch (TypeConversionException e)
{
throw new AttributeMethodNotImplemented("Unable to convert to String value: " + this);
}
}
public Serializable getSerializableValue()
{
// This can always be fulfilled by the raw value
return getRawValue();
}
public void setBlobValue(byte[] value)
{
throw new AttributeMethodNotImplemented("Not a Blob.");
}
public void setBooleanValue(boolean value)
{
throw new AttributeMethodNotImplemented("Not a boolean.");
}
public void setByteValue(byte value)
{
throw new AttributeMethodNotImplemented("Not a byte.");
}
public void setShortValue(short value)
{
throw new AttributeMethodNotImplemented("Not a short.");
}
public void setIntValue(int value)
{
throw new AttributeMethodNotImplemented("Not an int.");
}
public void setLongValue(long value)
{
throw new AttributeMethodNotImplemented("Not a long.");
}
public void setDoubleValue(double value)
{
throw new AttributeMethodNotImplemented("Not a double.");
}
public void setFloatValue(float value)
{
throw new AttributeMethodNotImplemented("Not a float.");
}
public void setStringValue(String value)
{
throw new AttributeMethodNotImplemented("Not a String.");
}
public void setSerializableValue(Serializable value)
{
throw new AttributeMethodNotImplemented("Not a Serializable.");
}
}

View File

@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.schema.SchemaBootstrap;
/**
* Interface for polymorphic attributes.
@@ -41,17 +42,373 @@ public interface Attribute extends Serializable, Iterable<Attribute>
{
public static enum Type implements Serializable
{
BOOLEAN,
BYTE,
SHORT,
INT,
LONG,
FLOAT,
DOUBLE,
STRING,
SERIALIZABLE,
MAP,
BOOLEAN
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof BooleanAttribute)
{
return new BooleanAttributeValue((BooleanAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof BooleanAttribute)
{
return new BooleanAttributeImpl((BooleanAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
BYTE
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof ByteAttribute)
{
return new ByteAttributeValue((ByteAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof ByteAttribute)
{
return new ByteAttributeImpl((ByteAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
SHORT
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof ShortAttribute)
{
return new ShortAttributeValue((ShortAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof ShortAttribute)
{
return new ShortAttributeImpl((ShortAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
INT
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof IntAttribute)
{
return new IntAttributeValue((IntAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof IntAttribute)
{
return new IntAttributeImpl((IntAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
LONG
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof LongAttribute)
{
return new LongAttributeValue((LongAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof LongAttribute)
{
return new LongAttributeImpl((LongAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
FLOAT
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof FloatAttribute)
{
return new FloatAttributeValue((FloatAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof FloatAttribute)
{
return new FloatAttributeImpl((FloatAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
DOUBLE
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof DoubleAttribute)
{
return new DoubleAttributeValue((DoubleAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof DoubleAttribute)
{
return new DoubleAttributeImpl((DoubleAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
STRING
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof StringAttribute)
{
return new StringAttributeValue((StringAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof StringAttribute)
{
// We need to check that the String will fit into the database
StringAttribute stringAttr = (StringAttribute) from;
String stringValue = stringAttr.getStringValue();
if (stringValue != null && stringValue.length() > SchemaBootstrap.getMaxStringLength())
{
// Need to serialize it
return new SerializableAttributeImpl(stringValue);
}
else
{
return new StringAttributeImpl(stringValue);
}
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
SERIALIZABLE
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof SerializableAttribute)
{
return new SerializableAttributeValue((SerializableAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof SerializableAttribute)
{
return new SerializableAttributeImpl((SerializableAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
MAP
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof MapAttribute)
{
return new MapAttributeValue((MapAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof MapAttribute)
{
return new MapAttributeImpl((MapAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
},
LIST
{
@Override
public AttributeValue getAttributeValue(Attribute from)
{
if (from instanceof ListAttribute)
{
return new ListAttributeValue((ListAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
@Override
public AttributeImpl getAttributeImpl(Attribute from)
{
if (from instanceof ListAttribute)
{
return new ListAttributeImpl((ListAttribute)from);
}
else
{
throw new IllegalArgumentException(
"Conversion to " + this + " not supported for " + from.getType() + "(" + from + ")");
}
}
};
/**
* Get the unpersisted attribute value implementation of the {@link Attribute} given an existing attribute.
* The <tt>from</tt> attribute may be a persistable entity or not but a new instance will
* be created.
* <p>
* No assumptions should be made about the return type. The raw type might not match the persisted type.
*
* @param from the instance supplying the data
* @return Returns a value object based on the provided data
*/
public abstract AttributeValue getAttributeValue(Attribute from);
/**
* Get a persistable implementation of the {@link Attribute} given an existing attribute.
* The <tt>from</tt> attribute may be a persistable entity or not but a new instance will
* be created.
* <p>
* No assumptions should be made about the return type. It is possible that the data will
* be converted to a different persistable type.
*
* @param from the instance supplying the data
* @return Returns a persistable entity based on the provided data
*/
public abstract AttributeImpl getAttributeImpl(Attribute from);
};
/**
@@ -67,10 +424,25 @@ public interface Attribute extends Serializable, Iterable<Attribute>
public DbAccessControlList getAcl();
/**
* Get the value type for this node.
* @return
* @return the enumerated type
*/
public Type getType();
/**
* Method to return the underlying raw data for possible conversion to the descired type.
* @return Returns a raw data value
*/
public Serializable getRawValue();
/**
* @see Type#getAttributeValue(Attribute)
*/
public abstract AttributeValue getAttributeValue();
/**
* @see Type#getAttributeImpl(Attribute)
*/
public abstract AttributeImpl getAttributeImpl();
/**
* Set a boolean value.

View File

@@ -25,13 +25,14 @@
package org.alfresco.repo.attributes;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMDAOs;
/**
* Handles conversions between persistent and value based Attributes.
*
* @see Attribute.Type#getAttributeImpl(Attribute)
* @see Attribute.Type#getAttributeValue(Attribute)
*
* @author britt
*/
public class AttributeConverter
@@ -44,133 +45,16 @@ public class AttributeConverter
*/
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);
}
case LIST :
{
return new ListAttributeImpl((ListAttribute)from);
}
default :
{
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
}
}
AttributeImpl attributeEntity = from.getAttributeImpl();
// Done
return attributeEntity;
}
public Attribute toValue(Attribute from)
{
Attribute ret = null;
switch (from.getType())
{
case BOOLEAN :
{
ret = new BooleanAttributeValue((BooleanAttribute)from);
break;
}
case BYTE :
{
ret = new ByteAttributeValue((ByteAttribute)from);
break;
}
case SHORT :
{
ret = new ShortAttributeValue((ShortAttribute)from);
break;
}
case INT :
{
ret = new IntAttributeValue((IntAttribute)from);
break;
}
case LONG :
{
ret = new LongAttributeValue((LongAttribute)from);
break;
}
case FLOAT :
{
ret = new FloatAttributeValue((FloatAttribute)from);
break;
}
case DOUBLE :
{
ret = new DoubleAttributeValue((DoubleAttribute)from);
break;
}
case STRING :
{
ret = new StringAttributeValue((StringAttribute)from);
break;
}
case SERIALIZABLE :
{
ret = new SerializableAttributeValue((SerializableAttribute)from);
break;
}
case MAP :
{
ret = new MapAttributeValue();
for (Map.Entry<String, Attribute> entry : from.entrySet())
{
ret.put(entry.getKey(), toValue(entry.getValue()));
}
break;
}
case LIST :
{
ret = new ListAttributeValue();
for (Attribute child : from)
{
ret.add(toValue(child));
}
break;
}
default :
{
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
}
}
AttributeValue attributeValue = from.getAttributeValue();
AVMDAOs.Instance().fAttributeDAO.evictFlat(from);
return ret;
// Done
return attributeValue;
}
}

View File

@@ -25,19 +25,13 @@
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;
import org.alfresco.repo.domain.DbAccessControlList;
/**
* The base class of the implementation of Values.
* @author britt
*/
public abstract class AttributeImpl implements Attribute
public abstract class AttributeImpl extends AbstractAttribute implements Attribute
{
/**
* The primary key.
@@ -89,226 +83,17 @@ public abstract class AttributeImpl implements Attribute
{
return fVersion;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#clear()
*/
public void clear()
public DbAccessControlList getAcl()
{
throw new AttributeMethodNotImplemented("Not ListValue or MapValue");
return fACL;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#entrySet()
*/
public Set<Entry<String, Attribute>> entrySet()
public void setAcl(DbAccessControlList acl)
{
throw new AttributeMethodNotImplemented("Not MapValue");
fACL = acl;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#get(java.lang.String)
*/
public Attribute get(String key)
{
throw new AttributeMethodNotImplemented("Not Map or List");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getBlobValue()
*/
public byte[] getBlobValue()
{
throw new AttributeMethodNotImplemented("Not BlobValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getDoubleValue()
*/
public double getDoubleValue()
{
throw new AttributeMethodNotImplemented("Not DoubleValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getIntValue()
*/
public int getIntValue()
{
throw new AttributeMethodNotImplemented("Not IntValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getLongValue()
*/
public long getLongValue()
{
throw new AttributeMethodNotImplemented("Not LongValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getSerializableValue()
*/
public Serializable getSerializableValue()
{
throw new AttributeMethodNotImplemented("Not SerializableValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getStringValue()
*/
public String getStringValue()
{
throw new AttributeMethodNotImplemented("Not StringValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#keySet()
*/
public Set<String> keySet()
{
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#put(java.lang.String, org.alfresco.repo.attributes.Value)
*/
public void put(String key, Attribute value)
{
throw new AttributeMethodNotImplemented("Not Map or List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#remove(java.lang.String)
*/
public void remove(String key)
{
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setBlobValue(byte[])
*/
public void setBlobValue(byte[] value)
{
throw new AttributeMethodNotImplemented("Not BlobValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setDoubleValue(double)
*/
public void setDoubleValue(double value)
{
throw new AttributeMethodNotImplemented("Not DoubleValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setIntValue(int)
*/
public void setIntValue(int value)
{
throw new AttributeMethodNotImplemented("Not IntValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setLongValue(long)
*/
public void setLongValue(long value)
{
throw new AttributeMethodNotImplemented("Not LongValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setSerializableValue(java.io.Serializable)
*/
public void setSerializableValue(Serializable value)
{
throw new AttributeMethodNotImplemented("Not SerializableValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setStringValue(java.lang.String)
*/
public void setStringValue(String value)
{
throw new AttributeMethodNotImplemented("Not StringValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#values()
*/
public Collection<Attribute> values()
{
throw new AttributeMethodNotImplemented("Not MapValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getBooleanValue()
*/
public boolean getBooleanValue()
{
throw new AttributeMethodNotImplemented("Not BooleanValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getByteValue()
*/
public byte getByteValue()
{
throw new AttributeMethodNotImplemented("Not ByteValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getFloatValue()
*/
public float getFloatValue()
{
throw new AttributeMethodNotImplemented("Not FloatValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#getShortValue()
*/
public short getShortValue()
{
throw new AttributeMethodNotImplemented("Not ShortValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setBooleanValue(boolean)
*/
public void setBooleanValue(boolean value)
{
throw new AttributeMethodNotImplemented("Not BooleanValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setByteValue(byte)
*/
public void setByteValue(byte value)
{
throw new AttributeMethodNotImplemented("Not ByteValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setFloatValue(float)
*/
public void setFloatValue(float value)
{
throw new AttributeMethodNotImplemented("Not FloatValue");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Value#setShortValue(short)
*/
public void setShortValue(short value)
{
throw new AttributeMethodNotImplemented("Not ShortValue");
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
@@ -323,84 +108,9 @@ public abstract class AttributeImpl implements Attribute
return fID == ((AttributeImpl)obj).fID;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return (int)fID;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getAcl()
*/
public DbAccessControlList getAcl()
{
return fACL;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setAcl(org.alfresco.repo.domain.DbAccessControlList)
*/
public void setAcl(DbAccessControlList acl)
{
fACL = acl;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#add(org.alfresco.repo.attributes.Attribute)
*/
public void add(Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#add(int, org.alfresco.repo.attributes.Attribute)
*/
public void add(int index, Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#iterator()
*/
public Iterator<Attribute> iterator()
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#size()
*/
public int size()
{
throw new AttributeMethodNotImplemented("Not a List or Map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#get(int)
*/
public Attribute get(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#remove(int)
*/
public void remove(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#set(int, org.alfresco.repo.attributes.Attribute)
*/
public void set(int index, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
}

View File

@@ -489,7 +489,7 @@ public class AttributeServiceImpl implements AttributeService
throw new AVMWrongTypeException("Attribute Not List: " + keys);
}
Attribute converted = fAttributeConverter.toPersistent(value);
found.set(index, fAttributeConverter.toPersistent(value));
found.set(index, converted);
}
/* (non-Javadoc)

View File

@@ -25,6 +25,7 @@
package org.alfresco.repo.attributes;
import java.rmi.server.LogStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -82,7 +83,7 @@ public class AttributeServiceTest extends TestCase
}
}
public void testBasic()
public void testBasic() throws Exception
{
try
{
@@ -126,15 +127,30 @@ public class AttributeServiceTest extends TestCase
}
catch (Exception e)
{
e.printStackTrace();
fail();
throw e;
}
}
public void testLongStrings() throws Exception
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; i++)
{
sb.append(i);
}
String longStr = sb.toString();
StringAttributeValue attributeValue = new StringAttributeValue(longStr);
fService.setAttribute("", "long-string", attributeValue);
// Check that we can get it back
Attribute checkAttribute = fService.getAttribute("long-string");
String checkStr = checkAttribute.getStringValue();
assertEquals("Retrieved String is not the same as the persisted one", longStr, checkStr);
}
/**
* Test the query capability.
*/
public void testQuery()
public void testQuery() throws Exception
{
try
{
@@ -236,12 +252,11 @@ public class AttributeServiceTest extends TestCase
}
catch (Exception e)
{
e.printStackTrace();
fail();
throw e;
}
}
public void testDelete()
public void testDelete() throws Exception
{
try
{
@@ -290,14 +305,14 @@ public class AttributeServiceTest extends TestCase
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
}
/**
* Test ListAttributes
*/
public void testList()
public void testList() throws Exception
{
try
{
@@ -344,8 +359,7 @@ public class AttributeServiceTest extends TestCase
}
catch (Exception e)
{
e.printStackTrace();
fail();
throw e;
}
}
}

View File

@@ -25,19 +25,13 @@
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;
import org.alfresco.repo.domain.DbAccessControlList;
/**
* Value based non-persistent implementation of Attribute.
* @author britt
*/
public abstract class AttributeValue implements Attribute
public abstract class AttributeValue extends AbstractAttribute implements Attribute
{
/**
* ACL for this Attribute
@@ -55,292 +49,14 @@ public abstract class AttributeValue implements Attribute
{
fACL = acl;
}
/* (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.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getAcl()
*/
public DbAccessControlList getAcl()
{
return fACL;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#setAcl(org.alfresco.repo.domain.DbAccessControlList)
*/
public void setAcl(DbAccessControlList acl)
{
fACL = acl;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#add(org.alfresco.repo.attributes.Attribute)
*/
public void add(Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#add(int, org.alfresco.repo.attributes.Attribute)
*/
public void add(int index, Attribute attr)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#iterator()
*/
public Iterator<Attribute> iterator()
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#size()
*/
public int size()
{
throw new AttributeMethodNotImplemented("Not a List or Map.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#get(int)
*/
public Attribute get(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#remove(int)
*/
public void remove(int index)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#set(int, org.alfresco.repo.attributes.Attribute)
*/
public void set(int index, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
}

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -55,35 +57,28 @@ public class BooleanAttributeImpl extends AttributeImpl implements
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getBooleanValue()
*/
@Override
public boolean getBooleanValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setBooleanValue(boolean)
*/
@Override
public void setBooleanValue(boolean value)
{
fValue = value;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.BOOLEAN;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public Serializable getRawValue()
{
return Boolean.valueOf(fValue);
}
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of a boolean attribute.
* @author britt
@@ -47,35 +49,28 @@ public class BooleanAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return Boolean.valueOf(fData);
}
@Override
public boolean getBooleanValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setBooleanValue(boolean)
*/
@Override
public void setBooleanValue(boolean value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class ByteAttributeImpl extends AttributeImpl implements ByteAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.BYTE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getByteValue()
*/
public Serializable getRawValue()
{
return Byte.valueOf(fValue);
}
@Override
public byte getByteValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setByteValue(byte)
*/
@Override
public void setByteValue(byte value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of byte attribute.
* @author britt
@@ -46,35 +48,28 @@ public class ByteAttributeValue extends AttributeValue implements ByteAttribute
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()
*/
public Serializable getRawValue()
{
return Byte.valueOf(fData);
}
@Override
public byte getByteValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setByteValue(byte)
*/
@Override
public void setByteValue(byte value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class DoubleAttributeImpl extends AttributeImpl implements DoubleAttribut
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.DOUBLE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getDoubleValue()
*/
public Serializable getRawValue()
{
return Double.valueOf(fValue);
}
@Override
public double getDoubleValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setDoubleValue(double)
*/
@Override
public void setDoubleValue(double value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of a double attribute.
* @author britt
@@ -47,35 +49,28 @@ public class DoubleAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return Double.valueOf(fData);
}
@Override
public double getDoubleValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setDoubleValue(double)
*/
@Override
public void setDoubleValue(double value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class FloatAttributeImpl extends AttributeImpl implements FloatAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.FLOAT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getFloatValue()
*/
public Serializable getRawValue()
{
return Float.valueOf(fValue);
}
@Override
public float getFloatValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setFloatValue(float)
*/
@Override
public void setFloatValue(float value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of float attribute
* @author britt
@@ -47,35 +49,28 @@ public class FloatAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return Float.valueOf(fData);
}
@Override
public float getFloatValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setFloatValue(float)
*/
@Override
public void setFloatValue(float value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class IntAttributeImpl extends AttributeImpl implements IntAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.INT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getIntValue()
*/
public Serializable getRawValue()
{
return Integer.valueOf(fValue);
}
@Override
public int getIntValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setIntValue(int)
*/
@Override
public void setIntValue(int value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of int attribute.
* @author britt
@@ -46,35 +48,28 @@ public class IntAttributeValue extends AttributeValue implements IntAttribute
fData = attr.getIntValue();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.INT;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#getIntValue()
*/
public Serializable getRawValue()
{
return Integer.valueOf(fData);
}
@Override
public int getIntValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setIntValue(int)
*/
@Override
public void setIntValue(int value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,11 +25,11 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
@@ -52,86 +52,30 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
for (Attribute entry : other)
{
Attribute newEntry = null;
switch (entry.getType())
{
case BOOLEAN :
{
newEntry = new BooleanAttributeImpl((BooleanAttribute)entry);
break;
}
case BYTE :
{
newEntry = new ByteAttributeImpl((ByteAttribute)entry);
break;
}
case SHORT :
{
newEntry = new ShortAttributeImpl((ShortAttribute)entry);
break;
}
case INT :
{
newEntry = new IntAttributeImpl((IntAttribute)entry);
break;
}
case LONG :
{
newEntry = new LongAttributeImpl((LongAttribute)entry);
break;
}
case FLOAT :
{
newEntry = new FloatAttributeImpl((FloatAttribute)entry);
break;
}
case DOUBLE :
{
newEntry = new DoubleAttributeImpl((DoubleAttribute)entry);
break;
}
case STRING :
{
newEntry = new StringAttributeImpl((StringAttribute)entry);
break;
}
case SERIALIZABLE :
{
newEntry = new SerializableAttributeImpl((SerializableAttribute)entry);
break;
}
case MAP :
{
newEntry = new MapAttributeImpl((MapAttribute)entry);
break;
}
case LIST :
{
newEntry = new ListAttributeImpl((ListAttribute)entry);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + entry.getType());
}
}
Attribute newAttr = entry.getAttributeImpl();
ListEntryKey key = new ListEntryKey(this, index++);
ListEntry listEntry = new ListEntryImpl(key, newEntry);
ListEntry listEntry = new ListEntryImpl(key, newAttr);
AVMDAOs.Instance().fListEntryDAO.save(listEntry);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.LIST;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#add(org.alfresco.repo.attributes.Attribute)
*/
public Serializable getRawValue()
{
List<ListEntry> entries = AVMDAOs.Instance().fListEntryDAO.get(this);
ArrayList<Serializable> ret = new ArrayList<Serializable>(entries.size());
for (ListEntry listEntry : entries)
{
Serializable rawEntry = listEntry.getAttribute().getRawValue();
ret.add(rawEntry);
}
return ret;
}
@Override
public void add(Attribute attr)
{
@@ -141,9 +85,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
AVMDAOs.Instance().fListEntryDAO.save(entry);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#add(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void add(int index, Attribute attr)
{
@@ -167,18 +108,12 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
dao.save(newEntry);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#clear()
*/
@Override
public void clear()
{
AVMDAOs.Instance().fListEntryDAO.delete(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#get(int)
*/
@Override
public Attribute get(int index)
{
@@ -191,9 +126,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
return entry.getAttribute();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#iterator()
*/
@Override
public Iterator<Attribute> iterator()
{
@@ -206,18 +138,12 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
return attrList.iterator();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#size()
*/
@Override
public int size()
{
return AVMDAOs.Instance().fListEntryDAO.size(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#remove(java.lang.String)
*/
@Override
public void remove(int index)
{
@@ -242,9 +168,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
@@ -259,9 +182,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#set(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void set(int index, Attribute value)
{

View File

@@ -25,12 +25,11 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Value based implementation of a list attribute.
* @author britt
@@ -49,139 +48,59 @@ public class ListAttributeValue extends AttributeValue implements ListAttribute
public ListAttributeValue(ListAttribute attr)
{
this();
for (Attribute child : attr)
for (Attribute entry : attr)
{
Attribute newAttr = null;
switch (child.getType())
{
case BOOLEAN :
{
newAttr = new BooleanAttributeValue((BooleanAttribute)child);
break;
}
case BYTE :
{
newAttr = new ByteAttributeValue((ByteAttribute)child);
break;
}
case SHORT :
{
newAttr = new ShortAttributeValue((ShortAttribute)child);
break;
}
case INT :
{
newAttr = new IntAttributeValue((IntAttribute)child);
break;
}
case LONG :
{
newAttr = new LongAttributeValue((LongAttribute)child);
break;
}
case FLOAT :
{
newAttr = new FloatAttributeValue((FloatAttribute)child);
break;
}
case DOUBLE :
{
newAttr = new DoubleAttributeValue((DoubleAttribute)child);
break;
}
case STRING :
{
newAttr = new StringAttributeValue((StringAttribute)child);
break;
}
case SERIALIZABLE :
{
newAttr = new SerializableAttributeValue((SerializableAttribute)child);
break;
}
case MAP :
{
newAttr = new MapAttributeValue((MapAttribute)child);
break;
}
case LIST :
{
newAttr = new ListAttributeValue((ListAttribute)child);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + child.getType());
}
}
// Use the type's factory for AttributeValue
Attribute newAttr = entry.getAttributeValue();
fData.add(newAttr);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#get(int)
*/
public Attribute get(int index)
{
return fData.get(index);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.LIST;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#add(org.alfresco.repo.attributes.Attribute)
*/
public Serializable getRawValue()
{
return (Serializable) fData;
}
@Override
public void add(Attribute attr)
{
fData.add(attr);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#add(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void add(int index, Attribute attr)
{
fData.add(index, attr);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#iterator()
*/
@Override
public Iterator<Attribute> iterator()
{
return fData.iterator();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#size()
*/
@Override
public int size()
{
return fData.size();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#remove(int)
*/
@Override
public void remove(int index)
{
fData.remove(index);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
@@ -196,9 +115,6 @@ public class ListAttributeValue extends AttributeValue implements ListAttribute
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#set(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void set(int index, Attribute value)
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class LongAttributeImpl extends AttributeImpl implements LongAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.LONG;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getLongValue()
*/
public Serializable getRawValue()
{
return Long.valueOf(fValue);
}
@Override
public long getLongValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setLongValue(long)
*/
@Override
public void setLongValue(long value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of a long attribute.
* @author britt
@@ -46,35 +48,28 @@ public class LongAttributeValue extends AttributeValue implements LongAttribute
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()
*/
public Serializable getRawValue()
{
return Long.valueOf(fData);
}
@Override
public long getLongValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setLongValue(long)
*/
@Override
public void setLongValue(long value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,7 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -34,7 +35,6 @@ 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;
@@ -56,96 +56,39 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
for (Map.Entry<String, Attribute> entry : attr.entrySet())
{
String key = entry.getKey();
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;
}
case LIST :
{
newAttr = new ListAttributeImpl((ListAttribute)value);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
}
}
MapEntryKey key = new MapEntryKey(this, entry.getKey());
MapEntry mapEntry = new MapEntryImpl(key, newAttr);
// Use the object's factory for AttributeValue
Attribute newAttr = value.getAttributeImpl();
// Persist it
MapEntryKey keyEntity = new MapEntryKey(this, key);
MapEntry mapEntry = new MapEntryImpl(keyEntity, newAttr);
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.MAP;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#clear()
*/
public Serializable getRawValue()
{
List<MapEntry> entries = AVMDAOs.Instance().fMapEntryDAO.get(this);
HashMap<String, Serializable> ret = new HashMap<String, Serializable>(entries.size() * 2);
for (MapEntry entry : entries)
{
ret.put(entry.getKey().getKey(), entry.getAttribute().getSerializableValue());
}
return ret;
}
@Override
public void clear()
{
AVMDAOs.Instance().fMapEntryDAO.delete(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#entrySet()
*/
@Override
public Set<Entry<String, Attribute>> entrySet()
{
@@ -158,9 +101,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
return map.entrySet();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#get(java.lang.String)
*/
@Override
public Attribute get(String key)
{
@@ -174,9 +114,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
return attr;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#keySet()
*/
@Override
public Set<String> keySet()
{
@@ -189,9 +126,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
return keys;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#put(java.lang.String, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void put(String key, Attribute value)
{
@@ -208,9 +142,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
AVMDAOs.Instance().fMapEntryDAO.save(entry);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#remove(java.lang.String)
*/
@Override
public void remove(String key)
{
@@ -225,9 +156,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
AVMDAOs.Instance().fAttributeDAO.delete(attr);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#values()
*/
@Override
public Collection<Attribute> values()
{
@@ -240,9 +168,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
return attrs;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
@@ -259,9 +184,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#size()
*/
@Override
public int size()
{

View File

@@ -25,14 +25,13 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
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
@@ -54,148 +53,67 @@ public class MapAttributeValue extends AttributeValue implements MapAttribute
fData = new HashMap<String, Attribute>();
for (Map.Entry<String, Attribute> entry : attr.entrySet())
{
String key = entry.getKey();
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;
}
case LIST :
{
newAttr = new ListAttributeValue((ListAttribute)value);
break;
}
default :
{
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
}
}
fData.put(entry.getKey(), newAttr);
// Use the object's factory for AttributeValue
Attribute newAttr = value.getAttributeValue();
// Put it into the map
fData.put(key, 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()
*/
public Serializable getRawValue()
{
return (Serializable) fData;
}
@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();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
@@ -212,9 +130,6 @@ public class MapAttributeValue extends AttributeValue implements MapAttribute
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#size()
*/
@Override
public int size()
{

View File

@@ -57,35 +57,28 @@ public class SerializableAttributeImpl extends AttributeImpl implements
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.SERIALIZABLE;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getSerializableValue()
*/
public Serializable getRawValue()
{
return fValue;
}
@Override
public Serializable getSerializableValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setSerializableValue(java.io.Serializable)
*/
@Override
public void setSerializableValue(Serializable value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -49,35 +49,28 @@ public class SerializableAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return fData;
}
@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;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -54,35 +56,28 @@ public class ShortAttributeImpl extends AttributeImpl implements ShortAttribute
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getShortValue()
*/
@Override
public short getShortValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setShortValue(short)
*/
@Override
public void setShortValue(short value)
{
fValue = value;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.SHORT;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public Serializable getRawValue()
{
return Short.valueOf(fValue);
}
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of a short attribute.
* @author britt
@@ -47,35 +49,28 @@ public class ShortAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return Short.valueOf(fData);
}
@Override
public short getShortValue()
{
return fData;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#setShortValue(short)
*/
@Override
public void setShortValue(short value)
{
fData = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
import org.alfresco.repo.avm.AVMDAOs;
/**
@@ -55,35 +57,28 @@ public class StringAttributeImpl extends AttributeImpl implements
AVMDAOs.Instance().fAttributeDAO.save(this);
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#getType()
*/
public Type getType()
{
return Type.STRING;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#getStringValue()
*/
public Serializable getRawValue()
{
return fValue;
}
@Override
public String getStringValue()
{
return fValue;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#setStringValue(java.lang.String)
*/
@Override
public void setStringValue(String value)
{
fValue = value;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -25,6 +25,8 @@
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Value based implementation of a String attribute.
* @author britt
@@ -47,35 +49,28 @@ public class StringAttributeValue extends AttributeValue implements
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()
*/
public Serializable getRawValue()
{
return fData;
}
@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;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{

View File

@@ -258,81 +258,71 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/
}
// Clear out the new nodes.
try
List<Long> allLayeredNodeIDs = AVMDAOs.Instance().fAVMNodeDAO.getNewLayeredInStoreIDs(me);
AVMDAOs.Instance().fAVMNodeDAO.clearNewInStore(me);
AVMDAOs.Instance().fAVMNodeDAO.clear();
List<Long> layeredNodeIDs = new ArrayList<Long>();
for (Long layeredID : allLayeredNodeIDs)
{
// attempt to clear only AVMNodes from cache, to allow direct batch update of them
AVMDAOs.Instance().fAVMNodeDAO.flush();
AVMDAOs.Instance().fAVMNodeDAO.noCache();
AVMDAOs.Instance().fAVMNodeDAO.clearNewInStore(me);
List<Long> allLayeredNodeIDs = AVMDAOs.Instance().fAVMNodeDAO.getNewLayeredInStoreIDs(me);
List<Long> layeredNodeIDs = new ArrayList<Long>();
for (Long layeredID : allLayeredNodeIDs)
Layered layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
String indirection = layered.getIndirection();
if (indirection == null)
{
Layered layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
String indirection = layered.getIndirection();
if (indirection == null)
continue;
}
layeredNodeIDs.add(layeredID);
String storeName = indirection.substring(0, indirection.indexOf(':'));
if (!snapShotMap.containsKey(storeName))
{
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByName(storeName);
if (store == null)
{
continue;
}
layeredNodeIDs.add(layeredID);
String storeName = indirection.substring(0, indirection.indexOf(':'));
if (!snapShotMap.containsKey(storeName))
{
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByName(storeName);
if (store == null)
{
layered.setIndirectionVersion(-1);
}
else
{
store.createSnapshot(null, null, snapShotMap);
layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
layered.setIndirectionVersion(snapShotMap.get(storeName));
}
layered.setIndirectionVersion(-1);
}
else
{
store.createSnapshot(null, null, snapShotMap);
layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
layered.setIndirectionVersion(snapShotMap.get(storeName));
}
}
AVMDAOs.Instance().fAVMNodeDAO.flush();
// Make up a new version record.
String user = RawServices.Instance().getAuthenticationComponent().getCurrentUserName();
if (user == null)
else
{
user = RawServices.Instance().getAuthenticationComponent().getSystemUserName();
}
me = (AVMStoreImpl)AVMDAOs.Instance().fAVMStoreDAO.getByID(fID);
VersionRoot versionRoot = new VersionRootImpl(me,
me.fRoot,
me.fNextVersionID++,
System.currentTimeMillis(),
user,
tag,
description);
// Another embarassing flush needed.
AVMDAOs.Instance().fAVMNodeDAO.flush();
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
for (Long nodeID : layeredNodeIDs)
{
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(nodeID);
List<String> paths = fAVMRepository.getVersionPaths(versionRoot, node);
for (String path : paths)
{
VersionLayeredNodeEntry entry =
new VersionLayeredNodeEntryImpl(versionRoot, path);
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.save(entry);
}
layered.setIndirectionVersion(snapShotMap.get(storeName));
}
}
finally
AVMDAOs.Instance().fAVMNodeDAO.flush();
// Make up a new version record.
String user = RawServices.Instance().getAuthenticationComponent().getCurrentUserName();
if (user == null)
{
AVMDAOs.Instance().fAVMNodeDAO.yesCache();
user = RawServices.Instance().getAuthenticationComponent().getSystemUserName();
}
me = (AVMStoreImpl)AVMDAOs.Instance().fAVMStoreDAO.getByID(fID);
VersionRoot versionRoot = new VersionRootImpl(me,
me.fRoot,
me.fNextVersionID++,
System.currentTimeMillis(),
user,
tag,
description);
// Another embarassing flush needed.
AVMDAOs.Instance().fAVMNodeDAO.flush();
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
for (Long nodeID : layeredNodeIDs)
{
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(nodeID);
List<String> paths = fAVMRepository.getVersionPaths(versionRoot, node);
for (String path : paths)
{
VersionLayeredNodeEntry entry =
new VersionLayeredNodeEntryImpl(versionRoot, path);
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.save(entry);
}
}
return snapShotMap;
}
/**
* Create a new directory.
* @param path The path to the containing directory.

View File

@@ -33,12 +33,11 @@ import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.DirectoryNode;
import org.alfresco.repo.avm.LayeredDirectoryNode;
import org.alfresco.repo.avm.LayeredFileNode;
import org.alfresco.repo.domain.hibernate.SessionSizeResourceManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.CacheMode;
import org.hibernate.Query;
import org.hibernate.impl.SessionImpl;
import org.hibernate.stat.SessionStatistics;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
@@ -250,7 +249,7 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
fgLogger.debug(getSession().getStatistics());
}
getSession().flush();
getSession().clear();
SessionSizeResourceManager.clear(getSession());
if (fgLogger.isDebugEnabled())
{
fgLogger.debug(getSession().getStatistics());

View File

@@ -40,6 +40,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.attributes.Attribute;
import org.alfresco.repo.attributes.AttributeConverter;
import org.alfresco.repo.domain.schema.SchemaBootstrap;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -171,7 +172,8 @@ public class PropertyValue implements Cloneable, Serializable
}
/**
* Strings longer than the maximum of 1024 characters will be serialized.
* Strings longer than the maximum of {@link PropertyValue#DEFAULT_MAX_STRING_LENGTH}
* characters will be serialized.
*/
@Override
protected ValueType getPersistedType(Serializable value)
@@ -179,7 +181,8 @@ public class PropertyValue implements Cloneable, Serializable
if (value instanceof String)
{
String valueStr = (String) value;
if (valueStr.length() > 1024)
// Check how long the String can be
if (valueStr.length() > SchemaBootstrap.getMaxStringLength())
{
return ValueType.SERIALIZABLE;
}

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.repo.domain.hibernate;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Map;
@@ -36,7 +35,6 @@ import org.alfresco.util.resource.MethodResourceManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.engine.CollectionKey;
import org.hibernate.engine.EntityKey;
import org.hibernate.stat.SessionStatistics;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -151,8 +149,20 @@ public class SessionSizeResourceManager extends HibernateDaoSupport implements M
}
}
/**
* Clear the session now.
*
* @param session
*/
public static void clear(Session session)
{
SessionStatistics stats = session.getStatistics();
selectivelyClear(session, stats);
}
@SuppressWarnings("unchecked")
private void selectivelyClear(Session session, SessionStatistics stats)
private static void selectivelyClear(Session session, SessionStatistics stats)
{
if (logger.isDebugEnabled())
{

View File

@@ -44,6 +44,9 @@ import java.util.Properties;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch;
import org.alfresco.repo.content.filestore.FileContentWriter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.descriptor.Descriptor;
@@ -60,10 +63,14 @@ import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.connection.UserSuppliedConnectionProvider;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.MySQLInnoDBDialect;
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.context.ApplicationContext;
@@ -103,6 +110,29 @@ public class SchemaBootstrap extends AbstractLifecycleBean
private static final String ERR_SCRIPT_NOT_FOUND = "schema.update.err.script_not_found";
private static final String ERR_STATEMENT_TERMINATOR = "schema.update.err.statement_terminator";
public static final int DEFAULT_MAX_STRING_LENGTH = 1024;
private static volatile int maxStringLength = DEFAULT_MAX_STRING_LENGTH;
/**
* @see PropertyValue#DEFAULT_MAX_STRING_LENGTH
*/
public static final void setMaxStringLength(int length)
{
if (length < 1024)
{
throw new AlfrescoRuntimeException("The maximum string length must >= 1024 characters.");
}
SchemaBootstrap.maxStringLength = length;
}
/**
* @return Returns the maximum number of characters that a string field can be
*/
public static final int getMaxStringLength()
{
return SchemaBootstrap.maxStringLength;
}
private static Log logger = LogFactory.getLog(SchemaBootstrap.class);
private LocalSessionFactoryBean localSessionFactory;
@@ -112,6 +142,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
private List<SchemaUpgradeScriptPatch> validateUpdateScriptPatches;
private List<SchemaUpgradeScriptPatch> preUpdateScriptPatches;
private List<SchemaUpgradeScriptPatch> postUpdateScriptPatches;
private int maximumStringLength;
private ThreadLocal<StringBuilder> executedStatementsThreadLocal = new ThreadLocal<StringBuilder>();
@@ -121,6 +152,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
validateUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
preUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
postUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
maximumStringLength = -1;
}
public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory)
@@ -200,6 +232,31 @@ public class SchemaBootstrap extends AbstractLifecycleBean
this.postUpdateScriptPatches = scriptPatches;
}
/**
* Optionally override the system's default maximum string length. Some databases have
* limitations on how long the <b>string_value</b> columns can be while other do not.
* When a <tt>String<tt> value exceeds the maximum size it is persisted in the
* <b>serializable_value</b> column instead. Some databases have limitation on the size
* of the serializable columns as well, but usually support much more.
* <p>
* The system - as of V2.1.2 - will attempt to adjust the maximum string length size
* automatically and therefore this method is not normally required. But it is possible
* to manually override the value if, for example, the system doesn't guess the correct
* maximum length or if the dialect is not explicitly catered for.
* <p>
* All negative or zero values are ignored and the system defaults to its best guess based
* on the dialect being used.
*
* @param maximumStringLength the maximum length of the <b>string_value</b> columns
*/
public void setMaximumStringLength(int maximumStringLength)
{
if (maximumStringLength > 0)
{
this.maximumStringLength = maximumStringLength;
}
}
/**
* Helper method to generate a schema creation SQL script from the given Hibernate
* configuration.
@@ -768,6 +825,76 @@ public class SchemaBootstrap extends AbstractLifecycleBean
try { stmt.close(); } catch (Throwable e) {}
}
}
/**
* Performs dialect-specific checking. This includes checking for InnoDB, dumping the dialect being used
* as well as setting any runtime, dialect-specific properties.
*/
private void checkDialect(Dialect dialect)
{
Class dialectClazz = dialect.getClass();
LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class))
{
LogUtil.warn(logger, WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
}
if (dialectClazz.equals(HSQLDialect.class))
{
LogUtil.info(logger, WARN_DIALECT_HSQL);
}
int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
// Adjust the maximum allowable String length according to the dialect
if (dialect instanceof AlfrescoSQLServerDialect)
{
// string_value nvarchar(1024) null,
// serializable_value image null,
maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
}
else if (dialect instanceof AlfrescoSybaseAnywhereDialect)
{
// string_value text null,
// serializable_value varbinary(8192) null,
maxStringLength = Integer.MAX_VALUE;
}
else if (dialect instanceof DB2Dialect)
{
// string_value varchar(1024),
// serializable_value varchar(8192) for bit data,
maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
}
else if (dialect instanceof HSQLDialect)
{
// string_value varchar(1024),
// serializable_value varbinary(8192),
maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
}
else if (dialect instanceof MySQLInnoDBDialect)
{
// string_value text,
// serializable_value blob,
maxStringLength = Integer.MAX_VALUE;
}
else if (dialect instanceof Oracle9Dialect)
{
// string_value varchar2(1024 char),
// serializable_value long raw,
maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
}
else if (dialect instanceof PostgreSQLDialect)
{
// string_value varchar(1024),
// serializable_value bytea,
maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
}
SchemaBootstrap.setMaxStringLength(maxStringLength);
// Now override the maximum string length if it was set directly
if (maximumStringLength > 0)
{
SchemaBootstrap.setMaxStringLength(maximumStringLength);
}
}
@Override
protected void onBootstrap(ApplicationEvent event)
@@ -789,16 +916,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
// Check and dump the dialect being used
Dialect dialect = Dialect.getDialect(cfg.getProperties());
Class dialectClazz = dialect.getClass();
LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class))
{
LogUtil.warn(logger, WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
}
if (dialectClazz.equals(HSQLDialect.class))
{
LogUtil.info(logger, WARN_DIALECT_HSQL);
}
checkDialect(dialect);
// Ensure that our static connection provider is used
String defaultConnectionProviderFactoryClass = cfg.getProperty(Environment.CONNECTION_PROVIDER);

View File

@@ -84,6 +84,35 @@ public class FullNodeServiceTest extends BaseNodeServiceTest
mlTextProperty.getValue(Locale.ENGLISH),
propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
}
public void testLongMLTextValues() throws Exception
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 4096; i++)
{
sb.append(" ").append(i);
}
String longString = sb.toString();
// Set the server default locale
Locale.setDefault(Locale.ENGLISH);
// Set it as a normal string
nodeService.setProperty(
rootNodeRef,
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
longString);
MLText mlTextProperty = new MLText();
mlTextProperty.addValue(Locale.ENGLISH, longString);
mlTextProperty.addValue(Locale.FRENCH, longString);
mlTextProperty.addValue(Locale.GERMAN, longString);
// Set it as MLText
nodeService.setProperty(
rootNodeRef,
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
mlTextProperty);
}
/**
* {@inheritDoc}

View File

@@ -116,7 +116,6 @@ public class JBPMTransactionTemplate extends JbpmTemplate
if (context == null)
{
context = super.getContext();
SessionSizeResourceManager.setDisableInTransaction();
AlfrescoTransactionSupport.bindResource(JBPM_CONTEXT_KEY, context);
AlfrescoTransactionSupport.bindListener(this);

View File

@@ -44,7 +44,6 @@ import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.attributes.Attribute;
import org.alfresco.repo.attributes.MapAttribute;
import org.alfresco.repo.attributes.MapAttributeValue;
import org.alfresco.repo.attributes.StringAttribute;
import org.alfresco.repo.attributes.StringAttributeValue;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -322,15 +321,9 @@ public class DefaultTypeConverter
"MapAttribute string key cannot be converted to a locales:" + localeStr, e);
}
Attribute valueAttribute = entry.getValue();
if (valueAttribute instanceof StringAttribute)
{
ret.put(locale, valueAttribute.getStringValue());
}
else
{
throw new TypeConversionException(
"MapAttribute must contain Locale-String mappings to convert to MLText");
}
// Use the attribute's built-in conversion
String valueStr = valueAttribute == null ? null : valueAttribute.getStringValue();
ret.put(locale, valueStr);
}
return ret;
}

View File

@@ -21,46 +21,79 @@
* 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"
*
* Author Jon Cox <jcox@alfresco.com>
* File RuntimeSystemPropertiesSetter.java
*----------------------------------------------------------------------------*/
package org.alfresco.util;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.Ordered;
/**
* Sets runtime JVM system properties for Spring Framework.
*
* This class is used by the Spring framework to inject system properties into
* the runtime environment (e.g.: alfresco.jmx.dir). The motivation for this
* is that certain values must be set within spring must be computed in advance
* for org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
* to work properly.
*
* Sets runtime JVM system properties for Spring Framework.
* <p>
* This class is used by the Spring framework to inject system properties into
* the runtime environment (e.g.: alfresco.jmx.dir). The motivation for this
* is that certain values must be set within spring must be computed in advance
* for org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
* to work properly.
*
* @author Jon Cox
* @see #setProperties(Map)
*/
public class RuntimeSystemPropertiesSetter
implements BeanFactoryPostProcessor, Ordered
public class RuntimeSystemPropertiesSetter implements BeanFactoryPostProcessor, Ordered
{
private static org.apache.commons.logging.Log log=
org.apache.commons.logging.LogFactory.getLog(
RuntimeSystemPropertiesSetter.class );
private static Log logger = LogFactory.getLog(RuntimeSystemPropertiesSetter.class );
// default: just before PropertyPlaceholderConfigurer
private int order = Integer.MAX_VALUE - 1;
/** default: just before PropertyPlaceholderConfigurer */
private int order = Integer.MAX_VALUE - 1;
/**
* @see #setProperties(Map)
*/
private Map<String, String> jvmProperties;
public void RuntimeSystemPropertiesSetter() { }
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException
public RuntimeSystemPropertiesSetter()
{
jvmProperties = new HashMap<String, String>(7);
}
/**
* Set the properties that will get pushed into the JVM system properties.
* This will be akin to running the JVM with the <b>-Dprop=value</b>. Existing system JVM properties
* <i>will not be overwritten</i>.
*
* @param jvmProperties properties to set if they are not already present in the VM
*/
public void setJvmProperties(Map<String, String> jvmProperties)
{
this.jvmProperties = jvmProperties;
}
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
{
// Push any mapped properties into the JVM
for (Map.Entry<String, String> entry : jvmProperties.entrySet())
{
String key = entry.getKey();
String value = entry.getValue();
// Push into VM
String currentValue = System.getProperty(key);
if (currentValue == null)
{
System.setProperty(key, value);
if (logger.isDebugEnabled())
{
logger.debug("Setting system property: " + key + " = " + value);
}
}
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
String path=null;
try
@@ -81,9 +114,8 @@ public class RuntimeSystemPropertiesSetter
catch (java.net.URISyntaxException e ) { e.printStackTrace(); }
catch (Exception e )
{
if ( log.isWarnEnabled() )
log.warn(
"Could not find alfresco-jmxrmi.password on classpath");
if ( logger.isWarnEnabled() )
logger.warn("Could not find alfresco-jmxrmi.password on classpath");
}
if ( path == null ) { System.setProperty("alfresco.jmx.dir", ""); }