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

rapture.kernel.EnvironmentApiImplWrapper Maven / Gradle / Ivy

/**
 * 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.EnvironmentApi;
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.model.RaptureServerStatus;
import rapture.common.model.RaptureServerInfo;

import rapture.common.shared.environment.GetThisServerPayload;

import rapture.common.shared.environment.GetServersPayload;

import rapture.common.shared.environment.SetThisServerPayload;

import rapture.common.shared.environment.SetApplianceModePayload;

import rapture.common.shared.environment.GetApplianceModePayload;

import rapture.common.shared.environment.GetServerStatusPayload;


/**
 * This class is a wrapper around the class {@link EnvironmentApiImpl}. 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 EnvironmentApiImplWrapper implements EnvironmentApi, KernelApi {
    private static final Logger log = Logger.getLogger(EnvironmentApiImplWrapper.class);
    private EnvironmentApiImpl apiImpl;

    public EnvironmentApiImplWrapper(Kernel kernel) {
        apiImpl = new EnvironmentApiImpl(kernel);
    }

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

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

    /**
    * 
    */
    @Override
    public RaptureServerInfo getThisServer(CallingContext context) {
        long functionStartTime = System.currentTimeMillis();
       
        GetThisServerPayload requestObj = new GetThisServerPayload();
        requestObj.setContext(context);
        ContextValidator.validateContext(context, EntitlementSet.Environment_getThisServer, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Environment_getThisServer);
        RaptureServerInfo returnValue = apiImpl.getThisServer(context);    Kernel.getApiHooksService().post(context, CallName.Environment_getThisServer);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.getThisServer.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.getThisServer.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

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

    /**
    * 
    */
    @Override
    public RaptureServerInfo setThisServer(CallingContext context, RaptureServerInfo info) {
        long functionStartTime = System.currentTimeMillis();
       
        SetThisServerPayload requestObj = new SetThisServerPayload();
        requestObj.setContext(context);
        requestObj.setInfo(info);
        ContextValidator.validateContext(context, EntitlementSet.Environment_setThisServer, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Environment_setThisServer);
        RaptureServerInfo returnValue = apiImpl.setThisServer(context, info);    Kernel.getApiHooksService().post(context, CallName.Environment_setThisServer);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.setThisServer.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.setThisServer.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void setApplianceMode(CallingContext context, Boolean mode) {
        long functionStartTime = System.currentTimeMillis();
       
        SetApplianceModePayload requestObj = new SetApplianceModePayload();
        requestObj.setContext(context);
        requestObj.setMode(mode);
        ContextValidator.validateContext(context, EntitlementSet.Environment_setApplianceMode, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Environment_setApplianceMode);
        apiImpl.setApplianceMode(context, mode);    Kernel.getApiHooksService().post(context, CallName.Environment_setApplianceMode);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.setApplianceMode.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.environmentApi.setApplianceMode.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

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

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

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy