Package org.wymiwyg.wrhapi

Examples of org.wymiwyg.wrhapi.HandlerException


    if (uri != null) {
      try {
        //try to create a new resource itemOrTopic
        itemOrTopic = model.createResource(new URL(baseURL, uri).toString());
      } catch (MalformedURLException e) {
        throw new HandlerException(e);
      }
    }
   
    //retrieve parameters from body:
   
    String language = requestBody.getParameter("language");
    String title = requestBody.getParameter("title");
    String summary = requestBody.getParameter("description");
    if (!"yes".equals(requestBody.getParameter("custom_summary"))) {
      summary = null;
    }
    String creator = requestBody.getParameter("creator");
    String date = requestBody.getParameter("date");
    String content = requestBody.getParameter("body");
   
    String[] permissions = requestBody.getParameterValues("permission");
    String[] maxShowInlineLength = requestBody.getParameterValues("maxShowInlineLength");
    if ((maxShowInlineLength != null) && (maxShowInlineLength.length > 0)) {
      Literal maxShowInlineLengthLiteral = model.createTypedLiteral(maxShowInlineLength[0], XSDDatatype.XSDdecimal);
      itemOrTopic.removeAll(KNOBOT.maxShowInlineLength);
      itemOrTopic.addProperty(KNOBOT.maxShowInlineLength, maxShowInlineLengthLiteral);
    }
    addPermissions(itemOrTopic, permissions);
    //shop
    boolean shop = "checked".equals(requestBody.getParameter("shop"));
    String priceString = requestBody.getParameter("price");
    String articleID = requestBody.getParameter("articleID");
    boolean commentable = "yes"
        .equals(requestBody.getParameter("comments"));
    float price = 0;
    if ((priceString != null) && (!priceString.equals(""))) {
      price = Float.parseFloat(priceString);
    }
   
    //custom shipping costs parameter (has to be float):
    String customShippingCostsString = requestBody.getParameter("customShippingCosts");
    String useDefaultShippingCosts = requestBody.getParameter("useShippingCosts");
    float customShippingCosts = 0;
    if ((customShippingCostsString != null) && (!customShippingCostsString.equals(""))) {
      customShippingCosts = Float.parseFloat(customShippingCostsString);
    }
   

   
    summary = tidy(summary);
    content = tidy(content);
   

    try {
      deletePropertiesByLanguage(itemOrTopic, RSS.title, language);
    } catch (Exception ex) {
    }
    try {
      deletePropertiesByLanguage(itemOrTopic, RSS.description, language);
    } catch (Exception ex) {
    }
    try {
      deletePropertiesByLanguage(itemOrTopic, CONTENT.encoded, language);
    } catch (Exception ex) {
    }
    try {
      // the author may want to write his name differently in different
      // languages
      deletePropertiesByLanguage(itemOrTopic, DC.creator, language);
    } catch (Exception ex) {
    }
    try {
      itemOrTopic.getProperty(DC.date).remove();
    } catch (Exception ex) {
    }
    if ((language == null) || (language.equals(""))) {
      throw new HandlerException("must specify a language");
    }
    model
        .createStatement(
            itemOrTopic,
            RDF.type,
View Full Code Here


    Date[] eventStartDts;
    try {
      eventStartDts = getDateTimes(eventStartDateStrings,
          eventStartTimeStrings);
    } catch (ParseException e) {
      throw new HandlerException("Invalid start date", e);
    }
    Date[] eventEndDts;
    try {
      eventEndDts = getDateTimes(eventEndDateStrings, eventEndTimeStrings);
    } catch (ParseException e) {
      throw new HandlerException("Invalid start date", e);
    }
   
    Map existingMap = getExistingEventsMap(target);
    Set newEventSet = new HashSet();
    target.removeAll(KNOBOT.announcesEvent);
View Full Code Here

        if (originalUrls[i] != null) {
          try {
            originalUrls[i] = new URL(baseURL, originalUrls[i])
                .toString();
          } catch (MalformedURLException e) {
            throw new HandlerException(e);
          }
        }
      }
      Collection originalUrlCol = Arrays.asList(originalUrls);
      Map originalLabelsMap = new HashMap();
      // this contains langugage specific attachments in other languages
      // as value and their poisition-Integer as key.
      Map untouchedAttachments = new HashMap();

      Statement attachStmt = target.getProperty(ATTACH.attachments);
      if (attachStmt != null) {
        Seq attachSeq = attachStmt.getSeq();
        for (int i = 1; i <= attachSeq.size(); i++) {
          Resource currentAttachment;
          try {
            currentAttachment = attachSeq.getResource(i);
          } catch (PropertyNotFoundException ex) {
            log.warn("Inncosistent sequence of attachment");
            fixSeq(attachSeq);
            i--;
            continue;
          }
          Statement languageStmt = currentAttachment
              .getProperty(DC.language);
          if ((languageStmt == null)
              || (languageStmt.getString().equals(language))) {
            String currentDocumentURL = currentAttachment
                .getProperty(ATTACH.document).getResource()
                .getURI();
            if (originalUrlCol.contains(currentDocumentURL)) {
              StmtIterator labelStmts = currentAttachment
                  .listProperties(RDFS.label);
              Collection otherLangLabels = new ArrayList();
              while (labelStmts.hasNext()) {
                Statement current = labelStmts.nextStatement();
                Literal value = current.getLiteral();
                if (!language.equals(value.getLanguage())) {
                  otherLangLabels.add(value);
                }
              }
              originalLabelsMap
                  .put(
                      currentDocumentURL,
                      otherLangLabels
                          .toArray(new Literal[otherLangLabels
                              .size()]));
              // TODO put in map of attachments to update
            }
            currentAttachment.removeProperties();

          } else {
            // remove attachment from sequence anyway and re-insert
            // it at the end at the best position
            // best position: for the moment the same index if
            // available in the new seq.
            untouchedAttachments.put(new Integer(i),
                currentAttachment);
          }
          attachSeq.remove(i--);
        }
      }
      // for every attachment
      String[] attachmentPositions = requestBody
          .getParameterValues("attachment_position");
      String[] attachmentTypes = requestBody
          .getParameterValues("attachment_type");
      String[] attachmentLabels = requestBody
          .getParameterValues("attachment_label");
      String[] attachmentWidths = requestBody
          .getParameterValues("attachment_width");
      String[] attachmentHeights = requestBody
          .getParameterValues("attachment_height");
      String[] attachmentMode = requestBody
          .getParameterValues("attachment_mode");
      String[] languageSpecific = requestBody
          .getParameterValues("attachment_language_specific");
      String[] summmaryViews = requestBody
          .getParameterValues("attachment_summary_view");
      // for url-attachments
      String[] attachmentURLs = requestBody
          .getParameterValues("attachment_url");
      String[] urlAttachmentContentTypes = requestBody
          .getParameterValues("attachment_contenttype");
      // for upload-attachments
      byte[][] attachmentContent = requestBody
          .getFileContents("attachment_file");
      String[] fileNames = requestBody.getFileNames("attachment_file");
      MimeType[] fileContentTypes = requestBody
          .getFileContentTypes("attachment_file");

      // int urlIter = 0;
      // int fileIter = 0;
      SortedSet attachmentsSet = new TreeSet();
      // Attachment[] attachments = new
      // Attachment[attachmentTypes.length];
      for (int i = 0; i < attachmentTypes.length; i++) {
        int position = Integer.parseInt(attachmentPositions[i]);
        if (position == -1) {
          continue;
        }
        String currentType = attachmentTypes[i];
        int width, height;
        try {
          width = Integer.parseInt(attachmentWidths[i]);
          height = Integer.parseInt(attachmentHeights[i]);
        } catch (NumberFormatException ex) {
          width = -1;
          height = -1;
        }
        Literal[] existingLabel = (Literal[]) originalLabelsMap
            .get(originalUrls[i]);
        Literal[] labels;
        if (existingLabel != null) {
          labels = new Literal[existingLabel.length + 1];
          System.arraycopy(existingLabel, 0, labels, 0,
              existingLabel.length);
        } else {
          labels = new Literal[1];
        }
        labels[labels.length - 1] = model.createLiteral(
            attachmentLabels[i], language);
        String attachmentLanguage;
        if (languageSpecific[i].equals("true")) {
          attachmentLanguage = language;
        } else {
          attachmentLanguage = null;
        }

        if ((currentType != null) && (currentType.equals("url"))) {
          if ((attachmentURLs[i] != null)
              && (!attachmentURLs[i].equals(""))) {
            URL attachmnetTargetURL;
            try {
              attachmnetTargetURL = new URL(baseURL,
                  attachmentURLs[i]);
            } catch (MalformedURLException e) {
              throw new RuntimeException(e);
            }

            MimeType mimeType;
            if ((urlAttachmentContentTypes[i] != null)
                && (!urlAttachmentContentTypes[i].equals(""))) {
              try {
                mimeType = new MimeType(
                    urlAttachmentContentTypes[i]);
              } catch (MimeTypeParseException e) {
                throw new HandlerException("Invalid MimeType",
                    e);
              }
            } else {
              mimeType = null;
            }
            attachmentsSet.add(new Attachment(labels,
                attachmnetTargetURL, mimeType, width, height,
                attachmentMode[i].equals("inline"),
                attachmentLanguage, position, summmaryViews[i]
                    .equals("true")));
            /*
             * Resource attachmentTarget =
             * model.createResource(attachmnetTargetURL.toString());
             * ItemUtil.addAttachment(target, attachmentTarget,
             * urlAttachmentContentTypes[i], attachmentLabels[i],
             * width, height, attachmentMode[i].equals("inline"));
             */
          }
          // urlIter++;

        } else {
          if ((attachmentContent != null)
              && (attachmentContent[i] != null)
              && (attachmentContent[i].length > 0)) {
            String fileName = fileNames[i];
            MimeType mimeType;
            mimeType = fileContentTypes[i];
            try {
              attachmentsSet.add(new Attachment(model, hashStore,
                  new URL(target.getURI()), labels,
                  attachmentContent[i], fileName, mimeType,
                  width, height, attachmentMode[i]
                      .equals("inline"),
                  attachmentLanguage, position,
                  summmaryViews[i].equals("true"),
                  permissions));
              /*
               * ItemUtil.addAttachment(target,
               * attachmentContent[i], fileNames[i],
               * fileContentTypes[i], attachmentLabels[i], width,
               * height, attachmentMode[i].equals("inline"));
               */
            } catch (IOException e) {
              throw new HandlerException(e);
            }
          }
          // fileIter++;
        }
      }
