2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.core
.deploy
;
19 import java
.io
.IOException
;
21 import org
.apache
.commons
.io
.FileUtils
;
22 import org
.apache
.commons
.logging
.Log
;
23 import org
.apache
.commons
.logging
.LogFactory
;
24 import org
.argeo
.slc
.SlcException
;
25 import org
.argeo
.slc
.deploy
.VersioningDriver
;
28 * Synchronizes an URL to a local directory, taking into account versioning
29 * information if possible.
31 public class VersionedDirSync
implements Runnable
{
32 private final static Log log
= LogFactory
.getLog(VersionedDirSync
.class);
34 private VersioningDriver versioningDriver
;
37 private Boolean clean
= false;
39 private Boolean changed
= null;
45 log
.info("Clean " + dir
);
46 FileUtils
.deleteDirectory(dir
);
47 } catch (IOException e
) {
48 throw new SlcException("Cannot delete checkout directory "
53 log
.info("Checkout " + url
+ " to " + dir
);
54 changed
= versioningDriver
.checkout(url
, dir
, true);
55 if (log
.isDebugEnabled())
56 log
.debug("Synchronized " + url
+ " to " + dir
);
59 public void setVersioningDriver(VersioningDriver versioningDriver
) {
60 this.versioningDriver
= versioningDriver
;
63 public void setDir(File dir
) {
67 public void setUrl(String url
) {
71 /** Delete before checkout */
72 public void setClean(Boolean clean
) {
76 /** Whether last call has changed the directory */
77 public Boolean
getChanged() {
79 throw new SlcException("Sync has not run");