Package org.wymiwyg.wrhapi

Examples of org.wymiwyg.wrhapi.HandlerException


      try {
        shortName = body.getParameterValues("shortName")[0];
      } catch (Exception ex) {
      }
      if (shortName == null) {
        throw new HandlerException("Must specify a shortName parameter");
      }
      String password = body.getParameterValues("password")[0];
      String create = null;
      try {
        create = body.getParameterValues("create")[0];
      } catch (Exception ex) {
      }
      ResIterator users = model.listSubjectsWithProperty(
          AUTHORIZATION.shortName, shortName);
      if (users.hasNext()) {
        user = users.nextResource();
      }
      /*
       * RDF.type, AUTHORIZATION.User); while (users.hasNext()) { Resource
       * current = users.nextResource(); if
       * (shortName.equals(current.getProperty(
       * AUTHORIZATION.shortName).getString())) { user = current; } }
       */
      users.close();

      if ((user == null) && ("true".equals(create))) {
        user = model.createResource();
        user.addProperty(RDF.type, AUTHORIZATION.User);
        user.addProperty(AUTHORIZATION.shortName, shortName);
      }
      boolean delete = false;
      try {
        delete = "delete".equals(body.getParameterValues("delete")[0]);
      } catch (Exception ex) {
      }

      if (delete) {
        user.removeProperties();
        new org.wymiwyg.rwcf.util.EnhancedResponse(response)
            .sendRedirect("/admin/user_manager");
        return;
      }
      user.removeAll(AUTHORIZATION.password);
      user.removeAll(AUTHORIZATION.pass_sha1sum);
      user.addProperty(AUTHORIZATION.pass_sha1sum, Util.sha1(password));
      String[] permissionStrings = body.getParameterValues("permission");
      user.removeAll(AUTHORIZATION.permission);
      if (permissionStrings != null) {
        for (int i = 0; i < permissionStrings.length; i++) {
          user.addProperty(AUTHORIZATION.permission, model
              .createResource(permissionStrings[i]));
        }
      }
    } else {
      String shortName = null;
      try {
        shortName = request.getRequestURI().getParameterValues(
            "shortName")[0];
      } catch (Exception ex) {
      }
      if (shortName == null) {
        throw new HandlerException("Must specify a shortName parameter");
      }
      /*
       * String password = request.getRequestURI()
       * .getParameterValues("password")[0];
       */
      String create = null;
      try {
        create = request.getRequestURI().getParameterValues("create")[0];
      } catch (Exception ex) {
      }
      ResIterator users = model.listSubjectsWithProperty(
          AUTHORIZATION.shortName, shortName);
      user = users.nextResource();
      /*
       * RDF.type, AUTHORIZATION.User); while (users.hasNext()) { Resource
       * current = users.nextResource(); if
       * (shortName.equals(current.getProperty(
       * AUTHORIZATION.shortName).getString())) { user = current; } }
       */
      users.close();
    }
    response.setHeader(HeaderName.CONTENT_TYPE, "application/xhtml+xml");
    PipedWriter pipedOut = new PipedWriter();
    PipedReader pipedIn;
    try {
      pipedIn = new PipedReader(pipedOut);
      response.setBody(pipedIn);
      PrintWriter out = new PrintWriter(pipedOut);
      printHeader(out);
      printTemplate(out, user);
      printFooter(out);
      out.close();
    } catch (IOException ex) {
      throw new HandlerException(ex);
    }

    //response.sendRedirect(go);
  }
View Full Code Here


      /*
       * try { Thread.sleep(1); } catch (InterruptedException e) { throw
       * new HandlerException(e); }
       */
    } catch (IOException e) {
      throw new HandlerException(e);
    } catch (SerializeException e) {
      throw new HandlerException(e);
    } catch (LanguageUnavailableException e) {
      throw new LanguageUnavailableHandlerException(e);
    } finally {
      try {
        out.close();
      } catch (IOException e) {
        throw new HandlerException(e);
      }
    }
    super.setBody(out.toByteArray());
   
  }
View Full Code Here

    body = (MultiPartBody) request.getBody();

    byte[] content = body.getFileContent("insertion");
    if (content == null) {
      log.error("No file specified, availabe Params are");
      throw new HandlerException("No file specified");
    }
    String base = body.getParameter("base");
    if (base == null) {
      base = "";
    }
