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

rapture.kernel.NotificationApiImplWrapper 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.NotificationApi;
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.RaptureNotificationConfig;
import rapture.common.NotificationResult;
import rapture.common.RaptureFolderInfo;
import rapture.common.NotificationInfo;

import rapture.common.shared.notification.GetNotificationManagerConfigsPayload;

import rapture.common.shared.notification.ListNotificationsByUriPrefixPayload;

import rapture.common.shared.notification.FindNotificationManagerConfigsByPurposePayload;

import rapture.common.shared.notification.CreateNotificationManagerPayload;

import rapture.common.shared.notification.NotificationManagerExistsPayload;

import rapture.common.shared.notification.GetNotificationManagerConfigPayload;

import rapture.common.shared.notification.DeleteNotificationManagerPayload;

import rapture.common.shared.notification.GetLatestNotificationEpochPayload;

import rapture.common.shared.notification.PublishNotificationPayload;

import rapture.common.shared.notification.FindNotificationsAfterEpochPayload;

import rapture.common.shared.notification.GetNotificationPayload;


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

    public NotificationApiImplWrapper(Kernel kernel) {
        apiImpl = new NotificationApiImpl(kernel);
    }

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

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

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

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

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

    /**
    * 
    */
    @Override
    public RaptureNotificationConfig createNotificationManager(CallingContext context, String notificationManagerUri, String config, String purpose) {
        long functionStartTime = System.currentTimeMillis();
       
        CreateNotificationManagerPayload requestObj = new CreateNotificationManagerPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        requestObj.setConfig(config);
        requestObj.setPurpose(purpose);
        ContextValidator.validateContext(context, EntitlementSet.Notification_createNotificationManager, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_createNotificationManager);
        RaptureNotificationConfig returnValue = apiImpl.createNotificationManager(context, notificationManagerUri, config, purpose);    Kernel.getApiHooksService().post(context, CallName.Notification_createNotificationManager);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.createNotificationManager.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.createNotificationManager.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

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

    /**
    * 
    */
    @Override
    public RaptureNotificationConfig getNotificationManagerConfig(CallingContext context, String notificationManagerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetNotificationManagerConfigPayload requestObj = new GetNotificationManagerConfigPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        ContextValidator.validateContext(context, EntitlementSet.Notification_getNotificationManagerConfig, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_getNotificationManagerConfig);
        RaptureNotificationConfig returnValue = apiImpl.getNotificationManagerConfig(context, notificationManagerUri);    Kernel.getApiHooksService().post(context, CallName.Notification_getNotificationManagerConfig);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getNotificationManagerConfig.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getNotificationManagerConfig.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void deleteNotificationManager(CallingContext context, String notificationManagerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteNotificationManagerPayload requestObj = new DeleteNotificationManagerPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        ContextValidator.validateContext(context, EntitlementSet.Notification_deleteNotificationManager, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_deleteNotificationManager);
        apiImpl.deleteNotificationManager(context, notificationManagerUri);    Kernel.getApiHooksService().post(context, CallName.Notification_deleteNotificationManager);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.deleteNotificationManager.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.deleteNotificationManager.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public Long getLatestNotificationEpoch(CallingContext context, String notificationManagerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetLatestNotificationEpochPayload requestObj = new GetLatestNotificationEpochPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        ContextValidator.validateContext(context, EntitlementSet.Notification_getLatestNotificationEpoch, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_getLatestNotificationEpoch);
        Long returnValue = apiImpl.getLatestNotificationEpoch(context, notificationManagerUri);    Kernel.getApiHooksService().post(context, CallName.Notification_getLatestNotificationEpoch);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getLatestNotificationEpoch.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getLatestNotificationEpoch.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public String publishNotification(CallingContext context, String notificationManagerUri, String referenceId, String content, String contentType) {
        long functionStartTime = System.currentTimeMillis();
       
        PublishNotificationPayload requestObj = new PublishNotificationPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        requestObj.setReferenceId(referenceId);
        requestObj.setContent(content);
        requestObj.setContentType(contentType);
        ContextValidator.validateContext(context, EntitlementSet.Notification_publishNotification, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_publishNotification);
        String returnValue = apiImpl.publishNotification(context, notificationManagerUri, referenceId, content, contentType);    Kernel.getApiHooksService().post(context, CallName.Notification_publishNotification);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.publishNotification.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.publishNotification.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public NotificationResult findNotificationsAfterEpoch(CallingContext context, String notificationManagerUri, Long epoch) {
        long functionStartTime = System.currentTimeMillis();
       
        FindNotificationsAfterEpochPayload requestObj = new FindNotificationsAfterEpochPayload();
        requestObj.setContext(context);
        requestObj.setNotificationManagerUri(notificationManagerUri);
        requestObj.setEpoch(epoch);
        ContextValidator.validateContext(context, EntitlementSet.Notification_findNotificationsAfterEpoch, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_findNotificationsAfterEpoch);
        NotificationResult returnValue = apiImpl.findNotificationsAfterEpoch(context, notificationManagerUri, epoch);    Kernel.getApiHooksService().post(context, CallName.Notification_findNotificationsAfterEpoch);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.findNotificationsAfterEpoch.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.findNotificationsAfterEpoch.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public NotificationInfo getNotification(CallingContext context, String notificationUri, String id) {
        long functionStartTime = System.currentTimeMillis();
       
        GetNotificationPayload requestObj = new GetNotificationPayload();
        requestObj.setContext(context);
        requestObj.setNotificationUri(notificationUri);
        requestObj.setId(id);
        ContextValidator.validateContext(context, EntitlementSet.Notification_getNotification, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Notification_getNotification);
        NotificationInfo returnValue = apiImpl.getNotification(context, notificationUri, id);    Kernel.getApiHooksService().post(context, CallName.Notification_getNotification);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getNotification.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.notificationApi.getNotification.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy