View Javadoc

1   /*
2      Licensed under the Apache License, Version 2.0 (the "License");
3      you may not use this file except in compliance with the License.
4      You may obtain a copy of the License at
5   
6        http://www.apache.org/licenses/LICENSE-2.0
7   
8      Unless required by applicable law or agreed to in writing, software
9      distributed under the License is distributed on an "AS IS" BASIS,
10     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11     See the License for the specific language governing permissions and
12     limitations under the License.
13  */
14  package uk.nhs.interoperability.client.samples.notification;
15  
16  import java.util.Date;
17  import java.util.HashMap;
18  
19  import uk.nhs.interoperability.util.Logger;
20  
21  /**
22   * The Class NotificationStore.
23   *
24   * @author Adam Hatherly
25   * @since 0.1
26   */
27  public class NotificationStore {
28  
29  	/** The messages. */
30  	private static HashMap<String, String> messages = new HashMap<String, String>();
31  	
32  	/** The message dates. */
33  	private static HashMap<String, Date> messageDates = new HashMap <String, Date>(); 
34  	
35  	/**
36  	 * Put notification.
37  	 *
38  	 * @param id the id
39  	 * @param document the document
40  	 */
41  	public static void putNotification(String id, String document){
42  		Logger.trace("Adding notification to store, with ID = " + id);
43  		messages.put(id,document);
44  		messageDates.put(id, new Date());
45  	}
46  
47  	/**
48  	 * Gets the notification.
49  	 *
50  	 * @param id the id
51  	 * @return the notification
52  	 */
53  	public static String getNotification(String id){
54  		return messages.get(id);
55  	}
56  
57  	/**
58  	 * Gets the message list.
59  	 *
60  	 * @return the message list
61  	 */
62  	public static HashMap<String, Date> getMessageList() {
63  		return messageDates;
64  	}
65  }