Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-connector-twitter
Commits
ad13dd91
Commit
ad13dd91
authored
Aug 30, 2013
by
mraoux
Browse files
BI-258 Update twitter definition (port is an Integer not a Long)
parent
990c1843
Changes
3
Hide whitespace changes
Inline
Side-by-side
bonita-connector-twitter-common/src/main/java/org/bonitasoft/connectors/twitter/TwitterConnector.java
View file @
ad13dd91
/**
/**
* 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.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.bonitasoft.engine.connector.Connector
;
import
org.bonitasoft.engine.connector.Connector
;
import
org.bonitasoft.engine.connector.ConnectorException
;
import
org.bonitasoft.engine.connector.ConnectorException
;
import
org.bonitasoft.engine.connector.ConnectorValidationException
;
import
org.bonitasoft.engine.connector.ConnectorValidationException
;
import
twitter4j.Twitter
;
import
twitter4j.Twitter
;
import
twitter4j.TwitterFactory
;
import
twitter4j.TwitterFactory
;
import
twitter4j.conf.ConfigurationBuilder
;
import
twitter4j.conf.ConfigurationBuilder
;
/**
/**
* This connector provides a twitter sending service.
* This connector provides a twitter sending service.
*
*
* @author Matthieu Chaffotte
* @author Matthieu Chaffotte
* @author Yanyan Liu
* @author Yanyan Liu
* @author Baptiste Mesta
* @author Baptiste Mesta
* @author Haris Subašić
* @author Haris Subašić
* @author Maxence Raoux
* @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
@Override
public
void
setInputParameters
(
final
Map
<
String
,
Object
>
parameters
)
{
public
void
setInputParameters
(
final
Map
<
String
,
Object
>
parameters
)
{
final
Object
proxyHostObject
=
parameters
.
get
(
"proxyHost"
);
final
Object
proxyHostObject
=
parameters
.
get
(
"proxyHost"
);
proxyHost
=
proxyHostObject
!=
null
?
(
String
)
proxyHostObject
:
""
;
proxyHost
=
proxyHostObject
!=
null
?
(
String
)
proxyHostObject
:
""
;
final
Object
proxyPortObject
=
parameters
.
get
(
"proxyPort"
);
final
Object
proxyPortObject
=
parameters
.
get
(
"proxyPort"
);
proxyPort
=
proxyPortObject
!=
null
?
(
Integer
)
proxyPortObject
:
0
;
proxyPort
=
proxyPortObject
!=
null
?
(
Integer
)
proxyPortObject
:
0
;
final
Object
proxyUserObject
=
parameters
.
get
(
"proxyUser"
);
final
Object
proxyUserObject
=
parameters
.
get
(
"proxyUser"
);
proxyUser
=
proxyUserObject
!=
null
?
(
String
)
proxyUserObject
:
""
;
proxyUser
=
proxyUserObject
!=
null
?
(
String
)
proxyUserObject
:
""
;
final
Object
proxyPassObject
=
parameters
.
get
(
"proxyPass"
);
final
Object
proxyPassObject
=
parameters
.
get
(
"proxyPass"
);
proxyPass
=
proxyPassObject
!=
null
?
(
String
)
proxyPassObject
:
""
;
proxyPass
=
proxyPassObject
!=
null
?
(
String
)
proxyPassObject
:
""
;
final
Object
consumerKeyObject
=
parameters
.
get
(
"consumerKey"
);
final
Object
consumerKeyObject
=
parameters
.
get
(
"consumerKey"
);
consumerKey
=
consumerKeyObject
!=
null
?
(
String
)
consumerKeyObject
consumerKey
=
consumerKeyObject
!=
null
?
(
String
)
consumerKeyObject
:
""
;
:
""
;
final
Object
consumerSecretObject
=
parameters
.
get
(
"consumerSecret"
);
final
Object
consumerSecretObject
=
parameters
.
get
(
"consumerSecret"
);
consumerSecret
=
consumerSecretObject
!=
null
?
(
String
)
consumerSecretObject
consumerSecret
=
consumerSecretObject
!=
null
?
(
String
)
consumerSecretObject
:
""
;
:
""
;
final
Object
accessTokenObject
=
parameters
.
get
(
"accessToken"
);
final
Object
accessTokenObject
=
parameters
.
get
(
"accessToken"
);
accessToken
=
accessTokenObject
!=
null
?
(
String
)
accessTokenObject
accessToken
=
accessTokenObject
!=
null
?
(
String
)
accessTokenObject
:
""
;
:
""
;
final
Object
accessTokenSecretObject
=
parameters
final
Object
accessTokenSecretObject
=
parameters
.
get
(
"accessTokenSecret"
);
.
get
(
"accessTokenSecret"
);
accessTokenSecret
=
accessTokenSecretObject
!=
null
?
(
String
)
accessTokenSecretObject
accessTokenSecret
=
accessTokenSecretObject
!=
null
?
(
String
)
accessTokenSecretObject
:
""
;
:
""
;
}
}
@Override
@Override
public
void
validateInputParameters
()
throws
ConnectorValidationException
{
public
void
validateInputParameters
()
throws
ConnectorValidationException
{
final
List
<
String
>
errors
=
new
ArrayList
<
String
>(
1
);
final
List
<
String
>
errors
=
new
ArrayList
<
String
>(
1
);
if
(
proxyPort
<
0
)
{
if
(
proxyPort
<
0
)
{
errors
.
add
(
"proxyPort cannot be less than 0!"
);
errors
.
add
(
"proxyPort cannot be less than 0!"
);
}
else
if
(
proxyPort
>
65535
)
{
}
else
if
(
proxyPort
>
65535
)
{
errors
.
add
(
"proxyPort cannot be greater than 65535!"
);
errors
.
add
(
"proxyPort cannot be greater than 65535!"
);
}
}
if
(!
errors
.
isEmpty
())
{
if
(!
errors
.
isEmpty
())
{
throw
new
ConnectorValidationException
(
this
,
errors
);
throw
new
ConnectorValidationException
(
this
,
errors
);
}
}
}
}
@Override
@Override
public
Map
<
String
,
Object
>
execute
()
throws
ConnectorException
{
public
Map
<
String
,
Object
>
execute
()
throws
ConnectorException
{
final
ConfigurationBuilder
configurationBuilder
=
new
ConfigurationBuilder
();
final
ConfigurationBuilder
configurationBuilder
=
new
ConfigurationBuilder
();
if
(
proxyHost
!=
null
&&
proxyPort
!=
null
)
{
if
(
proxyHost
!=
null
&&
proxyPort
!=
null
)
{
configurationBuilder
.
setHttpProxyHost
(
proxyHost
);
configurationBuilder
.
setHttpProxyHost
(
proxyHost
);
configurationBuilder
.
setHttpProxyPort
(
proxyPort
);
configurationBuilder
.
setHttpProxyPort
(
proxyPort
);
if
(
proxyUser
!=
null
&&
proxyPass
!=
null
)
{
if
(
proxyUser
!=
null
&&
proxyPass
!=
null
)
{
configurationBuilder
.
setHttpProxyUser
(
proxyUser
);
configurationBuilder
.
setHttpProxyUser
(
proxyUser
);
configurationBuilder
.
setHttpProxyPassword
(
proxyPass
);
configurationBuilder
.
setHttpProxyPassword
(
proxyPass
);
}
}
}
}
configurationBuilder
.
setOAuthConsumerKey
(
consumerKey
);
configurationBuilder
.
setOAuthConsumerKey
(
consumerKey
);
configurationBuilder
.
setOAuthConsumerSecret
(
consumerSecret
);
configurationBuilder
.
setOAuthConsumerSecret
(
consumerSecret
);
configurationBuilder
.
setOAuthAccessToken
(
accessToken
);
configurationBuilder
.
setOAuthAccessToken
(
accessToken
);
configurationBuilder
.
setOAuthAccessTokenSecret
(
accessTokenSecret
);
configurationBuilder
.
setOAuthAccessTokenSecret
(
accessTokenSecret
);
try
{
try
{
final
TwitterFactory
tf
=
new
TwitterFactory
(
final
TwitterFactory
tf
=
new
TwitterFactory
(
configurationBuilder
.
build
());
configurationBuilder
.
build
());
final
Twitter
twitter
=
tf
.
getInstance
();
final
Twitter
twitter
=
tf
.
getInstance
();
executeTask
(
twitter
);
executeTask
(
twitter
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
System
.
out
.
println
(
e
.
getMessage
());
throw
new
ConnectorException
(
e
.
getMessage
());
throw
new
ConnectorException
(
e
.
getMessage
());
}
}
return
null
;
return
null
;
}
}
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
{
}
}
}
}
bonita-connector-twitter-direct-def/src/main/resources/twitter-direct.def
View file @
ad13dd91
<?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.
Long
"
defaultValue=
"0"
/>
<input
name=
"proxyPort"
type=
"java.lang.
Integer
"
defaultValue=
"0"
/>
<input
name=
"proxyUser"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyUser"
/>
<input
name=
"proxyUser"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyUser"
/>
<input
name=
"proxyPass"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyPass"
/>
<input
name=
"proxyPass"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyPass"
/>
<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>
bonita-connector-twitter-update-def/src/main/resources/twitter-update-status.def
View file @
ad13dd91
<?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-update-status
</id>
<id>
twitter-update-status
</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.
Long
"
defaultValue=
"0"
/>
<input
name=
"proxyPort"
type=
"java.lang.
Integer
"
defaultValue=
"0"
/>
<input
name=
"proxyUser"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyUser"
/>
<input
name=
"proxyUser"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyUser"
/>
<input
name=
"proxyPass"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyPass"
/>
<input
name=
"proxyPass"
type=
"java.lang.String"
mandatory=
"true"
defaultValue=
"proxyPass"
/>
<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=
"status"
type=
"java.lang.String"
mandatory=
"true"
/>
<input
name=
"status"
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=
"Status"
inputName=
"status"
xsi:type=
"definition:TextArea"
/>
<widget
id=
"Status"
inputName=
"status"
xsi:type=
"definition:TextArea"
/>
</page>
</page>
</definition:ConnectorDefinition>
</definition:ConnectorDefinition>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment