Package edu.uga.galileo.voci.bo

Examples of edu.uga.galileo.voci.bo.Command


   *      javax.servlet.http.HttpServletResponse)
   */
  @Override
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");

    // set at the session level b/c customizable user prefs
    // will probably change it to session eventually
    request.getSession().setAttribute("resultsPerPage",
        Configuration.getInt("adminSearchResultsPerPage"));

    // get the default list of fields to use in creating search result
    // blurbs
    handleBlurbFieldData(command, request);

    // the 'fto' param should hold the url to forward the request to after
    // the search has been processed
    String forwardRequestTo = request.getParameter("fto");
   
    // make sure that the query is a valid one
    /*
    if ((command.isViewCommand())
        && (!isValidQuery(request.getParameter("query")))) {
      request
          .setAttribute(
              "errorMessage",
              "Your query must be at least three characters, "
                  + "and at least two of those must not be wildcards.");
      request.getSession().setAttribute("searchResults", null);
      request.getSession().setAttribute("queryString",
          request.getParameter("query"));
      try {
        request.getRequestDispatcher(
            response.encodeURL(forwardRequestTo)).forward(request,
            response);
      } catch (ServletException e) {
        Logger.warn("Couldn't forward request for URI "
            + request.getRequestURI() + " to the error page", e);
      } catch (IOException e) {
        Logger.warn("Couldn't forward request for URI "
            + request.getRequestURI() + " to the error page", e);
      }

      return;
    }
    */

    // then, if all's well, perform the actual searching
    if (forwardRequestTo != null) {
      boolean advanced = request.getParameter("adv") == null ? false
          : true;
      SearchType searchType = request.getParameter("type") == null ? SearchType.AND
          : SearchType.valueOf(request.getParameter("type")
              .toUpperCase());
      boolean activeOnly = request.getParameter("active") == null ? true
          : Boolean.valueOf(request.getParameter("active"));
      boolean allowsZero = request.getParameter("zeroes") == null ? false
          : Boolean.valueOf(request.getParameter("zeroes"));
      String username = request.getParameter("username");
      if ((username != null) && (username.trim().length() == 0)) {
        username = null;
      }
      String updateDateStart = request.getParameter("start");
      if ((updateDateStart != null)
          && (updateDateStart.trim().length() == 0)) {
        updateDateStart = null;
      }
      String updateDateEnd = request.getParameter("end");
      if ((updateDateEnd != null) && (updateDateEnd.trim().length() == 0)) {
        updateDateEnd = null;
      }
      List<SearchResult> results = null;

      // adjust blurb fields displayed based on user's preferences
      HashMap<ContentType, ArrayList<String>> useBlurbFields = getUserBlurbFields(
          command, request);

      if (advanced) {
        results = handleAdvancedSearchRequest(request, command,
            searchType, activeOnly, allowsZero, useBlurbFields,
            username, updateDateStart, updateDateEnd);
      } else {
        results = handleBasicSearchRequest(request, command,
            searchType, activeOnly, allowsZero, useBlurbFields,
            username, updateDateStart, updateDateEnd);
      }

      try {
        // '/do/...' urls are for admin areas, so we need to check user
        // editing permission for each, and attach that data to the
        // search results
        if ((forwardRequestTo.indexOf("/do/") != -1)
            && (results != null)) {
          WorkflowManager wm = new WorkflowManager();
          ProjectManager pm = new ProjectManager();
          User user = (User) request.getSession()
              .getAttribute("user");
          // if user is null, stick with the default that none of
          // the results is editable
          if (user != null) {
            SearchResult result;
            boolean includeExtras = request
                .getParameter("includeExtras") == null ? false
                : true;
            for (int m = results.size() - 1; m >= 0; m--) {
              result = results.get(m);
              try {
                if (wm.canEdit(user, pm.getProjectHandle(result
                    .getProjectId()), ContentType.valueOf(
                    result.getVBO().getType()).getPlural(),
                    result.getVBO().getId())) {
                  result.setUserEditable(true);
                } else if (!includeExtras) {
                  results.remove(m);
                }
              } catch (NoSuchProjectException e) {
                Logger
                    .error("Couldn't get project handle for ID "
                        + result.getProjectId());
              }
            }
          }
        }

        request.getRequestDispatcher(
            response.encodeURL(forwardRequestTo)).forward(request,
            response);
      } catch (ServletException e) {
        Logger.warn("Couldn't forward request for URI "
            + request.getRequestURI() + " to the error page", e);
      } catch (IOException e) {
        Logger.warn("Couldn't forward request for URI "
            + request.getRequestURI() + " to the error page", e);
      }
    } else {
      try {
        request.setAttribute("errorMessage",
            "The requested search didn't include a response page.");
        request.getRequestDispatcher(
            response.encodeURL("/" + command.getProject()
                + "/Error.jsp")).forward(request, response);
      } catch (ServletException e) {
        Logger.warn("Couldn't forward request for URI "
            + request.getRequestURI() + " to the error page", e);
      } catch (IOException e) {
View Full Code Here


   *      javax.servlet.http.HttpServletResponse)
   */
  @Override
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    ArrayList<VociBusinessObject> problems = new ArrayList<VociBusinessObject>();
    ImportManager iman = new ImportManager();

    // always get the list of importers for display to users
    String importers;
    if ((importers = Configuration.getString("vociImporters")) != null) {
      String[] importerArray = importers.split(",");
      ArrayList<Importer> importerCollection = new ArrayList<Importer>();
      String arrayElement;
      for (int m = 0; m < importerArray.length; m++) {
        arrayElement = importerArray[m].trim();
        if (arrayElement.length() > 0) {
          Importer importer = iman.getImporter(arrayElement, errors);
          importerCollection.add(importer);
        }
      }

      if (importerCollection.size() > 0) {
        request.setAttribute("vociImporters", importerCollection);
      }
    }

    // ...then handle user interaction
    String query;
    if ((command.getModifier() != null)
        && (command.getModifier().equals("query"))
        && ((query = request.getParameter("query")) != null)
        && ((query = query.trim()).length() > 0)) {
      Logger.debug("Import query started: " + query + " for type "
          + request.getParameter("ctype"));
      // successfulImportCount will get updated if some are done
      request.setAttribute("successfulImportCount", 0);

      request.setAttribute("successfulImportCount", iman.performImport(
          user, request.getParameter("importer"), query, request
              .getParameter("ctype"), command.getProject(),
          errors, problems));

      if ((problems == null) || (problems.size() == 0)) {
        request.setAttribute("problemImports", null);
      } else {
        request.setAttribute("problemImports", problems);
      }
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    try {
      request.getRequestDispatcher(
          response.encodeURL("/" + command.getDisplayProject()
              + "/admin/Importer.jsp"))
          .forward(request, response);
    } catch (ServletException e) {
      Logger.error("Couldn't forward request to Importer.jsp.", e);
    } catch (IOException e) {
View Full Code Here

  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    Command command = (Command) request.getAttribute("command");
    WorkflowManager workflowManager = new WorkflowManager();

    // handle the "view vs. admin"-specific changes
    String openNodesAttributeName = command.isViewCommand() ? "openViewNodes"
        : "openTreeNodes";
    String contentListPage = "/"
        + command.getDisplayProject()
        + (command.isViewCommand() ? "/Content.jsp"
            : "/admin/ContentList.jsp");
    String vboViewPage = "/"
        + command.getDisplayProject()
        + (command.isViewCommand() ? "/VBODisplay.jsp"
            : "/admin/Collection.jsp");
    if (command.isViewCommand()) {
      request.setAttribute("vboType", "Collection");
    }

    // then do the regular page processing
    ArrayList<Integer> openNodes = (ArrayList<Integer>) request
        .getSession().getAttribute(openNodesAttributeName);
    if (openNodes == null) {
      openNodes = new ArrayList<Integer>();
    }

    boolean goToList = true;
    String cancel;

    if ((command.getModifier() != null)
        && (command.getModifier().equals("items"))) {
      // get the listing of items that belong to this collection
      getItemWrappersForNode(command, (User) request.getSession()
          .getAttribute("user"), request);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("search"))) {
      // prep for search functions
      setSearchObject(command, new CollectionManager(), request, errors);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("open"))) {
      // open nodes in the content tree
      openNodes(command, request, openNodesAttributeName, openNodes);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("close"))) {
      // close nodes in the content tree
      closeNodes(command, request, openNodesAttributeName, openNodes);
    } else if (((cancel = request.getParameter("cancelChanges")) != null)
        && (cancel.equals("yes"))) {
      // user has elected to cancel changes made to a form
      request.setAttribute("successMessages",
          "Your changes have been cancelled.");
      int idToCancel = Integer.parseInt(request
          .getParameter("collectionId"));
      ContentLockManager.unlockContentByTypeAndID(ContentType.COLLECTION
          .getValue(), idToCancel);
      goToList = true;
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("add"))) {
      goToList = handleCollectionAddRequest(request, command, errors,
          user, openNodes, openNodesAttributeName);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("delete"))) {
      goToList = handleCollectionDeleteRequest(request, command, errors,
          user);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("view"))
        && (command.isViewCommand())) {
      goToList = handleCollectionViewRequest(request, command);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("update"))
        && (!command.isViewCommand())) {
      goToList = handleCollectionUpdateRequest(request, command, errors,
          user, openNodes, fieldMessages);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("history"))) {
      goToList = handleHistoryRequest(request, command, errors, user);
    }

    Collection collection = request.getAttribute("collection") == null ? null
        : (Collection) request.getAttribute("collection");

    // one last permissions check if we're on our way to the edit page
    if ((collection != null)
        && (!command.isViewCommand())
        && (errors.size() == 0)
        && (fieldMessages.size() == 0)
        && (!goToList)
        && (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), collection.getCollectionId()))) {
      errors.add("You don't have permission to "
          + "work on the requested content.");
      goToList = true;
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    if (fieldMessages.size() > 0) {
      request.setAttribute("fieldMessages", fieldMessages);
    }

    if (goToList) {
      // the request dispatcher's forward method strips anchors, so we
      // set page target here and let the ContentList.jsp handle it
      // in the body tag's onload event.
      if (collection != null) {
        request.setAttribute("jumpToTarget", "#node"
            + collection.getCollectionId());
      }

      if ((command.getModifier() == null)
          || (!command.getModifier().equals("search"))) {
        ArrayList<VBOTreeNodeWrapper> tree = TreeManager.getInstance()
            .getTreeNodeWrappers(
                command.getProject(),
                openNodes,
                command.isViewCommand() ? true : false,
                -1,
                (User) request.getSession()
                    .getAttribute("user"));
        request.setAttribute("tree", tree);
      }

      // if this is from a search, flag it as such for the ContentList.jsp
      // page
      if (request.getParameter("fs") != null) {
        command.setModifier("search");
        ArrayList<String> other = new ArrayList<String>();
        other.add("results");
        command.setOther(other);
      }

      try {
        request.getRequestDispatcher(
            response.encodeURL(contentListPage)).forward(request,
            response);
      } catch (ServletException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      } catch (IOException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      }
    } else {
      ArrayList<GUIElement> guiElements = collection.getGUIElements();
      String addToRepeatables = request.getParameter("addToRepeatables");
      if ((addToRepeatables != null)
          && (addToRepeatables.trim().length() > 0)) {
        for (GUIElement guiElem : guiElements) {
          if (guiElem.getName().equals(addToRepeatables)) {
            guiElem.setRepeatableElementsToAdd(3);
            request.setAttribute("isDirty", "t");
            break;
          }
        }
      }
      request.setAttribute("elements", guiElements);

      request.setAttribute(
          command.isViewCommand() ? "vbo" : "collection", collection);
      ArrayList<AuditLog> historyRecords = (new AuditLogManager())
          .getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.COLLECTION, collection
                  .getCollectionId());
      if ((historyRecords != null) && (historyRecords.size() > 0)) {
        request.setAttribute("history", historyRecords);
      }
View Full Code Here

      } finally {
        return;
      }
    }

    Command command = createCommand(req);

    HttpRequestWithModifiableParameters request = sanitizeRequest(command,
        req);

    addPrivacyPolicy(response);

    doProjectSetup(command, request);

    // get the query string for dispatching
    String queryString;
    if (((queryString = request.getQueryString()) != null)
        && (queryString.trim().length() > 0)) {
      queryString = '?' + queryString;
    } else {
      queryString = "";
    }

    // ... and save the whole original request for future reference
    request.setAttribute("originalRequest", request.getRequestURI()
        + queryString);

    Logger.debug("dispatching to /" + command.getCommand() + queryString);
    Logger.debug("command: " + command.toString());

    RequestDispatcher rd = request.getRequestDispatcher(response
        .encodeURL("/" + command.getCommand() + queryString));
    try {
      rd.forward(request, response);
      return;
    } catch (ServletException e) {
      Logger.warn("Couldn't forward request for URI "
          + request.getRequestURI() + " to /" + command.getCommand()
          + queryString, e);
    } catch (IOException e) {
      Logger.warn("Couldn't forward request for URI "
          + request.getRequestURI() + " to /" + command.getCommand()
          + queryString, e);
    }

    // if all else fails...
    try {
      request.getRequestDispatcher(
          response.encodeURL("/" + command.getProject()
              + "/Error.jsp")).forward(request, response);
    } catch (ServletException e) {
      Logger.warn("Couldn't forward request for URI "
          + request.getRequestURI() + " to the error page", e);
    } catch (IOException e) {
View Full Code Here

    // http://whatever.com/voci/[go|do]/project/command/modifier{/other}*
    // (no brackets or asterisk, and the '/other' portion is repeatable).
    String uri = req.getRequestURI();
    uri = uri.substring(1);
    String[] commandPieces = uri.split("/");
    Command command = new Command(commandPieces[2], commandPieces[3],
        (commandPieces.length > 4 ? commandPieces[4] : null),
        (commandPieces.length > 5 ? ArrayUtils.subset(commandPieces, 5,
            commandPieces.length - 1) : null));
    (new ProjectManager()).setDisplayProject(command);
    if (commandPieces[1].equals("go")) {
      command.setViewCommand(true);
    }

    // any command can be saved in the user's session for later retrieval
    // with sv=s, and the user can be routed back to whatever the saved page
    // was with sv=g. it's just a little helper functionality for
View Full Code Here

   *         <code>false</code> otherwise.
   */
  protected boolean needsAdminCheck(HttpServletRequest request,
      HttpServletResponse response) {
    WorkflowManager wm = new WorkflowManager();
    Command command = (Command) request.getAttribute("command");

    // first, block admin requests in production if that's what's
    // specified in the deployment descriptor
    if (Configuration.getString("serverType").equals("production")
        && (Configuration.getString("adminInProduction")
            .equals("false"))) {
      request
          .setAttribute("errorMessage",
              "Administrative functions are not available in this environment.");
      try {
        request.getRequestDispatcher(
            response.encodeURL("/" + command.getProject()
                + "/Error.jsp")).forward(request, response);
        return true;
      } catch (ServletException e) {
        Logger.warn("Couldn't forward request to the error page", e);
      } catch (IOException e) {
        Logger.warn("Couldn't forward request to the error page", e);
      }
    }

    // now do the real checks
    HttpSession session = request.getSession();
    // check to see if the user's already logged in, and if so,
    // check permissions for the command
    if (session.getAttribute("user") != null) {
      User user = (User) session.getAttribute("user");

      // this is a basic workflow check, and it only makes sure that the
      // user is allowed to perform administration on the requested
      // content type. specific item editing-related checks should be
      // done in the respective servlets.
      if (wm
          .canEdit(user, command.getProject(), command.getCommand(),
              -1)) {
        // user can manage command, so all's well
        Logger.debug("user '" + user.getUserName() + "' is an admin");
        return false;
      } else {
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  @Override
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    MetadataManager manager = new MetadataManager();
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();

    boolean goToMetadataList = false;
    String cancel;

    // parse the "other" data from the Command object into metadata ID
    // and sub-command
    int metadataId = -2;
    String subCommand = "";
    if ((command.getOther() != null) && (command.getOther().size() > 0)) {
      metadataId = Integer.parseInt((String) command.getOther().get(0));
      if (command.getOther().size() > 1) {
        subCommand = (String) command.getOther().get(1);
      }
    } else if (request.getParameter("metadataId") != null) {
      metadataId = Integer.parseInt(request.getParameter("metadataId"));
    }

    // the delete action's being performed from the metadata list
    if (subCommand.equals("del")) {
      try {
        // we really disable, though we talk about deleting to the user
        MetadataElement element = manager
            .getMetadataElement(metadataId);
        if (element.isKeyField()) {
          errors.add("Key fields can not be deleted.");
        } else {
          manager.deleteMetadata(element);
          request.setAttribute("successMessage", "Metadata element ("
              + metadataId + ") successfully deleted.");
        }
      } catch (NumberFormatException e) {
        request.setAttribute("errorMessage",
            "The metadata ID requested (" + metadataId
                + ") couldn't be located to delete.");
      } catch (NoSuchMetadataException e) {
        request.setAttribute("errorMessage",
            "The metadata ID requested (" + metadataId
                + ") couldn't be located to delete: "
                + e.getMessage());
      }

      goToMetadataList = true;

    } else
    // ... and this one is for re-ordering from the metadata list
    if ((subCommand.equals("down")) || (subCommand.equals("up"))) {
      try {
        // "up" in the GUI means "down" in the ordering, so the
        // true/false here may look a little goofy
        manager.moveMetadata(manager.getMetadataElement(metadataId),
            subCommand.equals("down") ? true : false);
        request.setAttribute("successMessage", "Metadata element "
            + metadataId + " successfully moved.");
      } catch (NumberFormatException e) {
        request.setAttribute("errorMessage",
            "The metadata ID requested (" + metadataId
                + ") couldn't be located to move.");
      } catch (NoSuchMetadataException e) {
        request.setAttribute("errorMessage",
            "The metadata ID requested (" + metadataId
                + ") couldn't be located to move: "
                + e.getMessage());
      }

      goToMetadataList = true;
    } else
    // cancel the changes
    if (((cancel = request.getParameter("cancelChanges")) != null)
        && (cancel.equals("yes"))) {
      request.setAttribute("successMessages",
          "Your changes have been cancelled.");
      goToMetadataList = true;
    } else
    // all other commands (user is adding or updating an element, or
    // retrieving from history)
    if (metadataId != -2) {
      AuditLogManager alm = null;
      MetadataElement elem = null;
      try {
        if (metadataId == -1) {
          // -1 is for a blank form request from the list, asking
          // to add a new element
          elem = new MetadataElement();
          try {
            elem.setIndexMultiplier(1);
          } catch (ValidationException e) {
            // won't happen
          }
          elem.setMetadataId(-1);
          elem.setProjectId(((Project) ((HashMap) getServletContext()
              .getAttribute("projectMap")).get(command
              .getProject())).getProjectId());
          if (subCommand.equals("kf")) {
            elem.setIsKeyField(true);
          }
        } else if (subCommand.equals("history")) {
          alm = new AuditLogManager();
          String[] vals = command.getOther().get(2).split("\\|");
          try {
            AuditLog record = alm.getRecord(Integer
                .parseInt(vals[0]), ContentType.valueOf(Integer
                .parseInt(vals[1])), metadataId, Timestamp
                .valueOf(vals[2]));
            String data = record.getDataExport();
            elem = new MetadataElement();
            elem.fromString(data);
            request.setAttribute("isDirty", "t");
          } catch (NullPointerException e) {
            errors.add("Invalid history request format.");
          } catch (NumberFormatException e) {
            errors.add("Invalid history request format.");
          } catch (NoSuchAuditLogRecordException e) {
            errors
                .add("The history record requested couldn't be located.");
          } catch (DataTypeMismatchException e) {
            Logger.error("Data type mismatch occurred pulling "
                + command.getOther().get(0)
                + " from the audit log", e);
            errors
                .add("A system error was encountered (DataTypeMismatch). "
                    + "Please contact a system administrator.");
          }

          if (elem == null) {
            elem = manager.getMetadataElement(metadataId);
          }
        } else {
          elem = manager.getMetadataElement(metadataId);
        }
      } catch (NumberFormatException e) {
        request.setAttribute("errorMessage",
            "Invalid metadata ID requested.");
      } catch (NoSuchMetadataException e) {
        request.setAttribute("errorMessage",
            "The requested metadata element could not be found.");
      }

      if (request.getParameter("projectId") != null) {
        // this is an add/update from the form
        String oldContent = elem.toString();
        populateVBOFromRequest(elem, request, fieldMessages, true);
        if (oldContent.equals(elem.toString())) {
          errors.add("No changes detected.");
        }

        if ((fieldMessages.size() == 0) && (errors.size() == 0)) {
          try {
            elem
                .setContentType(ContentType.valueOf(
                    command.getModifier().toUpperCase())
                    .getValue());
            if (elem.getMetadataId() == -1) {
              manager.addMetadata(((User) request.getSession()
                  .getAttribute("user")), elem);
            } else {
              manager.updateMetadata(elem, oldContent,
                  ((User) request.getSession().getAttribute(
                      "user")));
            }

            request
                .setAttribute(
                    "successMessage",
                    "Your metadata element ("
                        + elem
                            .getFriendlyElementQualifierName()
                        + ") was successfully updated.");
            goToMetadataList = true;
          } catch (NoSuchMetadataException e) {
            errors
                .add("Couldn't find the metadata element for updating, or an ID for adding.");
          }
        }

        if (fieldMessages.size() != 0) {
          String plural = "";
          if (fieldMessages.size() > 1) {
            plural = "s";
          }
          errors.add("Form field" + plural
              + " failed validation (see below).");
        }
      }

      if ((elem != null) && (!goToMetadataList)) {
        request.setAttribute("metadata", elem);
        // put the project's history in the request scope (the project
        // itself is in the application scope)
        if (elem.getMetadataId() != -1) {
          if (alm == null) {
            alm = new AuditLogManager();
          }
          ArrayList<AuditLog> historyRecords = alm.getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.METADATA, elem.getMetadataId());
          if ((historyRecords != null) && (historyRecords.size() > 0)) {
            request.setAttribute("history", historyRecords);
          }
        }
      } else if (elem == null) {
        goToMetadataList = true;
      }
    } else {
      goToMetadataList = true;
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    if (fieldMessages.size() > 0) {
      request.setAttribute("fieldMessages", fieldMessages);
    }

    if (goToMetadataList) {
      Project project = ((HashMap<String, Project>) getServletContext()
          .getAttribute("projectMap")).get(command.getProject());
      // use the community list by default, if none was provided
      if (command.getModifier() == null) {
        command.setModifier("community");
      }
      request.setAttribute("metadata", MetadataManager.getMetadataList(
          project.getId(), ContentType.valueOf(
              command.getModifier().toUpperCase()).getValue()));

      try {
        request.setAttribute("sessionId", request.getSession().getId());
        request.getRequestDispatcher(
            response.encodeURL("/" + command.getDisplayProject()
                + "/admin/MetadataList.jsp")).forward(request,
            response);
      } catch (ServletException e) {
        Logger.error("Couldn't dispatch to /"
            + command.getDisplayProject()
            + "/admin/MetadataList.jsp", e);
      } catch (IOException e) {
        Logger.error("Couldn't dispatch to /"
            + command.getDisplayProject()
            + "/admin/MetadataList.jsp", e);
      }
    } else {
      try {
        request.getRequestDispatcher(
            response.encodeURL("/" + command.getDisplayProject()
                + "/admin/MetadataElement.jsp")).forward(
            request, response);
      } catch (ServletException e) {
        Logger.error("Couldn't dispatch to /"
            + command.getDisplayProject()
            + "/admin/MetadataElement.jsp", e);
      } catch (IOException e) {
        Logger.error("Couldn't dispatch to /"
            + command.getDisplayProject()
            + "/admin/MetadataElement.jsp", e);
      }
    }
  }
View Full Code Here

      String projectHandle = options[0];
      ContentType contentType = ContentType.valueOf(options[1]
          .toUpperCase());
      int metadataId = Integer.parseInt(options[2]);

      Command command = new Command(projectHandle, "metadata",
          contentType.toString().toLowerCase(), null);

      HttpSession session = SessionTracker.getSessionById(options[3]);
      if (session == null) {
        return "ERROR: Requested session doesn't exist.";
      }

      if (session.getAttribute("user") == null) {
        return "ERROR: You're not logged in.";
      } else if (!(new WorkflowManager().canEdit((User) session
          .getAttribute("user"), command.getProject(), command
          .getCommand(), -1))) {
        return "ERROR: You don't have permission to make this request.";
      }

      MetadataManager manager = new MetadataManager();
View Full Code Here

   * @see edu.uga.galileo.voci.servlet.ControlledHttpServlet#handleRequest(javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    HttpSession session = request.getSession();
    if ((command.getModifier() != null)
        && (command.getModifier().equals("exit"))) {
      if (session.getAttribute("user") != null) {
        User user = (User) session.getAttribute("user");
        ContentLockManager.unlockAllUserContent(user);
        session.setAttribute("user", null);
      }
    }

    if (request.getParameter("username") == null) {
      forwardToLoginPage(request, response);
    } else {
      UserManager um = new UserManager();
      try {
        User user = um.getUser(request.getParameter("username"),
            request.getParameter("password"));
        session.setAttribute("user", user);
        try {
          if ((request.getParameter("originator") != null)
              && (request.getParameter("originator").indexOf(
                  "/login") == -1)) {
            response.sendRedirect(response
                .encodeRedirectURL(request
                    .getParameter("originator")));
          } else {
            response.sendRedirect(response
                .encodeRedirectURL("/voci/do/"
                    + command.getProject() + "/welcome"));
          }
        } catch (IOException e) {
          Logger.warn("Couldn't send redirect to "
              + request.getParameter("originator"));
        }
View Full Code Here

   * @param response
   *            The <code>HttpServletResponse</code>.
   */
  private void forwardToLoginPage(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    try {
      request.getRequestDispatcher(
          response.encodeURL("/" + command.getDisplayProject()
              + "/Login.jsp")).forward(request, response);
    } catch (ServletException e) {
      Logger.error("Couldn't forward to Login.jsp", e);
    } catch (IOException e) {
      Logger.error("Couldn't forward to Login.jsp", e);
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.bo.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.