Package org.wymiwyg.rwcf.form

Examples of org.wymiwyg.rwcf.form.MultiPartBody


   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {

    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      if (body.getParameter("action_CreateResource") != null) {
        Resource target = model.createResource(new EnhancedRequest(
            request).getRequestURLWithoutParams().toString());
        String typeString = body.getParameter("type");
        Resource type = model.createResource(typeString);
        target.addProperty(RDF.type, type);
        addSuperTypes(target, type);
       
      }
View Full Code Here


   * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request,
   *      org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    MultiPartBody body = (MultiPartBody) request.getBody();
    String resourceURIString = body.getParameter("resource");
    Resource resource = model.getResource(resourceURIString);
    AccessControlFilter.checkPermssionOnResource(resource);
    removeExistingPermissions(resource);
    setPermissions(resource, body);
   
    String target = body.getParameter("target");
    if (target == null) {
      target = resourceURIString;
    }
    EnhancedResponse ehResponse = new EnhancedResponse(response);
    ehResponse.sendRedirect(target);
View Full Code Here

  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    Resource target = model.createResource(new EnhancedRequest(request)
        .getFullRequestURL().toString());
    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      String origContentType = body.getParameter("origContentType");
      String contentType = body.getParameter("contentType");
      String contentURI = body.getParameter("contentURI");
      String language = body.getParameter("language");
      if ((language != null) && (language.equals("independent"))) {
        language = null;
      }
      if (body.getParameter("action_change") != null) {
        changeVariant(target, contentURI, origContentType, contentType, language);
      }
    } catch (ClassCastException e) {
    }
    chain.doNext(request, response);
