Discussion:
[jboss-user] [jBPM] - Re: Where can we find TwitterWorkItemHandler?
Jose Cavieres
2013-07-01 23:05:58 UTC
Permalink
Jose Cavieres [https://community.jboss.org/people/jcavieres] created the discussion

"Re: Where can we find TwitterWorkItemHandler?"

To view the discussion, visit: https://community.jboss.org/message/825853#825853

--------------------------------------------------------------
Hi.
The source code is not available in the jar file jbpm-twitter.jar, only the class files.
I've searched for it everywhere and it's not available.
Can you please post the sources or fix the jar file?

Thanks in advance
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825853#825853]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Jose Cavieres
2013-07-02 00:35:53 UTC
Permalink
Jose Cavieres [https://community.jboss.org/people/jcavieres] created the discussion

"Re: Where can we find TwitterWorkItemHandler?"

To view the discussion, visit: https://community.jboss.org/message/825857#825857

--------------------------------------------------------------
By the way, the twitter service in the repository is based in the Twitter API v1, which was switched off last month by Twitter,
so the service has to be rebuilt against the 3.0.x version of Twitter4J in order to be "v1.1 compatible".
But the source code for this twitter-jbpm service is not available, so this upgrade is impossible for now.
Please release the source code.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825857#825857]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Kris Verlaenen
2013-07-10 23:55:41 UTC
Permalink
Kris Verlaenen [https://community.jboss.org/people/KrisVerlaenen] created the discussion

"Re: Where can we find TwitterWorkItemHandler?"

To view the discussion, visit: https://community.jboss.org/message/827434#827434

--------------------------------------------------------------
Jose,

You are correct.  I just tested and updating twitter4j to version 3.0.3 seems to work well.

Kris

/**
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jbpm.process.workitem.twitter;

import java.util.Properties;

import org.kie.api.runtime.process.WorkItem;
import org.kie.api.runtime.process.WorkItemHandler;
import org.kie.api.runtime.process.WorkItemManager;

import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;

public class TwitterWorkItemHandler implements WorkItemHandler {

    private Twitter twitter;

    public void setCredentials(String consumerKey, String consumerSecret, String accessKey, String accessSecret) {
        ConfigurationBuilder configBuilder = new ConfigurationBuilder();
        configBuilder
            .setDebugEnabled(true)
            .setOAuthConsumerKey(consumerKey)
            .setOAuthConsumerSecret(consumerSecret)
            .setOAuthAccessToken(accessKey)
            .setOAuthAccessTokenSecret(accessSecret);
        twitter = new TwitterFactory(configBuilder.build()).getInstance();
    }

    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
        try {
            if (twitter == null) {
                initTwitter();
            }
            String message = (String)workItem.getParameter("Message");
            if (message != null && message.trim().length() > 0) {
                twitter.updateStatus(message);
            }
        }
        catch(Throwable t) {
            t.printStackTrace();
            manager.abortWorkItem(workItem.getId());
        }
        manager.completeWorkItem(workItem.getId(), null);
    }

    private void initTwitter() throws Exception {
        Properties p = new Properties();
        p.load(TwitterWorkItemHandler.class.getResourceAsStream("/twitter.properties"));
        setCredentials(
            p.getProperty("twitter.consumerKey"),
            p.getProperty("twitter.consumerSecret"),
            p.getProperty("twitter.accessKey"),
            p.getProperty("twitter.accessSecret"));
    }

    public void abortWorkItem(WorkItem workitem, WorkItemManager workitemmanager) {
    }
}
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827434#827434]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...