View Full Code Here

    if ("delete".equals(action)) {
      getLanguageResource(abbreviation).removeProperties();
    }
    if ("new".equals(action)) {
      if (getLanguageResource(abbreviation) != null) {
        throw new HandlerException("Language with that abbreviation already exists");
      }
      Resource languageRes = model.createResource();
      setPropertiesOn(languageRes, body);
    }
    if ("change".equals(action)) {
      Resource languageRes = getLanguageResource(abbreviation);
      if (languageRes == null) {
        throw new HandlerException("Language with that abbreviation does not exist");
      }
      languageRes.removeProperties();
      setPropertiesOn(languageRes, body);
    }
 
View Full Code Here

        }
        if (body instanceof byte[]) {
          in = new ByteArrayInputStream((byte[]) body);
        }
        if (in == null) {
          throw new HandlerException("Invalid body for template setting: "+body.getClass());
        } else {
          response.setBody(processor.process(in, template));
        }
      } catch (IOException e) {
        throw new HandlerException(e);
      }
    }
  }
View Full Code Here

    }
    String language = null;
    try {
      UploadHandler.createDocument(webDocument, fileContent, language, new MimeType(fileContentType), hashStore);
    } catch (MimeTypeParseException e) {
      throw new HandlerException(e);
    }
    return webDocument;
  }
View Full Code Here

      ResIterator iter = model.listSubjectsWithProperty(KNOBOT.target);
      process(iter, out);
      out.close();
     
    } catch (IOException e) {
      throw new HandlerException(e);
    }
   

  }
View Full Code Here

    if (startDateParamValues != null) {
      try {
        startDate = new SimpleDateFormat("yyyy-MM-dd")
            .parse(startDateParamValues[0]);
      } catch (ParseException e) {
        throw new HandlerException(e);
      }
    } else {
      startDate = getStartOfMonth(now);
     
    }
    Set relevantMonths = new HashSet();
    Date endDate;
    String[] endDateParamValues = ehRequest.getRequestURI()
        .getParameterValues("endDate");
    if (endDateParamValues != null) {
      try {
        endDate = new SimpleDateFormat("yyyy-MM-dd")
            .parse(endDateParamValues[0]);
      } catch (ParseException e) {
        throw new HandlerException(e);
      }
      endDate.setTime(endDate.getTime() + (24*60*60-1)*1000);
    } else {
      endDate = getEndOfMonth(now);
      if ((endDate.getTime() - now.getTime()) < (15*24*60*60*1000)) {
View Full Code Here

              new URL(relationSource.getURI()),
              relationTargetString).toString();
        }
        relationTarget = model.createResource(relationTargetURL);
      } catch (MalformedURLException e) {
        throw new HandlerException(e);
      }
    } else {
      String targetDescriptionString = requestBody.getParameter("targetDescription");
      URL targetDescriptionURL;
      try {
        if (targetDescriptionString.startsWith("http")) {
          targetDescriptionURL = new URL(targetDescriptionString);
        } else {
          targetDescriptionURL = new URL(new URL(relationSource
              .getURI()), targetDescriptionString);
        }
        Resource targetDescription = model
            .createResource(targetDescriptionURL.toString());
        relationTarget = BaseItemPostHandler.lookUpByIFP(model,
            FOAF.isPrimaryTopicOf, targetDescription);
      } catch (MalformedURLException e) {
        throw new HandlerException(e);
      }
    }

   
    float strength;
View Full Code Here

      try {
        relationSource = model.createResource(new URL(new URL(
            relationSource.toString()), relationSourceString)
            .toString());
      } catch (MalformedURLException e) {
        throw new HandlerException(e);
      }
    }
    if (targetString.equals("http://") || targetString.equals("")) {
      throw new HandlerException("Must specify a target");
    }
    Resource relationTarget;
    try {
      relationTarget = getTarget(targetTypeString, targetString, new URL(
          relationSource.getURI()));
    } catch (MalformedURLException e) {
      throw new HandlerException(e);
    }
    ResIterator relations = model.listSubjectsWithProperty(KNOBOT.target,
        relationTarget);
    while (relations.hasNext()) {
      Resource current = relations.nextResource();
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.HandlerException

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.