View Full Code Here

   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {

    EnhancedRequest ehRequest = new EnhancedRequest(request);
    MultiPartBody body = (MultiPartBody) request.getBody();
    String serializedModel = body.getParameter("model");
    Model importing = ModelFactory.createDefaultModel();
    importing.read(new StringReader(serializedModel), ehRequest
        .getRequestURLWithoutParams().toString(), "RDF/XML");

    ResIterator transactionIter = model.listSubjectsWithProperty(RDF.type,
        TRANSACTION.Transaction);
    Resource agentProfileDocument;
    String primaryResource = body.getParameter("primaryResource");
    if (primaryResource != null) {
      agentProfileDocument = importing.getResource(primaryResource);
    } else {
      if (transactionIter.hasNext()) {
        Resource transaction;
        transaction = transactionIter.nextResource();
        agentProfileDocument = transaction.getProperty(
            TRANSACTION.mainResponseResource).getResource();
      } else {
        agentProfileDocument = JenaUtil.getRoots(importing)[0];
      }
    }

    transactionIter.close();
    // normalization of inserion so that permission so that exiting
    // permission
    // stmts are recognized by InsertPermissionChecker
    addInverse(importing);
    addSeeAlsoAndPPD(importing);
    InsertionIFPResolver.process(model, importing);
    // check insertion before deleting staments in model
    InsertionPermissionChecker.check(importing, model);
    // TODO check if user has the right to remove statements
    FoafUtil.addSha1Mbox(importing);
    // import all agents (knows), removing only properties of the Main
    Resource agent = agentProfileDocument.getProperty(FOAF.primaryTopic)
        .getResource();

    try {
      AccessController
          .checkPermission(new RPermission(AUTHORIZATION.edit));
    } catch (AccessControlException e) {
      Resource user = VirtuserHandler.getSubject();
      if (agent.equals(user)) {

      } else {
        throw e;
      }
    }

    if (agentProfileDocument.isAnon()) {
      String name;
      try {
        name = agent.getProperty(FOAF.name).getString();
        if (name.equals("")) {
          name = Util.createRandomString(8);
        }
      } catch (NullPointerException ex) {
        name = Util.createRandomString(8);
      }
      Resource namedResource;
      namedResource = (Resource) NamedResourceGenerator
          .createNewResource(model, ehRequest.getRootURL(), name)
          .inModel(importing);
      /*
       * namedResource = new ContactHandler(importing, ehRequest
       * .getRootURL()).createContact();
       */
      JenaUtil.replace(importing, agentProfileDocument, namedResource);
      agentProfileDocument = namedResource;
    } else {
      Resource existingAgentDoc = (Resource) agentProfileDocument
          .inModel(model);
      if (existingAgentDoc.hasProperty(FOAF.primaryTopic)) {
        Resource existingAgent = existingAgentDoc.getProperty(
            FOAF.primaryTopic).getResource();
        existingAgentDoc.removeProperties();
        StmtIterator mboxes = existingAgent.listProperties(FOAF.mbox);
        while (mboxes.hasNext()) {
          Statement current = mboxes.nextStatement();
          current.getResource().removeProperties();
        }
        mboxes.close();
        existingAgent.removeProperties();
        // Remove properties of mboxes
        // no need, as this has already been done by IFPPResolver
        // JenaUtil.replace(importing, agent, existingAgent);
        agent = (Resource) existingAgent.inModel(importing);
        addParticipants(existingAgent); // reconstruct
        // the
        // hasParticipant
        // properties
        removeParticipations(existingAgent, importing);
      }
    }

    try {
      // change references with pseudo-url "formfile:"
      FormModelPost.handleFormFiles(
          new URL(agentProfileDocument.getURI()), importing, request,
          model, hashStore);
    } catch (MalformedURLException e) {
      throw new HandlerException("Not an URL for PPD "
          + agentProfileDocument.getURI(), e);
    }

    agentProfileDocument.addProperty(RDF.type, FOAFEX.AgentProfileDocument);
    agentProfileDocument.addProperty(RDF.type,
        RWCF.AuthoritativelyServedResource);
    agent.addProperty(RDF.type, FOAF.Agent);
    // agent.addProperty(FOAF.isPrimaryTopicOf, agentProfileDocument);
    // verifyAgentNew(agent);
    addKnows(ehRequest, agent);
    Set participationSet = new HashSet();
    /*
     * StmtIterator debugIter = agentProfileDocument.listProperties(); while
     * (debugIter.hasNext()) { Statement element = (Statement)
     * debugIter.next(); log.info(element); }
     */
    StmtIterator participationStmts = agent
        .listProperties(ROLE.participatesIn);
    while (participationStmts.hasNext()) {
      Resource currentParticipation = participationStmts.nextStatement()
          .getResource();
      participationSet.add(currentParticipation);
    }
    participationStmts.close();
    for (Iterator iter = participationSet.iterator(); iter.hasNext();) {
      Resource currentParticipation = (Resource) iter.next();
      Resource currentParticipationInModel = getExistingAgent(currentParticipation);
      if (currentParticipationInModel != null) {
        if (!currentParticipationInModel.hasProperty(RDF.type,
            ROLE.Participation)) {
          throw new RuntimeException(
              "Incompatible agent exists for email of participation");
        }
        Resource namedResource = (Resource) currentParticipationInModel
            .inModel(importing);
        JenaUtil
            .replace(importing, currentParticipation, namedResource);
        currentParticipation = namedResource;

      } else {
        Resource participationAgentResource = new ContactHandler(
            importing, ehRequest.getRootURL()).createContact();
        JenaUtil.replace(importing, currentParticipation,
            participationAgentResource);
        currentParticipation = participationAgentResource;

      }
      currentParticipation.addProperty(RDF.type,
          RWCF.AuthoritativelyServedResource);
      // de-anonymise role:group
      Resource group = currentParticipation.getProperty(ROLE.group)
          .getResource();
      Resource existingGroup = getExistingAgent(group);
      if (existingGroup != null) {
        // don't change existing group
        group.removeProperties();
        JenaUtil.replace(importing, group, (Resource) existingGroup
            .inModel(importing));
        group = existingGroup;
      } else {
        Resource namedGroup = new ContactHandler(importing, ehRequest
            .getRootURL()).createContact();
        JenaUtil.replace(importing, group, namedGroup);
        group.addProperty(RDF.type, RWCF.AuthoritativelyServedResource);
      }
      StmtIterator actsInRoleStmts = currentParticipation
          .listProperties(ROLE.actsInRole);
      while (actsInRoleStmts.hasNext()) {
        Resource currentRole = actsInRoleStmts.nextStatement()
            .getResource();
        Resource existingRole = getExistingAgent(currentRole, group);
        if (existingRole != null) {
          JenaUtil.replace(importing, currentRole, existingRole);
        } else {
          currentRole.addProperty(ROLE.group, group);
          group.addProperty(ROLE.providesRole, currentRole);
        }
      }
      actsInRoleStmts.close();
    }

    model.add(importing);
    EnhancedResponse ehResponse = new EnhancedResponse(response);
    if (body.getParameter("action_aggregate") != null) {
      model.leaveCriticalSection();
      try {
        Download.download(model, body.getParameter("aggregate"),
            new URL(ehRequest.getRequestURLWithoutParams(), "/"));
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      } finally {
        model.enterCriticalSection(ModelLock.WRITE);
      }
      ehResponse.sendRedirect(agentProfileDocument.getURI()
          + "?mode=edit");
    } else {
      if (body.getParameter("action_go") != null) {
        ehResponse.sendRedirect(body.getParameter("go"));
      } else {
        ehResponse.sendRedirect(agentProfileDocument.getURI());
      }
    }
  }
