Package org.jayasoft.woj.server.data.model

Examples of org.jayasoft.woj.server.data.model.UpdateTimer


    DataSource getDataSource() {
        return DSManager.getInstance().getMasterDS();
    }
   
    protected Object[] getInsertParameters(Object o) {
        UpdateTimer r = (UpdateTimer) o;
        List parameters = new ArrayList();
        parameters.add(new Integer(r.getFrequency()));
        parameters.add(r.getLastDone());
        parameters.add(r.getFilePrefix());
        return parameters.toArray();
    }
View Full Code Here


        parameters.add(r.getFilePrefix());
        return parameters.toArray();
    }
   
    protected Object[] getUpdateParameters(Object o) {
      UpdateTimer r = (UpdateTimer) o;
        List parameters = new ArrayList();
        parameters.add(r.getLastDone());
        parameters.add(r.getFilePrefix());
        parameters.add(new Integer(r.getFrequency()));
        return parameters.toArray();
    }
View Full Code Here

    return result;
  }

  private void fillUploadMap(Map result, FTPFile[] ftpFs, UpdateTimer[] timers) {
    for (int i = 0; i < timers.length; i++) {
      UpdateTimer timer = timers[i];
      Collection toUpdate = new ArrayList();
      for (int j = 0; j < ftpFs.length; j++) {
        FTPFile file = ftpFs[i];
        if (matchForUpload(file.getName(), timer)) {
          toUpdate.add(file.getName());
View Full Code Here

      updateDir.mkdirs();
    }

    Set set = namesByTimer.keySet();
    for (Iterator iter = set.iterator(); iter.hasNext();) {
      final UpdateTimer timer = (UpdateTimer) iter.next();
      List list = (List) namesByTimer.get(timer);
      Collections.sort(list, TimerHelper.createFileNameComparator(timer));
      LOGGER.info("Threading update for timer : " + timer.getFilePrefix() + " : " + list.size() + " files concerned.");
      for (Iterator iterator = list.iterator(); iterator.hasNext();) {
        final String name = (String) iterator.next();
        Thread th = new Thread(new Runnable() {
          public void run() {
            try {
              FTPClient client = getFtpClient();
              File zip = new File(getFileContentService().getBaseDir() + "/" + UPDATE_ZIP_DIRECTORY + "/" + name);
              zip.createNewFile();
              FileOutputStream fos = new FileOutputStream(zip);
              client.retrieveFile(name, fos);
              fos.close();
              closeFtpClient(client);
              unThreadedUpdate(zip);
              LOGGER.info("Update complete - file : " + name + " - for timer : " + timer.getFilePrefix());
            } catch (IOException e) {
              LOGGER.error("Problem occured while updating from zip file.", e);
            }
          };
        });
        th.start();     
      }
      timer.setLastDone((String) list.get(list.size()-1));
    }
    LOGGER.info("Updating timer info");
    updateUpdateTimers((UpdateTimer[]) namesByTimer.keySet().toArray(new UpdateTimer[namesByTimer.keySet().size()]));
  }
View Full Code Here

  }
 
  public void updateUpdateTimers(UpdateTimer[] timers) {
    UpdateTimerDao dao = WOJServer.getInstance().getDataService().getUpdateTimerDao();
    for (int i = 0; i < timers.length; i++) {
      UpdateTimer timer = timers[i];
      dao.update(timer);
    }
  }
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.server.data.model.UpdateTimer

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.