protected void preparePage(String page, RequestParameter params, Session session) {
   if (page.equals(PAGE_HOME)) {
     session.setAttribute("workspaces", as.getWorkgroups(getUserID(session)));
   } else if (page.equals(PAGE_TOPIC_LIST)) {
     String mode = getMode(session);
     if (mode == MODE_BY_NAME) {
       session.setAttribute("topics", cm.getTopicsByName(getSearchText(session)));
     } else if (mode == MODE_BY_TYPE) {
       session.setAttribute("topics", cm.getTopics(getTypeID(session)));
     } else {
       throw new DeepaMehtaException("unexpected mode: \"" + mode + "\"");
     }
   }
 }
 protected String performAction(String action, RequestParameter params, Session session)
     throws ServletException {
   if (action == null) {
     return PAGE_LOGIN;
   } else if (action.equals(ACTION_TRY_LOGIN)) {
     return actionTryLogin(params, session);
   } else if (action.equals(ACTION_GO_HOME)) {
     return PAGE_HOME;
   } else if (action.equals(ACTION_SEARCH)) {
     String search = params.getValue("search");
     setMode(MODE_BY_NAME, session);
     setSearchText(search, session);
     return PAGE_TOPIC_LIST;
   } else if (action.equals(ACTION_SHOW_TOPIC_FORM)) {
     String typeID = params.getValue("typeID");
     setTypeID(typeID, session);
     // if parameter "topicID" is set the specified topic is to be edited
     String topicID = params.getValue("topicID");
     if (topicID != null) {
       session.setAttribute("topic", cm.getTopic(topicID, 1));
     }
     return PAGE_TOPIC_FORM;
   } else if (action.equals(ACTION_SHOW_TOPIC_INFO)) {
     String topicID = params.getValue("topicID");
     session.setAttribute("topic", cm.getTopic(topicID, 1));
     session.setAttribute("relTopics", cm.getRelatedTopics(topicID));
     return PAGE_TOPIC_INFO;
   } else if (action.equals(ACTION_SHOW_TOPICS)) {
     String typeID = params.getValue("typeID");
     setMode(MODE_BY_TYPE, session);
     setTypeID(typeID, session);
     return PAGE_TOPIC_LIST;
   } else if (action.equals(ACTION_CREATE_TOPIC)) {
     String typeID = params.getValue("typeID");
     createTopic(typeID, params, session);
     return PAGE_TOPIC_LIST;
   } else if (action.equals(ACTION_UPDATE_TOPIC)) {
     String typeID = params.getValue("typeID");
     updateTopic(typeID, params, session);
     return PAGE_TOPIC_LIST;
   } else if (action.equals(ACTION_DELETE_TOPIC)) {
     String topicID = params.getValue("topicID");
     deleteTopic(topicID);
     return PAGE_TOPIC_LIST;
   } else {
     return super.performAction(action, params, session);
   }
 }
 public CorporateDirectives evoke(Session session, String topicmapID, String viewmode) {
   CorporateDirectives directives = super.evoke(session, topicmapID, viewmode);
   setProperty(PROPERTY_STATUS, EMAIL_STATE_DRAFT);
   String author = as.getEmailAddress(session.getUserID()); // may return null
   if (author != null) {
     setProperty(PROPERTY_FROM, author);
   }
   as.createLiveAssociation(
       as.getNewAssociationID(),
       ASSOCTYPE_SENDER,
       getID(),
       session.getUserID(),
       session,
       directives);
   return directives;
 }
 public CorporateDirectives executeCommand(
     String command, Session session, String topicmapID, String viewmode) {
   CorporateDirectives directives = new CorporateDirectives();
   if (command.equals(CMD_SEND)) {
     sendMail(directives);
   } else if (command.equals(CMD_ATTACH_DOCUMENT)) {
     createChildTopic(TOPICTYPE_DOCUMENT, SEMANTIC_EMAIL_ATTACHMENT, session, directives);
   } else if (command.equals(CMD_REPLY)) {
     createDraftForReply(session.getUserID(), 1, directives);
   } else if (command.equals(CMD_FORWARD)) {
     createDraftForForward(session.getUserID(), 1, directives);
   } else {
     return super.executeCommand(command, session, topicmapID, viewmode);
   }
   return directives;
 }
 public CorporateDirectives evoke(Session session, String topicmapID, String viewmode) {
   // set date
   String date = DeepaMehtaUtils.getDate();
   String time = DeepaMehtaUtils.getTime();
   setTopicData(PROPERTY_DATE, date);
   setTopicData(PROPERTY_LAST_REPLY_DATE, date);
   setTopicData(PROPERTY_LAST_REPLY_TIME, time);
   // set author
   String user = session.getUserName();
   if (user != null) { // ### Note: user is null when evoked through web interface
     setTopicData(PROPERTY_FROM, user);
   }
   //
   return super.evoke(session, topicmapID, viewmode);
 }
 private String getTypeID(Session session) {
   return (String) session.getAttribute("typeID");
 }
 private String getSearchText(Session session) {
   return (String) session.getAttribute("search");
 }
 private String getMode(Session session) {
   return (String) session.getAttribute("mode");
 }
 private void setTypeID(String typeID, Session session) {
   session.setAttribute("typeID", typeID);
   System.out.println("> \"typeID\" stored in session: \"" + typeID + "\"");
 }
 private void setSearchText(String search, Session session) {
   session.setAttribute("search", search);
   System.out.println("> \"search\" stored in session: \"" + search + "\"");
 }
 private void setMode(String mode, Session session) {
   session.setAttribute("mode", mode);
   System.out.println("> \"mode\" stored in session: \"" + mode + "\"");
 }
 private void setUser(BaseTopic user, Session session) {
   session.setAttribute("user", user);
   System.out.println("> \"user\" stored in session: " + user);
 }