示例#1
0
 public void addContentLocationForDataBean(DataBean bean, StorageMethod method, URL url)
     throws ContentLengthException, IOException {
   ContentLocation location = new ContentLocation(method, getHandlerFor(method), url);
   try {
     setOrVerifyContentLength(bean, getContentLength(location));
   } catch (IOException e) {
     throw new IOException("content length not available: " + e);
   } catch (ContentLengthException e) {
     try {
       DataManager manager = Session.getSession().getDataManager();
       String msg;
       msg =
           "Wrong content length for dataset "
               + bean.getName()
               + ". "
               + " In ContentLocation "
               + location.getUrl()
               + ", length is "
               + getContentLength(location)
               + " bytes. ";
       msg += "Content locations: ";
       for (ContentLocation loc : manager.getContentLocationsForDataBeanSaving(bean)) {
         msg += loc.getUrl() + " " + manager.getContentLength(loc) + " bytes, ";
       }
       throw new ContentLengthException(msg);
     } catch (IOException e1) {
       logger.error("another exception while handling " + Exceptions.getStackTrace(e), e);
     }
   }
   bean.addContentLocation(location);
 }
  @Override
  public List<DbSession> listRemoteSessions() throws FileBrokerException {

    try {
      HashMap<UUID, fi.csc.chipster.sessiondb.model.Session> sessions;
      sessions = sessionDbClient.getSessions();

      List<DbSession> dbSessions = new LinkedList<>();
      for (fi.csc.chipster.sessiondb.model.Session session : sessions.values()) {
        dbSessions.add(new DbSession(session.getSessionId().toString(), session.getName(), null));
      }

      return dbSessions;
    } catch (RestException e) {
      throw new FileBrokerException(Exceptions.getStackTrace(e));
    }
  }