CreateNotificationOperation.java 2.24 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.granite.ui.components.HtmlResponse
 *  com.day.cq.i18n.I18n
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.SlingHttpServletRequest
 */
package com.adobe.cq.mobile.notifications.impl.operations;

import com.adobe.cq.mobile.notifications.impl.Notification;
import com.adobe.cq.mobile.notifications.impl.exceptions.NotificationException;
import com.adobe.cq.mobile.notifications.impl.operations.AbstractNotificationOperation;
import com.adobe.cq.mobile.notifications.impl.services.NotificationService;
import com.adobe.cq.mobile.platform.MobileResource;
import com.adobe.cq.mobile.platform.MobileResourceType;
import com.adobe.granite.ui.components.HtmlResponse;
import com.day.cq.i18n.I18n;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;

@Component(metatype=0, label="Mobile Notification Creation Post Operation")
@Service
@Properties(value={@Property(name="sling.post.operation", value={"mobileapps:createNotification"})})
public class CreateNotificationOperation
extends AbstractNotificationOperation {
    public static final String OPERATION_NAME = "createNotification";

    @Override
    protected void performOperation(SlingHttpServletRequest request, HtmlResponse response, MobileResource mobileResource, NotificationService notificationService) throws NotificationException {
        if (!this.verifyMobileResourceType(response, mobileResource, MobileResourceType.INSTANCE.getType())) {
            return;
        }
        Notification notification = notificationService.create(mobileResource, request.getParameterMap());
        notification = notificationService.save(notification, mobileResource);
        this.generateResponse(response, 200, this.i18n.get("Notification created successfully"), this.i18n.get("Service Response"), notification.getPath(), this.i18n.get("Notification"));
    }
}