upayavira    2003/09/26 10:08:08

  Modified:    .        cli.xconf
               src/documentation/xdocs/userdocs/advanced/offline cli.xml
               src/java/org/apache/cocoon Main.java
  Log:
  Added -n option to command line, so that the user can request only one of the 
<uris> nodes to be processed, by referring to the @name attribute on the <uris> 
node.
  
  Revision  Changes    Path
  1.7       +11 -4     cocoon-2.1/cli.xconf
  
  Index: cli.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/cli.xconf,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- cli.xconf 19 Sep 2003 09:09:43 -0000      1.6
  +++ cli.xconf 26 Sep 2003 17:08:08 -0000      1.7
  @@ -207,20 +207,27 @@
          |   * type:               the method to be used to calculate
          |                         the destination URI. See above 
          |                         section on <uri> node for details.
  +       | 
  +       | Each <uris> node can have a name attribute. When a name
  +       | attribute has been specified, the -n switch on the command
  +       | line can be used to tell Cocoon to only process the URIs
  +       | within this URI group. When no -n switch is given, all 
  +       | <uris> nodes are processed. Thus, one xconf file can be 
  +       | used to manage multiple sites.
          +-->
  -   <uris follow-links="true">
  +   <uris name="docs" follow-links="true">
        <uri type="append" src-prefix="docs/" src="index.html"
             dest="build/dest/" />
      </uris>
      
  -   <uris follow-links="false"
  +   <uris name="samples" 
  +         follow-links="false"
            confirm-extensions="true"
            src-prefix="samples/"
            dest="build/dest/examples/"
            type="append"
            >
         <uri src=""/>
  -      <uri src="hello-world/"/>
         <uri src="hello-world/hello.html"/>
         <uri src="hello-world/hello.xml"/>
      </uris>
  
  
  
  1.3       +9 -2      
cocoon-2.1/src/documentation/xdocs/userdocs/advanced/offline/cli.xml
  
  Index: cli.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/advanced/offline/cli.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cli.xml   19 Sep 2003 09:09:43 -0000      1.2
  +++ cli.xml   26 Sep 2003 17:08:08 -0000      1.3
  @@ -247,13 +247,20 @@
          |   * type:               the method to be used to calculate
          |                         the destination URI. See above 
          |                         section on <uri> node for details.
  +       | 
  +       | Each <uris> node can have a name attribute. When a name
  +       | attribute has been specified, the -n switch on the command
  +       | line can be used to tell Cocoon to only process the URIs
  +       | within this URI group. When no -n switch is given, all 
  +       | <uris> nodes are processed. Thus, one xconf file can be 
  +       | used to manage multiple sites.
          +-->
  -   <uris follow-links="true">
  +   <uris name="docs" follow-links="true">
        <uri type="append" src-prefix="docs/" src="index.html"
             dest="build/dest/" />
      </uris>
      
  -   <uris follow-links="false"
  +   <uris name="samples" follow-links="false"
            confirm-extensions="true"
            src-prefix="samples/"
            dest="build/dest/examples/"
  
  
  
  1.19      +28 -8     cocoon-2.1/src/java/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Main.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Main.java 26 Sep 2003 08:25:21 -0000      1.18
  +++ Main.java 26 Sep 2003 17:08:08 -0000      1.19
  @@ -106,6 +106,7 @@
       protected static final String CONFIRM_EXTENSIONS_OPT = "e";
       protected static final String LOAD_CLASS_OPT =         "L";
       protected static final String DEFAULT_FILENAME_OPT =   "D";
  +    protected static final String URI_GROUP_NAME_OPT =     "n";
   
       protected static final String HELP_LONG =               "help";
       protected static final String VERSION_LONG =            "version";
  @@ -128,6 +129,7 @@
       protected static final String LOAD_CLASS_LONG =         "loadClass";
       protected static final String DEFAULT_FILENAME_LONG =   
