// Path: src/main/java/io/playpen/core/p3/IPackageStep.java
// public interface IPackageStep {
//     String getStepId();
// 
//     boolean runStep(P3Package p3, PackageContext ctx, JSONObject config);
// }
// 
// Path: src/main/java/io/playpen/core/p3/P3Package.java
// @Data
// @Log4j2
// public class P3Package {
// 
//     @Data
//     public static class PackageStepConfig {
//         IPackageStep step;
//         JSONObject config;
//     }
// 
//     @Data
//     public static class P3PackageInfo {
//         private String id;
//         private String version;
// 
//         @Override
//         public boolean equals(Object other) {
//             if(other instanceof P3PackageInfo) {
//                 P3PackageInfo o = (P3PackageInfo)other;
//                 return id.equals(o.getId()) && version.equals(o.getVersion());
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public int hashCode() {
//             return id.hashCode() ^ version.hashCode();
//         }
//     }
// 
//     private String localPath;
// 
//     private boolean resolved;
// 
//     // ALWAYS call calculateChecksum() before using this!
//     private String checksum = null;
// 
//     private String id;
// 
//     private String version;
// 
//     private List<P3Package> dependencies = new ArrayList<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private Set<String> attributes = new HashSet<>();
// 
//     private Map<String, String> strings = new HashMap<>();
// 
//     private List<PackageStepConfig> provisionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> executionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> shutdownSteps = new ArrayList<>();
// 
//     /**
//      * Checks to make sure required fields are filled. Does not check resolution status!
//      */
//     public boolean validate() {
//         if(id == null || id.isEmpty() || version == null || version.isEmpty())
//             return false;
// 
//         for(P3Package p3 : dependencies)
//         {
//             if(!p3.validate())
//                 return false;
//         }
// 
//         return true;
//     }
// 
//     public void calculateChecksum() throws PackageException {
//         calculateChecksum(false);
//     }
// 
//     public synchronized void calculateChecksum(boolean force) throws PackageException {
//         if (!force && checksum != null)
//             return;
// 
//         if (!resolved)
//             throw new PackageException("Cannot calculate checksum on unresolved package");
// 
//         if (localPath == null || localPath.isEmpty())
//             throw new PackageException("Cannot calculate checksum on package with invalid localPath");
// 
//         log.debug("Recalculating checksum on " + id + " (" + version + ")");
// 
//         try {
//             checksum = AuthUtils.createPackageChecksum(localPath);
//         } catch (IOException e) {
//             throw new PackageException("Unable to calculate checksum from package file", e);
//         }
//     }
// }
// 
// Path: src/main/java/io/playpen/core/p3/PackageContext.java
// @Data
// public class PackageContext {
//     private PackageManager packageManager;
// 
//     private File destination;
// 
//     private Map<String, String> properties = new HashMap<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private List<P3Package> dependencyChain = new ArrayList<>();
// 
//     private Object user;
// }
// 
// Path: src/main/java/io/playpen/core/utils/STUtils.java
// public class STUtils {
// 
//     public static void buildSTProperties(P3Package p3, PackageContext ctx, ST template) {
//         template.add("package-id", p3.getId());
//         template.add("package-version", p3.getVersion());
//         template.add("resources", ctx.getResources());
//         template.add("asset_path", Paths.get(Bootstrap.getHomeDir().getPath(), "assets").toFile().getAbsolutePath());
//         template.add("server_path", ctx.getDestination().getAbsolutePath());
// 
//         for(Map.Entry<String, String> entry : ctx.getProperties().entrySet()) {
//             template.add(entry.getKey(), entry.getValue());
//         }
// 
//         Map<String, String> versions = new HashMap<>();
//         for (P3Package p3Package : ctx.getDependencyChain()) {
//             versions.put(p3Package.getId(), p3Package.getVersion());
//         }
//         versions.put(p3.getId(), p3.getVersion());
// 
//         template.add("package_versions", versions);
//     }
// 
//     private STUtils() {}
// }


import io.playpen.core.p3.IPackageStep;
import io.playpen.core.p3.P3Package;
import io.playpen.core.p3.PackageContext;
import io.playpen.core.utils.STUtils;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.stringtemplate.v4.ST;
import java.io.File;
import java.io.IOException;
package io.playpen.core.p3.step;



@Log4j2
public class CopyStep implements IPackageStep {
    @Override
    public String getStepId() {
        return "copy-directory";
    }

    @Override
// Path: src/main/java/io/playpen/core/p3/IPackageStep.java
// public interface IPackageStep {
//     String getStepId();
// 
//     boolean runStep(P3Package p3, PackageContext ctx, JSONObject config);
// }
// 
// Path: src/main/java/io/playpen/core/p3/P3Package.java
// @Data
// @Log4j2
// public class P3Package {
// 
//     @Data
//     public static class PackageStepConfig {
//         IPackageStep step;
//         JSONObject config;
//     }
// 
//     @Data
//     public static class P3PackageInfo {
//         private String id;
//         private String version;
// 
//         @Override
//         public boolean equals(Object other) {
//             if(other instanceof P3PackageInfo) {
//                 P3PackageInfo o = (P3PackageInfo)other;
//                 return id.equals(o.getId()) && version.equals(o.getVersion());
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public int hashCode() {
//             return id.hashCode() ^ version.hashCode();
//         }
//     }
// 
//     private String localPath;
// 
//     private boolean resolved;
// 
//     // ALWAYS call calculateChecksum() before using this!
//     private String checksum = null;
// 
//     private String id;
// 
//     private String version;
// 
//     private List<P3Package> dependencies = new ArrayList<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private Set<String> attributes = new HashSet<>();
// 
//     private Map<String, String> strings = new HashMap<>();
// 
//     private List<PackageStepConfig> provisionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> executionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> shutdownSteps = new ArrayList<>();
// 
//     /**
//      * Checks to make sure required fields are filled. Does not check resolution status!
//      */
//     public boolean validate() {
//         if(id == null || id.isEmpty() || version == null || version.isEmpty())
//             return false;
// 
//         for(P3Package p3 : dependencies)
//         {
//             if(!p3.validate())
//                 return false;
//         }
// 
//         return true;
//     }
// 
//     public void calculateChecksum() throws PackageException {
//         calculateChecksum(false);
//     }
// 
//     public synchronized void calculateChecksum(boolean force) throws PackageException {
//         if (!force && checksum != null)
//             return;
// 
//         if (!resolved)
//             throw new PackageException("Cannot calculate checksum on unresolved package");
// 
//         if (localPath == null || localPath.isEmpty())
//             throw new PackageException("Cannot calculate checksum on package with invalid localPath");
// 
//         log.debug("Recalculating checksum on " + id + " (" + version + ")");
// 
//         try {
//             checksum = AuthUtils.createPackageChecksum(localPath);
//         } catch (IOException e) {
//             throw new PackageException("Unable to calculate checksum from package file", e);
//         }
//     }
// }
// 
// Path: src/main/java/io/playpen/core/p3/PackageContext.java
// @Data
// public class PackageContext {
//     private PackageManager packageManager;
// 
//     private File destination;
// 
//     private Map<String, String> properties = new HashMap<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private List<P3Package> dependencyChain = new ArrayList<>();
// 
//     private Object user;
// }
// 
// Path: src/main/java/io/playpen/core/utils/STUtils.java
// public class STUtils {
// 
//     public static void buildSTProperties(P3Package p3, PackageContext ctx, ST template) {
//         template.add("package-id", p3.getId());
//         template.add("package-version", p3.getVersion());
//         template.add("resources", ctx.getResources());
//         template.add("asset_path", Paths.get(Bootstrap.getHomeDir().getPath(), "assets").toFile().getAbsolutePath());
//         template.add("server_path", ctx.getDestination().getAbsolutePath());
// 
//         for(Map.Entry<String, String> entry : ctx.getProperties().entrySet()) {
//             template.add(entry.getKey(), entry.getValue());
//         }
// 
//         Map<String, String> versions = new HashMap<>();
//         for (P3Package p3Package : ctx.getDependencyChain()) {
//             versions.put(p3Package.getId(), p3Package.getVersion());
//         }
//         versions.put(p3.getId(), p3.getVersion());
// 
//         template.add("package_versions", versions);
//     }
// 
//     private STUtils() {}
// }


// Path: src/main/java/io/playpen/core/p3/step/CopyStep.java
import io.playpen.core.p3.IPackageStep;
import io.playpen.core.p3.P3Package;
import io.playpen.core.p3.PackageContext;
import io.playpen.core.utils.STUtils;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.stringtemplate.v4.ST;
import java.io.File;
import java.io.IOException;

package io.playpen.core.p3.step;



@Log4j2
public class CopyStep implements IPackageStep {
    @Override
    public String getStepId() {
        return "copy-directory";
    }

    @Override
    public boolean runStep(P3Package p3, PackageContext ctx, JSONObject config) {