Search in sources :

Example 11 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class PdfPipeTest method multiThreadedMailWithWordAttachment.

@Test
public void multiThreadedMailWithWordAttachment() throws Exception {
    pipe.setName("multiThreadedmailWithWordAttachment");
    pipe.setAction(DocumentAction.CONVERT);
    pipe.registerForward(new PipeForward("success", "dummy"));
    pipe.configure();
    pipe.start();
    PipeLineSession session = new PipeLineSession();
    List<URL> inputs = new ArrayList<URL>();
    for (int i = 0; i < 5; i++) {
        inputs.add(TestFileUtils.getTestFileURL("/PdfPipe/MailWithAttachments/mailWithWordAttachment.msg"));
    }
    String expected = TestFileUtils.getTestFileMessage("/PdfPipe/xml-results/mailWithWordAttachment.xml").asString();
    inputs.parallelStream().forEach(item -> {
        try {
            PipeRunResult prr = pipe.doPipe(Message.asMessage(new File(item.toURI())), session);
            Message result = prr.getResult();
            MatchUtils.assertXmlEquals("Conversion XML does not match", applyIgnores(result.asString()), applyIgnores(expected), true);
        } catch (Exception e) {
            fail("Failed to execute test " + e.getMessage());
        }
    });
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) ArrayList(java.util.ArrayList) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) PipeForward(nl.nn.adapterframework.core.PipeForward) File(java.io.File) URL(java.net.URL) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Test(org.junit.Test)

Example 12 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class PdfPipeTest method executeConversion.

public String executeConversion(String pipeName, String fileToConvert) throws Exception {
    pipe.setName(pipeName);
    pipe.setAction(DocumentAction.CONVERT);
    pipe.configure();
    pipe.start();
    PipeLineSession session = new PipeLineSession();
    URL input = TestFileUtils.getTestFileURL(fileToConvert);
    pipe.doPipe(Message.asMessage(new File(input.toURI())), session);
    // returns <main conversionOption="0" mediaType="xxx/xxx" documentName="filename" numberOfPages="1" convertedDocument="xxx.pdf" />
    return session.getMessage("documents").asString();
}
Also used : PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) File(java.io.File) URL(java.net.URL)

Example 13 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class CmisSender method sendMessage.

@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
    Session cmisSession = null;
    try {
        ParameterValueList pvl = null;
        if (getParameterList() != null) {
            try {
                pvl = getParameterList().getValues(message, session);
            } catch (ParameterException e) {
                throw new SenderException(getLogPrefix() + "Sender [" + getName() + "] caught exception evaluating parameters", e);
            }
        }
        if (runtimeSession) {
            cmisSession = createCmisSession(pvl);
        } else {
            cmisSession = globalSession;
        }
        switch(getActionEnum()) {
            case GET:
                return sendMessageForActionGet(cmisSession, message, session, pvl);
            case CREATE:
                return sendMessageForActionCreate(cmisSession, message, session, pvl);
            case DELETE:
                return sendMessageForActionDelete(cmisSession, message, session);
            case FIND:
                return sendMessageForActionFind(cmisSession, message);
            case UPDATE:
                return sendMessageForActionUpdate(cmisSession, message);
            case FETCH:
                return sendMessageForDynamicActions(cmisSession, message, session);
            case DYNAMIC:
                return sendMessageForDynamicActions(cmisSession, message, session);
            default:
                throw new SenderException(getLogPrefix() + "unknown action [" + getAction() + "]");
        }
    } finally {
        if (cmisSession != null && runtimeSession) {
            cmisSession.clear();
            cmisSession = null;
        }
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) ParameterException(nl.nn.adapterframework.core.ParameterException) SenderException(nl.nn.adapterframework.core.SenderException) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Session(org.apache.chemistry.opencmis.client.api.Session)

Example 14 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class IbisDiscoveryService method query.

@Override
public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
    if (!eventDispatcher.contains(CmisEvent.QUERY)) {
        return discoveryService.query(repositoryId, statement, searchAllVersions, includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension);
    } else {
        XmlBuilder cmisXml = new XmlBuilder("cmis");
        cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
        cmisXml.addSubElement(buildXml("statement", statement));
        cmisXml.addSubElement(buildXml("searchAllVersions", searchAllVersions));
        cmisXml.addSubElement(buildXml("includeAllowableActions", includeAllowableActions));
        cmisXml.addSubElement(buildXml("includeRelationships", includeRelationships.name()));
        cmisXml.addSubElement(buildXml("renditionFilter", renditionFilter));
        cmisXml.addSubElement(buildXml("maxItems", maxItems));
        cmisXml.addSubElement(buildXml("skipCount", skipCount));
        PipeLineSession context = new PipeLineSession();
        context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
        Element cmisResult = eventDispatcher.trigger(CmisEvent.QUERY, cmisXml.toXML(), context);
        Element typesXml = XmlUtils.getFirstChildTag(cmisResult, "objectList");
        return CmisUtils.xml2ObjectList(typesXml, context);
    }
}
Also used : Element(org.w3c.dom.Element) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession)

Example 15 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class IbisObjectService method getObject.

@Override
public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extensions) {
    if (!eventDispatcher.contains(CmisEvent.GET_OBJECT)) {
        return objectService.getObject(repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extensions);
    } else {
        XmlBuilder cmisXml = new XmlBuilder("cmis");
        cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
        cmisXml.addSubElement(buildXml("objectId", objectId));
        cmisXml.addSubElement(buildXml("filter", filter));
        cmisXml.addSubElement(buildXml("includeAllowableActions", includeAllowableActions));
        cmisXml.addSubElement(buildXml("includePolicies", includePolicyIds));
        cmisXml.addSubElement(buildXml("includeAcl", includeAcl));
        PipeLineSession context = new PipeLineSession();
        context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
        Element cmisElement = eventDispatcher.trigger(CmisEvent.GET_OBJECT, cmisXml.toXML(), context);
        return CmisUtils.xml2ObjectData(cmisElement, context);
    }
}
Also used : Element(org.w3c.dom.Element) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession)

Aggregations

PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)270 Message (nl.nn.adapterframework.stream.Message)210 Test (org.junit.Test)202 SenderException (nl.nn.adapterframework.core.SenderException)43 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)33 UrlMessage (nl.nn.adapterframework.stream.UrlMessage)30 ByteArrayInputStream (java.io.ByteArrayInputStream)26 IOException (java.io.IOException)25 Parameter (nl.nn.adapterframework.parameters.Parameter)23 PipeForward (nl.nn.adapterframework.core.PipeForward)21 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)17 Date (java.util.Date)15 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)14 InputStream (java.io.InputStream)11 TimeoutException (nl.nn.adapterframework.core.TimeoutException)11 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 Map (java.util.Map)10 SimpleDateFormat (java.text.SimpleDateFormat)9 SOAPMessage (javax.xml.soap.SOAPMessage)9 URL (java.net.URL)8