use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class TaskFormProcessorTest method testGetTypedItem.
public void testGetTypedItem() throws Exception {
try {
processor.getTypedItem(null);
fail("Should have thrown an Exception here!");
} catch (FormNotFoundException e) {
// Do nothing!
}
try {
processor.getTypedItem(new Item("task", "bad id"));
fail("Should have thrown an Exception here!");
} catch (FormNotFoundException e) {
// Do nothing!
}
WorkflowTask result = ((TaskFormProcessor) processor).getTypedItem(item);
assertNotNull(result);
assertEquals(TASK_ID, result.getId());
// Check URI-encoded id.
result = ((TaskFormProcessor) processor).getTypedItem(item);
assertNotNull(result);
assertEquals(TASK_ID, result.getId());
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class FormProcessorTest method testPersistPropertyComment.
public void testPersistPropertyComment(String taskId) throws Exception {
// MNT-11809 Activiti losses data with large Aspect or Type property values
// wiki Hamlet text
StringBuilder wikiHamlet = new StringBuilder();
wikiHamlet.append("Hamlet is the son of the King of Denmark. When Hamlet`s father dies, his uncle Claudius becomes king and marries Hamlet`s mother (Gertrude).");
wikiHamlet.append("Hamlet`s father appears as a ghost and tells Hamlet that he was murdered by Claudius. Hamlet is not sure that the ghost is really his father.");
wikiHamlet.append("He gets some travelling actors to perform a play which shows the murder of a king in the same way Hamlet`s father said he was killed.");
wikiHamlet.append("When Claudius reacts badly to seeing this, Hamlet believes he is guilty.");
wikiHamlet.append("Hamlet tells his mother that he knows about the murder. While there he kills Polonius, who is the king`s advisor, because he thinks he is Claudius.");
wikiHamlet.append("Rosencrantz and Guildenstern were Hamlet`s childhood friends.");
wikiHamlet.append("Claudius sends Rosencrantz and Guildenstern with Hamlet to England to have Hamlet killed, but their ship is attacked by pirates who take Hamlet prisoner but then return him to Denmark.");
wikiHamlet.append("Rosencrantz and Guildenstern are taken to England where they die. Ophelia is Polonius` daughter . After her father, Polonius, is killed by Hamlet she goes mad.");
wikiHamlet.append("Then she falls into a river and drowns. Hamlet returns just as her funeral is happening. Laertes, her brother, decides to kill Hamlet in revenge.");
wikiHamlet.append("He challenges Hamlet to a sword fight, and puts poison on his own sword. Claudius makes some poisoned wine for Hamlet to drink in case that does not work.");
wikiHamlet.append("At first Hamlet wins the sword fight, and in the meantime his mother drinks the poisoned wine without knowing, and dies.");
wikiHamlet.append("On the other hand Laertes falsely pierces Hamlet with a poisoned blade, but then Hamlet stabs Laertes with the same sword. Laertes tells Hamlet about the plot and then dies.");
wikiHamlet.append("Hamlet kills Claudius with the poisoned sword. Horatio, Hamlet`s friend, tells everyone about the murder of the old king.");
wikiHamlet.append("Hamlet tells everyone that the Norwegian prince, Fortinbras, should be king, and then dies from the poison.");
wikiHamlet.append("When Fortinbras arrives, Horatio recounts the tale and Fortinbras orders Hamlet`s body borne off in honour.");
wikiHamlet.append("Hamlet is one of the hardest parts for an actor to perform. It is one of the largest roles written by Shakespeare.");
wikiHamlet.append("Many people disagree about what Hamlet is really thinking. For many actors, playing Hamlet is one of the most important parts of their career.");
// Get max length of workflow comment property from repository.properties
String maxLength = "4000";
String dir = System.getProperty("user.dir");
File propFile = new File(dir + File.separator + "config" + File.separator + "alfresco" + File.separator + "repository.properties");
if (propFile.exists()) {
InputStream propStream = null;
try {
propStream = new FileInputStream(propFile);
Properties properties = new Properties();
properties.load(propStream);
maxLength = properties.getProperty("system.workflow.comment.property.max.length");
} finally {
if (propStream != null) {
propStream.close();
}
}
}
// Convert value of property to int
int maxLengthPropery;
try {
maxLengthPropery = Integer.valueOf(maxLength);
} catch (NumberFormatException e) {
maxLengthPropery = 4000;
}
FormData data = new FormData();
boolean repeatTest = true;
String test = wikiHamlet.toString();
Item item = new Item("task", taskId);
while (repeatTest) {
data.addFieldData("prop_bpm_comment", test);
int value = test.getBytes().length;
try {
processor.persist(item, data);
assertTrue("Value is " + value, value < maxLengthPropery);
} catch (Exception e) {
assertTrue("Caught Exception, value is " + value, value > maxLengthPropery);
}
if (value < maxLengthPropery) {
test += wikiHamlet.toString();
} else {
repeatTest = false;
}
}
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class TaskFormProcessorTest method setUp.
/*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
super.item = new Item("task", TASK_ID);
task = makeTask();
super.workflowService = makeWorkflowService();
super.nodeService = makeNodeService();
DictionaryService dictionaryService = makeDictionaryService();
super.namespaceService = makeNamespaceService();
authenticationService = makeAuthenticationService();
personService = makePersonService();
MockFieldProcessorRegistry fieldProcessorRegistry = new MockFieldProcessorRegistry(namespaceService, dictionaryService);
DefaultFieldProcessor defaultProcessor = super.makeDefaultFieldProcessor(dictionaryService);
super.processor = makeTaskFormProcessor(dictionaryService, fieldProcessorRegistry, defaultProcessor);
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class VirtualizationIntegrationTest method createVirtualizedFolder.
/**
* @param parent
* @param name
* @param templateSysPath system path of the template to be applied. If
* <code>null</code> the property is not set - this should
* trigger default predefined settings behavior.
* @return the {@link NodeRef} of a newly created folder that has the
* predefined virtualization method aspect applied
*/
protected NodeRef createVirtualizedFolder(NodeRef parent, String name, String templateSysPath) {
Item testItem = new Item("typeAndAspects", "cm:folder,smf:systemConfigSmartFolder");
FormData testFormData = new FormData();
testFormData.addFieldData(FORM_DATA_PROP_NAME, name);
if (templateSysPath != null) {
testFormData.addFieldData(PROP_VM_TEMPLATE_CLASSPATH, templateSysPath);
}
// alf_destination is mandatory
testFormData.addFieldData(FORM_DATA_PROP_ALF_DEF, parent.toString());
return (NodeRef) typeAndAspectsFormProcessor.persist(testItem, testFormData);
}
Aggregations