Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * Wikitty :: api
   * %%
   * Copyright (C) 2009 - 2011 CodeLutin
   * %%
   * This program 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 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 Lesser Public License for more details.
  * 
  * You should have received a copy of the GNU General Lesser Public 
  * License along with this program.  If not, see
  * <http://www.gnu.org/licenses/lgpl-3.0.html>.
  * #L%
  */
 package org.nuiton.wikitty.services;
 
 
 import java.util.List;
 import java.util.Map;
Cette classe permet d'intercepter les modifications faites via les differentes methodes de modification des données et d'executer les differents WikittyHook enregistres. Les WikittyHook peuvent

Author(s):
poussin
Version:
$Revision$ Last update: $Date$ by : $Author$
 
 public class WikittyServiceHook extends WikittyServiceDelegator {

    
to use log facility, just put in your code: log.info(\"...\");
 
     static private Log log = LogFactory.getLog(WikittyServiceHook.class);
 
     final static public String PRE_STORE = "pre-store";
     final static public String POST_STORE = "post-store";
     final static public String PRE_STORE_EXTENSION = "pre-storeExtension";
     final static public String POST_STORE_EXTENSION = "post-storeExtension";
     final static public String PRE_DELETE = "pre-delete";
     final static public String POST_DELETE = "post-delete";
     final static public String PRE_DELETE_EXTENSION = "pre-deleteExtension";
     final static public String POST_DELETE_EXTENSION = "post-deleteExtension";
     final static public String PRE_DELETE_TREE = "pre-deleteTree";
     final static public String POST_DELETE_TREE = "post-deleteTree";
     final static public String PRE_CLEAR = "pre-clear";
     final static public String POST_CLEAR = "post-clear";
     final static public String PRE_LOGIN = "pre-login";
     final static public String POST_LOGIN = "post-login";
     final static public String PRE_LOGOUT = "pre-logout";
     final static public String POST_LOGOUT = "post-logout";
     final static public String PRE_REPLAY = "pre-replay";
     final static public String POST_REPLAY = "post-replay";
     final static public String PRE_SYNC_SEARCH_ENGINE = "pre-syncSearchEngine";
     final static public String POST_SYNC_SEARCH_ENGINE = "post-syncSearchEngine";

    

Parameters:
config not use currently but needed in futur
ws
 
     public WikittyServiceHook(ApplicationConfig configWikittyService ws) {
         super(ws);
     }
 
     protected Collection<WikittygetHook(String securityTokenString actionName) {
         WikittyQuery query = new WikittyQueryMaker()
                 .and()
                    .exteq(.)
                    .eq(.actionName)
                 .end();
         WikittyQueryResult<Stringids = getClient(securityToken).findAllByQuery(query);
 
        List<Wikittyresult = getDelegate().restore(securityTokenids.getAll());
        return result;
    }
    protected Map<StringObjectcallHook(String securityTokenString actionName,
            Map<StringObjectargsWikittyEvent event) {
        Collection<Wikittyhooks = getHook(securityTokenactionName);
        WikittyService ws = getDelegate();
        args.put("actionName"actionName);
        args.put("ws"ws);
        args.put("event"event);
        for (Wikitty hook : hooks) {
            String hookName = WikittyHookHelper.getName(hook);
            String mimetype = WikittyHookHelper.getMimetype(hook);
            String script = WikittyHookHelper.getScript(hook);
            args.put("hook"hook);
            args = ScriptEvaluator.exec(nullhookNamescriptmimetypeargs);
        }
        return args;
    }
    @Override
    public WikittyEvent store(String securityTokenCollection<Wikittywikittiesboolean force) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("wikitties"wikitties);
        args.put("force"force);
        
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        wikitties = (Collection<Wikitty>)args.get("wikitties");
        force = (Boolean)args.get("force");
        WikittyEvent result = super.store(securityTokenwikittiesforce);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public WikittyEvent storeExtension(String securityTokenCollection<WikittyExtensionexts) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("exts"exts);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        exts = (Collection<WikittyExtension>) args.get("exts");
        WikittyEvent result = super.storeExtension(securityTokenexts);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public WikittyEvent delete(String securityTokenCollection<Stringids) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("ids"ids);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        ids = (Collection<String>) args.get("ids");
        WikittyEvent result = super.delete(securityTokenids);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public WikittyEvent deleteExtension(String securityTokenCollection<StringextNames) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("extNames"extNames);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        extNames = (Collection<String>) args.get("extNames");
        WikittyEvent result = super.deleteExtension(securityTokenextNames);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public WikittyEvent deleteTree(String securityTokenString wikittyId) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("wikittyId"wikittyId);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        wikittyId = (Stringargs.get("wikittyId");
        WikittyEvent result = super.deleteTree(securityTokenwikittyId);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public WikittyEvent clear(String securityToken) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        WikittyEvent result = super.clear(securityToken);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public String login(String loginString password) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("login"login);
        args.put("password"password);
        args = callHook(nullargsnull);
        login = (String)args.get("login");
        password = (Stringargs.get("password");
        String result = super.login(loginpassword);
        callHook(nullargsnull);
        return result;
    }
    @Override
    public void logout(String securityToken) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        super.logout(securityToken);
        callHook(securityTokenargsnull);
    }
    @Override
    public WikittyEvent replay(String securityTokenList<WikittyEventeventsboolean force) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args.put("events"events);
        args.put("force"force);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        events = (List<WikittyEvent>) args.get("events");
        force = (Boolean)args.get("force");
        WikittyEvent result = super.replay(securityTokeneventsforce);
        callHook(securityTokenargsresult);
        return result;
    }
    @Override
    public void syncSearchEngine(String securityToken) {
        Map<StringObjectargs = new HashMap<StringObject>();
        args.put("securityToken"securityToken);
        args = callHook(securityTokenargsnull);
        securityToken = (String)args.get("securityToken");
        super.syncSearchEngine(securityToken);
        callHook(securityTokenargsnull);
    }
New to GrepCode? Check out our FAQ X