Package org.intalio.tempo.workflow.task.attachments

Examples of org.intalio.tempo.workflow.task.attachments.Attachment


        String task1ID = nextRandom();
        PATask task1 = new PATask(task1ID, new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", Utils.createXMLDocument());
        task1.getUserOwners().add("test.system-test");
        task1.getUserOwners().add("intalio\\admin");
        Attachment attachment1 = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a1"));
        task1.addAttachment(attachment1);
        Attachment attachment2 = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a2"));
        task1.addAttachment(attachment2);
        tms.create(task1);

        PATask task2 = (PATask) tms.getTask(task1.getID());
        Assert.assertEquals(2, task2.getAttachments().size());

        tms.removeAttachment(task1.getID(), attachment1.getPayloadURL());

        PATask task3 = (PATask) tms.getTask(task1.getID());
        Assert.assertEquals(1, task3.getAttachments().size());
        Assert.assertEquals(attachment2.getPayloadURL(), task3.getAttachments().iterator().next().getPayloadURL());

        Attachment[] attachments = tms.getAttachments(task1.getID());
        Assert.assertEquals(1, attachments.length);
        Assert.assertEquals(attachment2.getPayloadURL(), attachments[0].getPayloadURL());

        tms.removeAttachment(task1.getID(), attachment2.getPayloadURL());
        tms.addAttachment(task1.getID(), attachment1);

        PATask task4 = (PATask) tms.getTask(task1.getID());
        Assert.assertEquals(1, task4.getAttachments().size());
        Assert.assertEquals(attachment1.getPayloadURL(), task4.getAttachments().iterator().next().getPayloadURL());
View Full Code Here


        if ((creationDateStr != null) && ! ("".equals(creationDateStr))) {
            metadata.setCreationDate(new XsdDateTime(creationDateStr).getTime());
        }

        String payloadURLStr = this.requireElementValue(rootQueue, "payloadUrl");
        return new Attachment(metadata, payloadURLStr);
    }
View Full Code Here

    public static void main(String[] args) {
        junit.textui.TestRunner.run(AttachmentMarshallerTest.class);
    }

    public void testAttachmentMarshaller() throws Exception {
        Attachment attachment1 = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a1"));
        OMElement att = AttachmentMarshaller.marshalAttachment(attachment1);

        _logger.debug(TestUtils.toPrettyXML(att));
    }
View Full Code Here

        _logger.debug(TestUtils.toPrettyXML(att));
    }

    public void testAttachmentsMarshaller() throws Exception {
        Attachment[] attachments = new Attachment[2];
        Attachment attachment1 = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a1"));
        Attachment attachment2 = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a2"));
        attachments[0] = attachment1;
        attachments[1] = attachment2;
        OMElement att = AttachmentMarshaller.marshalAttachments(attachments);

        _logger.debug(TestUtils.toPrettyXML(att));
View Full Code Here

    }
   
    public void testAttachmentUnmarshaller() throws Exception {
        OMElement att = TestUtils.loadElementFromResource("/attachment1.xml");
        AttachmentUnmarshaller au = new AttachmentUnmarshaller();
        Attachment attachment = au.unmarshalAttachment(att);
        assertEquals("http://localhost/a1", attachment.toString());
    }
View Full Code Here

      Assert.assertFalse(task.isAvailableTo(niko));
    }

    public void testAttachments() throws Exception {
        PATask task = this.createPATask();
        Attachment attachment = new Attachment(new AttachmentMetadata(), new URL("http://localhost/a1"));
        Assert.assertNull(task.addAttachment(attachment));
        Assert.assertTrue(task.getAttachments().size() == 1);
        Assert.assertEquals(attachment, task.getAttachments().iterator().next());
        Assert.assertEquals(attachment, task.removeAttachment(attachment.getPayloadURL()));
        Assert.assertTrue(task.getAttachments().isEmpty());
    }
