View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.
15   */
16  package org.kuali.common.util.execute;
17  
18  import java.io.File;
19  import java.util.List;
20  
21  import org.kuali.common.util.Assert;
22  import org.kuali.common.util.LocationUtils;
23  import org.kuali.common.util.nullify.NullUtils;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  @Deprecated
28  public abstract class AbstractCopyLocationsExecutable implements Executable {
29  
30  	private static final Logger logger = LoggerFactory.getLogger(AbstractCopyLocationsExecutable.class);
31  
32      public AbstractCopyLocationsExecutable() {
33          this(null, null);
34      }
35  
36      public AbstractCopyLocationsExecutable(String locationListing, File directory) {
37          this.locationListing = locationListing;
38          this.directory = directory;
39      }
40  
41  	String locationListing;
42  	File directory;
43  
44  	protected abstract List<File> getFiles(List<String> locations);
45  
46  	@Override
47  	public void execute() {
48  		if (NullUtils.isNullOrNone(locationListing)) {
49  			logger.info("Skipping execution.  Location listing [{}]", locationListing);
50  			return;
51  		}
52  		Assert.notNull(locationListing);
53  		Assert.notNull(directory);
54  		Assert.isTrue(LocationUtils.exists(locationListing));
55  		logger.info("Copying [{}] -> [{}]", locationListing, LocationUtils.getCanonicalPath(directory));
56  		List<String> locations = LocationUtils.getLocations(locationListing);
57  		List<File> files = getFiles(locations);
58  		LocationUtils.copyLocationsToFiles(locations, files);
59  		logger.info("Copied {} files", locations.size());
60  	}
61  
62  	public String getLocationListing() {
63  		return locationListing;
64  	}
65  
66  	public void setLocationListing(String locationListing) {
67  		this.locationListing = locationListing;
68  	}
69  
70  	public File getDirectory() {
71  		return directory;
72  	}
73  
74  	public void setDirectory(File directory) {
75  		this.directory = directory;
76  	}
77  }