private Location createLocation() {
    Location location = new Location();

    Policy policy = new Policy();

    policy.setActualAvailabilityStart(new DateTime(2012, 7, 3, 0, 10, 0, DateTimeZone.UTC));
    policy.setAvailabilityStart(new DateTime(2012, 7, 3, 0, 0, 0, DateTimeZone.UTC));
    policy.setAvailabilityEnd(new DateTime(2013, 7, 17, 0, 0, 0, DateTimeZone.UTC));

    location.setPolicy(policy);

    return location;
  }
Esempio n. 2
0
  public static Location locationFrom(
      String uri,
      String locationId,
      Map<String, String> lookup,
      Set<Country> availableCountries,
      DateTime lastUpdated,
      Platform platform) {
    Location location = new Location();
    location.setUri(uri);

    if (locationId != null) {
      // TODO new alias
      location.addAliasUrl(locationId);
    }
    location.setTransportType(TransportType.LINK);
    location.setLastUpdated(lastUpdated);

    // The feed only contains available content
    location.setAvailable(true);

    String availability = lookup.get(DC_TERMS_AVAILABLE);

    if (availability != null) {
      Matcher matcher = AVAILABILTY_RANGE_PATTERN.matcher(availability);
      if (!matcher.matches()) {
        throw new IllegalStateException(
            "Availability range format not recognised, was " + availability);
      }
      String txDate = lookup.get(DC_TX_DATE);
      Policy policy =
          new Policy()
              .withAvailabilityStart(
                  new DateTime(Strings.isNullOrEmpty(txDate) ? matcher.group(1) : txDate))
              .withAvailabilityEnd(new DateTime(matcher.group(2)));

      if (availableCountries != null) {
        policy.setAvailableCountries(availableCountries);
      }

      if (platform != null) {
        policy.setPlatform(platform);
      }

      location.setPolicy(policy);
    }
    return location;
  }
Esempio n. 3
0
 private Policy policyFor(WsAudioItem audioItem) {
   Policy policy = new Policy();
   for (String date :
       ImmutableList.of(
           audioItem.getAllowDownloadFrom(),
           audioItem.getInputDatetime(),
           audioItem.getLastAmendTimestamp())) {
     DateTime parsed = parse(date);
     if (parsed != null) {
       policy.setAvailabilityStart(parsed);
       break;
     }
   }
   policy.setAvailableCountries(ImmutableSet.of(Countries.ALL));
   policy.setRevenueContract(PRIVATE);
   return policy;
 }