View Full Code Here

        task.getUserOwners().add("test/user1");
        task.getRoleOwners().add("test.role1");
        task.getRoleOwners().add("test\\role2");
        task.setOutput(TestUtils.createXMLDocument());
     
        task.addAttachment(new Attachment(new AttachmentMetadata(), new URL("http://localhost/url1")));
        AttachmentMetadata metadata = new AttachmentMetadata();
        metadata.setMimeType("image/jpeg");
        task.addAttachment(new Attachment(metadata, new URL("http://localhost/url2")));

        this.testTaskMarshalling(task);
    }
View Full Code Here

        task.getUserOwners().add("test/user1");
        task.getRoleOwners().add("test.role1");
        task.getRoleOwners().add("test\\role2");
        task.setOutput(TestUtils.createXMLDocument());

        task.addAttachment(new Attachment(new AttachmentMetadata(), new URL("http://localhost/url1")));
        AttachmentMetadata metadata = new AttachmentMetadata();
        metadata.setMimeType("image/jpeg");
        task.addAttachment(new Attachment(metadata, new URL("http://localhost/url2")));

        this.testTaskMetadataMarshalling(task, null);
    }
View Full Code Here

        task.setPriority(1);
        task.setProcessID("processID1");
        task.authorizeActionForUser("claim", "test/user1");
        task.authorizeActionForRole("revoke", "test/role1");

        task.addAttachment(new Attachment(new AttachmentMetadata(), new URL("http://localhost/url1")));
        AttachmentMetadata metadata = new AttachmentMetadata();
        metadata.setMimeType("image/jpeg");
        task.addAttachment(new Attachment(metadata, new URL("http://localhost/url2")));

        this.testTaskMarshalling(task);
   
View Full Code Here

         @Test
         public void testAttachments() throws Exception {
          PATask task1 = new PATask(getUniqueTaskID(), new URI(
                  "http://hellonico.net"));
          AttachmentMetadata attMetadata = new AttachmentMetadata();
          Attachment att = new Attachment(attMetadata, new URL(
                  "file:///thisisadocument1.txt"));
          Attachment att2 = new Attachment(attMetadata, new URL(
                  "file:///thisisadocument2.txt"));
          task1.addAttachment(att);
          task1.addAttachment(att2);
          task1.getUserOwners().add("niko");
          persist(task1);
        
          PATask task2 = new PATask(getUniqueTaskID(), new URI(
                  "http://hellonico.net"));
          task2.getUserOwners().add("niko");
          AttachmentMetadata attMetadata2 = new AttachmentMetadata();
          Attachment att3 = new Attachment(attMetadata2, new URL(
                  "file:///thisisadocument3.txt"));
          task2.addAttachment(att3);
          persist(task2);
        
          UserRoles ur = new UserRoles("niko",
                  new String[] { "examples\\employee" });
          final TaskFetcher taskFetcher = new TaskFetcher(em);
        
          // test task1 has two attachments
          String query = "(T._id = '" + task1.getID() + "')";
          Task[] t2 = taskFetcher.fetchAvailableTasks(ur, PATask.class, query);
          Assert.assertTrue(t2[0] instanceof PATask);
          PATask t = (PATask) t2[0];
          Collection<Attachment> atts = t.getAttachments();
          Assert.assertEquals(2, atts.size());
        
          // test the two attachments are different
          Iterator<Attachment> iter = atts.iterator();
          Attachment a1 = iter.next();
          Attachment a2 = iter.next();
          Assert.assertNotSame(a1.getPayloadURL(), a2.getPayloadURL());
        
          // test task2 has one attachment
          query = "(T._id = '" + task2.getID() + "')";
          t2 = taskFetcher.fetchAvailableTasks(ur, PATask.class, query);
          Assert.assertTrue(t2[0] instanceof PATask);
          t = (PATask) t2[0];
          Assert.assertEquals(1, t.getAttachments().size());
        
          // task2 attachments are not the same as task1
          URL ur1 = t.getAttachments().iterator().next().getPayloadURL();
          Assert.assertNotSame(a1.getPayloadURL(), ur1);
          Assert.assertNotSame(a2.getPayloadURL(), ur1);
        
          checkRemoved(new Task[] { task1, task2 });
         }
View Full Code Here

TOP

Related Classes of org.intalio.tempo.workflow.task.attachments.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.