Commit 40cc4b96 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Merge remote-tracking branch 'origin/development'

parents ad13dd91 ebf697de
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>bonita-connector-twitter</artifactId> <artifactId>bonita-connector-twitter</artifactId>
<groupId>org.bonitasoft.connectors</groupId> <groupId>org.bonitasoft.connectors</groupId>
<version>6.1.0-SNAPSHOT</version> <version>1.0.0</version>
</parent> </parent>
<artifactId>bonita-connector-twitter-common</artifactId> <artifactId>bonita-connector-twitter-common</artifactId>
......
/** /**
* Copyright (C) 2009-2011 BonitaSoft S.A. * Copyright (C) 2009-2011 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or * the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version. * (at your option) any later version.
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.bonitasoft.connectors.twitter; package org.bonitasoft.connectors.twitter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Collections;
import java.util.Map; import java.util.List;
import java.util.Map;
import org.bonitasoft.engine.connector.Connector;
import org.bonitasoft.engine.connector.ConnectorException; import org.bonitasoft.engine.connector.Connector;
import org.bonitasoft.engine.connector.ConnectorValidationException; import org.bonitasoft.engine.connector.ConnectorException;
import org.bonitasoft.engine.connector.ConnectorValidationException;
import twitter4j.Twitter;
import twitter4j.TwitterFactory; import twitter4j.Twitter;
import twitter4j.conf.ConfigurationBuilder; import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
/**
* This connector provides a twitter sending service. /**
* * This connector provides a twitter sending service.
* @author Matthieu Chaffotte *
* @author Yanyan Liu * @author Matthieu Chaffotte
* @author Baptiste Mesta * @author Yanyan Liu
* @author Haris Subašić * @author Baptiste Mesta
* @author Maxence Raoux * @author Haris Subašić
*/ * @author Maxence Raoux
*/
public abstract class TwitterConnector implements Connector {
public abstract class TwitterConnector implements Connector {
private String proxyHost;
private String proxyHost;
private Integer proxyPort;
private Integer proxyPort;
private String proxyUser;
private String proxyUser;
private String proxyPass;
private String proxyPass;
private String consumerKey;
private String consumerKey;
private String consumerSecret;
private String consumerSecret;
private String accessToken;
private String accessToken;
private String accessTokenSecret;
private String accessTokenSecret;
@Override
public void setInputParameters(final Map<String, Object> parameters) { @Override
final Object proxyHostObject = parameters.get("proxyHost"); public void setInputParameters(final Map<String, Object> parameters) {
proxyHost = proxyHostObject != null ? (String) proxyHostObject : ""; final Object proxyHostObject = parameters.get("proxyHost");
final Object proxyPortObject = parameters.get("proxyPort"); proxyHost = proxyHostObject != null ? (String) proxyHostObject : "";
proxyPort = proxyPortObject != null ? (Integer) proxyPortObject : 0; final Object proxyPortObject = parameters.get("proxyPort");
final Object proxyUserObject = parameters.get("proxyUser"); proxyPort = proxyPortObject != null ? (Integer) proxyPortObject : 0;
proxyUser = proxyUserObject != null ? (String) proxyUserObject : ""; final Object proxyUserObject = parameters.get("proxyUser");
final Object proxyPassObject = parameters.get("proxyPass"); proxyUser = proxyUserObject != null ? (String) proxyUserObject : "";
proxyPass = proxyPassObject != null ? (String) proxyPassObject : ""; final Object proxyPassObject = parameters.get("proxyPass");
final Object consumerKeyObject = parameters.get("consumerKey"); proxyPass = proxyPassObject != null ? (String) proxyPassObject : "";
consumerKey = consumerKeyObject != null ? (String) consumerKeyObject final Object consumerKeyObject = parameters.get("consumerKey");
: ""; consumerKey = consumerKeyObject != null ? (String) consumerKeyObject
final Object consumerSecretObject = parameters.get("consumerSecret"); : "";
consumerSecret = consumerSecretObject != null ? (String) consumerSecretObject final Object consumerSecretObject = parameters.get("consumerSecret");
: ""; consumerSecret = consumerSecretObject != null ? (String) consumerSecretObject
final Object accessTokenObject = parameters.get("accessToken"); : "";
accessToken = accessTokenObject != null ? (String) accessTokenObject final Object accessTokenObject = parameters.get("accessToken");
: ""; accessToken = accessTokenObject != null ? (String) accessTokenObject
final Object accessTokenSecretObject = parameters : "";
.get("accessTokenSecret"); final Object accessTokenSecretObject = parameters
accessTokenSecret = accessTokenSecretObject != null ? (String) accessTokenSecretObject .get("accessTokenSecret");
: ""; accessTokenSecret = accessTokenSecretObject != null ? (String) accessTokenSecretObject
: "";
}
}
@Override
public void validateInputParameters() throws ConnectorValidationException { @Override
final List<String> errors = new ArrayList<String>(1); public void validateInputParameters() throws ConnectorValidationException {
final List<String> errors = new ArrayList<String>(1);
if (proxyPort < 0) {
errors.add("proxyPort cannot be less than 0!"); if (proxyPort < 0) {
} else if (proxyPort > 65535) { errors.add("proxyPort cannot be less than 0!");
errors.add("proxyPort cannot be greater than 65535!"); } else if (proxyPort > 65535) {
} errors.add("proxyPort cannot be greater than 65535!");
}
if (!errors.isEmpty()) {
throw new ConnectorValidationException(this, errors); if (!errors.isEmpty()) {
} throw new ConnectorValidationException(this, errors);
} }
}
@Override
public Map<String, Object> execute() throws ConnectorException { @Override
public Map<String, Object> execute() throws ConnectorException {
final ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
if (proxyHost != null && proxyPort != null) { final ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setHttpProxyHost(proxyHost); if (proxyHost != null && proxyPort != null) {
configurationBuilder.setHttpProxyPort(proxyPort); configurationBuilder.setHttpProxyHost(proxyHost);
if (proxyUser != null && proxyPass != null) { configurationBuilder.setHttpProxyPort(proxyPort);
configurationBuilder.setHttpProxyUser(proxyUser); if (proxyUser != null && proxyPass != null) {
configurationBuilder.setHttpProxyPassword(proxyPass); configurationBuilder.setHttpProxyUser(proxyUser);
} configurationBuilder.setHttpProxyPassword(proxyPass);
} }
configurationBuilder.setOAuthConsumerKey(consumerKey); }
configurationBuilder.setOAuthConsumerSecret(consumerSecret); configurationBuilder.setOAuthConsumerKey(consumerKey);
configurationBuilder.setOAuthAccessToken(accessToken); configurationBuilder.setOAuthConsumerSecret(consumerSecret);
configurationBuilder.setOAuthAccessTokenSecret(accessTokenSecret); configurationBuilder.setOAuthAccessToken(accessToken);
configurationBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
try {
final TwitterFactory tf = new TwitterFactory( try {
configurationBuilder.build()); final TwitterFactory tf = new TwitterFactory(
final Twitter twitter = tf.getInstance(); configurationBuilder.build());
executeTask(twitter); final Twitter twitter = tf.getInstance();
} catch (final Exception e) { executeTask(twitter);
System.out.println(e.getMessage()); } catch (final Exception e) {
throw new ConnectorException(e.getMessage()); throw new ConnectorException(e);
} }
return null; return Collections.emptyMap();
} }
protected abstract void executeTask(Twitter twitter) throws Exception; protected abstract void executeTask(Twitter twitter) throws Exception;
@Override @Override
public void connect() throws ConnectorException { public void connect() throws ConnectorException {
} }
@Override @Override
public void disconnect() throws ConnectorException { public void disconnect() throws ConnectorException {
} }
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>bonita-connector-twitter</artifactId> <artifactId>bonita-connector-twitter</artifactId>
<groupId>org.bonitasoft.connectors</groupId> <groupId>org.bonitasoft.connectors</groupId>
<version>6.1.0-SNAPSHOT</version> <version>1.0.0</version>
</parent> </parent>
<artifactId>bonita-connector-twitter-direct-def</artifactId> <artifactId>bonita-connector-twitter-direct-def</artifactId>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definition:ConnectorDefinition xmlns:definition="http://www.bonitasoft.org/ns/connector/definition/6.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <definition:ConnectorDefinition xmlns:definition="http://www.bonitasoft.org/ns/connector/definition/6.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>twitter-direct</id> <id>twitter-direct</id>
<version>1.0.0</version> <version>1.0.0</version>
<icon>twitter.png</icon> <icon>twitter.png</icon>
<category id="social" icon="social.png" /> <category id="social" icon="social.png" />
<category id="twitter" icon="twitter.png" parentCategoryId="social" /> <category id="twitter" icon="twitter.png" parentCategoryId="social" />
<input name="proxyHost" type="java.lang.String" /> <input name="proxyHost" type="java.lang.String" />
<input name="proxyPort" type="java.lang.Integer" defaultValue="0" /> <input name="proxyPort" type="java.lang.Integer" />
<input name="proxyUser" type="java.lang.String" mandatory="true" defaultValue="proxyUser" /> <input name="proxyUser" type="java.lang.String" />
<input name="proxyPass" type="java.lang.String" mandatory="true" defaultValue="proxyPass" /> <input name="proxyPass" type="java.lang.String" />
<input name="consumerKey" type="java.lang.String" mandatory="true" /> <input name="consumerKey" type="java.lang.String" mandatory="true" />
<input name="consumerSecret" type="java.lang.String" mandatory="true" /> <input name="consumerSecret" type="java.lang.String" mandatory="true" />
<input name="accessToken" type="java.lang.String" mandatory="true" /> <input name="accessToken" type="java.lang.String" mandatory="true" />
<input name="accessTokenSecret" type="java.lang.String" mandatory="true" /> <input name="accessTokenSecret" type="java.lang.String" mandatory="true" />
<input name="message" type="java.lang.String" mandatory="true" /> <input name="message" type="java.lang.String" mandatory="true" />
<input name="recipientId" type="java.lang.String" mandatory="true" /> <input name="recipientId" type="java.lang.String" mandatory="true" />
<page id="connection"> <page id="connection">
<widget id="ConsumerKey" inputName="consumerKey" xsi:type="definition:Password" /> <widget id="ConsumerKey" inputName="consumerKey" xsi:type="definition:Password" />
<widget id="ConsumerSecret" inputName="consumerSecret" xsi:type="definition:Password" /> <widget id="ConsumerSecret" inputName="consumerSecret" xsi:type="definition:Password" />
<widget id="AccessToken" inputName="accessToken" xsi:type="definition:Password" /> <widget id="AccessToken" inputName="accessToken" xsi:type="definition:Password" />
<widget id="AccessTokenSecret" inputName="accessTokenSecret" xsi:type="definition:Password" /> <widget id="AccessTokenSecret" inputName="accessTokenSecret" xsi:type="definition:Password" />
<widget id="ProxySettings" xsi:type="definition:Group"> <widget id="ProxySettings" xsi:type="definition:Group">
<widget id="ProxyHost" inputName="proxyHost" xsi:type="definition:Text" /> <widget id="ProxyHost" inputName="proxyHost" xsi:type="definition:Text" />
<widget id="ProxyPort" inputName="proxyPort" xsi:type="definition:Text" /> <widget id="ProxyPort" inputName="proxyPort" xsi:type="definition:Text" />
<widget id="ProxyUser" inputName="proxyUser" xsi:type="definition:Text" /> <widget id="ProxyUser" inputName="proxyUser" xsi:type="definition:Text" />
<widget id="ProxyPass" inputName="proxyPass" xsi:type="definition:Password" /> <widget id="ProxyPass" inputName="proxyPass" xsi:type="definition:Password" />
</widget> </widget>
</page> </page>
<page id="msg"> <page id="msg">
<widget id="Message" inputName="message" xsi:type="definition:Text" /> <widget id="Message" inputName="message" xsi:type="definition:Text" />
<widget id="RecipientID" inputName="recipientId" xsi:type="definition:Text" /> <widget id="RecipientID" inputName="recipientId" xsi:type="definition:Text" />
</page> </page>
</definition:ConnectorDefinition> </definition:ConnectorDefinition>
#X-Generator: crowdin.net #X-Generator: crowdin.net
social.category=Sozial social.category=Sozial
connectorDefinitionLabel=Twitter twitter.category=Twitter
connectorDefinitionDescription=Direkte Nachrichten senden connectorDefinitionLabel=Tweet senden
connectorDefinitionDescription=Tweet-Nachricht senden
msg.pageDescription=Direkte Nachrichten senden msg.pageDescription=Direkte Nachrichten senden
msg.pageTitle=Parameter und Nachricht eingeben msg.pageTitle=Parameter eingeben
connection.pageTitle=Nachricht und Empf\u00e4nger eingeben
connection.pageDescription=Direkte Nachrichten senden
ProxySettings.label=Proxy-Einstellungen ProxySettings.label=Proxy-Einstellungen
ProxyHost.label=HTTP-Proxy ProxyHost.label=HTTP-Proxy
ProxyHost.description=[leerer String] ProxyHost.description=
ProxyPort.label=Proxy-Port ProxyPort.label=Proxy-Port
ProxyPort.description=[leerer String] ProxyPort.description=
ProxyUser.label=Proxy-Benutzername ProxyUser.label=Proxy-Benutzername
ProxyUser.description=[leerer String] ProxyUser.description=
ProxyPass.label=Proxy-Passwort ProxyPass.label=Proxy-Passwort
ProxyPass.description=[leerer String] ProxyPass.description=
ConsumerKey.label=Verbraucherschl\u00fcssel ConsumerKey.label=Verbraucherschl\u00fcssel
ConsumerKey.description=[leerer String] ConsumerKey.description=
ConsumerSecret.label=Verbrauchergeheimnis ConsumerSecret.label=Verbrauchergeheimnis
ConsumerSecret.description=[leerer String] ConsumerSecret.description=
AccessToken.label=Zugriffstoken AccessToken.label=Zugriffstoken
AccessToken.description=[leerer String] AccessToken.description=
AccessTokenSecret.label=Geheimes Zugriffstoken AccessTokenSecret.label=Geheimes Zugriffstoken
AccessTokenSecret.description=[leerer String] AccessTokenSecret.description=
Message.label=Nachricht Message.label=Nachricht
Message.description=[leerer String] Message.description=
RecipientID.label=Empf\u00e4nger RecipientID.label=Empf\u00e4nger
RecipientID.description=[leerer String] RecipientID.description=ID oder Name des Empf\u00e4ngers
connection.pageTitle=Enter message and recipient
connection.pageDescription=Send direct messages
#X-Generator: crowdin.net
social.category=Social
twitter.category=Twitter
connectorDefinitionLabel=Send a Tweet
connectorDefinitionDescription=Send a tweet message
msg.pageDescription=Send direct messages
msg.pageTitle=Enter parameters
connection.pageTitle=Enter message and recipient
connection.pageDescription=Send direct messages
ProxySettings.label=Proxy settings
ProxyHost.label=HTTP proxy
ProxyHost.description=
ProxyPort.label=Proxy port
ProxyPort.description=
ProxyUser.label=Proxy user name
ProxyUser.description=
ProxyPass.label=Proxy password
ProxyPass.description=
ConsumerKey.label=Consumer key
ConsumerKey.description=
ConsumerSecret.label=Consumer secret
ConsumerSecret.description=
AccessToken.label=Access token
AccessToken.description=
AccessTokenSecret.label=Access token secret
AccessTokenSecret.description=
Message.label=Message
Message.description=
RecipientID.label=Recipient
RecipientID.description=ID or name of your recipient
#X-Generator: crowdin.net #X-Generator: crowdin.net
social.category=Social social.category=Social
connectorDefinitionLabel=Twitter twitter.category=Twitter
connectorDefinitionDescription=Envie mensajes directos connectorDefinitionLabel=Enviar un Tweet
connectorDefinitionDescription=Enviar un tweet
msg.pageDescription=Envie mensajes directos msg.pageDescription=Envie mensajes directos
msg.pageTitle=Introduzca los par\u00e1metros y el mensaje msg.pageTitle=Introduzca los parametros
connection.pageTitle=Introduzca el mensaje y el destinatario
connection.pageDescription=Envie mensajes directos
ProxySettings.label=configuraci\u00f3n proxy ProxySettings.label=configuraci\u00f3n proxy
ProxyHost.label=Proxy HTTP ProxyHost.label=Proxy HTTP
ProxyHost.description=[cadena vac\u00eda] ProxyHost.description=
ProxyPort.label=puerto Proxy ProxyPort.label=puerto Proxy
ProxyPort.description=[cadena vac\u00eda] ProxyPort.description=
ProxyUser.label=Usuario proxy ProxyUser.label=Usuario proxy
ProxyUser.description=[cadena vac\u00eda] ProxyUser.description=
ProxyPass.label=Contrase\u00f1a proxy ProxyPass.label=Contrase\u00f1a proxy
ProxyPass.description=[cadena vac\u00eda] ProxyPass.description=
ConsumerKey.label=Clave del Consumidor ConsumerKey.label=Clave del Consumidor
ConsumerKey.description=[cadena vac\u00eda] ConsumerKey.description=
ConsumerSecret.label=Secreto del consumidor ConsumerSecret.label=Secreto del consumidor
ConsumerSecret.description=[cadena vac\u00eda] ConsumerSecret.description=
AccessToken.label=token de acceso AccessToken.label=token de acceso
AccessToken.description=[cadena vac\u00eda] AccessToken.description=
AccessTokenSecret.label=El acceso secreto al contador AccessTokenSecret.label=El acceso secreto al contador
AccessTokenSecret.description=[cadena vac\u00eda] AccessTokenSecret.description=
Message.label=Mensaje Message.label=Mensaje
Message.description=[cadena vac\u00eda] Message.description=
RecipientID.label=beneficiario RecipientID.label=beneficiario
RecipientID.description=[cadena vac\u00eda] RecipientID.description=ID o nombre del destinatario
connection.pageTitle=Enter message and recipient
connection.pageDescription=Send direct messages
#X-Generator: crowdin.net #X-Generator: crowdin.net
social.category=Social social.category=Social
connectorDefinitionLabel=Twitter twitter.category=Mise \u00e0 jour du statut
connectorDefinitionDescription=Envoi de messages connectorDefinitionLabel=Poster un tweet
connectorDefinitionDescription=Poster un tweet
msg.pageDescription=Envoi de messages msg.pageDescription=Envoi de messages
msg.pageTitle=Veuillez entrer les informations du message msg.pageTitle=Renseignez les param\u00e8tres
connection.pageTitle=Renseignez le message et le destinataire
connection.pageDescription=Envoi de messages
ProxySettings.label=Param\u00e8tres du proxy ProxySettings.label=Param\u00e8tres du proxy
ProxyHost.label=Proxy HTTP ProxyHost.label=Proxy HTTP
ProxyHost.description= ProxyHost.description=
...@@ -24,6 +27,4 @@ AccessTokenSecret.description= ...@@ -24,6 +27,4 @@ AccessTokenSecret.description=
Message.label=Message Message.label=Message
Message.description= Message.description=
RecipientID.label=Destinataire RecipientID.label=Destinataire
RecipientID.description= RecipientID.description=Identifiant ou nom du destinataire
connection.pageTitle=Enter message and recipient
connection.pageDescription=Send direct messages
#X-Generator: crowdin.net #X-Generator: crowdin.net
social.category=Sociale social.category=Sociale
connectorDefinitionLabel=Twitter twitter.category=Twitter
connectorDefinitionDescription=Invia messaggi diretti connectorDefinitionLabel=Invia un Tweet
connectorDefinitionDescription=Invia un messaggio Tweet
msg.pageDescription=Invia messaggi diretti msg.pageDescription=Invia messaggi diretti
msg.pageTitle=Immetti i parametri e il messaggio msg.pageTitle=Immettere i parametri
connection.pageTitle=Inserisci il messaggio e il destinatario
connection.pageDescription=Invia messaggi diretti