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

rapture.kernel.BlobApiImplWrapper 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.BlobApi;
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.model.BlobRepoConfig;

import rapture.common.shared.blob.CreateBlobRepoPayload;

import rapture.common.shared.blob.GetBlobRepoConfigPayload;

import rapture.common.shared.blob.GetBlobRepoConfigsPayload;

import rapture.common.shared.blob.DeleteBlobRepoPayload;

import rapture.common.shared.blob.BlobRepoExistsPayload;

import rapture.common.shared.blob.BlobExistsPayload;

import rapture.common.shared.blob.AddBlobContentPayload;

import rapture.common.shared.blob.PutBlobPayload;

import rapture.common.shared.blob.GetBlobPayload;

import rapture.common.shared.blob.DeleteBlobPayload;

import rapture.common.shared.blob.GetBlobSizePayload;

import rapture.common.shared.blob.GetBlobMetaDataPayload;

import rapture.common.shared.blob.ListBlobsByUriPrefixPayload;

import rapture.common.shared.blob.DeleteBlobsByUriPrefixPayload;


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

    public BlobApiImplWrapper(Kernel kernel) {
        apiImpl = new BlobApiImpl(kernel);
    }

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

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

    /**
    * 
    */
    @Override
    public void createBlobRepo(CallingContext context, String blobRepoUri, String config, String metaConfig) {
        long functionStartTime = System.currentTimeMillis();
       
        CreateBlobRepoPayload requestObj = new CreateBlobRepoPayload();
        requestObj.setContext(context);
        requestObj.setBlobRepoUri(blobRepoUri);
        requestObj.setConfig(config);
        requestObj.setMetaConfig(metaConfig);
        ContextValidator.validateContext(context, EntitlementSet.Blob_createBlobRepo, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_createBlobRepo);
        apiImpl.createBlobRepo(context, blobRepoUri, config, metaConfig);    Kernel.getApiHooksService().post(context, CallName.Blob_createBlobRepo);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.createBlobRepo.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.createBlobRepo.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public BlobRepoConfig getBlobRepoConfig(CallingContext context, String blobRepoUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetBlobRepoConfigPayload requestObj = new GetBlobRepoConfigPayload();
        requestObj.setContext(context);
        requestObj.setBlobRepoUri(blobRepoUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_getBlobRepoConfig, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_getBlobRepoConfig);
        BlobRepoConfig returnValue = apiImpl.getBlobRepoConfig(context, blobRepoUri);    Kernel.getApiHooksService().post(context, CallName.Blob_getBlobRepoConfig);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobRepoConfig.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobRepoConfig.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

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

    /**
    * 
    */
    @Override
    public void deleteBlobRepo(CallingContext context, String repoUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteBlobRepoPayload requestObj = new DeleteBlobRepoPayload();
        requestObj.setContext(context);
        requestObj.setRepoUri(repoUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_deleteBlobRepo, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_deleteBlobRepo);
        apiImpl.deleteBlobRepo(context, repoUri);    Kernel.getApiHooksService().post(context, CallName.Blob_deleteBlobRepo);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.deleteBlobRepo.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.deleteBlobRepo.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

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

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

    /**
    * 
    */
    @Override
    public void addBlobContent(CallingContext context, String blobUri, byte[] content) {
        long functionStartTime = System.currentTimeMillis();
       
        AddBlobContentPayload requestObj = new AddBlobContentPayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        requestObj.setContent(content);
        ContextValidator.validateContext(context, EntitlementSet.Blob_addBlobContent, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_addBlobContent);
        apiImpl.addBlobContent(context, blobUri, content);    Kernel.getApiHooksService().post(context, CallName.Blob_addBlobContent);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.addBlobContent.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.addBlobContent.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public void putBlob(CallingContext context, String blobUri, byte[] content, String contentType) {
        long functionStartTime = System.currentTimeMillis();
       
        PutBlobPayload requestObj = new PutBlobPayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        requestObj.setContent(content);
        requestObj.setContentType(contentType);
        ContextValidator.validateContext(context, EntitlementSet.Blob_putBlob, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_putBlob);
        apiImpl.putBlob(context, blobUri, content, contentType);    Kernel.getApiHooksService().post(context, CallName.Blob_putBlob);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.putBlob.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.putBlob.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public BlobContainer getBlob(CallingContext context, String blobUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetBlobPayload requestObj = new GetBlobPayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_getBlob, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_getBlob);
        BlobContainer returnValue = apiImpl.getBlob(context, blobUri);    Kernel.getApiHooksService().post(context, CallName.Blob_getBlob);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlob.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlob.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void deleteBlob(CallingContext context, String blobUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteBlobPayload requestObj = new DeleteBlobPayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_deleteBlob, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_deleteBlob);
        apiImpl.deleteBlob(context, blobUri);    Kernel.getApiHooksService().post(context, CallName.Blob_deleteBlob);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.deleteBlob.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.deleteBlob.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public Long getBlobSize(CallingContext context, String blobUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetBlobSizePayload requestObj = new GetBlobSizePayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_getBlobSize, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_getBlobSize);
        Long returnValue = apiImpl.getBlobSize(context, blobUri);    Kernel.getApiHooksService().post(context, CallName.Blob_getBlobSize);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobSize.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobSize.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Map getBlobMetaData(CallingContext context, String blobUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetBlobMetaDataPayload requestObj = new GetBlobMetaDataPayload();
        requestObj.setContext(context);
        requestObj.setBlobUri(blobUri);
        ContextValidator.validateContext(context, EntitlementSet.Blob_getBlobMetaData, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Blob_getBlobMetaData);
        Map returnValue = apiImpl.getBlobMetaData(context, blobUri);    Kernel.getApiHooksService().post(context, CallName.Blob_getBlobMetaData);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobMetaData.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.blobApi.getBlobMetaData.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

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

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

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy