Package org.wymiwyg.wrhapi.util

Examples of org.wymiwyg.wrhapi.util.EnhancedRequest


                  mimeTypes, baseName);
              model.enterCriticalSection(Lock.READ);
              try {
                AccessControlFilter
                    .checkPermssionOnResource(model
                        .createResource(new EnhancedRequest(
                            request)
                            .getRequestURLWithoutParams()
                            .toString()));
              } finally {
                model.leaveCriticalSection();
View Full Code Here


public class ItemGetHandler extends GenericGetHandler implements Handler {
    private static Log log = LogFactory.getLog(ItemGetHandler.class);

    public void handle(Request request, Response response, HandlerChain chain)
            throws HandlerException {
        EnhancedRequest ehRequest = new EnhancedRequest(request);
        String requestURL;
        if (ehRequest.getRequestURI().getPath().startsWith("/remote")) {
            requestURL = new EnhancedRequestURI(ehRequest.getRequestURI())
                    .getParameter("url");
        } else {
            requestURL = ehRequest.getRequestURLWithoutParams().toString();
        }
        Resource item = model.createResource(requestURL);
        if (!model.containsResource(item)) {
            chain.doNext(request, response);
            return;
        }
        if (!isPermitted(item)) {
            throw new AccessControlException(
                    "No suitable permission to access item");
        }
        if (!model.contains(item, RDF.type, RSS.item)) {
            chain.doNext(request, response);
            return;
        }
        TopicGetHandler.checkLanguageAvailability(item, ehRequest);
        AcceptLanguagesIterator acceptedLanguages = ehRequest
                .getAcceptLanguages();
        List acceptLanguagesStringList = new ArrayList();
        while (acceptedLanguages.hasNext()) {
            String current = acceptedLanguages.nextAcceptLanguageHeader()
                    .getLocaleRange().getLocale().getLanguage();
            acceptLanguagesStringList.add(current);
        }
        int maxBackwardLinks;
        try {
          maxBackwardLinks = Integer.parseInt(new EnhancedRequestURI(ehRequest.getRequestURI()).getParameter("till"));
        } catch (Exception e) {
          maxBackwardLinks = 10;
        }
       
        float minimalRelevance;
View Full Code Here

          .getParameterValues("minimalRelevance")[0]);
    } catch (Exception ex) {
      minimalRelevance = DefaultValuesHandler
      .getDefaultMinimalRelevance(model);
    }
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    String requestURL;
    if (ehRequest.getRequestURI().getPath().startsWith("/remote")) {
      requestURL = new EnhancedRequestURI(ehRequest.getRequestURI())
          .getParameter("url");
    } else {
      requestURL = ehRequest.getRequestURLWithoutParams().toString();
    }
    log.info("looking up resource: " + requestURL);
    Resource resource = model.createResource(requestURL);
    if (!isPermitted(resource)) {
      throw new AccessControlException(
          "No suitable permission to access topic");
    }
    if (!model.containsResource(resource)) {
      chain.doNext(request, response);
      return;
    }

    if ((!resource.hasProperty(RDF.type, KNOBOT.CalendarTopic))) {
      chain.doNext(request, response);
      return;
    }
    checkLanguageAvailability(resource, ehRequest);
    /*
     * ItemsList itemsList = new ItemsListFactory(model)
     */
    // ItemsList itemsList = new ItemsList(resource, minimalRelevance);
    boolean onlyDirect = false;
    try {
      onlyDirect = "true".equals(request.getRequestURI()
          .getParameterValues("onlyDirect")[0]);
    } catch (Exception ex) {
    }

    boolean unOrdered = false;
    try {
      unOrdered = "true".equals(request.getRequestURI()
          .getParameterValues("unOrdered")[0]);
    } catch (Exception ex) {
    }
    RelationIterator itemIterator;
    itemIterator = new DirectRelationIterator(resource);
    if (!onlyDirect) {
      itemIterator = new IndirectRelationIterator(
          (CSRelationIterator) itemIterator, minimalRelevance);
    }
    if (!unOrdered) {
      itemIterator = new StrengthSortedRelationIterator(
          (CSRelationIterator) itemIterator);
    }
    /*
     * RelationIterator itemIterator = new IndirectRelationIterator(new
     * DirectRelationIterator( resource), minimalRelevance);
     */
    Model resultModel = PersonalHistory.update(resource); // ph updated
    // first to
    // avoid old
    // versions in
    // result (such
    // as if user is
    // maker of
    // item)
    resultModel.add(JenaUtil.getExpandedResource(resource, 1, true));
    try {
      Resource attachmentResource = resource.getProperty(
          ATTACH.attachments).getResource();
      resultModel
          .add(JenaUtil.getExpandedResource(attachmentResource, 2));
    } catch (NullPointerException ex) {

    }
    try {
      Resource requiresResource = resource.getProperty(
          AUTHORIZATION.requires).getResource();
      resultModel.add(JenaUtil.getExpandedResource(requiresResource, 2));
    } catch (NullPointerException ex) {
    }
    int from = 1;
    int till = 10000;
    Date now = new Date();
   
    Date startDate;
    String[] startDateParamValues = ehRequest.getRequestURI()
        .getParameterValues("startDate");
    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)) {
        relevantMonths.add(new Month(startDate, endDate));
        endDate = getEndOfMonth(new Date(now.getTime() + 15*24*60*60*1000));
        relevantMonths.add(new Month(endDate));
      }
    }   
    Set relevantAreas = new HashSet();
    relevantMonths.add(new Month(startDate));
    String[] regionParamValues = ehRequest.getRequestURI()
      .getParameterValues("region");
    Resource area;
    if (regionParamValues != null) {
      area = getRegion(regionParamValues[0]);
    } else {
View Full Code Here

    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      if (body.getParameter("action_ChangeItem") != null) {
        EnhancedRequest ehRequest = new EnhancedRequest(request);
        Resource target = model.createResource(ehRequest
            .getRequestURLWithoutParams().toString());
        setItemOrTopicProperties(target, ehRequest);
      }
    } catch (ClassCastException e) {
      log.warn("eception in changeItemHanndler", e);
View Full Code Here

      body = (MultiPartBody) request.getBody();
      if (body.getParameter("action_SetStrength") != null) {
        MultiPartBody requestBody = (MultiPartBody) request.getBody();
        String strengthString = requestBody.getParameter("strength");
        String childStrengthString = requestBody.getParameter("childStrength");
        Resource target = model.createResource(new EnhancedRequest(
            request).getRequestURLWithoutParams().toString());
        perform(target, request, strengthString, childStrengthString);
        if ("background".equals(body.getParameter("postMethod"))) {
            //response.setBody(new StringReader("<p>Commited</p>"));
            return;
        }
      }
      if (body.getParameter("action_SetStrengthToZero") != null) {
        Resource target = model.createResource(new EnhancedRequest(
            request).getRequestURLWithoutParams().toString());
        perform(target, request, "0", "0");
        if ("background".equals(body.getParameter("postMethod"))) {
            //response.setBody(new StringReader("<p>Commited</p>"));
            return;
View Full Code Here

   * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.wrhapi.Request,
   *      org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    MultiPartBody body = (MultiPartBody) request.getBody();
    String codeOrig = body.getParameter("codeOrig");
    String serializedModel = body.getParameter("model");
    Model importing = ModelFactory.createDefaultModel();
    importing.read(new StringReader(serializedModel), ehRequest
        .getRequestURLWithoutParams().toString(), "RDF/XML")
    if (codeOrig != null) {
      Resource resOrig = getCountryByCode(codeOrig);
      resOrig.removeProperties();
    }
View Full Code Here

    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      if (body.getParameter("action_NewRelation") != null) {
        Resource target = model.createResource(new EnhancedRequest(
            request).getRequestURLWithoutParams().toString());
        perform(target, request);
      }
    } catch (ClassCastException e) {
    }
View Full Code Here

        chain.doNext(request, response);
        return;
      }
    }
    String aggregatedParam = body.getParameter("channel");
    Resource relationSource = model.createResource(new EnhancedRequest(
        request).getFullRequestURL().toString());
    String aggregatedURL;
    try {
      aggregatedURL = new URL(new URL(relationSource.getURI()),
          aggregatedParam).toString();
View Full Code Here

    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      if (body.getParameter("action_DeleteItem") != null) {
        Resource target = model.createResource(new EnhancedRequest(
            request).getFullRequestURL().toString());
        perform(target, request);
      }
    } catch (ClassCastException e) {
    }
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 {
        Model resultModel = ModelFactory.createDefaultModel();
        EnhancedRequest ehRequest = new EnhancedRequest(request);
    String requestURL;
    if (ehRequest.getRequestURI().getPath().startsWith("/remote")) {
      requestURL = new EnhancedRequestURI(ehRequest.getRequestURI())
          .getParameter("url");
    } else {
      requestURL = ehRequest.getRequestURLWithoutParams().toString();
    }
    log.info("looking up resource: " + requestURL);
    Resource notebook = model.createResource(requestURL);
    addConcept(notebook, resultModel);
        response.setBody(resultModel);
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.util.EnhancedRequest

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.