/** * “Copyright 2012 Megam Systems” * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ package org.megam.deccanplato.provider.salesforce.crm.handler; import static org.megam.deccanplato.provider.Constants.*; import static org.megam.deccanplato.provider.salesforce.crm.Constants.*; import java.io.IOException; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; import org.apache.http.client.ClientProtocolException; import org.megam.deccanplato.http.TransportMachinery; import org.megam.deccanplato.http.TransportResponse; import org.megam.deccanplato.http.TransportTools; import org.megam.deccanplato.provider.BusinessActivity; import org.megam.deccanplato.provider.core.BusinessActivityInfo; /** * @author pandiyaraja * */ public class ChatterConversationImpl implements BusinessActivity{ private static final String SALESFORCE_CHATTER_CONVERSATION_URL = "/services/data/v25.0/query/?q=SELECT+Id+FROM+ChatterConversation"; private BusinessActivityInfo bizInfo; private Map<String, String> args = new HashMap<String, String>(); /* * (non-Javadoc) * * @see * org.megam.deccanplato.provider.BusinessActivity#setArguments(org.megam * .deccanplato.provider.core.BusinessActivityInfo, java.util.Map) */ @Override public void setArguments(BusinessActivityInfo tempBizInfo, Map<String, String> tempArgs) { this.bizInfo = tempBizInfo; this.args = tempArgs; } /* * (non-Javadoc) * * @see org.megam.deccanplato.provider.BusinessActivity#run() */ @Override public Map<String, String> run() { Map<String, String> outMap = new HashMap<String, String>(); switch (bizInfo.getActivityFunction()) { case LIST: outMap = list(outMap); break; } return outMap; } /** * @param outMap * @return */ private Map<String, String> list(Map<String, String> outMap) { Map<String, String> header = new HashMap<String, String>(); header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN)); TransportTools tst = new TransportTools(args.get(INSTANCE_URL)+SALESFORCE_CHATTER_CONVERSATION_URL, null, header); String responseBody = null; TransportResponse response = null; try { response = TransportMachinery.get(tst); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } responseBody = response.entityToString(); outMap.put(OUTPUT, responseBody); return outMap; } /* * (non-Javadoc) * * @see org.megam.deccanplato.provider.BusinessActivity#name() */ @Override public String name() { // TODO Auto-generated method stub return "chatterconversation"; } }