示例#1
0
 @Override
 public void rescheduleTask(FindDownloadableTask<T> item) {
   if (mustReschedule && item.getDownloadable().getStatus() == DownloadableStatus.WANTED) {
     item.setMinDate(getNextDate(60 * 24));
     BackLogProcessor.getInstance().schedule(item, false);
   }
 }
示例#2
0
  protected void selectResult(SearchResult selectedResult) {
    searchResultDAO.save(
        selectedResult.getUrl(),
        selectedResult.getProviderName(),
        selectedResult.getProviderClass(),
        selectedResult.getReferer(),
        selectedResult.getSizeInMegs(),
        selectedResult.getTitle(),
        selectedResult.getType(),
        getDownloadable().getId(),
        selectedResult.getClientId());

    BackLogProcessor.getInstance()
        .schedule(new DownloadSearchResultTask(selectedResult, getDownloadable()), false);
  }
示例#3
0
  @GET
  @Path("{url : .+}")
  public Response get(@PathParam("url") String url) throws IOException {

    java.nio.file.Path path = LocalImageCache.getInstance().resolveLocal(url);
    if (!Files.isReadable(path) || Files.size(path) == 0) {

      if (url.endsWith(".jpg")) {

        String[] groups = RegExp.parseGroups(url, "([\\w]+)/([\\d]+)\\.[\\w]+");
        if (groups != null) {
          String type = groups[0];
          Long downloadableId = Long.parseLong(groups[1]);
          Downloadable instance = DownloadableFactory.getInstance().createInstance(downloadableId);

          if (instance != null) {
            FindDownloadableImageTask instanceTask =
                DynamoObjectFactory.createInstance(FindDownloadableImageTask.class, instance);
            if (instanceTask != null) {
              BackLogProcessor.getInstance().schedule(instanceTask, false);
            }
          }
        }

        InputStream in = this.getClass().getResourceAsStream("/ring.svg");
        return Response.ok(in).header("Content-Type", "image/svg+xml").build();
      }

      return Response.status(404).build();
    } else {

      Calendar calendar = Calendar.getInstance();
      calendar.add(Calendar.DAY_OF_MONTH, 2);

      InputStream in = Files.newInputStream(path, StandardOpenOption.READ);
      return Response.ok(in)
          .header("Content-Length", Files.size(path))
          .header("Content-Type", Files.probeContentType(path))
          .header("Expires", calendar.getTimeInMillis())
          .build();
    }
  }
示例#4
0
 @Override
 public void rescheduleTask(HTTPDownloadTask item) {
   if (isFailed()) {
     BackLogProcessor.getInstance().schedule(item, getNextDate(60), false);
   }
 }