View Full Code Here

    /* (non-Javadoc)
     * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request, org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
     */
    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
       MultiPartBody body = (MultiPartBody) request.getBody();
       String itemString = body.getParameter("item");
       Resource item = model.createResource(itemString);
       Resource subject = VirtuserHandler.getSubject();
       if (!model.containsResource(subject) || subject.hasProperty(RDF.type, TEMPSUBJECT.TemporarySubject)) {
           throw new AccessControlException("no nots for temps");
       }
       model.createStatement(item, KNOBOT.notificationTarget, subject).remove();
       EnhancedResponse ehResponse = new EnhancedResponse(response);
       String go = body.getParameter("go");
       if ( go == null) {
           go = itemString;
       }
       ehResponse.sendRedirect(go);
    }
View Full Code Here

     * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request, org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
     */
    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
       Resource user = VirtuserHandler.getSubject();
       MultiPartBody body = (MultiPartBody) request.getBody();
       String topicURIString = body.getParameter("topic");
       String newStatus = body.getParameter("newStatus");
       boolean showOnlyUnread = newStatus.equals("hideRead");
       Resource topic = model.getResource(topicURIString);
       if (showOnlyUnread) {
           topic.addProperty(KNOBOT.showOnlyUnreadTo, user);
       } else {
View Full Code Here

  /**
   * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected void doPost(Request request, Response response)
      throws HandlerException {
    MultiPartBody body = (MultiPartBody) request.getBody();
    String action = body.getParameter("action");
    if ("delete".equals(action)) {
      performDelete(body);
    }
    doGet(request, response);
  }
View Full Code Here

     * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request, org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
     */
    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
       Resource user = VirtuserHandler.getSubject();
       MultiPartBody body = (MultiPartBody) request.getBody();
       String language = body.getParameter("language");
       String sourceURLString = body.getParameter("source");
       Resource source = model.getResource(sourceURLString);
       String targetTypeString = body.getParameter("targetType");
       String targetURLString = body.getParameter("target");
       boolean inline = "on".equals(body.getParameter("inline"));
       if (targetURLString.equals("http://") || targetURLString.equals("")) {
            throw new HandlerException("Must specify a target");
        }
        Resource target;
        try {
            target = getTarget(targetTypeString, targetURLString, new URL(
                    source.getURI()));
        } catch (MalformedURLException e) {
            throw new HandlerException(e);
        }
        removeExisting(source, target);
      
        Resource newRelation = model.createResource(KNOBOT.Relation);

        float strength;
        try {
            strength = Float.parseFloat(body.getParameter("strength"));
        } catch (Exception ex) {
            strength = (float) 1;//0.9;
        }
        Literal strengthLit = model.createTypedLiteral(strength);
        newRelation.addProperty(KNOBOT.strength, strengthLit);
        float strengthReduction;
        try {
            strengthReduction = Float.parseFloat(body
                    .getParameter("strengthReduction"));
        } catch (Exception ex) {
            strengthReduction = DefaultValuesHandler.getDefaultStrengthReduction(model);
        }
        newRelation.addProperty(KNOBOT.strengthReduction,
        model.createTypedLiteral(model.createTypedLiteral(strengthReduction)));
        String childStrengthString = body.getParameter("childStrength");
        float childStrength;
        if (childStrengthString != null) {
            if (!childStrengthString.equals("")) {
                childStrength = Float.parseFloat(childStrengthString);

            } else {
                childStrength = DefaultValuesHandler
                        .getDefaultChildStrength(model);
            }
            newRelation.addProperty(KNOBOT.childStrength, model.createTypedLiteral(childStrength));
        } else {
            childStrength = 0; //so it does not try to aggregate the
            // source
        }
        String childStrengthReduction = body
                .getParameter("minimumChildStrengthReduction");
        if ((childStrengthReduction != null)
                && (!childStrengthReduction.equals(""))) {
            newRelation.addProperty(KNOBOT.minimumChildStrengthReduction,
          model.createTypedLiteral(Float
                    .parseFloat(childStrengthReduction)));
        }
        newRelation.addProperty(KNOBOT.source, source);
        newRelation.addProperty(KNOBOT.target, target);
        Literal effectiveDateLiteral = model.createTypedLiteral(new W3CDateFormat()
                .format(new Date()), XSDDatatype.XSDdateTime);
        newRelation.addProperty(KNOBOT.effectiveDate, effectiveDateLiteral);
        if (inline) {
            newRelation.addProperty(RDF.type, KNOBOT.InlineRelation);
        }
        String targetLabel = body.getParameter("targetLabel");
        if (targetLabel == null) {
            targetLabel = body.getParameter("label");
        }
        if ((targetLabel != null) && (!targetLabel.equals(""))) {
            newRelation.addProperty(KNOBOT.targetLabel, targetLabel, language);
        }
        String sourceLabel = body.getParameter("sourceLabel");
        if ((sourceLabel != null) && (!sourceLabel.equals(""))) {
            newRelation.addProperty(KNOBOT.sourceLabel, sourceLabel, language);
        }
        String feedURLParam = body.getParameter("feedURL");
        if ((feedURLParam != null) && (!feedURLParam.equals("")) && (!feedURLParam.equals("-autodetect-"))) {
            try {
                target.addProperty(AGGREGATOR.feed, model
                        .createResource(new URL(feedURLParam).toString()));
            } catch (MalformedURLException e1) {
                throw new RuntimeException(e1);
            }
        }
        if ("true".equals(body.getParameter("isChannel"))) {
            log.warn("usage of deprecated isChannel argument");
            target.addProperty(RDF.type, RSS.channel);
        }
        RelationManager.addRelation(newRelation);
        //TODO clients send field indicating if feed was alreadydownloaded
View Full Code Here

    /* (non-Javadoc)
     * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request, org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
     */
    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
       MultiPartBody body = (MultiPartBody) request.getBody();
       String resourceString = body.getParameter("resource");
       String languageString = body.getParameter("language");
       Resource resource = model.createResource(resourceString);
       model.createStatement(resource, DC.language, languageString).remove();
       Collection deletingProperties = new ArrayList();
       StmtIterator properties = resource.listProperties();
       while (properties.hasNext()) {
View Full Code Here

    /* (non-Javadoc)
     * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.rwcf.Request, org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
     */
    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
       MultiPartBody body = (MultiPartBody) request.getBody();
       String itemString = body.getParameter("item");
       Resource item = model.createResource(itemString);
       Resource subject = VirtuserHandler.getSubject();
       if (!model.containsResource(subject) || subject.hasProperty(RDF.type, TEMPSUBJECT.TemporarySubject)) {
           throw new AccessControlException("no nots for temps");
       }
       StmtIterator allProperties = subject.listProperties();
       try {
           if (!allProperties.hasNext()) {
               throw new AccessControlException("no nots for temps");
           }
       } finally {
           allProperties.close();
       }
       item.addProperty(KNOBOT.notificationTarget, subject);
       EnhancedResponse ehResponse = new EnhancedResponse(response);
       String go = body.getParameter("go");
       if ( go == null) {
           go = itemString;
       }
       ehResponse.sendRedirect(go);
    }
View Full Code Here

TOP

Related Classes of org.wymiwyg.rwcf.form.MultiPartBody

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.