View Javadoc
1   /*
2    * Copyright (C) 2003-2015 eXo Platform SAS.
3    *
4    * This is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU Lesser General Public License as
6    * published by the Free Software Foundation; either version 3 of
7    * the License, or (at your option) any later version.
8    *
9    * This software is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this software; if not, write to the Free
16   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18   */
19  package org.exoplatform.shareextension.service;
20  
21  import org.exoplatform.model.SocialPostInfo;
22  
23  /**
24   * Created by The eXo Platform SAS
25   * 
26   * @author Philippe Aristote paristote@exoplatform.com
27   * @since Jun 17, 2015
28   */
29  public abstract class Action {
30  
31    protected final String   LOG_TAG = "____eXo_Action_" + this.getClass().getName() + "____";
32  
33    protected SocialPostInfo postInfo;
34  
35    protected ActionListener listener;
36  
37    protected void check() {
38      if (postInfo == null)
39        throw new IllegalArgumentException("Cannot pass null as the SocialPostInfo argument");
40      if (listener == null)
41        throw new IllegalArgumentException("Cannot pass null as the ActionListener argument");
42    }
43  
44    protected abstract boolean doExecute();
45  
46    protected boolean execute() {
47      check();
48      return doExecute();
49    }
50  
51    public static interface ActionListener {
52  
53      public boolean onSuccess(String message);
54  
55      public boolean onError(String error);
56  
57    }
58  
59  }