A test profile that can be used to test the functionality of vcscore/vcsgeneric framework.
The repository is represented as an XML file.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/vcs.advanced/test/unit/testprofile/build.xml Tue Oct 26 14:55:52 2004 +0000
1.3 @@ -0,0 +1,122 @@
1.4 +<?xml version='1.0' encoding='ISO-8859-1' ?>
1.5 +<!--
1.6 + Sun Public License Notice
1.7 +
1.8 +The contents of this file are subject to the Sun Public License
1.9 +Version 1.0 (the "License"). You may not use this file except in
1.10 +compliance with the License. A copy of the License is available at
1.11 +http://www.sun.com/
1.12 +
1.13 +The Original Code is NetBeans. The Initial Developer of the Original
1.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
1.15 +Microsystems, Inc. All Rights Reserved.
1.16 +-->
1.17 +
1.18 +
1.19 +<project name="vcsgeneric/test/unit/testprofiles" default="netbeans" basedir=".">
1.20 + <import file="../../../../nbbuild/default.xml"/>
1.21 +
1.22 + <property name="build.compiler.debug" value="on"/>
1.23 +
1.24 + <taskdef name="makelayer" classname="org.netbeans.nbbuild.MakeLayer" classpath="${nb_all}/nbbuild/nbantext.jar"/>
1.25 +
1.26 + <taskdef name="createmodulexml" classname="org.netbeans.nbbuild.CreateModuleXML" classpath="${nb_all}/nbbuild/nbantext.jar"/>
1.27 +
1.28 + <target name="init" depends="default.init">
1.29 + <patternset id="vcsgeneric/profiles/testprofiles.files">
1.30 + <include name="${nb.modules.dir}/test-profile.jar"/>
1.31 + </patternset>
1.32 + <path id="cp">
1.33 + <pathelement location="${openide.dir}/${nb.lib.dir}/openide.jar"/>
1.34 + <pathelement location="${openide/loaders.dir}/${nb.lib.dir}/openide-loaders.jar"/>
1.35 + <pathelement location="${openidex.dir}/${nb.modules.dir}/org-openidex-util.jar"/>
1.36 + <pathelement location="${vcscore.dir}/${nb.modules.dir}/org-netbeans-modules-vcscore.jar"/>
1.37 + <pathelement location="${vcsgeneric.dir}/${nb.modules.dir}/vcsgen.jar"/>
1.38 + <pathelement location="${diff.dir}/${nb.modules.dir}/org-netbeans-modules-diff.jar"/>
1.39 + <pathelement location="${projects/queries.dir}/${nb.modules.dir}/org-netbeans-modules-queries.jar"/>
1.40 + </path>
1.41 + </target>
1.42 +
1.43 + <target name="compile" depends="init">
1.44 + <!--<echo message="basedir = ${basedir}, nbroot1 = ${nbroot1}, nbext1 = ${nbext1}"/>-->
1.45 + <javac srcdir="src"
1.46 + deprecation="${build.compiler.deprecation}"
1.47 + debug="${build.compiler.debug}"
1.48 + source="1.4"
1.49 + destdir="src">
1.50 + <classpath refID="cp"/>
1.51 + </javac>
1.52 + </target>
1.53 +
1.54 + <target name="jars" depends="compile">
1.55 + <makelayer topdir="src" destfile="src/org/netbeans/modules/vcs/profiles/testprofiles/layer-includes-commands.xml" absolutepath="true">
1.56 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/commands/*.class"/>
1.57 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/commands/*.form"/>
1.58 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/commands/*.properties"/>
1.59 + </makelayer>
1.60 + <makelayer topdir="src" destfile="src/org/netbeans/modules/vcs/profiles/testprofiles/layer-includes-config.xml" absolutepath="true">
1.61 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/config/*.*"/>
1.62 + <exclude name="org/netbeans/modules/vcs/profiles/testprofiles/config/Bundle.properties"/>
1.63 + </makelayer>
1.64 + <makelayer topdir="src" destfile="src/org/netbeans/modules/vcs/profiles/testprofiles/layer-includes-list.xml" absolutepath="true">
1.65 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/list/*.class"/>
1.66 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/list/*.properties"/>
1.67 + </makelayer>
1.68 + <mkdir dir="${netbeans.dest.dir}/${cluster.dir}/${nb.modules.dir}"/>
1.69 + <filter token="BUILD_NUMBER_SUBST" value="${buildnumber}"/>
1.70 + <copy file="manifest.mf" tofile="manifest-subst.mf" filtering="on"/>
1.71 + <jar jarfile="${netbeans.dest.dir}/${cluster.dir}/${nb.modules.dir}/test-profile.jar"
1.72 + manifest="manifest-subst.mf"
1.73 + basedir="src"
1.74 + excludesfile="${nb_all}/nbbuild/standard-jar-excludes.txt"
1.75 + excludes="src/org/netbeans/modules/vcs/profiles/testprofiles/mf-layer_XX.xml"
1.76 + compress="false">
1.77 + <fileset dir="src/" excludesfile="${nb_all}/nbbuild/standard-jar-excludes.txt">
1.78 + <include name="**/*"/>
1.79 + </fileset>
1.80 + <fileset dir="src/">
1.81 + <include name="**/*.form"/>
1.82 + </fileset>
1.83 + </jar>
1.84 + <createmodulexml xmldir="${netbeans.dest.dir}/${cluster.dir}/${nb.system.dir}/Modules">
1.85 + <enabled dir="${netbeans.dest.dir}/${cluster.dir}">
1.86 + <include name="${nb.modules.dir}/test-profile.jar"/>
1.87 + </enabled>
1.88 + </createmodulexml>
1.89 + </target>
1.90 +
1.91 + <target name="netbeans" depends="jars">
1.92 + <genlist outputfiledir="${netbeans.dest.dir}/${cluster.dir}" module="${nb.modules.dir}/test-profile.jar">
1.93 + <fileset dir="${netbeans.dest.dir}/${cluster.dir}">
1.94 + <patternset refID="vcsgeneric/profiles/testprofiles.files"/>
1.95 + </fileset>
1.96 + </genlist>
1.97 + </target>
1.98 +
1.99 + <target name="nbm" depends="netbeans">
1.100 + <makenbm file="test-profile.nbm"
1.101 + productdir="${netbeans.dest.dir}/${cluster.dir}"
1.102 + module="${nb.modules.dir}/test-profile.jar"
1.103 + homepage="http://vcsgeneric.${homepage.base}/"
1.104 + distribution="http://${dist.base}/test-profile.nbm">
1.105 + <license file="${license.file}"/>
1.106 + <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
1.107 + </makenbm>
1.108 + </target>
1.109 +
1.110 + <target name="clean" depends="init">
1.111 + <delete>
1.112 + <fileset dir="src">
1.113 + <include name="**/*.class"/>
1.114 + <include name="**/*.jar"/>
1.115 + <include name="org/netbeans/modules/vcs/profiles/testprofiles/layer-include*.xml"/>
1.116 + </fileset>
1.117 + <fileset dir="${netbeans.dest.dir}/${cluster.dir}">
1.118 + <patternset refID="vcsgeneric/profiles/testprofiles.files"/>
1.119 + </fileset>
1.120 + </delete>
1.121 + <delete file="manifest-subst.mf"/>
1.122 + <delete file="test-profile.nbm"/>
1.123 + </target>
1.124 +
1.125 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/vcs.advanced/test/unit/testprofile/manifest.mf Tue Oct 26 14:55:52 2004 +0000
2.3 @@ -0,0 +1,15 @@
2.4 +Manifest-Version: 1.0
2.5 +OpenIDE-Module: org.netbeans.modules.vcs.profiles.testprofiles/1
2.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/vcs/profiles/testprofiles/Bundle.properties
2.7 +OpenIDE-Module-Specification-Version: 1.5
2.8 +OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
2.9 +OpenIDE-Module-Public-Packages: -
2.10 +OpenIDE-Module-IDE-Dependencies: IDE/1 > 3.18
2.11 +OpenIDE-Module-Module-Dependencies:
2.12 + org.netbeans.modules.vcscore/1 > 1.10,
2.13 + org.netbeans.modules.vcs.advanced/1 > 1.10,
2.14 + org.netbeans.modules.diff/1 > 1.8,
2.15 + org.openide.loaders > 4.11,
2.16 + org.netbeans.modules.queries/0 > 1.0
2.17 +OpenIDE-Module-Layer: org/netbeans/modules/vcs/profiles/testprofiles/mf-layer.xml
2.18 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/Bundle.properties Tue Oct 26 14:55:52 2004 +0000
3.3 @@ -0,0 +1,18 @@
3.4 +# Sun Public License Notice
3.5 +#
3.6 +# The contents of this file are subject to the Sun Public License
3.7 +# Version 1.0 (the "License"). You may not use this file except in
3.8 +# compliance with the License. A copy of the License is available at
3.9 +# http://www.sun.com/
3.10 +#
3.11 +# The Original Code is NetBeans. The Initial Developer of the Original
3.12 +# Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
3.13 +# Microsystems, Inc. All Rights Reserved.
3.14 +
3.15 +# Manifest
3.16 +OpenIDE-Module-Name=Test Profile
3.17 +#Version Control
3.18 +OpenIDE-Module-Display-Category=Version Control
3.19 +OpenIDE-Module-Short-Description=Integration of a test profile into generic VCS support.
3.20 +OpenIDE-Module-Long-Description=A test profile that works with a repository that is represented as an XML file.
3.21 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/commands/CheckOutFromXML.java Tue Oct 26 14:55:52 2004 +0000
4.3 @@ -0,0 +1,148 @@
4.4 +/*
4.5 + * Sun Public License Notice
4.6 + *
4.7 + * The contents of this file are subject to the Sun Public License
4.8 + * Version 1.0 (the "License"). You may not use this file except in
4.9 + * compliance with the License. A copy of the License is available at
4.10 + * http://www.sun.com/
4.11 + *
4.12 + * The Original Code is NetBeans. The Initial Developer of the Original
4.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
4.14 + * Microsystems, Inc. All Rights Reserved.
4.15 + */
4.16 +
4.17 +package org.netbeans.modules.vcs.profiles.testprofiles.commands;
4.18 +
4.19 +import java.io.File;
4.20 +import java.io.IOException;
4.21 +import java.text.DateFormat;
4.22 +import java.text.ParseException;
4.23 +import java.text.ParsePosition;
4.24 +import java.text.SimpleDateFormat;
4.25 +import java.util.Date;
4.26 +import java.util.Hashtable;
4.27 +import org.netbeans.modules.vcscore.Variables;
4.28 +
4.29 +import org.netbeans.modules.vcscore.cmdline.VcsAdditionalCommand;
4.30 +import org.netbeans.modules.vcscore.commands.CommandDataOutputListener;
4.31 +import org.netbeans.modules.vcscore.commands.CommandOutputListener;
4.32 +import org.openide.filesystems.FileObject;
4.33 +import org.openide.filesystems.XMLFileSystem;
4.34 +import org.xml.sax.SAXException;
4.35 +
4.36 +/**
4.37 + *
4.38 + * @author Martin Entlicher
4.39 + */
4.40 +public class CheckOutFromXML extends Object implements VcsAdditionalCommand {
4.41 +
4.42 + /** Creates a new instance of CheckOutFromXML */
4.43 + public CheckOutFromXML() {
4.44 + }
4.45 +
4.46 + /**
4.47 + * This method is used to execute the command.
4.48 + * @param vars the variables that can be passed to the command
4.49 + * @param args the command line parametres passed to it in properties
4.50 + * @param stdoutListener listener of the standard output of the command
4.51 + * @param stderrListener listener of the error output of the command
4.52 + * @param stdoutDataListener listener of the standard output of the command which
4.53 + * satisfies regex <CODE>dataRegex</CODE>
4.54 + * @param dataRegex the regular expression for parsing the standard output
4.55 + * @param stderrDataListener listener of the error output of the command which
4.56 + * satisfies regex <CODE>errorRegex</CODE>
4.57 + * @param errorRegex the regular expression for parsing the error output
4.58 + * @return true if the command was succesfull
4.59 + * false if some error occured.
4.60 + */
4.61 + public boolean exec(Hashtable vars, String[] args,
4.62 + CommandOutputListener stdoutListener, CommandOutputListener stderrListener,
4.63 + CommandDataOutputListener stdoutDataListener, String dataRegex,
4.64 + CommandDataOutputListener stderrDataListener, String errorRegex) {
4.65 + String path = Variables.expand(vars, "$[? MODULE] [${MODULE}${PS}][]${DIR}", false); // NOI18N
4.66 + String xml = (String) vars.get("XML_FS");
4.67 + XMLFileSystem xmlFS;
4.68 + try {
4.69 + xmlFS = new XMLFileSystem(xml);
4.70 + } catch (SAXException sex) {
4.71 + stderrListener.outputLine(sex.getLocalizedMessage());
4.72 + return false;
4.73 + }
4.74 + //System.out.println("path = "+path);
4.75 + FileObject pathFO = xmlFS.findResource(path);
4.76 + if (pathFO == null) {
4.77 + stderrListener.outputLine("Folder '"+path+"' not found on XML FS.");
4.78 + return false;
4.79 + }
4.80 + String dir;
4.81 + String rootDir = (String) vars.get("ROOTDIR"); // NOI18N
4.82 + dir = (String) vars.get("DIR"); // NOI18N
4.83 + if (dir == null) {
4.84 + dir = ""; // NOI18N
4.85 + }
4.86 + String module = (String) vars.get("MODULE"); // NOI18N
4.87 + if (dir.equals("")) { // NOI18N
4.88 + dir=rootDir;
4.89 + if (module != null && module.length() > 0) dir += File.separator + module;
4.90 + } else {
4.91 + if (module == null)
4.92 + dir=rootDir+File.separator+dir;
4.93 + else
4.94 + dir=rootDir+File.separator+module+File.separator+dir;
4.95 + }
4.96 + if (dir.charAt(dir.length() - 1) == File.separatorChar) {
4.97 + dir = dir.substring(0, dir.length() - 1);
4.98 + }
4.99 +
4.100 + return checkout(new File(dir), pathFO, stdoutListener, stderrListener);
4.101 + }
4.102 +
4.103 + private static boolean checkout(File dir, FileObject folder,
4.104 + CommandOutputListener stdoutListener,
4.105 + CommandOutputListener stderrListener) {
4.106 + if (!dir.exists()) {
4.107 + if (!dir.mkdir()) {
4.108 + stderrListener.outputLine("Can not create directory '"+dir.getAbsolutePath()+"'");
4.109 + return false;
4.110 + }
4.111 + }
4.112 + FileObject[] children = folder.getChildren();
4.113 + for (int i = 0; i < children.length; i++) {
4.114 + FileObject ch = children[i];
4.115 + String name = ch.getNameExt();
4.116 + File file = new File(dir, name);
4.117 + if (ch.isFolder()) {
4.118 + if (!checkout(file, ch, stdoutListener, stderrListener)) {
4.119 + return false;
4.120 + }
4.121 + } else {
4.122 + try {
4.123 + file.createNewFile();
4.124 + String time = (String) ch.getAttribute("time");
4.125 + String date = (String) ch.getAttribute("date");
4.126 + if (date != null) {
4.127 + if (time != null) {
4.128 + date = date + ", " + time;
4.129 + //try {
4.130 + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");
4.131 + ParsePosition pp = new ParsePosition(0);
4.132 + Date lmdate = sdf.parse(date, pp);
4.133 + //Date lmdate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).parse(date);
4.134 + if (lmdate == null) {
4.135 + stderrListener.outputLine("Can not parse date '"+date+"', error at "+pp.getErrorIndex());
4.136 + }
4.137 + file.setLastModified(lmdate.getTime());
4.138 + //} catch (ParseException pex) {
4.139 + // stderrListener.outputLine(pex.getLocalizedMessage());
4.140 + //}
4.141 + }
4.142 + }
4.143 + } catch (IOException ioex) {
4.144 + stderrListener.outputLine(ioex.getLocalizedMessage());
4.145 + return false;
4.146 + }
4.147 + }
4.148 + }
4.149 + return true;
4.150 + }
4.151 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/config/testprofile.xml Tue Oct 26 14:55:52 2004 +0000
5.3 @@ -0,0 +1,110 @@
5.4 +<?xml version="1.0"?>
5.5 +<!DOCTYPE configuration PUBLIC '-//NetBeans//DTD VCS Configuration 1.1//EN' 'http://www.netbeans.org/dtds/vcs-configuration-1_1.dtd'>
5.6 +<!--
5.7 + Sun Public License Notice
5.8 +
5.9 +The contents of this file are subject to the Sun Public License
5.10 +Version 1.0 (the "License"). You may not use this file except in
5.11 +compliance with the License. A copy of the License is available at
5.12 +http://www.sun.com/
5.13 +
5.14 +The Original Code is NetBeans. The Initial Developer of the Original
5.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
5.16 +Microsystems, Inc. All Rights Reserved.
5.17 +-->
5.18 +
5.19 +
5.20 +<configuration>
5.21 + <label>Test</label>
5.22 +
5.23 + <os>
5.24 + <compatible>"Windows", "Unix"</compatible>
5.25 + <uncompatible>"Windows 95", "Windows 98", "Windows Me"</uncompatible>
5.26 + </os>
5.27 +
5.28 + <condition var="IS_WINDOWS">
5.29 + <var name="os.name" valueContainsIgnoreCase="WINDOWS"/>
5.30 + </condition>
5.31 +
5.32 + <variables>
5.33 + <variable name="FS_DISPLAY_NAME" basic="false">
5.34 + <value>Test</value>
5.35 + </variable>
5.36 + <variable name="XML_FS" label="XML Filesystem" basic="true" isDir="true">
5.37 + <value></value>
5.38 + </variable>
5.39 + <variable name="CD" basic="false">
5.40 + <value>cd</value>
5.41 + </variable>
5.42 + <variable name="MAX_CMD_LENGTH" basic="false" if="IS_WINDOWS">
5.43 + <value>1000</value>
5.44 + </variable>
5.45 + </variables>
5.46 +
5.47 + <commands>
5.48 + <command name="ROOT" displayName="Test">
5.49 +
5.50 + <command name="LIST" displayName="Refresh">
5.51 +
5.52 + <property name="exec">
5.53 + <value>org.netbeans.modules.vcs.profiles.testprofiles.list.ListFromXMLFS.class $[? MODULE] [${MODULE}${PS}][]${DIR}</value>
5.54 + </property>
5.55 + <property name="onRoot">
5.56 + <value>true</value>
5.57 + </property>
5.58 + <property name="data.fileName.index">
5.59 + <value>0</value>
5.60 + </property>
5.61 + <property name="data.status.index">
5.62 + <value>1</value>
5.63 + </property>
5.64 + <property name="data.locker.index">
5.65 + <value>2</value>
5.66 + </property>
5.67 + <property name="data.revision.index">
5.68 + <value>3</value>
5.69 + </property>
5.70 + <property name="data.sticky.index">
5.71 + <value>4</value>
5.72 + </property>
5.73 + <property name="data.size.index">
5.74 + <value>7</value>
5.75 + </property>
5.76 + <property name="data.attr.index">
5.77 + <value>8</value>
5.78 + </property>
5.79 + <property name="data.time.index">
5.80 + <value>5</value>
5.81 + </property>
5.82 + <property name="data.date.index">
5.83 + <value>6</value>
5.84 + </property>
5.85 + </command>
5.86 + <command name="LIST_SUB" displayName="Refresh Recursively">
5.87 + <property name="exec">
5.88 + <!-- echo If this exec is empty, the command uses LIST to recursively obtain the directory structure -->
5.89 + <value></value>
5.90 + </property>
5.91 + <property name="onRoot">
5.92 + <value>true</value>
5.93 + </property>
5.94 + </command>
5.95 +
5.96 + <separator />
5.97 +
5.98 + <command name="CHECKOUT" displayName="Check Out">
5.99 + <property name="exec">
5.100 + <value>org.netbeans.modules.vcs.profiles.testprofiles.commands.CheckOutFromXML.class</value>
5.101 + </property>
5.102 + <property name="refreshParentFolder">
5.103 + <value>true</value>
5.104 + </property>
5.105 + <property name="refreshRecursivelyPatternMatched">
5.106 + <value>CheckOutFromXML</value>
5.107 + </property>
5.108 + </command>
5.109 +
5.110 + </command>
5.111 + </commands>
5.112 +</configuration>
5.113 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/list/ListFromXMLFS.java Tue Oct 26 14:55:52 2004 +0000
6.3 @@ -0,0 +1,205 @@
6.4 +/*
6.5 + * Sun Public License Notice
6.6 + *
6.7 + * The contents of this file are subject to the Sun Public License
6.8 + * Version 1.0 (the "License"). You may not use this file except in
6.9 + * compliance with the License. A copy of the License is available at
6.10 + * http://www.sun.com/
6.11 + *
6.12 + * The Original Code is NetBeans. The Initial Developer of the Original
6.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
6.14 + * Microsystems, Inc. All Rights Reserved.
6.15 + */
6.16 +
6.17 +package org.netbeans.modules.vcs.profiles.testprofiles.list;
6.18 +
6.19 +import java.io.File;
6.20 +import java.text.DateFormat;
6.21 +import java.text.ParseException;
6.22 +import java.text.ParsePosition;
6.23 +import java.text.SimpleDateFormat;
6.24 +import java.util.Date;
6.25 +import java.util.Hashtable;
6.26 +
6.27 +import org.netbeans.modules.vcscore.Variables;
6.28 +import org.netbeans.modules.vcscore.VcsFileSystem;
6.29 +import org.netbeans.modules.vcscore.caching.VcsCacheFile;
6.30 +import org.netbeans.modules.vcscore.caching.CacheStatuses;
6.31 +import org.netbeans.modules.vcscore.cmdline.VcsListCommand;
6.32 +import org.netbeans.modules.vcscore.util.*;
6.33 +import org.netbeans.modules.vcscore.commands.CommandOutputListener;
6.34 +import org.netbeans.modules.vcscore.commands.CommandDataOutputListener;
6.35 +
6.36 +import org.openide.filesystems.FileObject;
6.37 +import org.openide.filesystems.XMLFileSystem;
6.38 +import org.xml.sax.SAXException;
6.39 +
6.40 +//import org.netbeans.modules.vcs.profiles.list.AbstractListCommand;
6.41 +
6.42 +public class ListFromXMLFS extends VcsListCommand {
6.43 +
6.44 + public ListFromXMLFS() {
6.45 + }
6.46 +
6.47 + /**
6.48 + * List files of CVS Repository.
6.49 + * @param vars Variables used by the command
6.50 + * @param args Command-line arguments
6.51 + * filesByName listing of files with status attributes
6.52 + * @param stdoutNRListener listener of the standard output of the command
6.53 + * @param stderrNRListener listener of the error output of the command
6.54 + * @param stdoutListener listener of the standard output of the command which
6.55 + * satisfies regex <CODE>dataRegex</CODE>
6.56 + * @param dataRegex the regular expression for parsing the standard output
6.57 + * @param stderrListener listener of the error output of the command which
6.58 + * satisfies regex <CODE>errorRegex</CODE>
6.59 + * @param errorRegex the regular expression for parsing the error output
6.60 + */
6.61 + public boolean list(Hashtable vars, String[] args, Hashtable filesByName,
6.62 + CommandOutputListener stdoutNRListener, CommandOutputListener stderrNRListener,
6.63 + CommandDataOutputListener stdoutListener, String dataRegex,
6.64 + CommandDataOutputListener stderrListener, String errorRegex) {
6.65 + String path = args.length > 0 ? args[0] : "";
6.66 + String xml = (String) vars.get("XML_FS");
6.67 + XMLFileSystem xmlFS;
6.68 + try {
6.69 + xmlFS = new XMLFileSystem(xml);
6.70 + } catch (SAXException sex) {
6.71 + stderrNRListener.outputLine(sex.getLocalizedMessage());
6.72 + return false;
6.73 + }
6.74 + String dir;
6.75 + String rootDir = (String) vars.get("ROOTDIR"); // NOI18N
6.76 + dir = (String) vars.get("DIR"); // NOI18N
6.77 + if (dir == null) {
6.78 + dir = ""; // NOI18N
6.79 + }
6.80 + String module = (String) vars.get("MODULE"); // NOI18N
6.81 + if (dir.equals("")) { // NOI18N
6.82 + dir=rootDir;
6.83 + if (module != null && module.length() > 0) dir += File.separator + module;
6.84 + } else {
6.85 + if (module == null)
6.86 + dir=rootDir+File.separator+dir;
6.87 + else
6.88 + dir=rootDir+File.separator+module+File.separator+dir;
6.89 + }
6.90 + if (dir.charAt(dir.length() - 1) == File.separatorChar) {
6.91 + dir = dir.substring(0, dir.length() - 1);
6.92 + }
6.93 +
6.94 + File dirFile = new File(dir);
6.95 +
6.96 + //System.out.println("path = "+path);
6.97 + FileObject pathFO = xmlFS.findResource(path);
6.98 + if (pathFO == null) {
6.99 + stderrNRListener.outputLine("Folder '"+path+"' not found on XML FS.");
6.100 + return false;
6.101 + }
6.102 + FileObject[] children = pathFO.getChildren();
6.103 + for (int i = 0; i < children.length; i++) {
6.104 + FileObject ch = children[i];
6.105 + String name = ch.getNameExt();
6.106 + String status;// = (String) ch.getAttribute("status");
6.107 + String locker = (String) ch.getAttribute("locker");
6.108 + String revision = (String) ch.getAttribute("revision");
6.109 + String sticky = (String) ch.getAttribute("sticky");
6.110 + String time = (String) ch.getAttribute("time");
6.111 + String date = (String) ch.getAttribute("date");
6.112 + String size = (String) ch.getAttribute("size");
6.113 + String attr = (String) ch.getAttribute("attr");
6.114 + File file = new File(dirFile, name);
6.115 + if (!file.exists()) {
6.116 + if (ch.isData()) {
6.117 + status = "Needs Update";
6.118 + } else {
6.119 + status = "Missing";
6.120 + }
6.121 + } else {
6.122 + if (file.isFile()) {
6.123 + long lastModified = file.lastModified();
6.124 + long reposModified = 0;
6.125 + String dateStr;
6.126 + if (date != null) {
6.127 + if (time != null) {
6.128 + dateStr = date + ", " + time;
6.129 + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");
6.130 + ParsePosition pp = new ParsePosition(0);
6.131 + Date lmdate = sdf.parse(dateStr, pp);
6.132 + //Date lmdate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).parse(date);
6.133 + if (lmdate == null) {
6.134 + stderrNRListener.outputLine("Can not parse date '"+date+"', error at "+pp.getErrorIndex());
6.135 + } else {
6.136 + reposModified = lmdate.getTime();
6.137 + }
6.138 + /*
6.139 + try {
6.140 + Date lmdate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).parse(dateStr);
6.141 + reposModified = lmdate.getTime();
6.142 + } catch (ParseException pex) {
6.143 + stderrNRListener.outputLine(pex.getLocalizedMessage());
6.144 + }
6.145 + */
6.146 + }
6.147 + }
6.148 + if (lastModified == reposModified) {
6.149 + status = "Up-to-date";
6.150 + } else {
6.151 + if (lastModified < reposModified) {
6.152 + status = "Needs Patch";
6.153 + } else {
6.154 + status = "Locally Modified";
6.155 + }
6.156 + }
6.157 + } else {
6.158 + status = "";
6.159 + }
6.160 + }
6.161 + if (ch.isFolder()) name += '/';
6.162 + String[] elements = new String[] { name, status, locker, revision, sticky, time, date, size, attr };
6.163 + stdoutListener.outputData(elements);
6.164 + filesByName.put(name, elements);
6.165 + }
6.166 + return true;
6.167 + }
6.168 +
6.169 + public boolean list_XMLOnly(Hashtable vars, String[] args, Hashtable filesByName,
6.170 + CommandOutputListener stdoutNRListener, CommandOutputListener stderrNRListener,
6.171 + CommandDataOutputListener stdoutListener, String dataRegex,
6.172 + CommandDataOutputListener stderrListener, String errorRegex) {
6.173 + String path = args.length > 0 ? args[0] : "";
6.174 + String xml = (String) vars.get("XML_FS");
6.175 + XMLFileSystem xmlFS;
6.176 + try {
6.177 + xmlFS = new XMLFileSystem(xml);
6.178 + } catch (SAXException sex) {
6.179 + stderrNRListener.outputLine(sex.getLocalizedMessage());
6.180 + return false;
6.181 + }
6.182 + //System.out.println("path = "+path);
6.183 + FileObject pathFO = xmlFS.findResource(path);
6.184 + if (pathFO == null) {
6.185 + stderrNRListener.outputLine("Folder '"+path+"' not found on XML FS.");
6.186 + return false;
6.187 + }
6.188 + FileObject[] children = pathFO.getChildren();
6.189 + for (int i = 0; i < children.length; i++) {
6.190 + FileObject ch = children[i];
6.191 + String name = ch.getNameExt();
6.192 + if (ch.isFolder()) name += '/';
6.193 + String status = (String) ch.getAttribute("status");
6.194 + String locker = (String) ch.getAttribute("locker");
6.195 + String revision = (String) ch.getAttribute("revision");
6.196 + String sticky = (String) ch.getAttribute("sticky");
6.197 + String time = (String) ch.getAttribute("time");
6.198 + String date = (String) ch.getAttribute("date");
6.199 + String size = (String) ch.getAttribute("size");
6.200 + String attr = (String) ch.getAttribute("attr");
6.201 + String[] elements = new String[] { name, status, locker, revision, sticky, time, date, size, attr };
6.202 + stdoutListener.outputData(elements);
6.203 + filesByName.put(name, elements);
6.204 + }
6.205 + return true;
6.206 + }
6.207 +
6.208 +}
6.209 \ No newline at end of file
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/mf-layer.xml Tue Oct 26 14:55:52 2004 +0000
7.3 @@ -0,0 +1,44 @@
7.4 +<?xml version='1.0'?>
7.5 +<!--
7.6 + Sun Public License Notice
7.7 +
7.8 +The contents of this file are subject to the Sun Public License
7.9 +Version 1.0 (the "License"). You may not use this file except in
7.10 +compliance with the License. A copy of the License is available at
7.11 +http://www.sun.com/
7.12 +
7.13 +The Original Code is NetBeans. The Initial Developer of the Original
7.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
7.15 +Microsystems, Inc. All Rights Reserved.
7.16 +-->
7.17 +
7.18 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd" [
7.19 + <!ENTITY includefiles_commands SYSTEM "layer-includes-commands.xml">
7.20 + <!ENTITY includefiles_config SYSTEM "layer-includes-config.xml">
7.21 + <!ENTITY includefiles_list SYSTEM "layer-includes-list.xml">
7.22 +]>
7.23 +<filesystem>
7.24 + <folder name="org">
7.25 + <folder name="netbeans">
7.26 + <folder name="modules">
7.27 + <folder name="vcs">
7.28 + <folder name="profiles">
7.29 + <folder name="cvsprofiles">
7.30 + <folder name="commands">
7.31 + &includefiles_commands;
7.32 + </folder>
7.33 + <folder name="list">
7.34 + &includefiles_list;
7.35 + </folder>
7.36 + </folder>
7.37 + </folder>
7.38 + </folder>
7.39 + </folder>
7.40 + </folder>
7.41 + </folder>
7.42 + <folder name="vcs">
7.43 + <folder name="config">
7.44 + &includefiles_config;
7.45 + </folder>
7.46 + </folder>
7.47 +</filesystem>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/vcs.advanced/test/unit/testprofile/src/org/netbeans/modules/vcs/profiles/testprofiles/testrepos/TestRepo1.xml Tue Oct 26 14:55:52 2004 +0000
8.3 @@ -0,0 +1,29 @@
8.4 +<?xml version="1.0"?>
8.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
8.6 +<!--
8.7 + Sun Public License Notice
8.8 +
8.9 +The contents of this file are subject to the Sun Public License
8.10 +Version 1.0 (the "License"). You may not use this file except in
8.11 +compliance with the License. A copy of the License is available at
8.12 +http://www.sun.com/
8.13 +
8.14 +The Original Code is NetBeans. The Initial Developer of the Original
8.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
8.16 +Microsystems, Inc. All Rights Reserved.
8.17 +-->
8.18 +
8.19 +<filesystem>
8.20 + <file name="File.txt">
8.21 + <attr name="date" stringvalue="23/10/2004"/>
8.22 + <attr name="time" stringvalue="11:33:09"/>
8.23 + </file>
8.24 + <folder name="org">
8.25 + <folder name="test">
8.26 + <file name="Main.java">
8.27 + <attr name="date" stringvalue="23/01/2004"/>
8.28 + <attr name="time" stringvalue="09:33:09"/>
8.29 + </file>
8.30 + </folder>
8.31 + </folder>
8.32 +</filesystem>