Example usage for java.util.regex Matcher quoteReplacement

List of usage examples for java.util.regex Matcher quoteReplacement

Introduction

In this page you can find the example usage for java.util.regex Matcher quoteReplacement.

Prototype

public static String quoteReplacement(String s) 

Source Link

Document

Returns a literal replacement String for the specified String .

Usage

From source file:org.etudes.jforum.view.admin.ImportExportAction.java

/**
 * parse export content resource reference urls
 * @param message//w  ww  .ja v a2  s  .  c om
 *             - messge   
 * @param ref
 *             - reference
 * @param parentPath
 *             - parent path
 * @return
 *             - modified content
 */
private String parseExportContentResourceUrls(String message, String ref, String parentPath) {
    ref = Validator.escapeUrl(ref);

    // file name with spaces doesn't have %20 for spaces
    // get file name
    /*This may not be needed as spaces have %20
     String fileName = ref.substring(ref.lastIndexOf("/") + 1);
            
    try
    {
       fileName = URLDecoder.decode(fileName, "UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
       if (logger.isWarnEnabled()) logger.warn("parseExportContentResourceUrls: " + e);
    }*/

    //ref = ref.substring(0, ref.lastIndexOf("/") + 1) + fileName;

    parentPath = Validator.escapeUrl(parentPath);

    StringBuffer sb = new StringBuffer();

    Pattern p = Pattern.compile("(src|href)[\\s]*=[\\s]*[\\\"'](/access" + ref + ")[\\\"']",
            Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.UNICODE_CASE);

    Matcher m = p.matcher(message);
    while (m.find()) {
        if (m.groupCount() == 2) {
            String refMatch = m.group(2);
            if (parentPath == null || parentPath.trim().length() == 0) {
                String siteId = ToolManager.getCurrentPlacement().getContext();
                refMatch = refMatch.substring(("/access/content/group/" + siteId).length() + 1);
            } else {

                if (refMatch.indexOf(parentPath) == -1) {
                    String siteId = ToolManager.getCurrentPlacement().getContext();
                    refMatch = refMatch.substring(("/access/content/group/" + siteId).length() + 1);

                    String pathRef[] = parentPath.split("/");

                    StringBuilder refPath = new StringBuilder();

                    for (int i = 0; i < (pathRef.length - 1); i++) {
                        refPath.append("../");
                    }
                    refMatch = refPath.toString() + refMatch;
                } else {
                    int index = refMatch.indexOf(parentPath);
                    refMatch = refMatch.substring(index + parentPath.length() + 1);
                }
            }

            /*String fileName1 = null;
            boolean escapeFilePath = false;
                    
            try
            {
               if (logger.isDebugEnabled()) logger.debug("parseExportContentResourceUrls: refMatch :"+ refMatch);
                              
               if (refMatch.lastIndexOf("/") != -1)
               {
                  fileName1 = refMatch.substring(refMatch.lastIndexOf("/")+1);
                  refMatch = refMatch.substring(0, refMatch.lastIndexOf("/")+1);
                          
                  if (logger.isDebugEnabled()) logger.debug("parseExportContentResourceUrls: refMatch sub string :"+ refMatch);
                          
                  fileName1 = URLDecoder.decode(fileName1, "UTF-8");
                  escapeFilePath = true;
               }
            }
            catch (UnsupportedEncodingException e)
            {
               if (logger.isWarnEnabled()) logger.warn("parseExportContentResourceUrls: " + e);
            }
                    
            if (escapeFilePath)
            {
               m.appendReplacement(sb, Matcher.quoteReplacement(m.group(1)+ "=\""+ refMatch + fileName1 +"\""));
            }
            else
               m.appendReplacement(sb, Matcher.quoteReplacement(m.group(1)+ "=\""+ refMatch + "\""));*/
            m.appendReplacement(sb, Matcher.quoteReplacement(m.group(1) + "=\"" + refMatch + "\""));

        }
    }
    m.appendTail(sb);

    return sb.toString();
}

From source file:lcmc.gui.resources.ServiceInfo.java

/** Removes this service from the crm with confirmation dialog. */
@Override//  ww  w.ja v  a  2  s.c  om
public void removeMyself(final boolean testOnly) {
    if (getService().isNew()) {
        removeMyselfNoConfirm(getBrowser().getDCHost(), testOnly);
        getService().setNew(false);
        getService().doneRemoving();
        return;
    }
    String desc = Tools.getString("ClusterBrowser.confirmRemoveService.Description");

    desc = desc.replaceAll("@SERVICE@", Matcher.quoteReplacement(toString()));
    if (Tools.confirmDialog(Tools.getString("ClusterBrowser.confirmRemoveService.Title"), desc,
            Tools.getString("ClusterBrowser.confirmRemoveService.Yes"),
            Tools.getString("ClusterBrowser.confirmRemoveService.No"))) {
        removeMyselfNoConfirm(getBrowser().getDCHost(), testOnly);
        removeInfo();
        getService().setNew(false);
    }
}

From source file:es.pode.publicacion.negocio.servicios.SrvPublicacionServiceImpl.java

