private String formatHostForEdit(DavRepo davRepo) {
   if (davRepo.getPort() == 80) {
     return davRepo.getHostName();
   } else {
     return davRepo.getHostName() + ":" + davRepo.getPort();
   }
 }
Esempio n. 2
0
	@Action
	public void doSave() {
		System.out.println("doSave");
		if (!isValidSettings()) {
			return;
		}
		String jobName = userPanel.getAccountName() + "@" + userPanel.getHostName();
		Job jobToSave = this.job;
		Config c;
		if (jobToSave == null) {
			DavRepo davRepo = new DavRepo();
			List<Root> roots = new ArrayList<Root>();
			List<Repo> repos = new ArrayList<Repo>();
			repos.add(davRepo);
			jobToSave = new Job(jobName, repos, roots);
			jobToSave.setConfig(config);
			davRepo.setJob(jobToSave);

			config.getJobs().add(jobToSave);
			c = config;
		} else {
			c = jobToSave.getConfig();
		}
		scanService.cancelScan(); // if scanning, cancel it so new changes can take effect
		String accPath = c.getMediaLoungePath(userPanel.getAccountName());
		userPanel.save(accPath, jobToSave);
		backupLocations1.save("", jobToSave);
		jobToSave.getConfig().save();
		scanService.scan();
		_(QueueManager.class).setPaused(false);
		doClose();
	}
 private void saveRepo(String accPath, DavRepo davRepo) {
   String[] arr = txtHost.getText().split(":");
   davRepo.setHostName(arr[0]);
   if (arr.length > 1) {
     int port = Integer.parseInt(arr[1]);
     davRepo.setPort(port);
   } else {
     davRepo.setPort(80);
   }
   davRepo.setUser(txtAccountName.getText());
   davRepo.setPwd(txtPassword.getPassword());
   davRepo.setRootPath(accPath);
 }
 private void initRepo(DavRepo davRepo) {
   String hostName = formatHostForEdit(davRepo);
   this.txtHost.setText(hostName);
   this.txtAccountName.setText(davRepo.getUser());
   this.txtPassword.setText(davRepo.getPwd());
 }