From do-not-reply at jboss.org Wed Sep 14 04:56:45 2011 Content-Type: multipart/mixed; boundary="===============9023896478971472518==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: gatein-commits at lists.jboss.org Subject: [gatein-commits] gatein SVN: r7408 - epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core. Date: Wed, 14 Sep 2011 04:56:45 -0400 Message-ID: <201109140856.p8E8uj7l023897@svn01.web.mwc.hst.phx2.redhat.com> --===============9023896478971472518== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: theute Date: 2011-09-14 04:56:45 -0400 (Wed, 14 Sep 2011) New Revision: 7408 Removed: epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/org/exopla= tform/portal/gadget/core/ShindigClientEndpoint.java Log: Missing parts when porting to EPP Deleted: epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/org/= exoplatform/portal/gadget/core/ShindigClientEndpoint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/org/exopl= atform/portal/gadget/core/ShindigClientEndpoint.java 2011-09-14 08:49:35 UT= C (rev 7407) +++ epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/org/exopl= atform/portal/gadget/core/ShindigClientEndpoint.java 2011-09-14 08:56:45 UT= C (rev 7408) @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2011 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.portal.gadget.core; - -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.ValueParam; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.net.URL; -import java.net.URLConnection; -import java.util.Timer; -import java.util.TimerTask; - -/** - * An endpoint to send requests to Shindig from Portal. - * - * This endpoint is necessary as Shindig does not expose any public API to= manipulates - * its caches from Portal. - * - * @author Minh Hoang TO - * @date 8/15/11 - */ -public class ShindigClientEndpoint -{ - - private final long delay; - - private final Timer timer; - - public ShindigClientEndpoint(InitParams params) throws Exception - { - long delayTime =3D 1000; - if(params !=3D null) - { - ValueParam delayParam =3D params.getValueParam("delayTime"); - delayTime =3D Long.parseLong(delayParam.getValue()); - } - delay =3D delayTime; - timer =3D new Timer(true); - } - - /** - * Etablish URLConnection to shindigURL and post request data to it - * - * @param requestData - * @param shindigURL - */ - public void sendRequest(String requestData, String shindigURL) - { - timer.schedule(createTimerTask(requestData, shindigURL), delay); - } - - private TimerTask createTimerTask(final String requestData, final Strin= g shindigURL) - { - return new TimerTask() - { - @Override - public void run() - { - OutputStreamWriter out =3D null; - InputStream in =3D null; - - try - { - URLConnection conn =3D new URL(shindigURL).openConnection(); - conn.setDoOutput(true); - out =3D new OutputStreamWriter(conn.getOutputStream()); - out.write(requestData); - out.flush(); - - in =3D conn.getInputStream(); //Don't remove this if you do= n't understand! - } - catch (IOException ioEx) - { - ioEx.printStackTrace(); - - } - finally - { - try - { - if (out !=3D null) - out.close(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - - try - { - if (in !=3D null) - in.close(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - - } - }; - } - -} --===============9023896478971472518==--