private String imagePathGenerate(ManifestAgrega manifestAgrega, String sMec, String sLocalizador) {
    StringBuffer imagePathReturn = new StringBuffer();
    try {//from ww  w  .  java 2 s  .com
        DependentServerPropertiesItf properties = DependentServerProperties.getInstance();
        String serverOn = properties.getServerOn();

        String sLocalPath = this.localPathGenerate(manifestAgrega, sMec, sLocalizador, properties);
        logger.info(
                "Vamos a generar la imagen para el objeto cuya ruta en el servidor es [" + sLocalPath + "]");
        // Ahora debo saber en qu servidor estoy.
        if (logger.isDebugEnabled())
            logger.debug("El servidor es serverOn[" + serverOn + "]");
        AgregaProperties agregaProperties = AgregaPropertiesImpl.getInstance();

        // If we are dealing with a common image eg a static icon for a PDF,
        // the image path to return needs to be entirely different from that
        // generated for a resource thumbnail; see original code in the else
        // block for the latter.
        String localCommonPath = agregaProperties
                .getProperty(AgregaProperties.PROPERTY_IMAGE_COMMON_LOCAL_PATH);
        if (sLocalPath.contains(localCommonPath)) {
            String regex = "^.*" + Pattern.quote(localCommonPath);
            String replacement = Matcher.quoteReplacement(
                    agregaProperties.getProperty(AgregaProperties.PROPERTY_IMAGE_COMMON_PATH));

            imagePathReturn.append(sLocalPath.replaceFirst(regex, replacement));
        } else {
            // genero la URL de la imagen
            imagePathReturn.append(agregaProperties.getProperty(AgregaProperties.PROPERTY_IMAGE_APACHE_PATH));
            imagePathReturn.append(SrvPublicacionServiceImpl.FILE_SEPARATOR);
            //         Tenemos que aadir un codigo MD5 para impedir que en un mismo directorio haya mas de 32000 subdirectorios. El sistema de ficheros no lo 
            //         soporta. Lo hacemos por MEC, para valancear la carga entre los codigos que salgan.
            String md5 = EncriptacionUtiles.md5String(sMec).substring(0, 2);
            imagePathReturn.append(md5);
            imagePathReturn.append(SrvPublicacionServiceImpl.FILE_SEPARATOR);
            imagePathReturn.append(sMec);
            imagePathReturn.append(SrvPublicacionServiceImpl.FILE_SEPARATOR);
            imagePathReturn.append(sMec);
            imagePathReturn.append(agregaProperties.getProperty(AgregaProperties.PROPERTY_IMAGE_EXTENSION));
            if (logger.isDebugEnabled()) {
                logger.debug("Genero el objeto de intercambio Mec [" + sMec + "] localPath [" + sLocalPath
                        + "] serverOn [" + serverOn + "]");
            }
        }

        // genero el Objeto de intercambio
        OdeVO ode = new OdeVO(sMec, sLocalPath, serverOn);
        this.handleCreateImage4Ode(ode);
        if (logger.isDebugEnabled())
            logger.debug("La imagen a indexar es [" + imagePathReturn + "]");
    } catch (Exception ex) {
        logger.error("Se ha producido un error en imageGenerate", ex);
        // throw ex;
    }
    return imagePathReturn.toString();

}

From source file:org.etudes.jforum.view.admin.ImportExportAction.java

/**
 * parse embedded content resource urls//w  w w  . ja  v a2 s.  c  om
 * 
 * @param message
 *          - message
 * @param parentPath
 *          - parent path
 * @param embeddedRefs
 *          - embedded references
 * @return
 *          - modifed content
 */
private String parseEmbeddedContentResourceUrls(String message, String parentPath, Set<String> embeddedRefs) {
    /*try
    {
       parentPath = URLDecoder.decode(parentPath, "UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
       if (logger.isWarnEnabled()) logger.warn("parseEmbeddedContentResourceUrls: " + e);
    }*/

    StringBuffer sb = new StringBuffer();

    Pattern p = getEmbeddedContentResourcePattern();

    Matcher m = p.matcher(message);
    while (m.find()) {
        if (m.groupCount() == 2) {
            String ref = m.group(2);

            if (logger.isDebugEnabled())
                logger.debug("parseEmbeddedContentResourceUrls Before : ref : " + ref);

            //check for the resource in the unzipped file before changing the url
            // embeddedRefs.add(ref);

            boolean excludeParentPath = false;

            // for relative paths
            if (ref.startsWith("..")) {
                ref = ref.substring(ref.lastIndexOf("..") + "..".length() + 1);
                excludeParentPath = true;
            }

            if (logger.isDebugEnabled())
                logger.debug("parseEmbeddedContentResourceUrls After : ref : " + ref);

            String siteId = ToolManager.getCurrentPlacement().getContext();

            if (excludeParentPath) {
                m.appendReplacement(sb, Matcher.quoteReplacement(
                        m.group(1) + "=\"/access/content/group/" + siteId + "/" + ref + "\""));
                embeddedRefs.add(ref);
            } else {
                m.appendReplacement(sb, Matcher.quoteReplacement(m.group(1) + "=\"/access/content/group/"
                        + siteId + Validator.escapeUrl(parentPath) + "/" + ref + "\""));
                embeddedRefs.add(parentPath + "/" + ref);
            }
        }
    }
    m.appendTail(sb);

    return sb.toString();
}

From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java

/******************************************************************************************
 *  PRIVATE IMPLEMENTATION/*  w  ww  .  j ava 2  s  .c  o  m*/
 *  
 *  VCS CHECKIN/CHECKOUT [vcs_checkin, vcs_checkout]
 *  
 *  Specific implementation for a particular Version Control System (VCS)
 * 
 *******************************************************************************************/

