Copies the `cfg` files from `src/main/instances` to the Wisdom application directory.

@param mojo      the mojo
@param filtering the filtering support
@throws IOException if file cannot be copied
495134
public static void copyInstances(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering) throws IOException {
        File in = new File(mojo.basedir, Constants.INSTANCES_SRC_DIR);
        if (in.isDirectory()) {
            File out = new File(mojo.getWisdomRootDirectory(), Constants.APPLICATION_DIR);
            filterAndCopy(mojo, filtering, in, out);
        }
    }
825867
public void copyLatexOutputToOutputFolder( File texFile, File tempDirectory, File outputDirectory )
        throws MojoExecutionException, MojoFailureException
    {
        WildcardFileFilter fileFilter = new WildcardFileFilter( getFilesToCopy( texFile, LATEX_OUTPUT_FILES ) );
        copyLatexOutputToOutputFolder( texFile, tempDirectory, outputDirectory, fileFilter );
    }
581623
public static void copyStreamWithFilterSet(final InputStream in, final OutputStream out, final FilterSet set)
        throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
        String lSep = System.getProperty("line.separator");
        String line = reader.readLine();
        while (null != line) {
            writer.write(set.replaceTokens(line));
            writer.write(lSep);
            line = reader.readLine();
        }
        writer.flush();
    }
1204405
private void enhance(List<File> files) throws MojoExecutionException {
        Options opts = getOptions();

        // list of input files
        String[] args = getFilePaths(files);

        boolean ok;

        final ClassLoader original = Thread.currentThread().getContextClassLoader();
        try {
            if (!tmpClassLoader) {
                extendRealmClasspath();
            }

            ok = PCEnhancer.run(args, opts);
        } finally {
            // We may have change the TCCL, restore the original one
            Thread.currentThread().setContextClassLoader(original);
        }

        if (!ok) {
            throw new MojoExecutionException("The OpenJPA Enhancer tool detected an error, check log");
        }
    }
313376
public void addMappingFilter(String mapping, com.ibm.websphere.servlet.filter.IFilterConfig config){
        	context.addMappingFilter(mapping, config);
        }
645232
@SuppressWarnings({"UnusedDeclaration"})
    protected final void addFilterChain(String pattern, Key<? extends Filter>... keys) {
        filterChains.put(pattern, keys);
    }
286067
@Override
    public Archive<T> shallowCopy(Filter<ArchivePath> filter) {
        Validate.notNull(filter, "Filter must be specified");

        // Get the actual class type and make a shallow copy of the the underlying archive,
        // using the same underlying configuration
        final Class<T> actualClass = this.getActualClass();
        final Archive<?> underlyingArchive = this.getArchive();
        final Configuration existingConfig = ((Configurable) underlyingArchive).getConfiguration();
        final Domain domain = ShrinkWrap.createDomain(existingConfig);
        final ArchiveFactory factory = domain.getArchiveFactory();
        final Archive<T> newArchive = factory.create(actualClass, this.getName());
        final Map<ArchivePath, Node> contents = underlyingArchive.getContent();
        for (final ArchivePath path : contents.keySet()) {
            Asset asset = contents.get(path).getAsset();
            if (asset != null) {
                if(!filter.include(path)) {
                    continue;
                }
                newArchive.add(asset, path);
            }
        }
        return newArchive;
    }
307054
protected void copyJarsToStageDirectory() throws IOException {
        final String stagingDirectory = getDeploymentStagingDirectoryPath();
        info("");
        info(COPY_JARS + stagingDirectory);
        Utils.copyResources(
                getProject(),
                getSession(),
                getMavenResourcesFiltering(),
                getResources(),
                stagingDirectory);
        info(COPY_SUCCESS);
    }
1061560
protected void copyShareConfigCustom() throws MojoExecutionException {
        final String warOutputDir = getWarOutputDir(SHARE_WAR_PREFIX_NAME);
        final String distDir = warOutputDir + "/WEB-INF/classes/alfresco/web-extension/";
        String repoUrl = project.getProperties().getProperty("alfresco.repo.url");
        if (repoUrl == null) {
            project.getProperties().setProperty("alfresco.repo.url", "http://localhost:" + getPort() + "/alfresco");
        }

        getLog().info("Copying Share config custom to: " + distDir);

        executeMojo(
                plugin(
                        groupId("org.apache.maven.plugins"),
                        artifactId("maven-resources-plugin"),
                        version(MAVEN_RESOURCE_PLUGIN_VERSION)
                ),
                goal("copy-resources"),
                configuration(
                        element(name("outputDirectory"), distDir),
                        element(name("resources"),
                                element(name("resource"),
                                        element(name("directory"), "src/test/resources/share"),
                                        element(name("includes"),
                                                element(name("include"), "*.xml")
                                        ),
                                        element(name("filtering"), "true")
                                )
                        )
                ),
                execEnv
        );
    }
238153
private static void mergeFiles(File file, File destinationFile, String filter) throws IOException {
        String content = readFile(file);
        if (Checker.isNotEmpty(filter)) {
            content = content.replaceAll(filter, ValueConsts.EMPTY_STRING);
        }
        saveFile(destinationFile, content, ValueConsts.TRUE);
    }
