- log.debug("Hello world " + arguments);
- String sourceUri = arguments.get("-i");
- DavexFsProvider fsProvider = new DavexFsProvider();
-// Map<String, String> params = new HashMap<String, String>();
-// params.put(KernelConstants.JACKRABBIT_REPOSITORY_URI, sourceUri);
-// params.put(KernelConstants.JACKRABBIT_REMOTE_DEFAULT_WORKSPACE, "main");
-// Repository repository;
-// try {
-// repository = new Jcr2davRepositoryFactory().getRepository(params);
-// if (repository == null)
-// throw new ArgeoJcrException("Remote Davex repository " + sourceUri + " not found");
-// Session session = repository.login();
-// if (log.isDebugEnabled())
-// log.debug("Opened JCR session to " + sourceUri);
-// JcrUtils.logoutQuietly(session);
-// } catch (RepositoryException e) {
-// throw new ArgeoJcrException("Cannot load " + sourceUri, e);
-// }
+ try {
+ URI sourceUri = new URI(arguments.get("-i"));
+ URI targetUri = new URI(arguments.get("-o"));
+ FileSystemProvider sourceFsProvider = createFsProvider(sourceUri);
+ FileSystemProvider targetFsProvider = createFsProvider(targetUri);
+ Path sourceBasePath = sourceFsProvider.getPath(sourceUri);
+ Path targetBasePath = targetFsProvider.getPath(targetUri);
+ SyncFileVisitor syncFileVisitor = new SyncFileVisitor(sourceBasePath, targetBasePath);
+ ZonedDateTime begin = ZonedDateTime.now();
+ Files.walkFileTree(sourceBasePath, syncFileVisitor);
+ if (log.isDebugEnabled())
+ log.debug("Sync from " + sourceBasePath + " to " + targetBasePath + " took " + LangUtils.since(begin));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }