All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rapture.kernel.IdGenApiImplWrapper Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
/**
 * The MIT License (MIT)
 *
 * Copyright (C) 2011-2016 Incapture Technologies LLC
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * This is an autogenerated file. You should not edit this file as any changes
 * will be overwritten.
 */

package rapture.kernel;

import org.apache.log4j.Logger;

import java.util.List;
import java.util.Map;

import rapture.common.api.IdGenApi;
import rapture.common.CallingContext;
import rapture.common.RaptureEntitlementsContext;

import rapture.common.hooks.CallName;

import rapture.common.model.BasePayload;
import rapture.common.EntitlementSet;
import rapture.kernel.context.ContextValidator;

import rapture.common.RaptureIdGenConfig;

import rapture.common.shared.idgen.GetIdGenConfigsPayload;

import rapture.common.shared.idgen.GetIdGenConfigPayload;

import rapture.common.shared.idgen.CreateIdGenPayload;

import rapture.common.shared.idgen.IdGenExistsPayload;

import rapture.common.shared.idgen.DeleteIdGenPayload;

import rapture.common.shared.idgen.SetIdGenPayload;

import rapture.common.shared.idgen.NextPayload;

import rapture.common.shared.idgen.NextIdsPayload;

import rapture.common.shared.idgen.SetupDefaultIdGensPayload;


/**
 * This class is a wrapper around the class {@link IdGenApiImpl}. This is an auto-generated class that gives us the ability to add hooks such as entitlmeent
 * checks before each function call in the implementation. Since we always want to call these hooks, an instance of this class should be used 
 * (in {@link Kernel}) instead of using the implementation directly.
 * implementation directly. 
 *
 */
@SuppressWarnings("all")
public class IdGenApiImplWrapper implements IdGenApi, KernelApi {
    private static final Logger log = Logger.getLogger(IdGenApiImplWrapper.class);
    private IdGenApiImpl apiImpl;

    public IdGenApiImplWrapper(Kernel kernel) {
        apiImpl = new IdGenApiImpl(kernel);
    }

    /**
     * Returns the underlying implementation object. This should be used when a call is deliberately bypassing entitlement checks.
     * @return {@link IdGen}
     */
    public IdGenApiImpl getTrusted() {
        return apiImpl;
    }

    @Override
    public void start() {
        apiImpl.start();
    }

    /**
    * 
    */
    @Override
    public List getIdGenConfigs(CallingContext context, String authority) {
        long functionStartTime = System.currentTimeMillis();
       
        GetIdGenConfigsPayload requestObj = new GetIdGenConfigsPayload();
        requestObj.setContext(context);
        requestObj.setAuthority(authority);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_getIdGenConfigs, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_getIdGenConfigs);
        List returnValue = apiImpl.getIdGenConfigs(context, authority);    Kernel.getApiHooksService().post(context, CallName.IdGen_getIdGenConfigs);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.getIdGenConfigs.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.getIdGenConfigs.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public RaptureIdGenConfig getIdGenConfig(CallingContext context, String idGenUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetIdGenConfigPayload requestObj = new GetIdGenConfigPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_getIdGenConfig, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_getIdGenConfig);
        RaptureIdGenConfig returnValue = apiImpl.getIdGenConfig(context, idGenUri);    Kernel.getApiHooksService().post(context, CallName.IdGen_getIdGenConfig);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.getIdGenConfig.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.getIdGenConfig.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public RaptureIdGenConfig createIdGen(CallingContext context, String idGenUri, String config) {
        long functionStartTime = System.currentTimeMillis();
       
        CreateIdGenPayload requestObj = new CreateIdGenPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        requestObj.setConfig(config);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_createIdGen, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_createIdGen);
        RaptureIdGenConfig returnValue = apiImpl.createIdGen(context, idGenUri, config);    Kernel.getApiHooksService().post(context, CallName.IdGen_createIdGen);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.createIdGen.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.createIdGen.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Boolean idGenExists(CallingContext context, String idGenUri) {
        long functionStartTime = System.currentTimeMillis();
       
        IdGenExistsPayload requestObj = new IdGenExistsPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_idGenExists, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_idGenExists);
        Boolean returnValue = apiImpl.idGenExists(context, idGenUri);    Kernel.getApiHooksService().post(context, CallName.IdGen_idGenExists);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.idGenExists.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.idGenExists.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void deleteIdGen(CallingContext context, String idGenUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteIdGenPayload requestObj = new DeleteIdGenPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_deleteIdGen, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_deleteIdGen);
        apiImpl.deleteIdGen(context, idGenUri);    Kernel.getApiHooksService().post(context, CallName.IdGen_deleteIdGen);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.deleteIdGen.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.deleteIdGen.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public void setIdGen(CallingContext context, String idGenUri, Long count) {
        long functionStartTime = System.currentTimeMillis();
       
        SetIdGenPayload requestObj = new SetIdGenPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        requestObj.setCount(count);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_setIdGen, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_setIdGen);
        apiImpl.setIdGen(context, idGenUri, count);    Kernel.getApiHooksService().post(context, CallName.IdGen_setIdGen);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.setIdGen.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.setIdGen.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public String next(CallingContext context, String idGenUri) {
        long functionStartTime = System.currentTimeMillis();
       
        NextPayload requestObj = new NextPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_next, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_next);
        String returnValue = apiImpl.next(context, idGenUri);    Kernel.getApiHooksService().post(context, CallName.IdGen_next);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.next.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.next.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public String nextIds(CallingContext context, String idGenUri, Long num) {
        long functionStartTime = System.currentTimeMillis();
       
        NextIdsPayload requestObj = new NextIdsPayload();
        requestObj.setContext(context);
        requestObj.setIdGenUri(idGenUri);
        requestObj.setNum(num);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_nextIds, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_nextIds);
        String returnValue = apiImpl.nextIds(context, idGenUri, num);    Kernel.getApiHooksService().post(context, CallName.IdGen_nextIds);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.nextIds.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.nextIds.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void setupDefaultIdGens(CallingContext context, Boolean force) {
        long functionStartTime = System.currentTimeMillis();
       
        SetupDefaultIdGensPayload requestObj = new SetupDefaultIdGensPayload();
        requestObj.setContext(context);
        requestObj.setForce(force);
        ContextValidator.validateContext(context, EntitlementSet.IdGen_setupDefaultIdGens, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.IdGen_setupDefaultIdGens);
        apiImpl.setupDefaultIdGens(context, force);    Kernel.getApiHooksService().post(context, CallName.IdGen_setupDefaultIdGens);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.setupDefaultIdGens.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.idgenApi.setupDefaultIdGens.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy