-
1. Re: Where can we find TwitterWorkItemHandler?
pmancham Jan 10, 2012 6:05 PM (in response to pmancham)It is referred in this blog by Kris: http://kverlaen.blogspot.com/2011/10/introducing-service-repository.html
-
2. Re: Where can we find TwitterWorkItemHandler?
tsurdilovic Jan 11, 2012 10:08 AM (in response to pmancham)You can get the jar file from the repository here: people.redhat.com/kverlaen/repository/Twitter/lib/jbpm-twitter.jar.
It includes the sources of the handler.
-
3. Re: Where can we find TwitterWorkItemHandler?
jcavieres Jul 1, 2013 7:05 PM (in response to tsurdilovic)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
-
4. Re: Where can we find TwitterWorkItemHandler?
jcavieres Jul 1, 2013 8:35 PM (in response to jcavieres)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.
-
5. Re: Where can we find TwitterWorkItemHandler?
krisverlaenen Jul 10, 2013 7:55 PM (in response to jcavieres)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
*
* 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) {
}
}