mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -30,6 +30,9 @@
|
|||||||
<property name="localSessionFactory">
|
<property name="localSessionFactory">
|
||||||
<ref bean="&sessionFactory"></ref> <!-- inject the actual factory, not a session -->
|
<ref bean="&sessionFactory"></ref> <!-- inject the actual factory, not a session -->
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximumStringLength">
|
||||||
|
<value>${system.maximumStringLength}</value>
|
||||||
|
</property>
|
||||||
<property name="updateSchema">
|
<property name="updateSchema">
|
||||||
<value>${db.schema.update}</value>
|
<value>${db.schema.update}</value>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -67,6 +67,13 @@ system.acl.maxPermissionCheckTimeMillis=10000
|
|||||||
# The maximum number of results to perform permission checks against
|
# The maximum number of results to perform permission checks against
|
||||||
system.acl.maxPermissionChecks=1000
|
system.acl.maxPermissionChecks=1000
|
||||||
|
|
||||||
|
#
|
||||||
|
# Manually control how the system handles maximum string lengths.
|
||||||
|
# Any zero or negative value is ignored.
|
||||||
|
# Only change this after consulting support or reading the appropriate Javadocs for
|
||||||
|
# org.alfresco.repo.domain.schema.SchemaBootstrap for V2.1.2
|
||||||
|
system.maximumStringLength=-1
|
||||||
|
|
||||||
# #################### #
|
# #################### #
|
||||||
# Lucene configuration #
|
# Lucene configuration #
|
||||||
# #################### #
|
# #################### #
|
||||||
|
373
source/java/org/alfresco/repo/attributes/AbstractAttribute.java
Normal file
373
source/java/org/alfresco/repo/attributes/AbstractAttribute.java
Normal 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.");
|
||||||
|
}
|
||||||
|
}
|
@@ -32,6 +32,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.repo.domain.DbAccessControlList;
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
|
import org.alfresco.repo.domain.schema.SchemaBootstrap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for polymorphic attributes.
|
* Interface for polymorphic attributes.
|
||||||
@@ -41,17 +42,373 @@ public interface Attribute extends Serializable, Iterable<Attribute>
|
|||||||
{
|
{
|
||||||
public static enum Type implements Serializable
|
public static enum Type implements Serializable
|
||||||
{
|
{
|
||||||
BOOLEAN,
|
BOOLEAN
|
||||||
BYTE,
|
{
|
||||||
SHORT,
|
@Override
|
||||||
INT,
|
public AttributeValue getAttributeValue(Attribute from)
|
||||||
LONG,
|
{
|
||||||
FLOAT,
|
if (from instanceof BooleanAttribute)
|
||||||
DOUBLE,
|
{
|
||||||
STRING,
|
return new BooleanAttributeValue((BooleanAttribute)from);
|
||||||
SERIALIZABLE,
|
}
|
||||||
MAP,
|
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
|
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();
|
public DbAccessControlList getAcl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value type for this node.
|
* @return the enumerated type
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Type getType();
|
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.
|
* Set a boolean value.
|
||||||
|
@@ -25,13 +25,14 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles conversions between persistent and value based Attributes.
|
* Handles conversions between persistent and value based Attributes.
|
||||||
|
*
|
||||||
|
* @see Attribute.Type#getAttributeImpl(Attribute)
|
||||||
|
* @see Attribute.Type#getAttributeValue(Attribute)
|
||||||
|
*
|
||||||
* @author britt
|
* @author britt
|
||||||
*/
|
*/
|
||||||
public class AttributeConverter
|
public class AttributeConverter
|
||||||
@@ -44,133 +45,16 @@ public class AttributeConverter
|
|||||||
*/
|
*/
|
||||||
public Attribute toPersistent(Attribute from)
|
public Attribute toPersistent(Attribute from)
|
||||||
{
|
{
|
||||||
switch (from.getType())
|
AttributeImpl attributeEntity = from.getAttributeImpl();
|
||||||
{
|
// Done
|
||||||
case BOOLEAN :
|
return attributeEntity;
|
||||||
{
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attribute toValue(Attribute from)
|
public Attribute toValue(Attribute from)
|
||||||
{
|
{
|
||||||
Attribute ret = null;
|
AttributeValue attributeValue = from.getAttributeValue();
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AVMDAOs.Instance().fAttributeDAO.evictFlat(from);
|
AVMDAOs.Instance().fAttributeDAO.evictFlat(from);
|
||||||
return ret;
|
// Done
|
||||||
|
return attributeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,19 +25,13 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
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;
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base class of the implementation of Values.
|
* The base class of the implementation of Values.
|
||||||
* @author britt
|
* @author britt
|
||||||
*/
|
*/
|
||||||
public abstract class AttributeImpl implements Attribute
|
public abstract class AttributeImpl extends AbstractAttribute implements Attribute
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The primary key.
|
* The primary key.
|
||||||
@@ -89,226 +83,17 @@ public abstract class AttributeImpl implements Attribute
|
|||||||
{
|
{
|
||||||
return fVersion;
|
return fVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public DbAccessControlList getAcl()
|
||||||
* @see org.alfresco.repo.attributes.Value#clear()
|
|
||||||
*/
|
|
||||||
public void clear()
|
|
||||||
{
|
{
|
||||||
throw new AttributeMethodNotImplemented("Not ListValue or MapValue");
|
return fACL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void setAcl(DbAccessControlList acl)
|
||||||
* @see org.alfresco.repo.attributes.Value#entrySet()
|
|
||||||
*/
|
|
||||||
public Set<Entry<String, Attribute>> entrySet()
|
|
||||||
{
|
{
|
||||||
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
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
@@ -323,84 +108,9 @@ public abstract class AttributeImpl implements Attribute
|
|||||||
return fID == ((AttributeImpl)obj).fID;
|
return fID == ((AttributeImpl)obj).fID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return (int)fID;
|
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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -489,7 +489,7 @@ public class AttributeServiceImpl implements AttributeService
|
|||||||
throw new AVMWrongTypeException("Attribute Not List: " + keys);
|
throw new AVMWrongTypeException("Attribute Not List: " + keys);
|
||||||
}
|
}
|
||||||
Attribute converted = fAttributeConverter.toPersistent(value);
|
Attribute converted = fAttributeConverter.toPersistent(value);
|
||||||
found.set(index, fAttributeConverter.toPersistent(value));
|
found.set(index, converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.rmi.server.LogStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -82,7 +83,7 @@ public class AttributeServiceTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBasic()
|
public void testBasic() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -126,15 +127,30 @@ public class AttributeServiceTest extends TestCase
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
throw e;
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Test the query capability.
|
||||||
*/
|
*/
|
||||||
public void testQuery()
|
public void testQuery() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -236,12 +252,11 @@ public class AttributeServiceTest extends TestCase
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
throw e;
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDelete()
|
public void testDelete() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -290,14 +305,14 @@ public class AttributeServiceTest extends TestCase
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test ListAttributes
|
* Test ListAttributes
|
||||||
*/
|
*/
|
||||||
public void testList()
|
public void testList() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -344,8 +359,7 @@ public class AttributeServiceTest extends TestCase
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
throw e;
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,19 +25,13 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
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;
|
import org.alfresco.repo.domain.DbAccessControlList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based non-persistent implementation of Attribute.
|
* Value based non-persistent implementation of Attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
*/
|
*/
|
||||||
public abstract class AttributeValue implements Attribute
|
public abstract class AttributeValue extends AbstractAttribute implements Attribute
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* ACL for this Attribute
|
* ACL for this Attribute
|
||||||
@@ -55,292 +49,14 @@ public abstract class AttributeValue implements Attribute
|
|||||||
{
|
{
|
||||||
fACL = acl;
|
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()
|
public DbAccessControlList getAcl()
|
||||||
{
|
{
|
||||||
return fACL;
|
return fACL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#setAcl(org.alfresco.repo.domain.DbAccessControlList)
|
|
||||||
*/
|
|
||||||
public void setAcl(DbAccessControlList acl)
|
public void setAcl(DbAccessControlList acl)
|
||||||
{
|
{
|
||||||
fACL = 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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,35 +57,28 @@ public class BooleanAttributeImpl extends AttributeImpl implements
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getBooleanValue()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getBooleanValue()
|
public boolean getBooleanValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setBooleanValue(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setBooleanValue(boolean value)
|
public void setBooleanValue(boolean value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.BOOLEAN;
|
return Type.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see java.lang.Object#toString()
|
{
|
||||||
*/
|
return Boolean.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a boolean attribute.
|
* Value based implementation of a boolean attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -47,35 +49,28 @@ public class BooleanAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getBooleanValue();
|
fData = attr.getBooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.BOOLEAN;
|
return Type.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getBooleanValue()
|
{
|
||||||
*/
|
return Boolean.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getBooleanValue()
|
public boolean getBooleanValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setBooleanValue(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setBooleanValue(boolean value)
|
public void setBooleanValue(boolean value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class ByteAttributeImpl extends AttributeImpl implements ByteAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.BYTE;
|
return Type.BYTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getByteValue()
|
{
|
||||||
*/
|
return Byte.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getByteValue()
|
public byte getByteValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setByteValue(byte)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setByteValue(byte value)
|
public void setByteValue(byte value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of byte attribute.
|
* Value based implementation of byte attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -46,35 +48,28 @@ public class ByteAttributeValue extends AttributeValue implements ByteAttribute
|
|||||||
fData = attr.getByteValue();
|
fData = attr.getByteValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.BYTE;
|
return Type.BYTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getByteValue()
|
{
|
||||||
*/
|
return Byte.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getByteValue()
|
public byte getByteValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setByteValue(byte)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setByteValue(byte value)
|
public void setByteValue(byte value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class DoubleAttributeImpl extends AttributeImpl implements DoubleAttribut
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.DOUBLE;
|
return Type.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getDoubleValue()
|
{
|
||||||
*/
|
return Double.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDoubleValue()
|
public double getDoubleValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setDoubleValue(double)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setDoubleValue(double value)
|
public void setDoubleValue(double value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a double attribute.
|
* Value based implementation of a double attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -47,35 +49,28 @@ public class DoubleAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getDoubleValue();
|
fData = attr.getDoubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.DOUBLE;
|
return Type.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getDoubleValue()
|
{
|
||||||
*/
|
return Double.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDoubleValue()
|
public double getDoubleValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setDoubleValue(double)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setDoubleValue(double value)
|
public void setDoubleValue(double value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class FloatAttributeImpl extends AttributeImpl implements FloatAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.FLOAT;
|
return Type.FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getFloatValue()
|
{
|
||||||
*/
|
return Float.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFloatValue()
|
public float getFloatValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setFloatValue(float)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setFloatValue(float value)
|
public void setFloatValue(float value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of float attribute
|
* Value based implementation of float attribute
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -47,35 +49,28 @@ public class FloatAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getFloatValue();
|
fData = attr.getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.FLOAT;
|
return Type.FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getFloatValue()
|
{
|
||||||
*/
|
return Float.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFloatValue()
|
public float getFloatValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setFloatValue(float)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setFloatValue(float value)
|
public void setFloatValue(float value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class IntAttributeImpl extends AttributeImpl implements IntAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.INT;
|
return Type.INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getIntValue()
|
{
|
||||||
*/
|
return Integer.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIntValue()
|
public int getIntValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setIntValue(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setIntValue(int value)
|
public void setIntValue(int value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of int attribute.
|
* Value based implementation of int attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -46,35 +48,28 @@ public class IntAttributeValue extends AttributeValue implements IntAttribute
|
|||||||
fData = attr.getIntValue();
|
fData = attr.getIntValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.INT;
|
return Type.INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getIntValue()
|
{
|
||||||
*/
|
return Integer.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIntValue()
|
public int getIntValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setIntValue(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setIntValue(int value)
|
public void setIntValue(int value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||||
|
|
||||||
@@ -52,86 +52,30 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
for (Attribute entry : other)
|
for (Attribute entry : other)
|
||||||
{
|
{
|
||||||
Attribute newEntry = null;
|
Attribute newAttr = entry.getAttributeImpl();
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListEntryKey key = new ListEntryKey(this, index++);
|
ListEntryKey key = new ListEntryKey(this, index++);
|
||||||
ListEntry listEntry = new ListEntryImpl(key, newEntry);
|
ListEntry listEntry = new ListEntryImpl(key, newAttr);
|
||||||
AVMDAOs.Instance().fListEntryDAO.save(listEntry);
|
AVMDAOs.Instance().fListEntryDAO.save(listEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.LIST;
|
return Type.LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#add(org.alfresco.repo.attributes.Attribute)
|
{
|
||||||
*/
|
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
|
@Override
|
||||||
public void add(Attribute attr)
|
public void add(Attribute attr)
|
||||||
{
|
{
|
||||||
@@ -141,9 +85,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
AVMDAOs.Instance().fListEntryDAO.save(entry);
|
AVMDAOs.Instance().fListEntryDAO.save(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#add(int, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void add(int index, Attribute attr)
|
public void add(int index, Attribute attr)
|
||||||
{
|
{
|
||||||
@@ -167,18 +108,12 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
dao.save(newEntry);
|
dao.save(newEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#clear()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
AVMDAOs.Instance().fListEntryDAO.delete(this);
|
AVMDAOs.Instance().fListEntryDAO.delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#get(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Attribute get(int index)
|
public Attribute get(int index)
|
||||||
{
|
{
|
||||||
@@ -191,9 +126,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
return entry.getAttribute();
|
return entry.getAttribute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#iterator()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Attribute> iterator()
|
public Iterator<Attribute> iterator()
|
||||||
{
|
{
|
||||||
@@ -206,18 +138,12 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
return attrList.iterator();
|
return attrList.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#size()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public int size()
|
||||||
{
|
{
|
||||||
return AVMDAOs.Instance().fListEntryDAO.size(this);
|
return AVMDAOs.Instance().fListEntryDAO.size(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#remove(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(int index)
|
public void remove(int index)
|
||||||
{
|
{
|
||||||
@@ -242,9 +168,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@@ -259,9 +182,6 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#set(int, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int index, Attribute value)
|
public void set(int index, Attribute value)
|
||||||
{
|
{
|
||||||
|
@@ -25,12 +25,11 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a list attribute.
|
* Value based implementation of a list attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -49,139 +48,59 @@ public class ListAttributeValue extends AttributeValue implements ListAttribute
|
|||||||
public ListAttributeValue(ListAttribute attr)
|
public ListAttributeValue(ListAttribute attr)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
for (Attribute child : attr)
|
for (Attribute entry : attr)
|
||||||
{
|
{
|
||||||
Attribute newAttr = null;
|
// Use the type's factory for AttributeValue
|
||||||
switch (child.getType())
|
Attribute newAttr = entry.getAttributeValue();
|
||||||
{
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fData.add(newAttr);
|
fData.add(newAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#get(int)
|
|
||||||
*/
|
|
||||||
public Attribute get(int index)
|
public Attribute get(int index)
|
||||||
{
|
{
|
||||||
return fData.get(index);
|
return fData.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.LIST;
|
return Type.LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#add(org.alfresco.repo.attributes.Attribute)
|
{
|
||||||
*/
|
return (Serializable) fData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(Attribute attr)
|
public void add(Attribute attr)
|
||||||
{
|
{
|
||||||
fData.add(attr);
|
fData.add(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#add(int, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void add(int index, Attribute attr)
|
public void add(int index, Attribute attr)
|
||||||
{
|
{
|
||||||
fData.add(index, attr);
|
fData.add(index, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#iterator()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Attribute> iterator()
|
public Iterator<Attribute> iterator()
|
||||||
{
|
{
|
||||||
return fData.iterator();
|
return fData.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#size()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public int size()
|
||||||
{
|
{
|
||||||
return fData.size();
|
return fData.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#remove(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(int index)
|
public void remove(int index)
|
||||||
{
|
{
|
||||||
fData.remove(index);
|
fData.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@@ -196,9 +115,6 @@ public class ListAttributeValue extends AttributeValue implements ListAttribute
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#set(int, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int index, Attribute value)
|
public void set(int index, Attribute value)
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class LongAttributeImpl extends AttributeImpl implements LongAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.LONG;
|
return Type.LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getLongValue()
|
{
|
||||||
*/
|
return Long.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLongValue()
|
public long getLongValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setLongValue(long)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setLongValue(long value)
|
public void setLongValue(long value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a long attribute.
|
* Value based implementation of a long attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -46,35 +48,28 @@ public class LongAttributeValue extends AttributeValue implements LongAttribute
|
|||||||
fData = attr.getLongValue();
|
fData = attr.getLongValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.LONG;
|
return Type.LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getLongValue()
|
{
|
||||||
*/
|
return Long.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLongValue()
|
public long getLongValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setLongValue(long)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setLongValue(long value)
|
public void setLongValue(long value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -34,7 +35,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||||
|
|
||||||
@@ -56,96 +56,39 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
for (Map.Entry<String, Attribute> entry : attr.entrySet())
|
for (Map.Entry<String, Attribute> entry : attr.entrySet())
|
||||||
{
|
{
|
||||||
|
String key = entry.getKey();
|
||||||
Attribute value = entry.getValue();
|
Attribute value = entry.getValue();
|
||||||
Attribute newAttr = null;
|
// Use the object's factory for AttributeValue
|
||||||
switch (value.getType())
|
Attribute newAttr = value.getAttributeImpl();
|
||||||
{
|
// Persist it
|
||||||
case BOOLEAN :
|
MapEntryKey keyEntity = new MapEntryKey(this, key);
|
||||||
{
|
MapEntry mapEntry = new MapEntryImpl(keyEntity, newAttr);
|
||||||
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);
|
|
||||||
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
|
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.MAP;
|
return Type.MAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#clear()
|
{
|
||||||
*/
|
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
|
@Override
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
AVMDAOs.Instance().fMapEntryDAO.delete(this);
|
AVMDAOs.Instance().fMapEntryDAO.delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#entrySet()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Entry<String, Attribute>> entrySet()
|
public Set<Entry<String, Attribute>> entrySet()
|
||||||
{
|
{
|
||||||
@@ -158,9 +101,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
return map.entrySet();
|
return map.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#get(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Attribute get(String key)
|
public Attribute get(String key)
|
||||||
{
|
{
|
||||||
@@ -174,9 +114,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#keySet()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> keySet()
|
public Set<String> keySet()
|
||||||
{
|
{
|
||||||
@@ -189,9 +126,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#put(java.lang.String, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void put(String key, Attribute value)
|
public void put(String key, Attribute value)
|
||||||
{
|
{
|
||||||
@@ -208,9 +142,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
AVMDAOs.Instance().fMapEntryDAO.save(entry);
|
AVMDAOs.Instance().fMapEntryDAO.save(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#remove(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(String key)
|
public void remove(String key)
|
||||||
{
|
{
|
||||||
@@ -225,9 +156,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.delete(attr);
|
AVMDAOs.Instance().fAttributeDAO.delete(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#values()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Attribute> values()
|
public Collection<Attribute> values()
|
||||||
{
|
{
|
||||||
@@ -240,9 +168,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@@ -259,9 +184,6 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#size()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public int size()
|
||||||
{
|
{
|
||||||
|
@@ -25,14 +25,13 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a map attribute.
|
* Value based implementation of a map attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -54,148 +53,67 @@ public class MapAttributeValue extends AttributeValue implements MapAttribute
|
|||||||
fData = new HashMap<String, Attribute>();
|
fData = new HashMap<String, Attribute>();
|
||||||
for (Map.Entry<String, Attribute> entry : attr.entrySet())
|
for (Map.Entry<String, Attribute> entry : attr.entrySet())
|
||||||
{
|
{
|
||||||
|
String key = entry.getKey();
|
||||||
Attribute value = entry.getValue();
|
Attribute value = entry.getValue();
|
||||||
Attribute newAttr = null;
|
// Use the object's factory for AttributeValue
|
||||||
switch (value.getType())
|
Attribute newAttr = value.getAttributeValue();
|
||||||
{
|
// Put it into the map
|
||||||
case BOOLEAN :
|
fData.put(key, newAttr);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.MAP;
|
return Type.MAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#clear()
|
{
|
||||||
*/
|
return (Serializable) fData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
fData.clear();
|
fData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#entrySet()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Entry<String, Attribute>> entrySet()
|
public Set<Entry<String, Attribute>> entrySet()
|
||||||
{
|
{
|
||||||
return fData.entrySet();
|
return fData.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#get(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Attribute get(String key)
|
public Attribute get(String key)
|
||||||
{
|
{
|
||||||
return fData.get(key);
|
return fData.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#keySet()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> keySet()
|
public Set<String> keySet()
|
||||||
{
|
{
|
||||||
return fData.keySet();
|
return fData.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#put(java.lang.String, org.alfresco.repo.attributes.Attribute)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void put(String key, Attribute value)
|
public void put(String key, Attribute value)
|
||||||
{
|
{
|
||||||
fData.put(key, value);
|
fData.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#remove(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(String key)
|
public void remove(String key)
|
||||||
{
|
{
|
||||||
fData.remove(key);
|
fData.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#values()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Attribute> values()
|
public Collection<Attribute> values()
|
||||||
{
|
{
|
||||||
return fData.values();
|
return fData.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@@ -212,9 +130,6 @@ public class MapAttributeValue extends AttributeValue implements MapAttribute
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#size()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int size()
|
public int size()
|
||||||
{
|
{
|
||||||
|
@@ -57,35 +57,28 @@ public class SerializableAttributeImpl extends AttributeImpl implements
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.SERIALIZABLE;
|
return Type.SERIALIZABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getSerializableValue()
|
{
|
||||||
*/
|
return fValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getSerializableValue()
|
public Serializable getSerializableValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setSerializableValue(java.io.Serializable)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setSerializableValue(Serializable value)
|
public void setSerializableValue(Serializable value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -49,35 +49,28 @@ public class SerializableAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getSerializableValue();
|
fData = attr.getSerializableValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.SERIALIZABLE;
|
return Type.SERIALIZABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getSerializableValue()
|
{
|
||||||
*/
|
return fData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getSerializableValue()
|
public Serializable getSerializableValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setSerializableValue(java.io.Serializable)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setSerializableValue(Serializable value)
|
public void setSerializableValue(Serializable value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,35 +56,28 @@ public class ShortAttributeImpl extends AttributeImpl implements ShortAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getShortValue()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public short getShortValue()
|
public short getShortValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setShortValue(short)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setShortValue(short value)
|
public void setShortValue(short value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.SHORT;
|
return Type.SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see java.lang.Object#toString()
|
{
|
||||||
*/
|
return Short.valueOf(fValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a short attribute.
|
* Value based implementation of a short attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -47,35 +49,28 @@ public class ShortAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getShortValue();
|
fData = attr.getShortValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.SHORT;
|
return Type.SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getShortValue()
|
{
|
||||||
*/
|
return Short.valueOf(fData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getShortValue()
|
public short getShortValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setShortValue(short)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setShortValue(short value)
|
public void setShortValue(short value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,35 +57,28 @@ public class StringAttributeImpl extends AttributeImpl implements
|
|||||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.STRING;
|
return Type.STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#getStringValue()
|
{
|
||||||
*/
|
return fValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStringValue()
|
public String getStringValue()
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeImpl#setStringValue(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setStringValue(String value)
|
public void setStringValue(String value)
|
||||||
{
|
{
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value based implementation of a String attribute.
|
* Value based implementation of a String attribute.
|
||||||
* @author britt
|
* @author britt
|
||||||
@@ -47,35 +49,28 @@ public class StringAttributeValue extends AttributeValue implements
|
|||||||
fData = attr.getStringValue();
|
fData = attr.getStringValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
|
||||||
*/
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.STRING;
|
return Type.STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public Serializable getRawValue()
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#getStringValue()
|
{
|
||||||
*/
|
return fData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStringValue()
|
public String getStringValue()
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.AttributeValue#setStringValue(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setStringValue(String value)
|
public void setStringValue(String value)
|
||||||
{
|
{
|
||||||
fData = value;
|
fData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -258,81 +258,71 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
// Clear out the new nodes.
|
// 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
|
Layered layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
String indirection = layered.getIndirection();
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.noCache();
|
if (indirection == null)
|
||||||
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);
|
continue;
|
||||||
String indirection = layered.getIndirection();
|
}
|
||||||
if (indirection == null)
|
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;
|
layered.setIndirectionVersion(-1);
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
store.createSnapshot(null, null, snapShotMap);
|
||||||
|
layered = (Layered)AVMDAOs.Instance().fAVMNodeDAO.getByID(layeredID);
|
||||||
layered.setIndirectionVersion(snapShotMap.get(storeName));
|
layered.setIndirectionVersion(snapShotMap.get(storeName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
else
|
||||||
// Make up a new version record.
|
|
||||||
String user = RawServices.Instance().getAuthenticationComponent().getCurrentUserName();
|
|
||||||
if (user == null)
|
|
||||||
{
|
{
|
||||||
user = RawServices.Instance().getAuthenticationComponent().getSystemUserName();
|
layered.setIndirectionVersion(snapShotMap.get(storeName));
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
return snapShotMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new directory.
|
* Create a new directory.
|
||||||
* @param path The path to the containing directory.
|
* @param path The path to the containing directory.
|
||||||
|
@@ -33,12 +33,11 @@ import org.alfresco.repo.avm.AVMStore;
|
|||||||
import org.alfresco.repo.avm.DirectoryNode;
|
import org.alfresco.repo.avm.DirectoryNode;
|
||||||
import org.alfresco.repo.avm.LayeredDirectoryNode;
|
import org.alfresco.repo.avm.LayeredDirectoryNode;
|
||||||
import org.alfresco.repo.avm.LayeredFileNode;
|
import org.alfresco.repo.avm.LayeredFileNode;
|
||||||
|
import org.alfresco.repo.domain.hibernate.SessionSizeResourceManager;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.hibernate.CacheMode;
|
import org.hibernate.CacheMode;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.impl.SessionImpl;
|
|
||||||
import org.hibernate.stat.SessionStatistics;
|
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,7 +249,7 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
|||||||
fgLogger.debug(getSession().getStatistics());
|
fgLogger.debug(getSession().getStatistics());
|
||||||
}
|
}
|
||||||
getSession().flush();
|
getSession().flush();
|
||||||
getSession().clear();
|
SessionSizeResourceManager.clear(getSession());
|
||||||
if (fgLogger.isDebugEnabled())
|
if (fgLogger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
fgLogger.debug(getSession().getStatistics());
|
fgLogger.debug(getSession().getStatistics());
|
||||||
|
@@ -40,6 +40,7 @@ import java.util.Map;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.attributes.Attribute;
|
import org.alfresco.repo.attributes.Attribute;
|
||||||
import org.alfresco.repo.attributes.AttributeConverter;
|
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.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
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
|
@Override
|
||||||
protected ValueType getPersistedType(Serializable value)
|
protected ValueType getPersistedType(Serializable value)
|
||||||
@@ -179,7 +181,8 @@ public class PropertyValue implements Cloneable, Serializable
|
|||||||
if (value instanceof String)
|
if (value instanceof String)
|
||||||
{
|
{
|
||||||
String valueStr = (String) value;
|
String valueStr = (String) value;
|
||||||
if (valueStr.length() > 1024)
|
// Check how long the String can be
|
||||||
|
if (valueStr.length() > SchemaBootstrap.getMaxStringLength())
|
||||||
{
|
{
|
||||||
return ValueType.SERIALIZABLE;
|
return ValueType.SERIALIZABLE;
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.domain.hibernate;
|
package org.alfresco.repo.domain.hibernate;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.engine.CollectionKey;
|
|
||||||
import org.hibernate.engine.EntityKey;
|
import org.hibernate.engine.EntityKey;
|
||||||
import org.hibernate.stat.SessionStatistics;
|
import org.hibernate.stat.SessionStatistics;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
private void selectivelyClear(Session session, SessionStatistics stats)
|
private static void selectivelyClear(Session session, SessionStatistics stats)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -44,6 +44,9 @@ import java.util.Properties;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch;
|
import org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch;
|
||||||
import org.alfresco.repo.content.filestore.FileContentWriter;
|
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.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.descriptor.Descriptor;
|
import org.alfresco.service.descriptor.Descriptor;
|
||||||
@@ -60,10 +63,14 @@ import org.hibernate.SessionFactory;
|
|||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.connection.UserSuppliedConnectionProvider;
|
import org.hibernate.connection.UserSuppliedConnectionProvider;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
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.DatabaseMetadata;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.springframework.context.ApplicationContext;
|
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_SCRIPT_NOT_FOUND = "schema.update.err.script_not_found";
|
||||||
private static final String ERR_STATEMENT_TERMINATOR = "schema.update.err.statement_terminator";
|
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 static Log logger = LogFactory.getLog(SchemaBootstrap.class);
|
||||||
|
|
||||||
private LocalSessionFactoryBean localSessionFactory;
|
private LocalSessionFactoryBean localSessionFactory;
|
||||||
@@ -112,6 +142,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
private List<SchemaUpgradeScriptPatch> validateUpdateScriptPatches;
|
private List<SchemaUpgradeScriptPatch> validateUpdateScriptPatches;
|
||||||
private List<SchemaUpgradeScriptPatch> preUpdateScriptPatches;
|
private List<SchemaUpgradeScriptPatch> preUpdateScriptPatches;
|
||||||
private List<SchemaUpgradeScriptPatch> postUpdateScriptPatches;
|
private List<SchemaUpgradeScriptPatch> postUpdateScriptPatches;
|
||||||
|
private int maximumStringLength;
|
||||||
|
|
||||||
private ThreadLocal<StringBuilder> executedStatementsThreadLocal = new ThreadLocal<StringBuilder>();
|
private ThreadLocal<StringBuilder> executedStatementsThreadLocal = new ThreadLocal<StringBuilder>();
|
||||||
|
|
||||||
@@ -121,6 +152,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
validateUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
validateUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
||||||
preUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
preUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
||||||
postUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
postUpdateScriptPatches = new ArrayList<SchemaUpgradeScriptPatch>(4);
|
||||||
|
maximumStringLength = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory)
|
public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory)
|
||||||
@@ -200,6 +232,31 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
this.postUpdateScriptPatches = scriptPatches;
|
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
|
* Helper method to generate a schema creation SQL script from the given Hibernate
|
||||||
* configuration.
|
* configuration.
|
||||||
@@ -768,6 +825,76 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
try { stmt.close(); } catch (Throwable e) {}
|
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
|
@Override
|
||||||
protected void onBootstrap(ApplicationEvent event)
|
protected void onBootstrap(ApplicationEvent event)
|
||||||
@@ -789,16 +916,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
|||||||
|
|
||||||
// Check and dump the dialect being used
|
// Check and dump the dialect being used
|
||||||
Dialect dialect = Dialect.getDialect(cfg.getProperties());
|
Dialect dialect = Dialect.getDialect(cfg.getProperties());
|
||||||
Class dialectClazz = dialect.getClass();
|
checkDialect(dialect);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that our static connection provider is used
|
// Ensure that our static connection provider is used
|
||||||
String defaultConnectionProviderFactoryClass = cfg.getProperty(Environment.CONNECTION_PROVIDER);
|
String defaultConnectionProviderFactoryClass = cfg.getProperty(Environment.CONNECTION_PROVIDER);
|
||||||
|
@@ -84,6 +84,35 @@ public class FullNodeServiceTest extends BaseNodeServiceTest
|
|||||||
mlTextProperty.getValue(Locale.ENGLISH),
|
mlTextProperty.getValue(Locale.ENGLISH),
|
||||||
propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
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}
|
* {@inheritDoc}
|
||||||
|
@@ -116,7 +116,6 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
context = super.getContext();
|
context = super.getContext();
|
||||||
SessionSizeResourceManager.setDisableInTransaction();
|
|
||||||
AlfrescoTransactionSupport.bindResource(JBPM_CONTEXT_KEY, context);
|
AlfrescoTransactionSupport.bindResource(JBPM_CONTEXT_KEY, context);
|
||||||
AlfrescoTransactionSupport.bindListener(this);
|
AlfrescoTransactionSupport.bindListener(this);
|
||||||
|
|
||||||
|
@@ -44,7 +44,6 @@ import org.alfresco.i18n.I18NUtil;
|
|||||||
import org.alfresco.repo.attributes.Attribute;
|
import org.alfresco.repo.attributes.Attribute;
|
||||||
import org.alfresco.repo.attributes.MapAttribute;
|
import org.alfresco.repo.attributes.MapAttribute;
|
||||||
import org.alfresco.repo.attributes.MapAttributeValue;
|
import org.alfresco.repo.attributes.MapAttributeValue;
|
||||||
import org.alfresco.repo.attributes.StringAttribute;
|
|
||||||
import org.alfresco.repo.attributes.StringAttributeValue;
|
import org.alfresco.repo.attributes.StringAttributeValue;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
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);
|
"MapAttribute string key cannot be converted to a locales:" + localeStr, e);
|
||||||
}
|
}
|
||||||
Attribute valueAttribute = entry.getValue();
|
Attribute valueAttribute = entry.getValue();
|
||||||
if (valueAttribute instanceof StringAttribute)
|
// Use the attribute's built-in conversion
|
||||||
{
|
String valueStr = valueAttribute == null ? null : valueAttribute.getStringValue();
|
||||||
ret.put(locale, valueAttribute.getStringValue());
|
ret.put(locale, valueStr);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TypeConversionException(
|
|
||||||
"MapAttribute must contain Locale-String mappings to convert to MLText");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -21,46 +21,79 @@
|
|||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
* the FLOSS exception, and it is also available here:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
|
||||||
*
|
|
||||||
* Author Jon Cox <jcox@alfresco.com>
|
|
||||||
* File RuntimeSystemPropertiesSetter.java
|
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
package org.alfresco.util;
|
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.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.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets runtime JVM system properties for Spring Framework.
|
* Sets runtime JVM system properties for Spring Framework.
|
||||||
*
|
* <p>
|
||||||
* This class is used by the Spring framework to inject system properties into
|
* 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
|
* 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
|
* is that certain values must be set within spring must be computed in advance
|
||||||
* for org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
|
* for org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
|
||||||
* to work properly.
|
* to work properly.
|
||||||
*
|
*
|
||||||
|
* @author Jon Cox
|
||||||
|
* @see #setProperties(Map)
|
||||||
*/
|
*/
|
||||||
public class RuntimeSystemPropertiesSetter
|
public class RuntimeSystemPropertiesSetter implements BeanFactoryPostProcessor, Ordered
|
||||||
implements BeanFactoryPostProcessor, Ordered
|
|
||||||
{
|
{
|
||||||
private static org.apache.commons.logging.Log log=
|
private static Log logger = LogFactory.getLog(RuntimeSystemPropertiesSetter.class );
|
||||||
org.apache.commons.logging.LogFactory.getLog(
|
|
||||||
RuntimeSystemPropertiesSetter.class );
|
|
||||||
|
|
||||||
// default: just before PropertyPlaceholderConfigurer
|
/** default: just before PropertyPlaceholderConfigurer */
|
||||||
private int order = Integer.MAX_VALUE - 1;
|
private int order = Integer.MAX_VALUE - 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #setProperties(Map)
|
||||||
|
*/
|
||||||
|
private Map<String, String> jvmProperties;
|
||||||
|
|
||||||
public void RuntimeSystemPropertiesSetter() { }
|
public RuntimeSystemPropertiesSetter()
|
||||||
|
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
|
|
||||||
throws BeansException
|
|
||||||
{
|
{
|
||||||
|
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();
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
String path=null;
|
String path=null;
|
||||||
try
|
try
|
||||||
@@ -81,9 +114,8 @@ public class RuntimeSystemPropertiesSetter
|
|||||||
catch (java.net.URISyntaxException e ) { e.printStackTrace(); }
|
catch (java.net.URISyntaxException e ) { e.printStackTrace(); }
|
||||||
catch (Exception e )
|
catch (Exception e )
|
||||||
{
|
{
|
||||||
if ( log.isWarnEnabled() )
|
if ( logger.isWarnEnabled() )
|
||||||
log.warn(
|
logger.warn("Could not find alfresco-jmxrmi.password on classpath");
|
||||||
"Could not find alfresco-jmxrmi.password on classpath");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( path == null ) { System.setProperty("alfresco.jmx.dir", ""); }
|
if ( path == null ) { System.setProperty("alfresco.jmx.dir", ""); }
|
||||||
|
Reference in New Issue
Block a user