Beispiel #1
0
 void setFormData(WObject.FormData formData) {
   if (!(formData.values.length == 0)) {
     List<String> attributes = new ArrayList<String>();
     attributes = new ArrayList<String>(Arrays.asList(formData.values[0].split(";")));
     if (attributes.size() == 6) {
       try {
         this.volume_ = Double.parseDouble(attributes.get(0));
       } catch (RuntimeException e) {
         this.volume_ = -1;
       }
       try {
         this.current_ = Double.parseDouble(attributes.get(1));
       } catch (RuntimeException e) {
         this.current_ = -1;
       }
       try {
         this.duration_ = Double.parseDouble(attributes.get(2));
       } catch (RuntimeException e) {
         this.duration_ = -1;
       }
       this.playing_ = attributes.get(3).equals("0");
       this.ended_ = attributes.get(4).equals("1");
       try {
         this.readyState_ = intToReadyState(Integer.parseInt(attributes.get(5)));
       } catch (RuntimeException e) {
         throw new WException(
             "WAbstractMedia: error parsing: " + formData.values[0] + ": " + e.toString());
       }
     } else {
       throw new WException("WAbstractMedia: error parsing: " + formData.values[0]);
     }
   }
 }
Beispiel #2
0
 private void forceReindexMetadata() {
   ArchivalUnit au = getAu();
   if (au == null) return;
   try {
     startReindexingMetadata(au, true);
   } catch (RuntimeException e) {
     log.error("Can't reindex metadata", e);
     errMsg = "Error: " + e.toString();
   }
 }
Beispiel #3
0
 private void doDisableMetadataIndexing() {
   ArchivalUnit au = getAu();
   if (au == null) return;
   try {
     disableMetadataIndexing(au, false);
   } catch (RuntimeException e) {
     log.error("Can't disable metadata indexing", e);
     errMsg = "Error: " + e.toString();
   }
 }
Beispiel #4
0
  private boolean startCrawl(ArchivalUnit au, boolean force, boolean deep)
      throws CrawlManagerImpl.NotEligibleException {
    CrawlManagerImpl cmi = (CrawlManagerImpl) crawlMgr;
    if (force) {
      RateLimiter limit = cmi.getNewContentRateLimiter(au);
      if (!limit.isEventOk()) {
        limit.unevent();
      }
    }
    cmi.checkEligibleToQueueNewContentCrawl(au);
    String delayMsg = "";
    String deepMsg = "";
    try {
      cmi.checkEligibleForNewContentCrawl(au);
    } catch (CrawlManagerImpl.NotEligibleException e) {
      delayMsg = ", Start delayed due to: " + e.getMessage();
    }
    Configuration config = ConfigManager.getCurrentConfig();
    int pri = config.getInt(PARAM_CRAWL_PRIORITY, DEFAULT_CRAWL_PRIORITY);

    CrawlReq req;
    try {
      req = new CrawlReq(au);
      req.setPriority(pri);
      if (deep) {
        int d = Integer.parseInt(formDepth);
        if (d < 0) {
          errMsg = "Illegal refetch depth: " + d;
          return false;
        }
        req.setRefetchDepth(d);
        deepMsg = "Deep (" + req.getRefetchDepth() + ") ";
      }
    } catch (NumberFormatException e) {
      errMsg = "Illegal refetch depth: " + formDepth;
      return false;
    } catch (RuntimeException e) {
      log.error("Couldn't create CrawlReq: " + au, e);
      errMsg = "Couldn't create CrawlReq: " + e.toString();
      return false;
    }
    cmi.startNewContentCrawl(req, null);
    statusMsg = deepMsg + "Crawl requested for " + au.getName() + delayMsg;
    return true;
  }
Beispiel #5
0
 private OAuthAccessToken parseJsonToken(HttpMessage response) {
   com.google.gson.JsonObject root = new com.google.gson.JsonObject();
   com.google.gson.JsonParseException pe = null;
   try {
     root =
         (com.google.gson.JsonObject) new com.google.gson.JsonParser().parse(response.getBody());
   } catch (com.google.gson.JsonParseException error) {
     pe = error;
   }
   boolean ok = root != null;
   if (!ok) {
     logger.error(
         new StringWriter().append("parseJsonToken(): ").append(pe.toString()).toString());
     throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badjson"));
   } else {
     if (response.getStatus() == 200) {
       try {
         String accessToken = root.get("access_token").getAsString();
         int secs = JsonUtils.orIfNullInt(root.get("expires_in"), -1);
         WDate expires = null;
         if (secs > 0) {
           expires = new WDate(new Date()).addSeconds(secs);
         }
         String refreshToken = JsonUtils.orIfNullString(root.get("refreshToken"), "");
         return new OAuthAccessToken(accessToken, expires, refreshToken);
       } catch (RuntimeException e) {
         logger.error(
             new StringWriter().append("token response error: ").append(e.toString()).toString());
         throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
       }
     } else {
       throw new OAuthProcess.TokenError(
           WString.tr(
               "Wt.Auth.OAuthService."
                   + JsonUtils.orIfNullString(root.get("error"), "missing error")));
     }
   }
 }