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