- Timestamp:
- 2005-01-12T11:39:22+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingService.java
r8874 r8888 10 10 11 11 import java.lang.reflect.Method; 12 import java.net.MalformedURLException;13 12 import java.net.URL; 14 13 import java.sql.SQLException; … … 24 23 import org.greenstone.gsdlas.database.DatabaseException; 25 24 import org.greenstone.gsdlas.profiles.Predicate; 25 import org.greenstone.gsdlas.profiles.Subscription; 26 26 import org.greenstone.gsdlas.users.UserManagementException; 27 27 import org.greenstone.gsdlas.users.UserManager; … … 58 58 "deleteSubscription", 59 59 "editSubscription", 60 "showEvents", 60 61 "showFeed", 61 62 "listSubscriptions", … … 175 176 } 176 177 177 public String showFeed(Map arguments, Context context) { 178 context.put("list", ""/* TODO pass subscription list */); 178 public String showFeed(Map arguments, Context context) throws NumberFormatException, DatabaseException, SQLException { 179 HttpSession session = ((HttpServletRequest)context.get(REQUEST)).getSession(true); 180 if (!UserManager.getInstance().isLoggedIn(session)) { 181 session.setAttribute("next_action", "showFeed"); 182 return showLoginForm(arguments, context); 183 } 184 String subscriptionID = (String) arguments.get("subscriptionID"); 185 Integer subID = new Integer(subscriptionID); 186 Set events = EventStore.getInstance().getEvents(subID); 187 context.put("list", events); 188 context.put("subscription", ProfileStore.getInstance().getSubscription(subID.intValue())); 189 HttpServletResponse res = (HttpServletResponse) context.get(RESPONSE); 190 res.setContentType("text/xml"); 179 191 return "feed.vm"; 192 } 193 194 public String showEvents(Map arguments, Context context) throws NumberFormatException, DatabaseException, SQLException { 195 HttpSession session = ((HttpServletRequest)context.get(REQUEST)).getSession(true); 196 if (!UserManager.getInstance().isLoggedIn(session)) { 197 session.setAttribute("next_action", "showEvents"); 198 return showLoginForm(arguments, context); 199 } 200 String subscriptionID = (String) arguments.get("subscriptionID"); 201 Integer subID = new Integer(subscriptionID); 202 Set events = EventStore.getInstance().getEvents(subID); 203 context.put("list", events); 204 context.put("subscription", ProfileStore.getInstance().getSubscription(subID.intValue())); 205 return "events.vm"; 180 206 } 181 207 … … 250 276 for (Iterator iter = rawEvent.keySet().iterator(); iter.hasNext();) { 251 277 String key = (String) iter.next(); 278 if (key.equals("action")) continue; // we don't want this 252 279 String[] value = (String[]) rawEvent.get(key); 253 280 event.put(key, value[0]); … … 259 286 String hostID = (String) event.get(Constants.HOST_ID_FIELD); 260 287 gsComm = new GreenstoneCommunicator(new URL(hostID)); 261 } catch ( MalformedURLException e) {262 // TODO Auto-generated catch block288 } catch (Exception e) { 289 System.err.println("Can't communicate to Greenstone: " + e.getMessage()); 263 290 e.printStackTrace(); 291 } 292 293 Set matchedSubscriptions = ProfileStore.getInstance().filter(event, gsComm); 294 295 try { 296 EventStore.getInstance().add(event, matchedSubscriptions); 297 Notifier.getInstance().sendNotifications(event, matchedSubscriptions); 264 298 } catch (Exception e) { 265 // TODO Auto-generated catch block299 System.err.println("Couldn't save events: " + e.getMessage()); 266 300 e.printStackTrace(); 267 301 } 268 Set matchedSubscriptions = ProfileStore.getInstance().filter(event, gsComm);269 302 System.out.println(matchedSubscriptions.size() + " matching subscriptions: " + matchedSubscriptions); 270 // TODO do something with the matched subscriptions271 303 } 272 304 … … 322 354 */ 323 355 private String showSubscriptionWizardPage(Map arguments, Context context, boolean create) throws Exception { 356 HttpSession session = ((HttpServletRequest)context.get(REQUEST)).getSession(true); 324 357 if (create) { 325 358 context.put(Constants.ACTION_PARAM, "createSubscription"); 326 359 } else { 360 // prefill from existing subscription 327 361 context.put(Constants.ACTION_PARAM, "editSubscription"); 362 String subscriptionID = (String) arguments.get("subscriptionID"); 363 int subID = Integer.parseInt(subscriptionID); 364 prefillFromSubscription(session, subID); 328 365 } 329 366 if (!arguments.containsKey("current_page")) { … … 331 368 } 332 369 333 HttpSession session = ((HttpServletRequest)context.get(REQUEST)).getSession(true);334 370 String currentPage = (String) arguments.get("current_page"); 335 371 String direction = (String) arguments.get("next_page"); … … 412 448 413 449 /** 450 * @param session 451 * @param subID 452 */ 453 private void prefillFromSubscription(HttpSession session, int subID) { 454 Subscription sub = ProfileStore.getInstance().getSubscription(subID); 455 Map typeArgs = new HashMap(); 456 // TODO really fill stuff 457 savePageArgsToSession("type-details", typeArgs, session); 458 Map hostArgs = new HashMap(); 459 savePageArgsToSession("host", hostArgs, session); 460 Map collArgs = new HashMap(); 461 savePageArgsToSession("collection", collArgs, session); 462 Map notificationArgs = new HashMap(); 463 savePageArgsToSession("notification", notificationArgs, session); 464 } 465 466 /** 414 467 * @param nextPage 415 468 * @param session
Note:
See TracChangeset
for help on using the changeset viewer.