"defaultFilename";
       protected static final String URI_LONG =                "uri";
  +    protected static final String URI_GROUP_NAME_LONG =     "uris";
   
       private static final String NODE_ROOT = "cocoon";
       private static final String ATTR_VERBOSE = "verbose";
  @@ -172,7 +174,8 @@
       private static final String ATTR_URI_DESTURI = "dest";
   
       private static final String NODE_URIS = "uris";
  -
  +    private static final String ATTR_NAME = "name";
  +    
       private static Options options;
       private static OutputStreamListener listener;
   
  @@ -285,6 +288,11 @@
                                        true,
                                        "specify a filename to be appended to a 
URI when the"
                                        + " URI refers to a directory"));
  +        options.addOption(new Option(URI_GROUP_NAME_OPT,
  +                                     URI_GROUP_NAME_LONG,
  +                                     true,
  +                                     "specify which <uris> element to 
process in the configuration"
  +                                     + " file specified with the -x 
parameter"));
       }
   
       /**
  @@ -307,10 +315,15 @@
                printVersion();
           }
   
  +        String uriGroup = null;
  +        if (line.hasOption(URI_GROUP_NAME_OPT)) {
  +            uriGroup = line.getOptionValue(URI_GROUP_NAME_OPT);
  +        }
  +            
           String destDir = null;
           if (line.hasOption(XCONF_OPT)) {
               // destDir from command line overrides one in xconf file
  -            destDir = Main.processXConf(cocoon, 
line.getOptionValue(XCONF_OPT), destDir);
  +            destDir = Main.processXConf(cocoon, 
line.getOptionValue(XCONF_OPT), destDir, uriGroup);
           }
           if (line.hasOption(DEST_DIR_OPT)) {
               destDir = line.getOptionValue(DEST_DIR_OPT);
  @@ -435,7 +448,7 @@
        * @param cocoon a <code>CocoonBean</code> that will be configured by 
the xconf file
        * @param filename a <code>String</code> value
        */
  -    private static String processXConf(CocoonBean cocoon, String filename, 
String destDir) {
  +    private static String processXConf(CocoonBean cocoon, String filename, 
String destDir, String uriGroup) {
   
           try {
               final DocumentBuilder builder = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
  @@ -513,7 +526,7 @@
                           Main.parseURINode(cocoon, node, destDir);
   
                       } else if (nodeName.equals(NODE_URIS)) {
  -                        Main.parseURIsNode(cocoon, node, destDir);
  +                        Main.parseURIsNode(cocoon, node, destDir, uriGroup);
   
                       } else if (nodeName.equals(NODE_URI_FILE)) {
                           
cocoon.addTargets(Main.processURIFile(getNodeValue(node)), destDir);
  @@ -584,7 +597,7 @@
           }
       }
   
  -    private static void parseURIsNode(CocoonBean cocoon, Node node, String 
destDir) throws IllegalArgumentException {
  +    private static void parseURIsNode(CocoonBean cocoon, Node node, String 
destDir, String uriGroup) throws IllegalArgumentException {
   
           boolean followLinks = cocoon.followLinks();
           boolean confirmExtensions = cocoon.confirmExtensions();
  @@ -592,7 +605,8 @@
           String destURI = destDir;
           String root = null;
           String type = null;
  -
  +        String name = null;
  +        
           if (Main.hasAttribute(node, ATTR_FOLLOW_LINKS)) {
               followLinks = Main.getBooleanAttributeValue(node, 
ATTR_FOLLOW_LINKS);
           }
  @@ -611,7 +625,13 @@
           if (Main.hasAttribute(node, ATTR_LOGGER)) {
               logger = Main.getAttributeValue(node, ATTR_LOGGER);
           }
  -
  +        if (Main.hasAttribute(node, ATTR_NAME)) {
  +            name = Main.getAttributeValue(node, ATTR_NAME);
  +            if (name != null && uriGroup != null && !name.equals(uriGroup)) {
  +                // The user has not selected this URI group, so ignore it.
  +                return;
  +            }
  +        }
           NodeList nodes = node.getChildNodes();
           for (int i = 0; i < nodes.getLength(); i++) {
               Node child = nodes.item(i);
  
  
  

Reply via email to