View Full Code Here

      response.setResponseStatus(ResponseStatus.getInstanceByCode(responseCode));
      if (responseCode == ResponseStatus.SUCCESS.getCode()) {
        response.setBody(connection.getInputStream());
      }
    } catch (MalformedURLException e) {
      throw new HandlerException(e);
    } catch (IOException e) {
      throw new HandlerException(e);
    }
   
  }
View Full Code Here

            final PipedInputStream pipedIn = new PipedInputStream();
            final PipedOutputStream pipedOut;
            try {
                pipedOut = new PipedOutputStream(pipedIn);
            } catch (IOException e) {
                throw new HandlerException(e);
            }

            transformingThread = new Thread() {
                public void run() {
                 
View Full Code Here

                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }

            } catch (MimeTypeParseException e) {
                throw new HandlerException(e);
            }

        } else {
            super.setHeader(headerName, value);
        }
View Full Code Here

    try {
      Resource document = createDocument(model, hashStore, baseUrl,
          typedContent.data, fileName, typedContent.type);
      JenaUtil.replace(importing, current, document);
    } catch (IOException e) {
      throw new HandlerException(e);
    }

  }
View Full Code Here

    PipedWriter pipedOut = new PipedWriter();
    PipedReader pipedReader;
    try {
      pipedReader = new PipedReader(pipedOut);
    } catch (IOException e) {
      throw new HandlerException(e);
    }
    response.setHeader(HeaderName.CONTENT_TYPE, "application/xhtml+xml");
    response.setBody(pipedReader);
    PrintWriter out = new PrintWriter(pipedOut);
    out.println("<!DOCTYPE html PUBLIC \"-//WYMIWYG//DTD extended XHTML//EN\" \"http://wymiwyg.org/dtd/exhtml.dtd\">");
View Full Code Here

        out.println(max+" are enough for now, call again to continue. (use get paramet \"max\" to change value");
      else
        out.println("processed all (=" + statements.size() + ") statements");
      out.close();
    } catch (IOException e) {
      throw new HandlerException(e);
    }
  }
View Full Code Here

    String[] typeStrings = request.getHeaderValues(HeaderName.CONTENT_TYPE);
    if (typeStrings.length > 0) {
      try {
        type = new MimeType(typeStrings[0]);
      } catch (MimeTypeParseException e) {
        throw new HandlerException("Invalid MimeType: "
            + typeStrings[0]);
      }
    } else {
      type = DEFAULT_MIME_TYPE;
    }
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.