diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java index 338bea86a6f0016c55e114f831b03354e263d084..e46696ad71846385e0198a411f51e07db5095d75 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java @@ -262,7 +262,7 @@ public class ManagedPropertySection extends DisposableTabContent return null; // make eclipse happy } else { - final String value = StringEscapeUtils.unescapeHtml(managedProperty.getValue()); + final String value = StringEscapeUtils.unescapeHtml((String)managedProperty.getValue()); // if there is a script error than value will contain error message if (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) && (value.equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE) == false)) @@ -306,7 +306,7 @@ public class ManagedPropertySection extends DisposableTabContent return null; // make eclipse happy } else { - final String value = StringEscapeUtils.unescapeHtml(managedProperty.getValue()); + final String value = StringEscapeUtils.unescapeHtml((String)managedProperty.getValue()); // if there is a script error than value will contain error message if (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) && (value.equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE) == false)) diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java index e2887e2d6180832f0d8dbc5253d8d98cd88fde9e..a5627340d91ecd6ed5b8d8af77602d58a8b62d1c 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java @@ -121,7 +121,7 @@ public final class ManagedPropertyGridActionDialog extends inputDescription.setValue(value); } // old value was escaped going to the client - unescape it before sending back to the server - managedProperty.setValue(StringEscapeUtils.unescapeHtml(managedProperty.getValue())); + managedProperty.setValue(StringEscapeUtils.unescapeHtml((String)managedProperty.getValue())); viewContext.getService().updateManagedProperty(TechId.create(entity), entity.getEntityKind(), managedProperty, managedAction, callback); } diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java index ad4af19015b1563c48f9d57c18a2453e07e74ac3..ec185b0ef49a64f374d992439f58c8f8873e230f 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java @@ -71,8 +71,6 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.PersonTranslator; public final class EntityPropertiesConverter implements IEntityPropertiesConverter { - private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, - EntityPropertiesConverter.class); private static final IKeyExtractor<PropertyTypePE, ExtendedEntityTypePropertyType> EXTENDED_ETPT_KEY_EXTRACTOR = new IKeyExtractor<PropertyTypePE, ExtendedEntityTypePropertyType>() @@ -268,7 +266,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert final PersonPE registrator, final EntityTypePE entityTypePE, final IEntityProperty property) { - operationLog.info("||> tryConvertProperty START"); final String propertyCode = property.getPropertyType().getCode(); final PropertyTypePE propertyType = getPropertyType(propertyCode); final String valueOrNull = property.tryGetAsString(); @@ -281,8 +278,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert { throw UserFailureException.fromTemplate(NO_ENTITY_PROPERTY_VALUE_FOR_S, propertyCode); } - operationLog.info("||> tryConvertProperty " + propertyCode + " " + - propertyType + " val:|" + valueOrNull + "| isBlank:" + isNullOrBlank(valueOrNull)); if (isNullOrBlank(valueOrNull) == false) { List<T> results = new ArrayList<>(); @@ -290,12 +285,8 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert final String validatedValue = propertyValueValidator.validatePropertyValue(propertyType, translatedValue); - operationLog.info("||> tryConvertProperty translated:" + translatedValue + " validated:"+validatedValue); results.addAll(createEntityProperty(registrator, propertyType, entityTypePropertyTypePE, validatedValue)); - operationLog.info("||> tryConvertProperty POST1"); - results.forEach(operationLog::info); - operationLog.info("||> tryConvertProperty POST2"); return results; } return null; @@ -308,18 +299,15 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert { List<T> entityProperties = new ArrayList<>(); String val = value; - operationLog.info("||> createEntityProperty=" + val + " " + propertyType.isMultiValue() + " " + propertyType); if (propertyType.isMultiValue()) { if (val.startsWith("[")) { - operationLog.info("||> createEntityProperty array:" + val); val = val.substring(1, val.length() - 1); } for (String v : val.split(",")) { String singleValue = v.trim(); - operationLog.info("||> createEntityProperty single=" + singleValue); final T entityProperty = getEntityPropertyBase(registrator, entityTypePropertyType); setPropertyValue(entityProperty, propertyType, singleValue); entityProperties.add(entityProperty); @@ -328,12 +316,8 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert { final T entityProperty = getEntityPropertyBase(registrator, entityTypePropertyType); setPropertyValue(entityProperty, propertyType, val); - operationLog.info("||> createEntityProperty single:" + entityProperty); entityProperties.add(entityProperty); } - operationLog.info("||> createEntityProperty POST1"); - entityProperties.forEach(operationLog::info); - operationLog.info("||> createEntityProperty POST2"); return entityProperties; } @@ -356,8 +340,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert final IEntityProperty[] properties, final String entityTypeCode, final PersonPE registrator) { - operationLog.info("||> convertProperties" + Arrays.toString(properties)); - System.out.println("|||> convertProperties" + Arrays.toString(properties)); return convertProperties(properties, entityTypeCode, registrator, true, true); } @@ -372,30 +354,19 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert final EntityTypePE entityTypePE = getEntityType(entityTypeCode); Set<String> dynamicProperties = getDynamicProperties(entityTypePE); Set<String> managedProperties = getManagedProperties(entityTypePE); - operationLog.info("||> convertProperties dynamicProperties"); - dynamicProperties.forEach(operationLog::info); - operationLog.info("||> convertProperties managedProperties"); - managedProperties.forEach(operationLog::info); Set<IEntityProperty> definedProperties = new LinkedHashSet<IEntityProperty>(Arrays.asList(properties)); - operationLog.info("||> convertProperties definedProps1"); - definedProperties.forEach(operationLog::info); if (createDynamicPropertiesPlaceholders) { placeholderCreator.addDynamicPropertiesPlaceholders(definedProperties, dynamicProperties); - operationLog.info("||> convertProperties definedProps2"); - definedProperties.forEach(operationLog::info); } if (createManagedPropertiesPlaceholders) { placeholderCreator.addManagedPropertiesPlaceholders(definedProperties, managedProperties); - operationLog.info("||> convertProperties definedProps3"); - definedProperties.forEach(operationLog::info); } final List<T> list = new ArrayList<T>(); - operationLog.info("||> convertProperties PRE"); for (final IEntityProperty property : definedProperties) { final List<T> convertedPropertyOrNull = @@ -405,9 +376,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert list.addAll(convertedPropertyOrNull); } } - operationLog.info("||> convertProperties POST"); - list.forEach(l -> operationLog.info("||> "+l)); - list.forEach(l -> System.out.println("|||> "+l)); return list; } @@ -666,7 +634,7 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert T existingProperty = tryFind(oldProperties, managedProperty.getPropertyTypeCode()); if (existingProperty != null) { - existingProperty.setUntypedValue(managedProperty.getValue(), null, null, null, + existingProperty.setUntypedValue((String) managedProperty.getValue(), null, null, null, null, null, null, null, null); existingProperty.setAuthor(author); @@ -687,12 +655,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert EntityTypePE entityType, List<IEntityProperty> newProperties, PersonPE author, Set<String> propertiesToUpdate) { - operationLog.info("||> updateProperties " + entityType + " " + entityType + " "); - propertiesToUpdate.forEach(l -> operationLog.info("||> "+l)); - newProperties.forEach(l -> operationLog.info("||> "+l)); - - propertiesToUpdate.forEach(l -> System.out.println("|||> "+l)); - newProperties.forEach(l -> System.out.println("|||> "+l)); // all new properties should be among propertiesToUpdate (no need to check it) final Set<T> set = updateProperties(oldProperties, entityType, newProperties, author); // add old properties that are not among propertiesToUpdate (preserve those properties) @@ -816,7 +778,7 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert } evaluator.updateFromRegistrationForm(managedProperty, person, bindingsList); - return managedProperty.getValue(); + return (String) managedProperty.getValue(); } catch (Exception ex) { throw CheckedExceptionTunnel.wrapIfNecessary(ex); diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java index 3cb749fa1f3d4ef1469abdc0266c14cd985cbeff..3c5278c2da4b8823ea40110de70ba8ce4a370927 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java @@ -150,7 +150,7 @@ public class ManagedEntityProperty implements IEntityProperty, IManagedProperty } @Override - public String getValue() + public String getStringValue() { return (String) entityProperty.getValue(); } diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java index 817292dacf2848def124155dedd0637deb85de0b..8888e008694dc3f2bae3b5baaa8baeacbfd22ed1 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java @@ -19,6 +19,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiDescription; +import java.io.Serializable; + /** * A holder of information specific to a managed property value. * @@ -29,16 +31,23 @@ public class ManagedProperty implements IManagedProperty private static final long serialVersionUID = ServiceVersionHolder.VERSION; - public static boolean isSpecialValue(String valueOrNull) + public static boolean isSpecialValue(Serializable valueOrNull) { - return valueOrNull != null - && (valueOrNull.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) || valueOrNull + if(valueOrNull != null) { + if(valueOrNull.getClass().isArray()) { + return false; + } else { + String value = valueOrNull.toString(); + return (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) || value .equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE)); + } + } + return false; } // NOTE: defaults are set for testing - scripts should override them - private String value = BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE; + private Serializable value = BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE; private String propertyTypeCode = null; @@ -80,7 +89,7 @@ public class ManagedProperty implements IManagedProperty } @Override - public String getValue() + public Serializable getValue() { return value; } @@ -92,7 +101,7 @@ public class ManagedProperty implements IManagedProperty } @Override - public void setValue(String value) + public void setValue(Serializable value) { this.value = value; } diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java index 4eb1471340bfe5c1fb58b82d634b02e6417080fa..f4867dfd529c233872c59ea730e36394ac267571 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java @@ -43,10 +43,10 @@ public interface IManagedProperty extends Serializable boolean isSpecialValue(); /** Returns the current value of the property. */ - String getValue(); + Serializable getValue(); /** Set the value of the property. */ - void setValue(String value); + void setValue(Serializable value); /** * Return an object which allows to manage data for the user interface (input as well as output). diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java index 2b15d8acf04a6bf3472d08b0d68f396a69f1af53..41813afd8c50ab158a0624e01f5fea2f3778d188 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java @@ -127,7 +127,7 @@ public class JsonStructuredPropertyConverter implements IStructuredPropertyConve public boolean canHandle(IManagedProperty property) { - return canHandle(property.getValue()); + return canHandle((String)property.getValue()); } public boolean canHandle(String string) @@ -138,7 +138,7 @@ public class JsonStructuredPropertyConverter implements IStructuredPropertyConve @Override public List<IElement> convertToElements(IManagedProperty property) { - return convertStringToElements(property.getValue()); + return convertStringToElements((String)property.getValue()); } @Override diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java index c8e8e17d01f773f2b690e9a8904d1e8da4a92eca..3b38341de660f64451cf5e433199425c9a1ab838 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java @@ -61,7 +61,7 @@ public class XmlStructuredPropertyConverter implements IStructuredPropertyConver public boolean canHandle(IManagedProperty property) { - return canHandle(property.getValue()); + return canHandle((String)property.getValue()); } public boolean canHandle(String string) @@ -73,7 +73,7 @@ public class XmlStructuredPropertyConverter implements IStructuredPropertyConver @Override public List<IElement> convertToElements(IManagedProperty property) { - return convertStringToElements(property.getValue()); + return convertStringToElements((String)property.getValue()); } @Override