예제 #1
0
 protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo) {
   VitroRequest vreq = new VitroRequest(request);
   request.setAttribute("epoKey", epo.getKey());
   request.setAttribute("epo", epo);
   request.setAttribute("globalErrorMsg", epo.getAttribute("globalErrorMsg"));
   request.setAttribute(
       "css",
       "<link rel=\"stylesheet\" type=\"text/css\" href=\""
           + vreq.getAppBean().getThemeDir()
           + "css/edit.css\"/>");
 }
예제 #2
0
  private Object getApplicationName(VitroRequest vreq) {
    String name = "";
    try {
      name = vreq.getAppBean().getApplicationName();
    } catch (Exception e) {
      // deal with problems below
    }

    if ((name != null) && (!name.isEmpty())) {
      return name;
    } else {
      return getContextPath();
    }
  }
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditOntology()))) {
      return;
    }

    VitroRequest request = new VitroRequest(req);

    EditProcessObject epo = super.createEpo(request);
    request.setAttribute("epoKey", epo.getKey());

    OntologyDao oDao = request.getFullWebappDaoFactory().getOntologyDao();
    Ontology o = null;
    if (request.getParameter("uri") == null) {
      log.error("doPost() expects non-null uri parameter");
    } else {
      o = oDao.getOntologyByURI(request.getParameter("uri"));
      if (o == null) {
        if (!VitroVocabulary.vitroURI.equals(request.getParameter("uri"))) {
          log.debug(
              "doPost(): no ontology object found for the namespace "
                  + request.getParameter("uri"));
        }
      } else {
        request.setAttribute("Ontology", o);
      }
    }
    ArrayList<String> results = new ArrayList<String>();
    results.add("Ontology");
    results.add("Namespace");
    results.add("Prefix");
    String name = o == null ? "" : (o.getName() == null) ? "" : o.getName();
    results.add(name);
    String namespace = o == null ? "" : (o.getURI() == null) ? "" : o.getURI();
    results.add(namespace);
    String prefix = o == null ? "" : (o.getPrefix() == null) ? "" : o.getPrefix();
    results.add(prefix);
    request.setAttribute("results", results);
    request.setAttribute("columncount", 3);
    request.setAttribute("suppressquery", "true");

    epo.setDataAccessObject(oDao);
    FormObject foo = new FormObject();
    HashMap<String, List<Option>> OptionMap = new HashMap<String, List<Option>>();

    HashMap formSelect =
        new HashMap(); // tells the JSP what select lists are populated, and thus should be
                       // displayed
    request.setAttribute("formSelect", formSelect);

    // add the options
    foo.setOptionLists(OptionMap);
    epo.setFormObject(foo);

    // funky hack because Ontology.getURI() will append a hash for a hash namespace
    // See OntologyDaoJena.ontologyFromOntologyResource() comments
    String realURI = OntologyDaoJena.adjustOntologyURI(o.getURI());
    request.setAttribute("realURI", realURI);
    request.setAttribute("exportURL", request.getContextPath() + Controllers.EXPORT_RDF);

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("epoKey", epo.getKey());
    request.setAttribute("bodyJsp", "/templates/edit/specific/ontologies_edit.jsp");
    request.setAttribute("title", "Ontology Control Panel");
    request.setAttribute(
        "css",
        "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + request.getAppBean().getThemeDir()
            + "css/edit.css\"/>");

    try {
      rd.forward(request, response);
    } catch (Exception e) {
      log.error("OntologyEditController could not forward to view.");
      log.error(e.getMessage());
      log.error(e.getStackTrace());
    }
  }