CreateNotificationOperation.java
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* 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"));
}
}