// ***********************************************************************************************
// Execute a VCS Generalized Scripts  ** vcs_checkin_checkout_cvs vcs_checkin **
// ***********************************************************************************************
private void vcs_checkin_checkout__vcs_checkin(String resourcePath, String resourceType, String message,
        VcsStruct vcsStruct) throws CompositeException {
    /*
       # $1 -> Resource path        (e.g. /shared/MyFolder/My__View), using file system (encoded) names
       # $2 -> Resource type        (e.g. FOLDER, table etc.)
       # $3 -> Checkin message     (e.g. Adding MyFolder)
       # $4 -> VCS Workspace Folder (e.g. /tmp/workspaces/workspace_CIS)
    */
    String prefix = "vcs_checkin_checkout__vcs_checkin_" + vcsStruct.getVcsType();
    List<String> argList = new ArrayList<String>();
    List<String> envList = new ArrayList<String>();
    boolean initArgList = true;
    boolean preserveQuotes = false;
    String command = vcsStruct.getVcsExecCommand();
    String arguments = null;
    String execFromDir = null;
    String commandDesc = null;
    String commentFilePath = null;
    if (message == null)
        message = "";

    try {
        /********************************************
         * [CVS] vcs_checkin_checkout__vcs_checkin: 
         *     CVS=Concurrent Versions System
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("CVS")) {
            //cd "${Workspace}"
            //    e.g: vcsWorkspaceProject:  D:/PDTool/cvs_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            // 2012-10-29 mtinius: differentiate between folder and data_source
            if (resourceType.equalsIgnoreCase("FOLDER") || resourceType.equalsIgnoreCase("data_source")) {
                //------------------------------------------
                // Check in Folder
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
                //Derived from script:
                // cvs commit -m "${Message}" ${fullResourcePath} ${VCS_CHECKIN_OPTIONS}
                arguments = " commit -m \"" + message + "\" " + fullResourcePath + " "
                        + vcsStruct.getVcsCheckinOptions();
                // cvs commit -m ${Message} ./${resourcePath} ${VCS_CHECKIN_OPTIONS}
                // (previous code): arguments=" commit -m \""+message+"\" ./"+resourcePath + " " + vcsStruct.getVcsCheckinOptions();

                commandDesc = "    Commit folder changes to the CVS Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

            } else {
                //------------------------------------------
                // Check in File
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath + "_" + resourceType + ".cmf")
                        .replaceAll("//", "/");
                //Derived from script:
                // cvs commit -m "${Message}" ${fullResourcePath} ${VCS_CHECKIN_OPTIONS}
                arguments = " commit -m \"" + message + "\" " + fullResourcePath + " "
                        + vcsStruct.getVcsCheckinOptions();
                // cvs commit -m ${Message} ./${resourcePath}_${resourceType}.cmf ${VCS_CHECKIN_OPTIONS}
                // (previous code): arguments=" commit -m \""+message+"\" ./"+resourcePath+"_"+resourceType+".cmf" + " " + vcsStruct.getVcsCheckinOptions();

                commandDesc = "    Commit file changes to the CVS Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [P4] vcs_checkin_checkout__vcs_checkin:
         *      P4=Perforce
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("P4")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/p4_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            //------------------------------------------
            // Submit the changelist to perforce
            //------------------------------------------

            // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
            validateCheckinRequired(vcsStruct.getVcsCheckinOptions(), vcsStruct.getVcsCheckinOptionsRequired());

            /* 
             * mtinius: 2012-02-22 - modified command to include a concatenated message [message + CIS path]
             *      This syntax did not include the passed in message but used the path as the message
             *         arguments=" submit -d ./"+resourcePath;
             *
             *      This syntax is not correct and results in errors and no files being submitted.
             *         arguments=" submit -d \""+message+"\" ./"+resourcePath;
             *         Error=No files to submit from the default changelist.
             *         <vcs_checkin_checkout__vcs_checkin_p4::::Error message ignored.  Error Message matches VCS_IGNORE_MESSAGES=No files to submit
             *
             *      This syntax works and combines the message and path into a single quoted message
             *         arguments=" submit -d \""+message+" ./"+resourcePath+"\"";
             *         example: submit -d "changed procedure .//shared/testsvn"
             */
            String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
            //Derived from script:
            // p4 submit -d "${Message}" ${fullResourcePath} ${VCS_CHECKIN_OPTIONS}
            arguments = " submit -d \"" + message + " " + fullResourcePath + "\"" + " "
                    + vcsStruct.getVcsCheckinOptions();
            // p4 submit -d "${Message}" ./${resourcePath} ${VCS_CHECKIN_OPTIONS}
            // (previous code): arguments=" submit -d \""+message+" ./"+resourcePath+"\"" + " " + vcsStruct.getVcsCheckinOptions();
            preserveQuotes = true;

            commandDesc = "    Submit the change list to the Perforce Repository...";
            CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
            CommonUtils.writeOutput(
                    "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                    "-debug3", logger, debug1, debug2, debug3);
            CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                    debug1, debug2, debug3);

            // Parse the command arguments into a list
            argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                    preserveQuotes, propertyFile);
            envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(), "|");

            // Execute the command line
            getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                    vcsStruct.getVcsIgnoreMessages());
        }

        /********************************************
         * [SVN] vcs_checkin_checkout__vcs_checkin:
         *      SVN=Subversion
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("SVN")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/svn_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            // 2012-10-29 mtinius: differentiate between folder and data_source
            if (resourceType.equalsIgnoreCase("FOLDER") || resourceType.equalsIgnoreCase("data_source")) {
                //------------------------------------------
                // Check in Folder
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
                //Derived from script:
                // svn commit ${fullResourcePath} -m "${Message}" ${SVN_AUTH} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                arguments = " commit " + fullResourcePath + " -m \"" + message + "\" "
                        + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckinOptions();
                // svn commit ./${resourcePath} -m "${Message}" ${SVN_OPTIONS} ${SVN_AUTH}
                // (previous code): arguments=" commit ./"+resourcePath+" -m \""+message+"\" "+vcsStruct.getVcsOptions();

                commandDesc = "    Commit folder changes to the Subversion Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

            } else {
                //------------------------------------------
                // Check in File
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath + "_" + resourceType + ".cmf")
                        .replaceAll("//", "/");
                //Derived from script:
                // svn commit ${fullResourcePath} -m "${Message}"  ${SVN_AUTH} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                arguments = " commit " + fullResourcePath + " -m \"" + message + "\" "
                        + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckinOptions();
                // svn commit ./${resourcePath}_${resourceType}.cmf -m "${Message}" ${SVN_OPTIONS} ${SVN_AUTH}
                // (previous code): arguments=" commit ./"+resourcePath+"_"+resourceType+".cmf -m \""+message+"\" "+vcsStruct.getVcsOptions();

                commandDesc = "    Commit file changes to the Subversion Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [TFS] vcs_checkin_checkout__vcs_checkin:
         *      TFS=Team Foundation Server
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("TFS2010")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2012")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2013")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2005")) {
            //cd "${Workspace}"
            //    e.g: vcsWorkspaceProject:  D:/PDTool/tfs_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();
            preserveQuotes = true;
            String filename = null;

            // 2012-10-29 mtinius: differentiate between folder and data_source
            if (resourceType.equalsIgnoreCase("FOLDER") || resourceType.equalsIgnoreCase("data_source")) {

                // Validate the VCS_CHECKOUT_OPTIONS against the VCS_CHECKOUT_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckoutRequired(vcsStruct.getVcsCheckoutOptions(),
                        vcsStruct.getVcsCheckoutOptionsRequired());

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                //------------------------------------------
                // Check out Folder for editing
                //------------------------------------------

                String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
                //Derived from script:
                // tf.cmd checkout ${fullResourcePath} -lock:Checkout -recursive -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKOUT_OPTIONS}
                arguments = " checkout " + fullResourcePath + " -lock:Checkout -recursive -noprompt "
                        + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckoutOptions();
                // tf.cmd checkout ./${resourcePath} -lock:Checkout -recursive -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                //(previous code:) arguments=" checkout ./"+resourcePath+" -lock:Checkout -recursive -noprompt "+vcsStruct.getVcsOptions();

                commandDesc = "    Checkout for editing the folder from the Team Foundation Server Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                //logger.debug("TFS Unparsed Arguments: " + arguments);

                // Only checkin the resource folder workspace when TFS_USE_EXISTING_WORKSPACE=false
                if (vcsStruct.getVcsUseExistingWorkdspace().equals("true")) {
                    if (logger.isInfoEnabled()) {
                        logger.info(
                                "Warning: Resource folder will not be checked-in when variable \"TFS_USE_EXISTING_WORKSPACE=true\" is set.");
                        logger.info("Warning: User must commit resources using TFS Team Explorer.");
                    }
                } else {

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    //logger.debug("TFS Argument List: " + argList);

                    // Execute the command line
                    getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                            vcsStruct.getVcsIgnoreMessages());

                    //------------------------------------------
                    // Check in Folder
                    //------------------------------------------

                    // Create a file in the execution directory with the checkin message
                    filename = CommonUtils.getUniqueFilename("comment", "txt");
                    commentFilePath = (execFromDir + "/" + filename).replaceAll("//", "/");
                    CommonUtils.createFileWithContent(commentFilePath, message);
                    String commentCommand = " -comment:@" + filename;

                    //Derived from script:            
                    // tf.cmd checkin ${fullResourcePath} -comment:@${filename} -recursive -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                    arguments = " checkin " + fullResourcePath + commentCommand + " -recursive -noprompt "
                            + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckinOptions();
                    // tf.cmd checkin ./${resourcePath} -comment:@${filename} -recursive -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                    //(previous code:) arguments=" checkin ./"+resourcePath+commentCommand+" -recursive -noprompt "+vcsStruct.getVcsOptions() + " " + vcsStruct.getTfsCheckinOptions();

                    commandDesc = "    Commit folder changes to the Team Foundation Server Repository...";
                    CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput(
                            "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments),
                            prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3",
                            logger, debug1, debug2, debug3);

                    //logger.debug("TFS Unparsed Arguments: " + arguments);

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    //logger.debug("TFS Argument List: " + argList);

                    // Execute the command line
                    getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                            vcsStruct.getVcsIgnoreMessages());

                    // Remove the comment file
                    boolean result = CommonUtils.removeFile(commentFilePath);

                    //------------------------------------------
                    // Status of Folder - Get Pending changes
                    //------------------------------------------

                    // Get the status which will provide a list of pending changes for the parent folders that were checked in but not committed.
                    //   The use case is occurs when a folder is checked in but the parent folder lineage is new and therefore does not yet exist
                    //   in TFS.  The folder.cmf files get placed into TFS in a pending state but are not committed.  This process is intended
                    //   to get the list of pending changes and then commit them if they fall within the parent path of the fullResourcePath.

                    //arguments=" status -collection:"+vcsStruct.getVcsRepositoryUrl()+ " -workspace:" +
                    arguments = " status -collection:" + vcsStruct.getVcsRepositoryUrl() + " -workspace:"
                            + vcsStruct.getVcsWorkspaceName() + " -noprompt " + vcsStruct.getVcsOptions() + " ";
                    // tf.cmd status -collection:{VCS_REPOSITORY_URL} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}

                    commandDesc = "    Status of pending changes to the Team Foundation Server Repository...";
                    CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput(
                            "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments),
                            prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3",
                            logger, debug1, debug2, debug3);

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    // Execute the command line
                    StringBuilder stdout = getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList,
                            envList, vcsStruct.getVcsIgnoreMessages());

                    // Determine if there is any status messages containing an "add" status which indicates a pending change that is not committed.
                    // This results from a file or folder that is committed but the parent folder or folders have not yet been committed.
                    if (stdout != null) {
                        try {
                            String vcsout = stdout.toString();
                            StringReader is = new StringReader(vcsout);

                            BufferedReader reader = new BufferedReader(is);
                            String line = null;
                            int lnCount = 0;
                            String statusFilepath = null;
                            // Iterate through the orchestration property file
                            while ((line = reader.readLine()) != null) {
                                lnCount++;
                                int idx = line.indexOf(" add ");
                                if (idx >= 0) {
                                    String chkinFilename = line.substring(0, idx).trim();
                                    statusFilepath = line.substring(idx + 5, line.length()).trim();
                                    statusFilepath = statusFilepath.replaceAll(Matcher.quoteReplacement("\\\\"),
                                            "/");
                                    statusFilepath = statusFilepath.replaceAll(Matcher.quoteReplacement("\\"),
                                            "/");

                                    // Get the next parent directory to validate
                                    String statusFilePathDir = CommonUtils.getDirectory(statusFilepath);

                                    // Only commit when the status pending path is contained within the full resource path of the original resource.
                                    if (fullResourcePath.contains(statusFilePathDir)) {
                                        //------------------------------------------
                                        // Check in File for Parent Lineage Folder
                                        //------------------------------------------

                                        // Create a file in the execution directory with the checkin message
                                        filename = CommonUtils.getUniqueFilename("comment", "txt");
                                        commentFilePath = (execFromDir + "/" + filename).replaceAll("//", "/");
                                        CommonUtils.createFileWithContent(commentFilePath,
                                                message + "  Check-in parent folder=" + chkinFilename);
                                        commentCommand = " -comment:@" + filename;

                                        //Derived from script:
                                        // tf.cmd checkin ${fullResourcePath} -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                                        arguments = " checkin " + statusFilepath + commentCommand
                                                + " -noprompt " + vcsStruct.getVcsOptions() + " "
                                                + vcsStruct.getVcsCheckinOptions();
                                        // tf.cmd checkin ./${resourcePath}_${resourceType}.cmf -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                                        //(previous code:) arguments=" checkin ./"+resourcePath+"_"+resourceType+".cmf"+commentCommand+" -noprompt "+vcsStruct.getVcsOptions() + " " + vcsStruct.getTfsCheckinOptions();

                                        commandDesc = "    Commit parent lineage folder changes to the Team Foundation Server Repository...";
                                        CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1,
                                                debug2, debug3);
                                        CommonUtils.writeOutput(
                                                "    VCS Execute Command=" + command + " "
                                                        + CommonUtils.maskCommand(arguments),
                                                prefix, "-debug3", logger, debug1, debug2, debug3);
                                        CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir,
                                                prefix, "-debug3", logger, debug1, debug2, debug3);

                                        // Parse the command arguments into a list
                                        argList = CommonUtils.parseArguments(argList, initArgList,
                                                command + " " + arguments, preserveQuotes, propertyFile);
                                        envList = CommonUtils.getArgumentsList(envList, initArgList,
                                                vcsStruct.getVcsEnvironment(), "|");

                                        // Execute the command line
                                        getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList,
                                                envList, vcsStruct.getVcsIgnoreMessages());

                                        // Remove the comment file
                                        result = CommonUtils.removeFile(commentFilePath);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            throw new CompositeException(e.getMessage(), e);
                        }
                    } // if (stdout != null)
                }

            } else {

                // Validate the VCS_CHECKOUT_OPTIONS against the VCS_CHECKOUT_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckoutRequired(vcsStruct.getVcsCheckoutOptions(),
                        vcsStruct.getVcsCheckoutOptionsRequired());

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                //------------------------------------------
                // Check out File for editing
                //------------------------------------------

                String fullResourcePath = (execFromDir + "/" + resourcePath + "_" + resourceType + ".cmf")
                        .replaceAll("//", "/");
                //Derived from script:
                // tf.cmd checkout ${fullResourcePath} -lock:Checkout -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKOUT_OPTIONS}
                arguments = " checkout " + fullResourcePath + " -lock:Checkout -noprompt "
                        + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckoutOptions();
                // tf.cmd checkout ./${resourcePath}_${resourceType}.cmf -lock:Checkout -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                //(previous code:) arguments=" checkout ./"+resourcePath+"_"+resourceType+".cmf -lock:Checkout -noprompt "+vcsStruct.getVcsOptions();

                commandDesc = "    Checkout for editing the file from the Team Foundation Server Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Only checkin the resource file workspace when TFS_USE_EXISTING_WORKSPACE=false
                if (vcsStruct.getVcsUseExistingWorkdspace().equals("true")) {
                    if (logger.isInfoEnabled()) {
                        logger.info(
                                "Warning: Resource file will not be checked-in when variable \"TFS_USE_EXISTING_WORKSPACE=true\" is set.");
                        logger.info("Warning: User must commit resources using TFS Team Explorer.");
                    }
                } else {

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    // Execute the command line
                    getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                            vcsStruct.getVcsIgnoreMessages());

                    //------------------------------------------
                    // Check in File
                    //------------------------------------------

                    // Create a file in the execution directory with the checkin message
                    filename = CommonUtils.getUniqueFilename("comment", "txt");
                    commentFilePath = (execFromDir + "/" + filename).replaceAll("//", "/");
                    CommonUtils.createFileWithContent(commentFilePath, message);
                    String commentCommand = " -comment:@" + filename;

                    //Derived from script:
                    // tf.cmd checkin ${fullResourcePath} -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                    arguments = " checkin " + fullResourcePath + commentCommand + " -noprompt "
                            + vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsCheckinOptions();
                    // tf.cmd checkin ./${resourcePath}_${resourceType}.cmf -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                    //(previous code:) arguments=" checkin ./"+resourcePath+"_"+resourceType+".cmf"+commentCommand+" -noprompt "+vcsStruct.getVcsOptions() + " " + vcsStruct.getTfsCheckinOptions();

                    commandDesc = "    Commit file changes to the Team Foundation Server Repository...";
                    CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput(
                            "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments),
                            prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3",
                            logger, debug1, debug2, debug3);

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    // Execute the command line
                    getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                            vcsStruct.getVcsIgnoreMessages());

                    // Remove the comment file
                    boolean result = CommonUtils.removeFile(commentFilePath);

                    //------------------------------------------
                    // Status of File - Get Pending changes
                    //------------------------------------------

                    // Get the status which will provide a list of pending changes for the parent folders that were checked in but not committed.
                    //   The use case is occurs when a file is checked in but the parent folder lineage is new and therefore does not yet exist
                    //   in TFS.  The folder.cmf files get placed into TFS in a pending state but are not committed.  This process is intended
                    //   to get the list of pending changes and then commit them if they fall within the parent path of the fullResourcePath.

                    //arguments=" status -collection:"+vcsStruct.getVcsRepositoryUrl()+ " -workspace:" +
                    arguments = " status -collection:" + vcsStruct.getVcsRepositoryUrl() + " -workspace:"
                            + vcsStruct.getVcsWorkspaceName() + " -noprompt " + vcsStruct.getVcsOptions() + " ";
                    // tf.cmd status --collection:{VCS_REPOSITORY_URL} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}

                    commandDesc = "    Status of pending changes to the Team Foundation Server Repository...";
                    CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput(
                            "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments),
                            prefix, "-debug3", logger, debug1, debug2, debug3);
                    CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3",
                            logger, debug1, debug2, debug3);

                    // Parse the command arguments into a list
                    argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                            preserveQuotes, propertyFile);
                    envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                            "|");

                    // Execute the command line
                    StringBuilder stdout = getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList,
                            envList, vcsStruct.getVcsIgnoreMessages());

                    // Determine if there is any status messages containing an "add" status which indicates a pending change that is not committed.
                    // This results from a file or folder that is committed but the parent folder or folders have not yet been committed.
                    if (stdout != null) {
                        try {
                            String vcsout = stdout.toString();
                            StringReader is = new StringReader(vcsout);

                            BufferedReader reader = new BufferedReader(is);
                            String line = null;
                            int lnCount = 0;
                            String statusFilepath = null;
                            // Iterate through the orchestration property file
                            while ((line = reader.readLine()) != null) {
                                lnCount++;
                                int idx = line.indexOf(" add ");
                                if (idx >= 0) {
                                    String chkinFilename = line.substring(0, idx).trim();
                                    statusFilepath = line.substring(idx + 5, line.length()).trim();
                                    statusFilepath = statusFilepath.replaceAll(Matcher.quoteReplacement("\\\\"),
                                            "/");
                                    statusFilepath = statusFilepath.replaceAll(Matcher.quoteReplacement("\\"),
                                            "/");

                                    // Get the next parent directory to validate
                                    String statusFilePathDir = CommonUtils.getDirectory(statusFilepath);

                                    // Only commit when the status pending path is contained within the full resource path of the original resource.
                                    if (fullResourcePath.contains(statusFilePathDir)) {
                                        //------------------------------------------
                                        // Check in File for Parent Lineage Folder
                                        //------------------------------------------

                                        // Create a file in the execution directory with the checkin message
                                        filename = CommonUtils.getUniqueFilename("comment", "txt");
                                        commentFilePath = (execFromDir + "/" + filename).replaceAll("//", "/");
                                        CommonUtils.createFileWithContent(commentFilePath,
                                                message + "  Check-in parent folder=" + chkinFilename);
                                        commentCommand = " -comment:@" + filename;

                                        //Derived from script:
                                        // tf.cmd checkin ${fullResourcePath} -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                                        arguments = " checkin " + statusFilepath + commentCommand
                                                + " -noprompt " + vcsStruct.getVcsOptions() + " "
                                                + vcsStruct.getVcsCheckinOptions();
                                        // tf.cmd checkin ./${resourcePath}_${resourceType}.cmf -comment:@${filename} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS}
                                        //(previous code:) arguments=" checkin ./"+resourcePath+"_"+resourceType+".cmf"+commentCommand+" -noprompt "+vcsStruct.getVcsOptions() + " " + vcsStruct.getTfsCheckinOptions();

                                        commandDesc = "    Commit parent lineage file changes to the Team Foundation Server Repository...";
                                        CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1,
                                                debug2, debug3);
                                        CommonUtils.writeOutput(
                                                "    VCS Execute Command=" + command + " "
                                                        + CommonUtils.maskCommand(arguments),
                                                prefix, "-debug3", logger, debug1, debug2, debug3);
                                        CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir,
                                                prefix, "-debug3", logger, debug1, debug2, debug3);

                                        // Parse the command arguments into a list
                                        argList = CommonUtils.parseArguments(argList, initArgList,
                                                command + " " + arguments, preserveQuotes, propertyFile);
                                        envList = CommonUtils.getArgumentsList(envList, initArgList,
                                                vcsStruct.getVcsEnvironment(), "|");

                                        // Execute the command line
                                        getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList,
                                                envList, vcsStruct.getVcsIgnoreMessages());

                                        // Remove the comment file
                                        result = CommonUtils.removeFile(commentFilePath);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            throw new CompositeException(e.getMessage(), e);
                        }
                    } // if (stdout != null)
                }
            }
        }

        /********************************************
         * [GIT] vcs_checkin_checkout__vcs_checkin:
         *      GIT=Git
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("GIT")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/GITuw/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            // 2012-10-29 mtinius: differentiate between folder and data_source
            if (resourceType.equalsIgnoreCase("FOLDER") || resourceType.equalsIgnoreCase("data_source")) {
                //------------------------------------------
                // Check in Folder
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
                //Derived from script:
                // git commit -m "${Message}" ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS} ${fullResourcePath}
                arguments = " commit -m \"" + message + "\" " + vcsStruct.getVcsOptions() + " "
                        + vcsStruct.getVcsCheckinOptions() + " " + fullResourcePath;

                commandDesc = "    Commit folder changes to the local Git clone ...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

                // git push
                arguments = " push";

                commandDesc = "    Push folder changes to the Git Repository ...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

            } else {
                //------------------------------------------
                // Check in File
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath + "_" + resourceType + ".cmf")
                        .replaceAll("//", "/");
                //Derived from script:
                // git commit -m "${Message}"  ${SVN_AUTH} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS} ${fullResourcePath}
                arguments = " commit -m \"" + message + "\" " + vcsStruct.getVcsOptions() + " "
                        + vcsStruct.getVcsCheckinOptions() + " " + fullResourcePath;

                commandDesc = "    Commit file changes to the local Git clone ...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

                // git push
                arguments = " push";

                commandDesc = "    Push file changes to the Git Repository ...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [CLC] vcs_checkin_checkout__vcs_checkin:
         *      CLC=Clearcase
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("CLC")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/svn_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            // 2012-10-29 mtinius: differentiate between folder and data_source
            if (resourceType.equalsIgnoreCase("FOLDER") || resourceType.equalsIgnoreCase("data_source")) {
                //------------------------------------------
                // Check in Folder
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath).replaceAll("//", "/");
                /**************************
                 *  CLEARCASE CHECKIN               
                 **************************/
                //Derived from script:
                // cleatool ci ./${resourcePath} -c "${Message}" ${CLC_OPTIONS} ${CLC_AUTH}
                // cleatool ci ${fullResourcePath} -c "${Message}" ${CLC_AUTH} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                arguments = " ci " + fullResourcePath + " -c \"" + message + "\" " + vcsStruct.getVcsOptions()
                        + " " + vcsStruct.getVcsCheckinOptions();

                commandDesc = "    Commit folder changes to the Clearcase Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());

            } else {
                //------------------------------------------
                // Check in File
                //------------------------------------------

                // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
                validateCheckinRequired(vcsStruct.getVcsCheckinOptions(),
                        vcsStruct.getVcsCheckinOptionsRequired());

                String fullResourcePath = (execFromDir + "/" + resourcePath + "_" + resourceType + ".cmf")
                        .replaceAll("//", "/");
                /**************************
                 *  CLEARCASE CHECKIN               
                 **************************/
                //Derived from script:
                // cleartool ci ./${resourcePath}_${resourceType}.cmf -m "${Message}" ${CLC_OPTIONS} ${CLC_AUTH}
                // cleatool ci ${fullResourcePath} -c "${Message}"  ${CLC_AUTH} ${VCS_OPTIONS} ${VCS_CHECKIN_OPTIONS}
                arguments = " ci " + fullResourcePath + " -c \"" + message + "\" " + vcsStruct.getVcsOptions()
                        + " " + vcsStruct.getVcsCheckinOptions();

                commandDesc = "    Commit file changes to the Clearcase Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * vcs_checkin_checkout__vcs_checkin:
         *      NEW_VCS_TYPE=New VCS Type
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("NEW_VCS_TYPE")) {
            // Implement VCS Checkin here
        }

    } catch (CompositeException e) {
        CommonUtils.writeOutput("Action [" + prefix + "] Failed.", prefix, "-error", logger, debug1, debug2,
                debug3);
        logger.error("Failed executing " + prefix + ".", e);
        boolean result = CommonUtils.removeFile(commentFilePath);
        throw new CompositeException(e.getMessage(), e);
    }
}

