001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.ken.util;
017    
018    import org.kuali.rice.ken.bo.NotificationProducerBo;
019    import org.kuali.rice.kew.api.KewApiConstants;
020    
021    /**
022     * This class houses all constants for the NotificationSystem.
023     * @author Kuali Rice Team (rice.collab@kuali.org)
024     */
025    public final class NotificationConstants {
026    
027        /**
028         * This inner class holds contants that are used for parsing and resolving of content 
029         * inside of the XML message format that represents a notification request.
030         * @author Kuali Rice Team (rice.collab@kuali.org)
031         */
032        public static final class XML_MESSAGE_CONSTANTS {
033            public static final String MESSAGE_OPEN = "<message><![CDATA[";
034            public static final String MESSAGE_CLOSE = "]]></message>";
035            public static final String CONTENT_SIMPLE_OPEN = "<content xmlns=\"ns:notification/ContentTypeSimple\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"ns:notification/ContentTypeSimple resource:notification/ContentTypeSimple\">";
036            public static final String CONTENT_EVENT_OPEN = "<content xmlns=\"ns:notification/ContentTypeEvent\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"ns:notification/ContentTypeEvent resource:notification/ContentTypeEvent\">";
037            public static final String CONTENT_CLOSE = "</content>";
038    
039            private XML_MESSAGE_CONSTANTS() {
040                throw new UnsupportedOperationException("do not call");
041            }
042        }
043    
044        /**
045         * Different content types for the Notification System.  These are static out of the box content types that have specific UIs built for them.
046     * @author Kuali Rice Team (rice.collab@kuali.org)
047         */
048        public static final class CONTENT_TYPES {
049            public static final String EVENT_CONTENT_TYPE = "Event";
050            public static final String SIMPLE_CONTENT_TYPE = "Simple";
051    
052            private CONTENT_TYPES() {
053                throw new UnsupportedOperationException("do not call");
054            }
055        }
056    
057        /**
058         * Different delivery types for the Notification System.
059         * FYI - user gets notification in list, but can remove without actually viewing details and taking action
060         * ACK - user gets notification in list, but has to view details and conciously press the acknowledge button
061     * @author Kuali Rice Team (rice.collab@kuali.org)
062         */
063        public static final class DELIVERY_TYPES {
064            public static final String FYI = "FYI";
065            public static final String ACK = "ACK";
066    
067            private DELIVERY_TYPES() {
068                throw new UnsupportedOperationException("do not call");
069            }
070        }
071    
072        /**
073         * String that indicates the cause of a dismissal of a messageDelivery was
074         * due to autoremoval
075         */
076        public static final String AUTO_REMOVE_CAUSE = "autoremove";
077        public static final String ACK_CAUSE = "ack";
078        public static final String FYI_CAUSE = "fyi";
079    
080        /**
081         * This class holds constants for different detail views of a notification.
082         * INLINE - display the details inline (i.e. without any menus around them)
083         * NORMAL_VIEW - display the details in a normal view with all of the appropriate menus
084     * @author Kuali Rice Team (rice.collab@kuali.org)
085         */
086        public static final class NOTIFICATION_DETAIL_VIEWS {
087            public static final String NORMAL_VIEW = "displayActionListView";
088            public static final String INLINE = "displayActionListInlineView";
089            public static final String DOC_SEARCH_VIEW = "displayDocSearchView";
090    
091            private NOTIFICATION_DETAIL_VIEWS() {
092                throw new UnsupportedOperationException("do not call");
093            }
094        }
095    
096        /**
097         * Constants for request processing (web layer).
098     * @author Kuali Rice Team (rice.collab@kuali.org)
099         */
100        public static final class NOTIFICATION_CONTROLLER_CONSTANTS {
101            public static final String MSG_DELIVERY_ID = "messageDeliveryId";
102            public static final String DELIVERER_ID = "delivererId";
103            public static final String DOC_ID = "docId";
104            public static final String COMMAND = "command";
105            public static final String STANDALONE_WINDOW = "standaloneWindow";
106    
107            private NOTIFICATION_CONTROLLER_CONSTANTS() {
108                throw new UnsupportedOperationException("do not call");
109            }
110        }
111    
112        /**
113         * Different delivery status flags for the notification system.
114         * UNDELIVERED - the notification has not been delivered by the delivery machine
115         * DELIVERED - the notification has been delivered by the delivery machine
116         * REMOVED - the notification has been removed by the delivery machine
117         * AUTO_REMOVED - the notification was auto removed by the delivery machine
118     * @author Kuali Rice Team (rice.collab@kuali.org)
119         */
120        public static final class MESSAGE_DELIVERY_STATUS {
121            public static final String UNDELIVERED = "UNDELIVERED";
122            public static final String DELIVERED = "DELIVERED";
123            public static final String REMOVED = "REMOVED";
124            public static final String AUTO_REMOVED = "AUTO_REMOVED";
125    
126            private MESSAGE_DELIVERY_STATUS() {
127                throw new UnsupportedOperationException("do not call");
128            }
129        }
130    
131        /**
132         * Different message delivery types for the notification system.
133         * KEW_ACTION_LIST_MESSAGE_DELIVERY_TYPE - the KEW action list
134         * DEFAULT_MESSAGE_DELIVERY_TYPE - the default message delivery type
135     * @author Kuali Rice Team (rice.collab@kuali.org)
136         */
137        public static final class MESSAGE_DELIVERY_TYPES {
138            public static final String KEW_ACTION_LIST_MESSAGE_DELIVERY_TYPE = "KEWActionList"; 
139            public static final String DEFAULT_MESSAGE_DELIVERY_TYPE = KEW_ACTION_LIST_MESSAGE_DELIVERY_TYPE;
140    
141            private MESSAGE_DELIVERY_TYPES() {
142                throw new UnsupportedOperationException("do not call");
143            }
144        }
145    
146        /**
147         * Different recipient types for the notification system.
148         * USER - the notification specifically has a user as one of its recipients
149         * GROUP - the notification specifically has a group as one of its recipients
150     * @author Kuali Rice Team (rice.collab@kuali.org)
151         */
152        public static final class RECIPIENT_TYPES {
153            public static final String USER = "USER";
154            public static final String GROUP = "GROUP";
155    
156            private RECIPIENT_TYPES() {
157                throw new UnsupportedOperationException("do not call");
158            }
159        }
160    
161        /**
162         * Different processing flags for the notification system.
163         * RESOLVED - the notification has been resolved by the system and specific message deliveries have been created
164         * UNRESOLVED - the notification has not been resolved by the system
165     * @author Kuali Rice Team (rice.collab@kuali.org)
166         */
167        public static final class PROCESSING_FLAGS {
168            public static final String RESOLVED = "RESOLVED";
169            public static final String UNRESOLVED = "UNRESOLVED";
170    
171            private PROCESSING_FLAGS() {
172                throw new UnsupportedOperationException("do not call");
173            }
174        }
175    
176        /**
177         * Flags for record locking
178     * @author Kuali Rice Team (rice.collab@kuali.org)
179         */
180        public static final class LOCKED_FLAG {
181            public static final String UNLOCKED = "U";
182            public static final String LOCKED = "L";
183    
184            private LOCKED_FLAG() {
185                throw new UnsupportedOperationException("do not call");
186            }
187        }
188    
189        /**
190         * Different response statuses for sending notifications.
191         * SUCCESS - the notification message was successfully received and will be processed and delivered by the system
192         * FAILURE - the notification message was received but there were problems and it will not be processed and delivered by the system.
193     * @author Kuali Rice Team (rice.collab@kuali.org)
194         */
195        public static final class RESPONSE_STATUSES {
196            public static final String SUCCESS = "Success";
197            public static final String FAILURE = "Failure";
198    
199            private RESPONSE_STATUSES() {
200                throw new UnsupportedOperationException("do not call");
201            }
202        }
203    
204        /**
205         * Different response messages for sending notifications.
206     * @author Kuali Rice Team (rice.collab@kuali.org)
207         */
208        public static final class RESPONSE_MESSAGES {
209            public static final String SUCCESSFULLY_RECEIVED = "The notification message has been successfully received by the system and will be processed and delivered.";
210            public static final String PRODUCER_NOT_AUTHORIZED_FOR_CHANNEL = "The notification message was received by the system; however, " +
211                "we cannot process it because the Producer specified cannot send notifications for the Notification Channel specified.";
212            public static final String INVALID_RECIPIENT = "The notification message was received by the system; however, we cannot process it because one of " +
213                "the recipients that was specified was invalid and is not registered in the system.";
214            public static final String ERROR_SAVING_NOTIFICATION = "The notification message was received by the system; however, we cannot process it because " +
215                "there was a problem when trying to save the notification to the database.";
216            public static final String INVALID_DELIVERY_TYPE = "The notification message was received by the system; however, we cannot process it because " +
217                "the specified delivery type was invalid.";
218            public static final String INVALID_REMOVE_DATE = "The notification message was received by the system; however, we cannot process it because " +
219        "the specified auto-remove date is before the send date.";
220    
221            private RESPONSE_MESSAGES() {
222                throw new UnsupportedOperationException("do not call");
223            }
224        }
225    
226        /**
227         * This class houses constants that represent the property names for the business objects.  This should 
228         * be used for building database queries.
229     * @author Kuali Rice Team (rice.collab@kuali.org)
230         */
231        public static final class BO_PROPERTY_NAMES {
232            public static final String ID = "id";
233            public static final String NAME = "name";
234            public static final String DESCRIPTION = "description";
235            public static final String NAMESPACE = "namespace";
236            public static final String CHANNEL_ID = "channel.id";
237            public static final String RECIPIENT_TYPE = "recipientType";
238            public static final String RECIPIENT_ID = "recipientId";
239            public static final String REVIEWER_ID = "reviewerId";
240            public static final String RECIPIENTS_RECIPIENT_ID = "recipients.recipientId";
241            public static final String PROPERTY = "property";
242            public static final String VALUE = "value";
243            public static final String USER_ID = "userId";
244            public static final String CONTENT = "content";
245            public static final String PRODUCER_ID = "producerId";
246            public static final String CONTENT_TYPE_ID = "contentType.id";
247            public static final String CONTENT_TYPE_NAME = "contentType.name";
248            public static final String PROCESSING_FLAG = "processingFlag";
249            public static final String SEND_DATE_TIME = "sendDateTimeValue";
250            public static final String NOTIFICATION_AUTO_REMOVE_DATE_TIME = "notification.autoRemoveDateTimeValue";
251            public static final String MESSAGE_DELIVERY_STATUS = "messageDeliveryStatus";
252            public static final String LOCKED_DATE = "lockedDateValue";
253            // NotificationMessageDelivery
254            public static final String NOTIFICATION = "notification";
255            public static final String USER_RECIPIENT_ID = "userRecipientId";
256            public static final String DELIVERY_SYSTEM_ID = "deliverySystemId";
257    
258            private BO_PROPERTY_NAMES() {
259                throw new UnsupportedOperationException("do not call");
260            }
261        }
262    
263        /**
264         * This inner class is used to hold constants needed for KEW integration.
265     * @author Kuali Rice Team (rice.collab@kuali.org)
266         */
267        public static final class KEW_CONSTANTS {
268            public static final String NOTIFICATION_DOC_TYPE = "KualiNotification";
269            public static final String NOTIFICATION_SYSTEM_USER = "notsys";
270            public static final String NOTIFICATION_SYSTEM_USER_NAME = "Notification System";
271            public static final String NOTIFICATION_SYSTEM_USER_PARAM = "ken.system.user";
272            public static final String FYI_AD_HOC_ROUTE = KewApiConstants.ACTION_REQUEST_FYI_REQ;
273            public static final String ACK_AD_HOC_ROUTE = KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ;
274            public static final String GENERIC_DELIVERY_ANNOTATION = "The notification message has been delivered by the Notification System.";
275            public static final String GENERIC_AUTO_REMOVE_ANNOTATION = "The notification message has been auto-removed by the Notification System.";
276            public static final String NOTIFICATION_ADMIN_GROUP_NAME = "NotificationAdmin";
277            public static final String SEND_NOTIFICATION_REQ_DOC_TYPE = "SendNotificationRequest";
278    
279            private KEW_CONSTANTS() {
280                throw new UnsupportedOperationException("do not call");
281            }
282        }
283    
284        /**
285         * This inner class is used to hold constants around needed for the default system producer which all channels must be exposed 
286         * to for the generic message sending form to work with.
287     * @author Kuali Rice Team (rice.collab@kuali.org)
288         */
289        public static final class NOTIFICATION_PRODUCERS {
290            public static final NotificationProducerBo NOTIFICATION_SYSTEM_PRODUCER = buildNotificationSystemProducer();
291    
292            public static final String NOTIFICATION_SYSTEM_PRODUCER_NAME = "Notification System";
293            public static final String NOTIFICATION_SYSTEM_PRODUCER_DESCRIPTION = "This producer represents messages sent from the general message sending form.";
294            public static final String NOTIFICATION_SYSTEM_PRODUCER_CONTACT_INFO = "admins-notsys@cornell.edu";
295    
296            /**
297             * This method is a helper to build the static NotificationProducer Notification System Producer instance, which is the 
298             * default producer that all channels automatically have added to them when they are created.
299             * @return NotificationProducer
300             */
301            private static final NotificationProducerBo buildNotificationSystemProducer() {
302                NotificationProducerBo producer = new NotificationProducerBo();
303                producer.setName(NOTIFICATION_SYSTEM_PRODUCER_NAME);
304                producer.setDescription(NOTIFICATION_SYSTEM_PRODUCER_DESCRIPTION);
305                producer.setContactInfo(NOTIFICATION_SYSTEM_PRODUCER_CONTACT_INFO);
306                return producer;
307            }
308    
309            private NOTIFICATION_PRODUCERS() {
310                throw new UnsupportedOperationException("do not call");
311            }
312        }
313    }