Package org.wymiwyg.wrhapi.util

Examples of org.wymiwyg.wrhapi.util.EnhancedRequest


  }

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

    EnhancedRequest ehRequest = new EnhancedRequest(request);
    String urlString = ehRequest
    .getRequestURLWithoutParams().toString();
    Resource requestResource = model.createResource(urlString);
    try {
    if (urlString.charAt(urlString.length()-1) != '/') {
      mkCol(requestResource, model.createResource(urlString+'/'));
View Full Code Here


        }
      }
    }
    URL refreshURL;
    try {
      refreshURL = new URL(new EnhancedRequest(req)
          .getRequestURLWithoutParams(), "/admin/refresh-cache");
      refreshURL.openStream().close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
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 {
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    if (request.getRequestURI().toString().equals("/admin/refresh-cache")) {
      templatesCache = Collections
          .synchronizedMap(new HashMap<TemplateKey, SoftReference<Templates>>());
      // response.setBody(new StringReader("Template cache reset"));
      chain.doNext(request, response);
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 serializedModel = body.getParameter("model");
        Model importing = ModelFactory.createDefaultModel();
        importing.read(new StringReader(serializedModel), ehRequest
                .getRequestURLWithoutParams().toString(), "RDF/XML");  
        FormModelPost.handleFormFiles(ehRequest.getRootURL(), importing,
                request, model, hashStore);
        InsertionPermissionChecker.check(importing, model);
        model.add(importing);
    }
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 {
    Resource target = model.createResource(new EnhancedRequest(request)
        .getRequestURLWithoutParams().toString());
    try {
      MultiPartBody body;
      body = (MultiPartBody) request.getBody();
      String contentType = body.getParameter("contentType");
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 {
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    URL requestURL = ehRequest.getRequestURLWithoutParams();
    Resource vPermDefinitions = model.createResource(requestURL.toString());
    Model resultModel = ModelFactory.createDefaultModel();
    resultModel.add(JenaUtil.getExpandedResource(vPermDefinitions,1));
    vPermDefinitions = (Resource) vPermDefinitions.inModel(resultModel);
    vPermDefinitions.addProperty(RDF.type, Definitions);
View Full Code Here

    } catch (ArrayIndexOutOfBoundsException e) {
      throw new HandlerException("no go parameter specified");
    } catch (NullPointerException e) {
      throw new HandlerException("no go parameter specified");
    }
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    Model resultModel = ModelFactory.createDefaultModel();
    // URL test = getClass().getResource("selection.rdf");
    // resultModel.read(getClass().getResourceAsStream("selection.rdf"),
    // "");
    resultModel.read(getClass().getResource("selection.rdf").toString());
    Resource mainFromFile = resultModel.listSubjectsWithProperty(RDF.type,
        RSS.channel).nextResource();
    Resource main = resultModel.createResource(ehRequest.getFullRequestURL().toString());
    JenaUtil.replace(resultModel, mainFromFile, main);

    /*
     * String resourceURL = go + "_unavailable"; //
     * request.getRequestURL().toString(); Resource result =
     * resultModel.createResource(resourceURL, RSS.channel);
     * result.addProperty(RSS.title, "Language Selection");
     * result.addProperty( RSS.description, "Unfortunately the requested
     * resource is available only in the following language(s):");
     * result.addProperty( RSS.title,
     * resultModel.createLiteral("Sprachwahl", "de")); result.addProperty(
     * RSS.description, resultModel.createLiteral( "Leider ist die
     * gew??nschte Ressource nur in folgender/folgenden Sprache(n)
     * verf??gbar:",
     */
    Seq linkSeq = resultModel.createSeq();
    URL requestURL = ehRequest.getFullRequestURL();
    /*
     * StringBuffer targetLinkBuffer = new
     * StringBuffer(ehRequest.getRootURL() .toString());
     * targetLinkBuffer.append("/languageSetter?go="); try {
     * targetLinkBuffer.append(URLEncoder.encode(go, "utf-8")); } catch
View Full Code Here

  private static final Log log = LogFactory.getLog(CookieLangFilter.class);
  //private final CookieLangSetter cookieLangSetter = new CookieLangSetter();

  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    EnhancedRequest ehRequest = new EnhancedRequest(request);
   
    String cookieValue = getCookieValue(ehRequest);
    if ((cookieValue != null) && (!cookieValue.equals(""))) {
      request = new RequestWrapper(ehRequest, cookieValue);
    } else {
      //silly, this is set only because adobe reader < 7 used together with Internet Explorer does not sent the accept-language header
      List languagesForCookie = new ArrayList();
      AcceptLanguagesIterator langIter = ehRequest.getAcceptLanguages();
      while (langIter.hasNext()) {
        languagesForCookie.add(langIter.nextAcceptLanguageHeader().getLocaleRange());
      }
      CookieLangSetter.setCookieLang(response, languagesForCookie);
    }
    try {
      cookieValue = CookieLangSetter.setCookieLangFromParams(request, response);
      request = new RequestWrapper(ehRequest, cookieValue);
    } catch (CookieLangSetter.MissingParameterException ex) {
      //to nothing
    }
    try {
      chain.doNext(request, response);
    } catch (LanguageUnavailableHandlerException e) {
      response.setResponseStatus(ResponseStatus.MULTIPLE_CHOICES);
      StringBuffer redirect = new StringBuffer();
      redirect.append("/languageChooser?");

      String[] available = e.getLanguageUnavailableException()
          .getAvailableLocales();
      if (available.length == 0) {
        log.error("LanguageUnavailableException without alternative langugaes", e);
        throw new RuntimeException(e);
      }
      for (int i = 0; i < available.length; i++) {
        if (i > 0) {
          redirect.append('&');
        }
        redirect.append("available=" + available[i]);
      }
      String selfURL = ehRequest.getFullRequestURL().toString();
      //TODO remove possible language-extensions
      try {
        redirect.append("&go=" + URLEncoder.encode(selfURL, "UTF-8"));
      } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
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(final Request request, final Response response,
      final HandlerChain chain) throws HandlerException {
    final EnhancedRequest ehRequest = new EnhancedRequest(request);
    LoginContext loginContext;
    boolean httpLoginForced = false;
    if (noAdminUserConfigured) {
      noAdminUserConfigured = !isAdminExisting();

      if (noAdminUserConfigured && initialConfiguratorAvailable) {
        String path = request.getRequestURI().getPath();
        if (path.equals("/admin/initial-configuration")
            || path.equals("/admin/refresh-cache")
            || (path.startsWith("/stylesheets/"))
            || (path.startsWith("/images/"))
            || (path.startsWith("/scripts/"))) {
          chain.doNext(request, response);
          return;
        }
        EnhancedResponse ehResponse = new EnhancedResponse(response);
        ehResponse.sendRedirect("/admin/initial-configuration");
        return;
      }
    }
    try {
     
      try {
        httpLoginForced = request.getRequestURI().getParameterValues(
            "forceHttpLogin")[0].equals("true");
      } catch (Exception ex) {
      }
      CallbackHandler callbackHandler;
      if (useCookieLogin && !httpLoginForced) {
        callbackHandler = new CookieCallBackHandler(ehRequest, response);
      } else {
        callbackHandler = new WebCallBackHandler(request);
      }

      loginContext = new LoginContext(servletContextName, callbackHandler);
    } catch (LoginException e) {
      logger.error("Initializing LoginContext", e);
      throw new RuntimeException(e.toString());
    }
    try {
      loginContext.login();

    } catch (LoginException e) {

    }
    try {
      Subject subject = loginContext.getSubject();
      Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
        public Object run() throws Exception {
          // setting the policy only in the init method causes the
          // current ProtectionDomain to
          // be cached, i.E. all checks from classes within the
          // current classpath entry to authorized
          Policy.setPolicy(new RPolicy());
          boolean isAdmin = false;
          try {
            AccessController.checkPermission(new RPermission(
                AUTHORIZATION.admin));
            isAdmin = true;
          } catch (Exception e) {
          }
          if (!isAdmin) {
            AccessControlFilter.checkPermssionOnResource(model
                .createResource(ehRequest
                    .getRequestURLWithoutParams()
                    .toString()));
          }
          Request requestNoLoginParam = checkLoginRequested(request);
          chain.doNext(requestNoLoginParam, response);
          return null;
        }
      }, null);
    } catch (AccessControlException e) {
      // Authentication failed.
      logger.debug("AccessControlException, will prompt for login", e);
      if (useCookieLogin  && !httpLoginForced
          && !ehRequest.getMethod().equals(Method.POST)
          && !ehRequest.getMethod().equals(Method.PUT)
          && !ehRequest.getMethod().equals(Method.MKCOL)
          && !ehRequest.getMethod().equals(Method.PROPFIND)) {
        EnhancedResponse ehResponse = new EnhancedResponse(response);
        try {
          ehResponse.sendRedirect("/login?target="
              + URLEncoder.encode(ehRequest.getFullRequestURL()
                  .toString(), "utf-8"));
        } catch (UnsupportedEncodingException e1) {
          throw new RuntimeException(e1);
        }
      } else {
View Full Code Here

   * @throws HandlerException
   */
  private void handlePut(Request request, Response response,
      HandlerChain chain) throws HandlerException {
    // TODO finish
    String requestURLString = new EnhancedRequest(request)
        .getRequestURLWithoutParams().toString();
    int lastDot = requestURLString.lastIndexOf('.');
    int lastSlash = requestURLString.lastIndexOf('/');
    // String extension
    if (lastDot > lastSlash) {
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.