From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java

private void vcs_add__vcs_checkin(String resourcePath, String resourceType, String baseFolderPath,
        VcsStruct vcsStruct) throws CompositeException {
    /*/*from www  .  j a  v  a  2  s  .c  o  m*/
       # $1 -> Resource path        (e.g. /shared/MyFolder/My__View), using file system (encoded) names
       # $2 -> Resource type        (e.g. FOLDER, table etc.)
       # $3 -> Checkin message     (e.g. Adding MyFolder)
       # $4 -> VCS Workspace Folder (e.g. /tmp/workspaces/workspace_CIS)
    */
    String prefix = "vcs_add__vcs_checkin_" + vcsStruct.getVcsType();
    List<String> argList = new ArrayList<String>();
    List<String> envList = new ArrayList<String>();
    boolean initArgList = true;
    boolean preserveQuotes = false;
    String command = vcsStruct.getVcsExecCommand();
    String arguments = null;
    String execFromDir = null;
    String commandDesc = null;

    try {
        /********************************************
         * [CVS] vcs_add__vcs_checkin: 
         *     CVS=Concurrent Versions System
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("CVS")) {
            //cd "${Workspace}"
            //    e.g: vcsWorkspaceProject:  D:/PDTool/cvs_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            //------------------------------------------
            // Add Files or Folders
            //------------------------------------------

            File dir = new File(baseFolderPath);
            String excludeFileList = "CVS/Entries,CVS/Entries.Extra,CVS/Entries.Extra.old,CVS/Entries.Old,CVS/Repository,CVS/root";
            boolean includeParentDir = false;
            boolean includeFiles = true;
            boolean includeDirs = false;
            boolean recursive = true;
            // Get the /resources/vcs_initial/baseFolders + additional processed folders by using vcsTemp as a checklist against the workspace
            File[] files = CommonUtils.getFilesParent(dir, excludeFileList, includeParentDir, includeFiles,
                    includeDirs, recursive);

            // Iterate over the checklist of files and add them into the VCS
            for (int i = 0; i < files.length; i++) {
                String remainderPath = files[i].toString();
                remainderPath = remainderPath.replaceAll(Matcher.quoteReplacement("\\"), "/");
                remainderPath = remainderPath.replaceAll(baseFolderPath, "");

                String fullResourcePath = (execFromDir + "/" + remainderPath).replaceAll("//", "/");

                //Derived from script:
                // cvs add ${fullResourcePath} ${VCS_BASE_FOLDER_INIT_ADD}
                arguments = " add " + fullResourcePath + " " + vcsStruct.getVcsBaseFolderInitAddOptions();

                commandDesc = "    Add folder changes to the CVS Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [P4] vcs_add__vcs_checkin:
         *      P4=Perforce
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("P4")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/p4_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            //------------------------------------------
            // Add Files or Folders
            //------------------------------------------

            File dir = new File(baseFolderPath);
            String excludeFileList = "";
            boolean includeParentDir = false;
            boolean includeFiles = true;
            boolean includeDirs = false;
            boolean recursive = true;
            // Get the /resources/vcs_initial/baseFolders + additional processed folders by using vcsTemp as a checklist against the workspace
            File[] files = CommonUtils.getFilesParent(dir, excludeFileList, includeParentDir, includeFiles,
                    includeDirs, recursive);

            // Iterate over the checklist of files and add them into the VCS
            for (int i = 0; i < files.length; i++) {
                String remainderPath = files[i].toString();
                remainderPath = remainderPath.replaceAll(Matcher.quoteReplacement("\\"), "/");
                remainderPath = remainderPath.replaceAll(baseFolderPath, "");

                String fullResourcePath = (execFromDir + "/" + remainderPath).replaceAll("//", "/");

                //Derived from script:
                // p4 add ${fullResourcePath} ${VCS_BASE_FOLDER_INIT_ADD}
                arguments = " add " + fullResourcePath + "\"" + " "
                        + vcsStruct.getVcsBaseFolderInitAddOptions();
                preserveQuotes = true;

                commandDesc = "    Add the change list to the Perforce Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [SVN] vcs_add__vcs_checkin:
         *      SVN=Subversion
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("SVN")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/svn_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            //------------------------------------------
            // Add Files or Folders
            //------------------------------------------

            File dir = new File(baseFolderPath);
            String excludeFileList = ".svn";
            boolean includeParentDir = false;
            boolean includeFiles = true;
            boolean includeDirs = true;
            boolean recursive = true;
            // Get the /resources/vcs_initial/baseFolders + additional processed folders by using vcsTemp as a checklist against the workspace
            File[] files = CommonUtils.getFilesParent(dir, excludeFileList, includeParentDir, includeFiles,
                    includeDirs, recursive);

            // Iterate over the checklist of files and add them into the VCS
            for (int i = 0; i < files.length; i++) {
                String remainderPath = files[i].toString();
                remainderPath = remainderPath.replaceAll(Matcher.quoteReplacement("\\"), "/");
                remainderPath = remainderPath.replaceAll(baseFolderPath, "");

                String fullResourcePath = (execFromDir + "/" + remainderPath).replaceAll("//", "/");
                //Derived from script:
                // svn add ${fullResourcePath} ${SVN_AUTH} ${VCS_OPTIONS} ${VCS_BASE_FOLDER_INIT_ADD}
                arguments = " add " + fullResourcePath + " " + vcsStruct.getVcsOptions() + " "
                        + vcsStruct.getVcsBaseFolderInitAddOptions();

                commandDesc = "    Add folder changes to the Subversion Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * [TFS] vcs_add__vcs_checkin:
         *      TFS=Team Foundation Server
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("TFS2010")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2012")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2013")
                || vcsStruct.getVcsType().equalsIgnoreCase("TFS2005")) {
            //cd "${Workspace}"
            //    e.g: vcsWorkspaceProject:  D:/PDTool/tfs_workspace/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();
            preserveQuotes = true;

            //------------------------------------------
            // Add Files or Folders
            //------------------------------------------

            // Validate the VCS_CHECKIN_OPTIONS against the VCS_CHECKIN_OPTIONS_REQUIRED and throw an exception if a required option is not found
            validateCheckinRequired(vcsStruct.getVcsCheckinOptions(), vcsStruct.getVcsCheckinOptionsRequired());

            File dir = new File(baseFolderPath);
            String excludeFileList = "";
            boolean includeParentDir = false;
            boolean includeFiles = true;
            boolean includeDirs = false;
            boolean recursive = true;
            // Get the /resources/vcs_initial/baseFolders + additional processed folders by using vcsTemp as a checklist against the workspace
            File[] files = CommonUtils.getFilesParent(dir, excludeFileList, includeParentDir, includeFiles,
                    includeDirs, recursive);

            // Iterate over the checklist of files and add them into the VCS
            for (int i = 0; i < files.length; i++) {
                String remainderPath = files[i].toString();
                remainderPath = remainderPath.replaceAll(Matcher.quoteReplacement("\\"), "/");
                remainderPath = remainderPath.replaceAll(baseFolderPath, "");

                String fullResourcePath = (execFromDir + "/" + remainderPath).replaceAll("//", "/");
                //Derived from script:            
                // tf.cmd add ${fullResourcePath} -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_BASE_FOLDER_INIT_ADD}
                arguments = " add " + fullResourcePath + " -noprompt " + vcsStruct.getVcsOptions() + " "
                        + vcsStruct.getVcsBaseFolderInitAddOptions();

                commandDesc = "    Add folder changes to the Team Foundation Server Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                //logger.debug("TFS Unparsed Arguments: " + arguments);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }

            /*
            //------------------------------------------
            // Add Folders recursively
            //------------------------------------------
                    
            String fullResourcePath = (execFromDir+"/"+resourcePath).replaceAll("//", "/");
            //Derived from script:            
            // tf.cmd add ${fullResourcePath} -recursive -noprompt /login:${VCS_USERNAME},${VCS_PASSWORD} ${VCS_OPTIONS} ${VCS_BASE_FOLDER_INIT_ADD}
            arguments=" add "+fullResourcePath+" -recursive -noprompt "+vcsStruct.getVcsOptions() + " " + vcsStruct.getVcsBaseFolderInitAddOptions();
                    
            commandDesc = "    Add folder changes to the Team Foundation Server Repository...";
            CommonUtils.writeOutput(commandDesc,prefix,"-debug3",logger,debug1,debug2,debug3);
            CommonUtils.writeOutput("    VCS Execute Command="+command+" "+CommonUtils.maskCommand(arguments),prefix,"-debug3",logger,debug1,debug2,debug3);
            CommonUtils.writeOutput("    VCS Execute Directory="+execFromDir,prefix,"-debug3",logger,debug1,debug2,debug3);
                    
            //logger.debug("TFS Unparsed Arguments: " + arguments);
                    
            // Parse the command arguments into a list
            argList = CommonUtils.parseArguments(argList, initArgList, command+" "+arguments, preserveQuotes, propertyFile);
            envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(), "|");   
                    
            //logger.debug("TFS Argument List: " + argList);
                    
            // Execute the command line
            getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList, vcsStruct.getVcsIgnoreMessages());   
            */
        }

        /********************************************
         * [GIT] vcs_add__vcs_checkin:
         *      GIT=Git
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("GIT")) {
            //cd "${Workspace}"
            //   e.g: vcsWorkspaceProject:  D:/PDTool/GITuw/cis_objects
            execFromDir = vcsStruct.getVcsWorkspaceProject();

            //------------------------------------------
            // Add Files or Folders
            //------------------------------------------

            File dir = new File(baseFolderPath);
            String excludeFileList = "";
            boolean includeParentDir = false;
            boolean includeFiles = true;
            boolean includeDirs = true;
            boolean recursive = true;
            // Get the /resources/vcs_initial/baseFolders + additional processed folders by using vcsTemp as a checklist against the workspace
            File[] files = CommonUtils.getFilesParent(dir, excludeFileList, includeParentDir, includeFiles,
                    includeDirs, recursive);

            // Iterate over the checklist of files and add them into the VCS
            for (int i = 0; i < files.length; i++) {
                String remainderPath = files[i].toString();
                remainderPath = remainderPath.replaceAll(Matcher.quoteReplacement("\\"), "/");
                remainderPath = remainderPath.replaceAll(baseFolderPath, "");

                String fullResourcePath = (execFromDir + "/" + remainderPath).replaceAll("//", "/");
                //Derived from script:
                // svn add ${VCS_OPTIONS} ${VCS_BASE_FOLDER_INIT_ADD} ${fullResourcePath}
                arguments = " add " + vcsStruct.getVcsOptions() + " "
                        + vcsStruct.getVcsBaseFolderInitAddOptions() + " " + fullResourcePath;

                commandDesc = "    Add folder changes to the Subversion Repository...";
                CommonUtils.writeOutput(commandDesc, prefix, "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput(
                        "    VCS Execute Command=" + command + " " + CommonUtils.maskCommand(arguments), prefix,
                        "-debug3", logger, debug1, debug2, debug3);
                CommonUtils.writeOutput("    VCS Execute Directory=" + execFromDir, prefix, "-debug3", logger,
                        debug1, debug2, debug3);

                // Parse the command arguments into a list
                argList = CommonUtils.parseArguments(argList, initArgList, command + " " + arguments,
                        preserveQuotes, propertyFile);
                envList = CommonUtils.getArgumentsList(envList, initArgList, vcsStruct.getVcsEnvironment(),
                        "|");

                // Execute the command line
                getVCSDAO().execCommandLineVCS(prefix, execFromDir, command, argList, envList,
                        vcsStruct.getVcsIgnoreMessages());
            }
        }

        /********************************************
         * vcs_add__vcs_checkin:
         *      NEW_VCS_TYPE=New VCS Type
         ********************************************/
        if (vcsStruct.getVcsType().equalsIgnoreCase("NEW_VCS_TYPE")) {
            // Implement VCS Checkin here
        }

    } catch (CompositeException e) {
        CommonUtils.writeOutput("Action [" + prefix + "] Failed.", prefix, "-error", logger, debug1, debug2,
                debug3);
        logger.error("Failed executing " + prefix + ".", e);
        throw new CompositeException(e.getMessage(), e);
    }
}

From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java

private static String substituteVariables(String stringToReplace, HashMap<String, String> vcsSubstitutionVars) {
    if (vcsSubstitutionVars != null) {

        String[] keys = new String[vcsSubstitutionVars.keySet().size()];
        vcsSubstitutionVars.keySet().toArray(keys);

        for (int i = 0; i < keys.length; i++) {
            String key = keys[i].toString();
            String value = vcsSubstitutionVars.get(key);
            if (value != null) {
                stringToReplace = stringToReplace.replaceAll(Matcher.quoteReplacement(key),
                        Matcher.quoteReplacement(value));
            }/*  w  w  w. j a  va 2  s.  c o  m*/
        }
    }
    return stringToReplace;
}