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

rapture.kernel.JarApiImplWrapper 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.JarApi;
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.BlobContainer;
import rapture.common.RaptureFolderInfo;

import rapture.common.shared.jar.JarExistsPayload;

import rapture.common.shared.jar.PutJarPayload;

import rapture.common.shared.jar.GetJarPayload;

import rapture.common.shared.jar.DeleteJarPayload;

import rapture.common.shared.jar.GetJarSizePayload;

import rapture.common.shared.jar.GetJarMetaDataPayload;

import rapture.common.shared.jar.ListJarsByUriPrefixPayload;

import rapture.common.shared.jar.JarIsEnabledPayload;

import rapture.common.shared.jar.EnableJarPayload;

import rapture.common.shared.jar.DisableJarPayload;


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

    public JarApiImplWrapper(Kernel kernel) {
        apiImpl = new JarApiImpl(kernel);
    }

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

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

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

    /**
    * 
    */
    @Override
    public void putJar(CallingContext context, String jarUri, byte[] jarContent) {
        long functionStartTime = System.currentTimeMillis();
       
        PutJarPayload requestObj = new PutJarPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        requestObj.setJarContent(jarContent);
        ContextValidator.validateContext(context, EntitlementSet.Jar_putJar, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_putJar);
        apiImpl.putJar(context, jarUri, jarContent);    Kernel.getApiHooksService().post(context, CallName.Jar_putJar);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.putJar.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.putJar.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public BlobContainer getJar(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetJarPayload requestObj = new GetJarPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_getJar, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_getJar);
        BlobContainer returnValue = apiImpl.getJar(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_getJar);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJar.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJar.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void deleteJar(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteJarPayload requestObj = new DeleteJarPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_deleteJar, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_deleteJar);
        apiImpl.deleteJar(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_deleteJar);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.deleteJar.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.deleteJar.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public Long getJarSize(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetJarSizePayload requestObj = new GetJarSizePayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_getJarSize, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_getJarSize);
        Long returnValue = apiImpl.getJarSize(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_getJarSize);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJarSize.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJarSize.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Map getJarMetaData(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetJarMetaDataPayload requestObj = new GetJarMetaDataPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_getJarMetaData, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_getJarMetaData);
        Map returnValue = apiImpl.getJarMetaData(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_getJarMetaData);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJarMetaData.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.getJarMetaData.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Map listJarsByUriPrefix(CallingContext context, String uriPrefix, int depth) {
        long functionStartTime = System.currentTimeMillis();
       
        ListJarsByUriPrefixPayload requestObj = new ListJarsByUriPrefixPayload();
        requestObj.setContext(context);
        requestObj.setUriPrefix(uriPrefix);
        requestObj.setDepth(depth);
        ContextValidator.validateContext(context, EntitlementSet.Jar_listJarsByUriPrefix, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_listJarsByUriPrefix);
        Map returnValue = apiImpl.listJarsByUriPrefix(context, uriPrefix, depth);    Kernel.getApiHooksService().post(context, CallName.Jar_listJarsByUriPrefix);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.listJarsByUriPrefix.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.listJarsByUriPrefix.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

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

    /**
    * 
    */
    @Override
    public void enableJar(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        EnableJarPayload requestObj = new EnableJarPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_enableJar, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_enableJar);
        apiImpl.enableJar(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_enableJar);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.enableJar.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.enableJar.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public void disableJar(CallingContext context, String jarUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DisableJarPayload requestObj = new DisableJarPayload();
        requestObj.setContext(context);
        requestObj.setJarUri(jarUri);
        ContextValidator.validateContext(context, EntitlementSet.Jar_disableJar, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Jar_disableJar);
        apiImpl.disableJar(context, jarUri);    Kernel.getApiHooksService().post(context, CallName.Jar_disableJar);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.disableJar.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.jarApi.disableJar.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy