Package org.restlet.data

Examples of org.restlet.data.Tag


  protected void addCacheableMediaTypes(Collection<MediaType> mediaTypes) {
    CacheInfo cacheInfo = getCacheInfo();

    if (cacheInfo != null) {
      Date lastModified = cacheInfo.getLastModified();
      Tag entityTag = cacheInfo.getEntityTag();

      for (MediaType mediaType : mediaTypes) {
        getVariants().add(new RepresentationInfo(mediaType, lastModified, entityTag));
      }
    }
View Full Code Here


   * Methods *
   *---------*/

  public synchronized void processUpdate() {
    lastModified = new Date();
    entityTag = new Tag(tagPrefix + "_" + Long.toHexString(++version));
  }
View Full Code Here

                    result.setUnmodifiedSince(ifUnmodifiedSince);
                }

                // Set the If-Match tags
                List<Tag> match = null;
                Tag current = null;
                if (ifMatchHeader != null) {
                    try {
                        HeaderReader<Object> hr = new HeaderReader<Object>(
                                ifMatchHeader);
                        String value = hr.readRawValue();

                        while (value != null) {
                            current = Tag.parse(value);

                            // Is it the first tag?
                            if (match == null) {
                                match = new ArrayList<Tag>();
                                result.setMatch(match);
                            }

                            // Add the new tag
                            match.add(current);

                            // Read the next token
                            value = hr.readRawValue();
                        }
                    } catch (Exception e) {
                        this.context.getLogger().log(
                                Level.INFO,
                                "Unable to process the if-match header: "
                                        + ifMatchHeader);
                    }
                }

                // Set the If-None-Match tags
                List<Tag> noneMatch = null;
                if (ifNoneMatchHeader != null) {
                    try {
                        HeaderReader<Object> hr = new HeaderReader<Object>(
                                ifNoneMatchHeader);
                        String value = hr.readRawValue();

                        while (value != null) {
                            current = Tag.parse(value);

                            // Is it the first tag?
                            if (noneMatch == null) {
                                noneMatch = new ArrayList<Tag>();
                                result.setNoneMatch(noneMatch);
                            }

                            noneMatch.add(current);

                            // Read the next token
                            value = hr.readRawValue();
                        }
                    } catch (Exception e) {
                        this.context.getLogger().log(
                                Level.INFO,
                                "Unable to process the if-none-match header: "
                                        + ifNoneMatchHeader);
                    }
                }

                if (ifRangeHeader != null && ifRangeHeader.length() > 0) {
                    Tag tag = Tag.parse(ifRangeHeader);
                    if (tag != null) {
                        result.setRangeTag(tag);
                    } else {
                        Date date = HeaderReader.readDate(ifRangeHeader, false);
                        result.setRangeDate(date);
View Full Code Here

        final Response response = put("date", null, conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }

    public void testDateAndEntityTag3Get() throws Exception {
        final Conditions conditions = createConditions(BEFORE, new Tag(
                "shkhsdk"));
        final Response response = get("date", conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }
View Full Code Here

        final Response response = get("date", conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }

    public void testDateAndEntityTag3Put() throws Exception {
        final Conditions conditions = createConditions(BEFORE, new Tag(
                "shkhsdk"));
        final Response response = put("date", null, conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }
View Full Code Here

        assertEquals(PREC_FAILED, response.getStatus());
    }

    public void testDateAndEntityTag4Get() throws Exception {
        final Conditions conditions = createConditions(AFTER,
                new Tag("shkhsdk"));
        final Response response = get("date", conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }
View Full Code Here

        assertEquals(PREC_FAILED, response.getStatus());
    }

    public void testDateAndEntityTag4Put() throws Exception {
        final Conditions conditions = createConditions(AFTER,
                new Tag("shkhsdk"));
        final Response response = put("date", null, conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }
View Full Code Here

        assertEquals(getDatastoreETag(), response.getEntity().getTag());
        assertNotNull(response.getEntity().getText());
        assertTrue(response.getEntity().getSize() > 0);

        conditions = new Conditions();
        conditions.setMatch(TestUtils.createList(new Tag("affer")));
        response = get("date", conditions);
        assertEquals(PREC_FAILED, response.getStatus());
    }
View Full Code Here

        conditions.setNoneMatch(TestUtils.createList(getDatastoreETag()));
        Response response = get("date", conditions);
        assertEquals(Status.REDIRECTION_NOT_MODIFIED, response.getStatus());

        conditions = new Conditions();
        conditions.setNoneMatch(TestUtils.createList(new Tag("affer")));
        response = get("date", conditions);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
    }
View Full Code Here

                result.setUnmodifiedSince(ifUnmodifiedSince);
            }

            // Set the If-Match tags
            List<Tag> match = null;
            Tag current = null;
            if (ifMatchHeader != null) {
                try {
                    HeaderReader<Object> hr = new HeaderReader<Object>(
                            ifMatchHeader);
                    String value = hr.readRawValue();

                    while (value != null) {
                        current = Tag.parse(value);

                        // Is it the first tag?
                        if (match == null) {
                            match = new ArrayList<Tag>();
                            result.setMatch(match);
                        }

                        // Add the new tag
                        match.add(current);

                        // Read the next token
                        value = hr.readRawValue();
                    }
                } catch (Exception e) {
                    this.context.getLogger().log(
                            Level.INFO,
                            "Unable to process the if-match header: "
                                    + ifMatchHeader);
                }
            }

            // Set the If-None-Match tags
            List<Tag> noneMatch = null;
            if (ifNoneMatchHeader != null) {
                try {
                    HeaderReader<Object> hr = new HeaderReader<Object>(
                            ifNoneMatchHeader);
                    String value = hr.readRawValue();

                    while (value != null) {
                        current = Tag.parse(value);

                        // Is it the first tag?
                        if (noneMatch == null) {
                            noneMatch = new ArrayList<Tag>();
                            result.setNoneMatch(noneMatch);
                        }

                        noneMatch.add(current);

                        // Read the next token
                        value = hr.readRawValue();
                    }
                } catch (Exception e) {
                    this.context.getLogger().log(
                            Level.INFO,
                            "Unable to process the if-none-match header: "
                                    + ifNoneMatchHeader);
                }
            }

            if (ifRangeHeader != null && ifRangeHeader.length() > 0) {
                Tag tag = Tag.parse(ifRangeHeader);

                if (tag != null) {
                    result.setRangeTag(tag);
                } else {
                    Date date = HeaderReader.readDate(ifRangeHeader, false);
View Full Code Here

TOP

Related Classes of org.restlet.data.Tag

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.