@Test public void shouldAddEntryIntoStringList() throws Exception { assertNull(doc.getPropertyValue("lists:string")); operation.run(doc); String[] value = (String[]) doc.getPropertyValue("lists:string"); assertEquals(1, value.length); assertEquals("Test", value[0]); operation.value = "Test2"; operation.run(doc); value = (String[]) doc.getPropertyValue("lists:string"); assertEquals(2, value.length); assertEquals("Test2", value[1]); operation.value = "Test2"; operation.run(doc); value = (String[]) doc.getPropertyValue("lists:string"); assertEquals(2, value.length); assertEquals("Test2", value[1]); operation.checkExists = false; operation.value = "Test2"; operation.run(doc); value = (String[]) doc.getPropertyValue("lists:string"); assertEquals(3, value.length); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; } }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); static final String ID; }