]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/deploy/LocalFilesDeployment.java
a2e372dde04c2b0e0b2501f8019537af3bbec94e
1 package org
.argeo
.slc
.core
.deploy
;
4 import java
.io
.IOException
;
5 import java
.io
.InputStream
;
6 import java
.io
.OutputStream
;
9 import org
.apache
.commons
.io
.FileUtils
;
10 import org
.apache
.commons
.io
.IOUtils
;
11 import org
.argeo
.slc
.SlcException
;
12 import org
.springframework
.core
.io
.Resource
;
14 public class LocalFilesDeployment
implements Runnable
{
15 private String targetBase
= "";
16 private ResourceSet resourceSet
;
19 Map
<String
, Resource
> resources
= resourceSet
.listResources();
20 for (String relPath
: resources
.keySet()) {
21 File targetFile
= new File(targetBase
+ File
.separator
+ relPath
);
22 File parentDir
= targetFile
.getParentFile();
23 if (!parentDir
.exists())
26 Resource resource
= resources
.get(relPath
);
28 InputStream in
= null;
29 OutputStream out
= null;
31 in
= resource
.getInputStream();
32 out
= FileUtils
.openOutputStream(targetFile
);
33 IOUtils
.copy(in
, out
);
34 } catch (IOException e
) {
35 throw new SlcException("Cannot extract " + resource
+ " to "
38 IOUtils
.closeQuietly(in
);
39 IOUtils
.closeQuietly(out
);
44 public void setTargetBase(String targetBase
) {
45 this.targetBase
= targetBase
;
48 public void setResourceSet(ResourceSet resourceSet
) {
49 this.resourceSet
= resourceSet
;