Package org.w3c.jigsaw.frames

Examples of org.w3c.jigsaw.frames.HTTPFrame


  ResourceReference rr_root = ((httpd) getServer()).getRootReference();
  return getRealPath(path, rr_root, reference);
    }

    protected static String getFilePath(DirectoryResource dir) {
  HTTPFrame frame =
      (HTTPFrame)dir.getFrame("org.w3c.jigsaw.frames.HTTPFrame");
  String indexes[] = frame.getIndexes();
  if (indexes != null) {
      for (int i = 0 ; i < indexes.length ; i++) {
    String index = indexes[i];
    if ( index != null && index.length() > 0) {
        ResourceReference rr = dir.lookup(index);
View Full Code Here


  }
  String strcount = Integer.toString(count);
  // Set cookie with next value:
  FramedResource frame = (FramedResource) getResource();
  if (frame instanceof HTTPFrame) {
      HTTPFrame target = (HTTPFrame) frame;
      HttpSetCookieList setcookies = HttpFactory.makeSetCookieList(null);
      HttpSetCookie     setcookie  = setcookies.addSetCookie(NAME,
                   strcount);
      setcookie.setMaxAge(getCookieMaxAge());
      URL url = target.getURL(request);
      setcookie.setPath(url.getFile());
      setcookie.setDomain(url.getHost());
      reply.setSetCookie(setcookies);
      reply.addNoCache("Set-Cookie");
  }
View Full Code Here

          return;
      }
      try {
          res = rr_res.lock();
          if (res instanceof FileResource) {
        HTTPFrame httpFrame = (HTTPFrame)
            res.getFrame(
           Class.forName(
             "org.w3c.jigsaw.frames.HTTPFrame"));
        this.setValue(ATTR_CONTENT_LANGUAGE,
                httpFrame.getContentLanguage());
        this.setValue(ATTR_CONTENT_ENCODING,
                httpFrame.getContentEncoding());
        this.setValue(ATTR_CONTENT_TYPE,
                httpFrame.getContentType());
          }
      } catch (InvalidResourceException ex) {
          //nothing to do ;(
      } catch (ClassNotFoundException ex2) {
          //pfff
View Full Code Here

            zdr.delete();
        } catch (MultipleLockException ex) {};
        continue;
          }
      }
      HTTPFrame itsframe = null;
      if (http_class != null) {
          itsframe =
         (HTTPFrame) resource.getFrame(http_class);
      }
      if (itsframe != null) {
          // Icon first, if available
          String icon = itsframe.getIcon() ;
          if ( icon != null )
        g.append("<img src=\""+
           getIconDirectory() +"/" + icon+
           "\" alt=\"" + icon + "\">");
          // Resource's name with link:
          if (resource instanceof ContainerInterface)
        g.append("<a href=\""
           , URLEncoder.encode(name)
           , "/\">"+name+"</a>");
          else
        g.append("<a href=\""
           , URLEncoder.encode(name)
           , "\">"+name+"</a>");
          // resource's title, if any:
          String title = itsframe.getTitle();
          if ( title != null )
        g.append(" "+title);
          //size (if any)
          if (size != -1) {
        String s = null;
View Full Code Here

      String contentEncoding[] =
          request.getContentEncoding();
      //get the HTTPFrame.
      Class httpFrameClass =
          Class.forName("org.w3c.jigsaw.frames.HTTPFrame");
      HTTPFrame hframe = (HTTPFrame)
          resource.getFrame(httpFrameClass);
      if (hframe != null) {
          if ((contentLanguage != null) &&
        (contentLanguage.length > 0))
        hframe.setValue("content-language",
            contentLanguage[0]);
          if ((contentEncoding != null) &&
        (contentEncoding.length > 0))
        hframe.setValue("content-encoding",
            contentEncoding[0]);
      }
      return resource;
        } catch (Exception ex) {
      ex.printStackTrace() ;
View Full Code Here

        if (rrf == null) {
      throw new ResourceException("DirectoryResource has "+
                "no HTTPFrame");
        }
        try {
      HTTPFrame httpframe = (HTTPFrame) rrf.unsafeLock();
      if (p instanceof DirectoryResource)
          return httpframe.getDirectoryListing(request);
      else
          return httpframe.get(request);
        } catch (InvalidResourceException ex) {
      throw new ResourceException(
          "Invalid parent frame (lister):"+
          ex.getMessage());
        } finally {
View Full Code Here

    private void updateNonce() {
  updateNonce(getResource());
    }

    private synchronized void updateNonce(FramedResource fr) {
  HTTPFrame htf;
  if (fr instanceof HTTPFrame) {
      htf = (HTTPFrame) fr;
      try {
    MessageDigest md = MessageDigest.getInstance(getAlgorithm());
    md.update((new Date()).toString().getBytes());
    try {
        md.update(htf.getETag().getTag().getBytes());
    } catch (Exception ex) {
        // hum... try without it
        md.update(htf.getURLPath().getBytes());
    }
    byte b[] = md.digest();
    if (nonce != null)
        old_nonce = nonce;
    nonce = StringUtils.toHexString(b);
View Full Code Here

            + "valign=\"bottom\">");
      } else {
    buffer.append("<tr class=\"oddlist\" align=\"left\" "
            + "valign=\"bottom\">")
      }
      HTTPFrame itsframe = null;
      if (httpClass != null)
    itsframe = (HTTPFrame)resource.getFrame(httpClass);
      if (itsframe instanceof CvsFrame) {
    buffer.append("<td></td>");
      } else {
    buffer.append("<td>");
    buffer.append("<INPUT TYPE=\"CHECKBOX\" NAME=\"" + name
            + "\"> ");
    buffer.append("</td>");
      }
      buffer.append("<td>");
      if (itsframe != null) {
    String icon = itsframe.getIcon() ;
    if ( icon != null )
        buffer.append("<IMG SRC=\""+
          getIconDirectory() +"/" + icon+
          "\">");
    // Resource's name with link:
    buffer.append("<A HREF=\""+resource.getURLPath()+
            "\">"+name+"</A>");
    // resource's title, if any:
    String title = itsframe.getTitle();
    if (title != null) {
        buffer.append("</td><td>"+title);
    } else {
       buffer.append("</td><td>");
    }
    int clength = itsframe.getContentLength();
    if (clength != -1) {
        int kcl = clength / 1024;
        buffer.append("</td><td>[ " + kcl + " kB ]");
    } else {
        buffer.append("</td><td>-");
    }
    long clm = itsframe.getLastModified();
    if (clm != -1) {
        buffer.append("</td><td>"+ df.format(new Date(clm)));
    } else {
        buffer.append("</td><td>-");
    }
View Full Code Here

      // verify that the target resource is putable
      ResourceReference rr = request.getTargetResource();
      if (rr != null) {
    try {
        FramedResource target = (FramedResource) rr.lock();
        HTTPFrame frame = null;
        try {
      frame = (HTTPFrame) target.getFrame(
         Class.forName("org.w3c.jigsaw.frames.HTTPFrame"));
        } catch (ClassNotFoundException cex) {
      cex.printStackTrace();
      //big big problem ...
        }
        if (frame == null) // can't be putable
      return null;
        // now we can verify if the target resource is putable
        if (! frame.getPutableFlag()) {
      return null;
        }
        // and that the PUT can happen (taken from putFileResource
        int cim = frame.checkIfMatch(request);
        if ((cim == HTTPFrame.COND_FAILED)
      || (cim == HTTPFrame.COND_WEAK)
      || (frame.checkIfNoneMatch(request) ==
          HTTPFrame.COND_FAILED)
      || (frame.checkIfModifiedSince(request) ==
          HTTPFrame.COND_FAILED)
      || (frame.checkIfUnmodifiedSince(request) ==
          HTTPFrame.COND_FAILED)) {
      Reply r = request.makeReply(HTTP.PRECONDITION_FAILED);
      r.setContent("Pre-condition failed.");
      return r;
        }
View Full Code Here

      // verify that the target resource is putable
      ResourceReference rr = request.getTargetResource();
      if (rr != null) {
    try {
        FramedResource target = (FramedResource) rr.lock();
        HTTPFrame frame = null;
        try {
      frame = (HTTPFrame) target.getFrame(
         Class.forName("org.w3c.jigsaw.frames.HTTPFrame"));
        } catch (ClassNotFoundException cex) {
      cex.printStackTrace();
      //big big problem ...
        }
        if (frame == null) // can't be putable
      return null;
        // now we can verify if the target resource is putable
        if (! frame.getPutableFlag()) {
      return null;
        }
        // and that the PUT can happen (taken from putFileResource
        int cim = frame.checkIfMatch(request);
        if ((cim == HTTPFrame.COND_FAILED)
      || (cim == HTTPFrame.COND_WEAK)
      || (frame.checkIfNoneMatch(request) ==
          HTTPFrame.COND_FAILED)
      || (frame.checkIfModifiedSince(request) ==
          HTTPFrame.COND_FAILED)
      || (frame.checkIfUnmodifiedSince(request) ==
          HTTPFrame.COND_FAILED)) {
      Reply r = request.makeReply(HTTP.PRECONDITION_FAILED);
      r.setContent("Pre-condition failed.");
      return r;
        }
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.frames.HTTPFrame

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.