Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 129189 Details for
Bug 150174
[connector] Eventum
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Example code on how to talk from java with eventum's xmlrpc.php
EventumRpc.java (text/x-java), 4.23 KB, created by
Robbert-Jan
on 2009-03-18 06:38:43 EDT
(
hide
)
Description:
Example code on how to talk from java with eventum's xmlrpc.php
Filename:
MIME Type:
Creator:
Robbert-Jan
Created:
2009-03-18 06:38:43 EDT
Size:
4.23 KB
patch
obsolete
>import java.net.MalformedURLException; >import java.net.URL; >import java.util.ArrayList; >import java.util.Collection; >import java.util.List; >import java.util.Map; > >import javax.mail.SendFailedException; > >import nl.base.comm.mail.Mail; >import nl.base.mime.MimeType; >import nl.base.util.Utils; > >import org.apache.xmlrpc.XmlRpcException; >import org.apache.xmlrpc.client.XmlRpcClient; >import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; > >import com.Ostermiller.util.Base64; > >/** > * Communicate with eventum through RPC. > * > * See source code of eventum /rpc/xmlrpc.php for more methods. > */ >public final class EventumRpc { > > private static final String SERVER_URL = > "http://XXXX/eventum/rpc/xmlrpc.php"; > > private static final Object RESOLUTION_AUTOMATICALLY_CLOSED = 10; > > private final XmlRpcClient client; > > private final String username; > private final String password; > > public EventumRpc(final String username, final String password) { > this.username = username; > this.password = password; > final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > try { > final URL url = new URL(SERVER_URL); > config.setServerURL(url); > } catch (MalformedURLException e) { > throw new RuntimeException(e); > } > client = new XmlRpcClient(); > client.setConfig(config); > } > > private XmlRpcClient getClient() { > return client; > } > > private Object execute(final String methodName, > final Collection<Object> params) { > final List<Object> executionParams = > new ArrayList<Object>(params.size() * 2); > executionParams.add(username); > executionParams.add(password); > executionParams.addAll(params); > try { > return getClient().execute(methodName, executionParams); > } catch (final XmlRpcException e) { > throw new RuntimeException(e); > } > } > > private List<Map<String, String>> decodeList(Object objectList) { > Object[] arr = (Object[]) objectList; > List<Map<String, String>> out = new ArrayList<Map<String,String>>(); > for (Object obj : arr) { > out.add(decodeMap(obj)); > } > return out; > } > > private Map<String, String> decodeMap(Object objectMap) { > Map<String, String> map = (Map<String, String>) objectMap; > for (String key : map.keySet()) { > String strBase64 = map.get(key); > String value = Base64.decode(strBase64); > map.put(key, value); > } > return map; > } > > public void closeIssue(final int issuenr, final EventumStatus status, > final String closeMessage) { > Utils.assertNotNull("status == null!", status); > Utils.assertTrue("Status is not a closed status!", > status.isClosedStatus()); > Utils.assertNotEmpty("closemessage is empty!", closeMessage); > > final List<Object> params = new ArrayList<Object>(); > params.add(issuenr); > params.add(status.getName()); > params.add(RESOLUTION_AUTOMATICALLY_CLOSED); > params.add(true); //send notification > params.add(closeMessage); > > execute("closeIssue", params); > } > > public void updateIssueStatus(final int issuenr, > final EventumStatus status, final String emailSubject, > final String emailBody) { > final Collection<Object> params = new ArrayList<Object>(); > params.add(issuenr); > params.add(status.getName()); > execute("setIssueStatus", params); > if (emailSubject != null && emailBody != null) { > try { > sendEmailToIssue(issuenr, emailSubject, emailBody); > } catch (SendFailedException e) { > throw new RuntimeException(e); > } > } > } > > public void sendEmailToIssue(final int issuenr, final String subject, > final String body) throws SendFailedException { > final Map<String, String> issueDetails = getIssueDetails(issuenr); > final String id = issueDetails.get("iss_root_message_id"); > final Mail mail = new Mail(); > mail.setTo("eventum@XXXXXX.nl"); > mail.addHeader("In-Reply-To", id); > mail.setSubject(subject); > mail.setFromAddress(username); > mail.setMessage(body, MimeType.MIMETYPE_PLAIN); > mail.send(); > } > > public List<Map<String,String>> getEmails(final int issuenr) { > final Collection<Object> params = new ArrayList<Object>(); > params.add(issuenr); > final Object result = execute("getEmailListing", params); > return decodeList(result); > > } > > public Map<String,String> getIssueDetails(int issuenr) { > final Collection<Object> params = new ArrayList<Object>(); > params.add(issuenr); > final Object result = execute("getIssueDetails", params); > return decodeMap(result); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 150174
: 129189 |
146398
|
146399
|
146558