270520
public void stop(AbstractWisdomMojo mojo) throws MojoExecutionException {
        File script = new File(mojo.getWisdomRootDirectory(), "chameleon.sh");
        if (!script.isFile()) {
            throw new MojoExecutionException("The 'chameleon.sh' file does not exist in " + mojo
                    .getWisdomRootDirectory().getAbsolutePath() + " - cannot stop the Wisdom instance");
        }

        // If there is a RUNNING_PID file, exit immediately.
        File pid = new File(mojo.getWisdomRootDirectory(), "RUNNING_PID");
        if (!pid.isFile()) {
            mojo.getLog().info("The RUNNING_PID file does not exist, are you sure Wisdom is running ?");
            return;
        }

        CommandLine cmdLine = new CommandLine(script);
        cmdLine.addArgument("stop");

        try {
            mojo.getLog().info("Stopping Wisdom Server using '" + cmdLine.toString() + "'.");
            // As we know which command line we are executing, we can safely execute the command.
            Runtime.getRuntime().exec(cmdLine.toStrings(), null, mojo.getWisdomRootDirectory()); //NOSONAR
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot stop Wisdom", e);
        }
    }
57332
@Override
    public void execute() throws MojoExecutionException {
        new WisdomExecutor().stop(this);
        File pid = new File(getWisdomRootDirectory(), "RUNNING_PID");
        if (WisdomExecutor.waitForFileDeletion(pid)) {
            getLog().info("Wisdom server stopped.");
        } else {
            throw new MojoExecutionException("The " + pid.getName() + " file still exists after having stopped the " +
                    "Wisdom instance - check log");
        }
    }
783819
protected void copyBundledPlugin(URL src, String fileName) throws IOException {
        LOGGER.log(FINE, "Copying {0}", src);
        fileName = fileName.replace(".hpi",".jpi"); // normalize fileNames to have the correct suffix
        String legacyName = fileName.replace(".jpi",".hpi");
        long lastModified = getModificationDate(src);
        File file = new File(rootDir, fileName);

        // normalization first, if the old file exists.
        rename(new File(rootDir,legacyName),file);

        // update file if:
        //  - no file exists today
        //  - bundled version and current version differs (by timestamp).
        if (!file.exists() || file.lastModified() != lastModified) {
            FileUtils.copyURLToFile(src, file);
            file.setLastModified(getModificationDate(src));
            // lastModified is set for two reasons:
            // - to avoid unpacking as much as possible, but still do it on both upgrade and downgrade
            // - to make sure the value is not changed after each restart, so we can avoid
            // unpacking the plugin itself in ClassicPluginStrategy.explode
        }

        // Plugin pinning has been deprecated.
        // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
    }
182127
public void execute(AbstractWisdomMojo mojo) throws MojoExecutionException {
        String version = PluginExtractor.getBuildPluginVersion(mojo, MAVEN_COMPILER_PLUGIN);
        if (version == null) {
            version = DEFAULT_VERSION;
        }
        final Plugin plugin = plugin(
                GROUP_ID,
                MAVEN_COMPILER_PLUGIN,
                version
        );

        Xpp3Dom configuration = PluginExtractor.getBuildPluginConfiguration(mojo, MAVEN_COMPILER_PLUGIN, COMPILE_GOAL);
        if (configuration == null) {
            Properties properties = mojo.project.getProperties();
            String source = properties.getProperty("maven.compiler.source", "1.7");
            String target = properties.getProperty("maven.compiler.target", "1.7");
            configuration = configuration(
                    element("compileSourceRoots", "${project.compileSourceRoots}"),
                    element("classpathElements", "${project.compileClasspathElements}"),
                    element("outputDirectory", "${project.build.outputDirectory}"),
                    element("projectArtifact", "${project.artifact}"),
                    element("generatedSourcesDirectory",
                            "${project.build.directory}/generated-sources/annotations"),
                    element("target", source),
                    element("source", target)
            );
        } else {
            mojo.getLog().debug("Loading maven-compiler-plugin configuration:");
            PluginExtractor.extractEligibleConfigurationForGoal(mojo, plugin, COMPILE_GOAL, configuration);
            mojo.getLog().debug(configuration.toString());

        }

        // Compile sources
        executeMojo(
                plugin,
                goal(COMPILE_GOAL),
                configuration,
                executionEnvironment(
                        mojo.project,
                        mojo.session,
                        mojo.pluginManager
                )
        );
    }
1307710
public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent )
	throws IOException {

		File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance );
		Utils.createDirectory( dir );

		if( fileNameToFileContent != null ) {
			for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) {

				File f = new File( dir, entry.getKey());
				Utils.createDirectory( f.getParentFile());

				ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue());
				Utils.copyStream( in, f );
			}
		}
	}
1237761
static void copy(final Configuration conf, final Arguments args
      ) throws IOException {
    DistCopier copier = getCopier(conf, args);
    
    if (copier != null) {
      try {
        JobClient client = copier.getJobClient();
        RunningJob job = client.submitJob(copier.getJobConf());
        try {
          if (!client.monitorAndPrintJob(copier.getJobConf(), job)) {
            throw new IOException("Job failed!");
          }
        } catch (InterruptedException ie) {
          Thread.currentThread().interrupt();
        }
        copier.finalizeCopiedFiles();
      } finally {
        copier.cleanupJob();
      }
    }
  }
828999
@Override
    public void filterWrite(NextFilter nextFilter, IoSession session,
            WriteRequest writeRequest) throws Exception {

        Object data = writeRequest.getMessage();

        if (data instanceof IoBuffer) {
            write(session, (IoBuffer) data);
        } else {
            throw new IllegalArgumentException(
                    "This filter should only buffer IoBuffer objects");
        }
    }