@Test public void shouldFailedForComplextType() throws Exception { doc = session.createDocumentModel("/", "test", "File"); session.createDocument(doc); session.save(); operation.xpath = "files:files"; try { operation.run(doc); fail(); } catch (UnsupportedOperationException e) { assertEquals("Manage only lists of scalar items", e.getMessage()); } catch (Exception e) { fail(); } }
@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; }