replace main/contrib/modulemanagement w/ main/autoupdate.cli nbi_check_updates_216192
authorJiri Rechtacek <jrechtacek@netbeans.org>
Wed, 29 Aug 2012 15:30:58 +0200
branchnbi_check_updates_216192
changeset 178672d6a60e2df6f
parent 17866 f63faeafba09
child 17869 9e8ec9814f90
replace main/contrib/modulemanagement w/ main/autoupdate.cli
modulemanagement/build.xml
modulemanagement/manifest.mf
modulemanagement/nbproject/project.properties
modulemanagement/nbproject/project.xml
modulemanagement/src/org/netbeans/modules/modulemanagement/Bundle.properties
modulemanagement/src/org/netbeans/modules/modulemanagement/ModuleOptions.java
modulemanagement/src/org/netbeans/modules/modulemanagement/PrintTable.java
modulemanagement/src/org/netbeans/modules/modulemanagement/Status.java
modulemanagement/test/unit/src/org/netbeans/modules/modulemanagement/EnableDisableTest.java
modulemanagement/test/unit/src/org/netbeans/modules/modulemanagement/ListModulesTest.java
     1.1 --- a/modulemanagement/build.xml	Tue Aug 28 22:07:58 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,47 +0,0 @@
     1.4 -<?xml version="1.0" encoding="UTF-8"?>
     1.5 -<!--
     1.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.7 -
     1.8 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     1.9 -
    1.10 -
    1.11 -The contents of this file are subject to the terms of either the GNU
    1.12 -General Public License Version 2 only ("GPL") or the Common
    1.13 -Development and Distribution License("CDDL") (collectively, the
    1.14 -"License"). You may not use this file except in compliance with the
    1.15 -License. You can obtain a copy of the License at
    1.16 -http://www.netbeans.org/cddl-gplv2.html
    1.17 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    1.18 -specific language governing permissions and limitations under the
    1.19 -License.  When distributing the software, include this License Header
    1.20 -Notice in each file and include the License file at
    1.21 -nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    1.22 -particular file as subject to the "Classpath" exception as provided
    1.23 -by Sun in the GPL Version 2 section of the License file that
    1.24 -accompanied this code. If applicable, add the following below the
    1.25 -License Header, with the fields enclosed by brackets [] replaced by
    1.26 -your own identifying information:
    1.27 -"Portions Copyrighted [year] [name of copyright owner]"
    1.28 -
    1.29 -Contributor(s):
    1.30 -
    1.31 -The Original Software is NetBeans. The Initial Developer of the Original
    1.32 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    1.33 -Microsystems, Inc. All Rights Reserved.
    1.34 -
    1.35 -If you wish your version of this file to be governed by only the CDDL
    1.36 -or only the GPL Version 2, indicate your decision by adding
    1.37 -"[Contributor] elects to include this software in this distribution
    1.38 -under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.39 -single choice of license, a recipient has the option to distribute
    1.40 -your version of this file under either the CDDL, the GPL Version 2 or
    1.41 -to extend the choice of license to its licensees as provided above.
    1.42 -However, if you add GPL Version 2 code and therefore, elected the GPL
    1.43 -Version 2 license, then the option applies only if the new code is
    1.44 -made subject to such option by the copyright holder.
    1.45 --->
    1.46 -
    1.47 -<project basedir="." default="netbeans" name="contrib/modulemanagement">
    1.48 -    <description>Builds, tests, and runs the project org.netbeans.modules.modulemanagement</description>
    1.49 -    <import file="../../nbbuild/templates/projectized.xml"/>
    1.50 -</project>
     2.1 --- a/modulemanagement/manifest.mf	Tue Aug 28 22:07:58 2012 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,5 +0,0 @@
     2.4 -Manifest-Version: 1.0
     2.5 -OpenIDE-Module: org.netbeans.modules.modulemanagement
     2.6 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/modulemanagement/Bundle.properties
     2.7 -OpenIDE-Module-Specification-Version: 1.5
     2.8 -
     3.1 --- a/modulemanagement/nbproject/project.properties	Tue Aug 28 22:07:58 2012 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,47 +0,0 @@
     3.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.5 -#
     3.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     3.7 -#
     3.8 -# The contents of this file are subject to the terms of either the GNU
     3.9 -# General Public License Version 2 only ("GPL") or the Common
    3.10 -# Development and Distribution License("CDDL") (collectively, the
    3.11 -# "License"). You may not use this file except in compliance with the
    3.12 -# License. You can obtain a copy of the License at
    3.13 -# http://www.netbeans.org/cddl-gplv2.html
    3.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.15 -# specific language governing permissions and limitations under the
    3.16 -# License.  When distributing the software, include this License Header
    3.17 -# Notice in each file and include the License file at
    3.18 -# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    3.19 -# particular file as subject to the "Classpath" exception as provided
    3.20 -# by Sun in the GPL Version 2 section of the License file that
    3.21 -# accompanied this code. If applicable, add the following below the
    3.22 -# License Header, with the fields enclosed by brackets [] replaced by
    3.23 -# your own identifying information:
    3.24 -# "Portions Copyrighted [year] [name of copyright owner]"
    3.25 -#
    3.26 -# Contributor(s):
    3.27 -#
    3.28 -# The Original Software is NetBeans. The Initial Developer of the Original
    3.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    3.30 -# Microsystems, Inc. All Rights Reserved.
    3.31 -#
    3.32 -# If you wish your version of this file to be governed by only the CDDL
    3.33 -# or only the GPL Version 2, indicate your decision by adding
    3.34 -# "[Contributor] elects to include this software in this distribution
    3.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.36 -# single choice of license, a recipient has the option to distribute
    3.37 -# your version of this file under either the CDDL, the GPL Version 2 or
    3.38 -# to extend the choice of license to its licensees as provided above.
    3.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
    3.40 -# Version 2 license, then the option applies only if the new code is
    3.41 -# made subject to such option by the copyright holder.
    3.42 -
    3.43 -javac.compilerargs=-Xlint:unchecked
    3.44 -javac.source=1.5
    3.45 -javac.target=jsr14
    3.46 -
    3.47 -
    3.48 -test.unit.cp.extra=${core.startup.dir}/core/core.jar:\
    3.49 -    ${o.n.bootstrap.dir}/lib/boot.jar
    3.50 -
     4.1 --- a/modulemanagement/nbproject/project.xml	Tue Aug 28 22:07:58 2012 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,125 +0,0 @@
     4.4 -<?xml version="1.0" encoding="UTF-8"?>
     4.5 -<!--
     4.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.7 -
     4.8 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     4.9 -
    4.10 -
    4.11 -The contents of this file are subject to the terms of either the GNU
    4.12 -General Public License Version 2 only ("GPL") or the Common
    4.13 -Development and Distribution License("CDDL") (collectively, the
    4.14 -"License"). You may not use this file except in compliance with the
    4.15 -License. You can obtain a copy of the License at
    4.16 -http://www.netbeans.org/cddl-gplv2.html
    4.17 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.18 -specific language governing permissions and limitations under the
    4.19 -License.  When distributing the software, include this License Header
    4.20 -Notice in each file and include the License file at
    4.21 -nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    4.22 -particular file as subject to the "Classpath" exception as provided
    4.23 -by Sun in the GPL Version 2 section of the License file that
    4.24 -accompanied this code. If applicable, add the following below the
    4.25 -License Header, with the fields enclosed by brackets [] replaced by
    4.26 -your own identifying information:
    4.27 -"Portions Copyrighted [year] [name of copyright owner]"
    4.28 -
    4.29 -Contributor(s):
    4.30 -
    4.31 -The Original Software is NetBeans. The Initial Developer of the Original
    4.32 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    4.33 -Microsystems, Inc. All Rights Reserved.
    4.34 -
    4.35 -If you wish your version of this file to be governed by only the CDDL
    4.36 -or only the GPL Version 2, indicate your decision by adding
    4.37 -"[Contributor] elects to include this software in this distribution
    4.38 -under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.39 -single choice of license, a recipient has the option to distribute
    4.40 -your version of this file under either the CDDL, the GPL Version 2 or
    4.41 -to extend the choice of license to its licensees as provided above.
    4.42 -However, if you add GPL Version 2 code and therefore, elected the GPL
    4.43 -Version 2 license, then the option applies only if the new code is
    4.44 -made subject to such option by the copyright holder.
    4.45 --->
    4.46 -<project xmlns="http://www.netbeans.org/ns/project/1">
    4.47 -    <type>org.netbeans.modules.apisupport.project</type>
    4.48 -    <configuration>
    4.49 -        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
    4.50 -            <code-name-base>org.netbeans.modules.modulemanagement</code-name-base>
    4.51 -            <module-dependencies>
    4.52 -                <dependency>
    4.53 -                    <code-name-base>org.netbeans.api.progress</code-name-base>
    4.54 -                    <build-prerequisite/>
    4.55 -                    <compile-dependency/>
    4.56 -                    <run-dependency>
    4.57 -                        <release-version>1</release-version>
    4.58 -                        <specification-version>1.9</specification-version>
    4.59 -                    </run-dependency>
    4.60 -                </dependency>
    4.61 -                <dependency>
    4.62 -                    <code-name-base>org.netbeans.modules.autoupdate.services</code-name-base>
    4.63 -                    <build-prerequisite/>
    4.64 -                    <compile-dependency/>
    4.65 -                    <run-dependency>
    4.66 -                        <specification-version>1.0</specification-version>
    4.67 -                    </run-dependency>
    4.68 -                </dependency>
    4.69 -                <dependency>
    4.70 -                    <code-name-base>org.netbeans.modules.sendopts</code-name-base>
    4.71 -                    <build-prerequisite/>
    4.72 -                    <compile-dependency/>
    4.73 -                    <run-dependency>
    4.74 -                        <release-version>2</release-version>
    4.75 -                        <specification-version>2.0</specification-version>
    4.76 -                    </run-dependency>
    4.77 -                </dependency>
    4.78 -                <dependency>
    4.79 -                    <code-name-base>org.openide.filesystems</code-name-base>
    4.80 -                    <build-prerequisite/>
    4.81 -                    <compile-dependency/>
    4.82 -                    <run-dependency>
    4.83 -                        <specification-version>7.19</specification-version>
    4.84 -                    </run-dependency>
    4.85 -                </dependency>
    4.86 -                <dependency>
    4.87 -                    <code-name-base>org.openide.modules</code-name-base>
    4.88 -                    <build-prerequisite/>
    4.89 -                    <compile-dependency/>
    4.90 -                    <run-dependency>
    4.91 -                        <specification-version>6.6</specification-version>
    4.92 -                    </run-dependency>
    4.93 -                </dependency>
    4.94 -                <dependency>
    4.95 -                    <code-name-base>org.openide.util</code-name-base>
    4.96 -                    <build-prerequisite/>
    4.97 -                    <compile-dependency/>
    4.98 -                    <run-dependency>
    4.99 -                        <specification-version>8.0</specification-version>
   4.100 -                    </run-dependency>
   4.101 -                </dependency>
   4.102 -                <dependency>
   4.103 -                    <code-name-base>org.openide.util.lookup</code-name-base>
   4.104 -                    <build-prerequisite/>
   4.105 -                    <compile-dependency/>
   4.106 -                    <run-dependency>
   4.107 -                        <specification-version>8.0</specification-version>
   4.108 -                    </run-dependency>
   4.109 -                </dependency>
   4.110 -            </module-dependencies>
   4.111 -            <test-dependencies>
   4.112 -                <test-type>
   4.113 -                    <name>unit</name>
   4.114 -                    <test-dependency>
   4.115 -                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
   4.116 -                        <compile-dependency/>
   4.117 -                    </test-dependency>
   4.118 -                    <test-dependency>
   4.119 -                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
   4.120 -                        <recursive/>
   4.121 -                        <compile-dependency/>
   4.122 -                    </test-dependency>
   4.123 -                </test-type>
   4.124 -            </test-dependencies>
   4.125 -            <public-packages/>
   4.126 -        </data>
   4.127 -    </configuration>
   4.128 -</project>
     5.1 --- a/modulemanagement/src/org/netbeans/modules/modulemanagement/Bundle.properties	Tue Aug 28 22:07:58 2012 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,74 +0,0 @@
     5.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.5 -#
     5.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     5.7 -#
     5.8 -# The contents of this file are subject to the terms of either the GNU
     5.9 -# General Public License Version 2 only ("GPL") or the Common
    5.10 -# Development and Distribution License("CDDL") (collectively, the
    5.11 -# "License"). You may not use this file except in compliance with the
    5.12 -# License. You can obtain a copy of the License at
    5.13 -# http://www.netbeans.org/cddl-gplv2.html
    5.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    5.15 -# specific language governing permissions and limitations under the
    5.16 -# License.  When distributing the software, include this License Header
    5.17 -# Notice in each file and include the License file at
    5.18 -# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    5.19 -# particular file as subject to the "Classpath" exception as provided
    5.20 -# by Sun in the GPL Version 2 section of the License file that
    5.21 -# accompanied this code. If applicable, add the following below the
    5.22 -# License Header, with the fields enclosed by brackets [] replaced by
    5.23 -# your own identifying information:
    5.24 -# "Portions Copyrighted [year] [name of copyright owner]"
    5.25 -#
    5.26 -# Contributor(s):
    5.27 -#
    5.28 -# The Original Software is NetBeans. The Initial Developer of the Original
    5.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    5.30 -# Microsystems, Inc. All Rights Reserved.
    5.31 -#
    5.32 -# If you wish your version of this file to be governed by only the CDDL
    5.33 -# or only the GPL Version 2, indicate your decision by adding
    5.34 -# "[Contributor] elects to include this software in this distribution
    5.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
    5.36 -# single choice of license, a recipient has the option to distribute
    5.37 -# your version of this file under either the CDDL, the GPL Version 2 or
    5.38 -# to extend the choice of license to its licensees as provided above.
    5.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
    5.40 -# Version 2 license, then the option applies only if the new code is
    5.41 -# made subject to such option by the copyright holder.
    5.42 -
    5.43 -OpenIDE-Module-Display-Category=Infrastructure
    5.44 -OpenIDE-Module-Long-Description=\
    5.45 -    Allows to query and administer already running IDE from command line. \
    5.46 -    It is possible to query the list all modules with their state, query state of an individual module, change state of a module, etc.
    5.47 -OpenIDE-Module-Name=Command-line Serviceability
    5.48 -OpenIDE-Module-Short-Description=Provides CLI interface to query running NetBeans system
    5.49 -
    5.50 -
    5.51 -# {0} - the file
    5.52 -ERR_FileNotFound=File {0} cannot be found
    5.53 -ERR_NotModule=File {0} does not seem to be a module
    5.54 -# {0} - the file
    5.55 -# {1} - codenamebase
    5.56 -ERR_AlreadyInstalled=Module with code base {1} is already installed. Cannot install {0}
    5.57 -# {0} - codenamebase
    5.58 -ERR_ModuleNotFound=Module with code base {0} not found
    5.59 -# {0} - codenamebase
    5.60 -# {1} - 0 if the module should be disabled, 1 if it should be enabled
    5.61 -ERR_TimeOut=Time out while waiting for module {0} to be {1,choice,0#disabled|1#enabled}
    5.62 -# {0} - codenamebase
    5.63 -# {1} - text of the old config
    5.64 -# {2} - text of new config (the same)
    5.65 -ERR_ModuleChanged=No change applied to module {0}. The config file was:\n{1}\n
    5.66 -
    5.67 -
    5.68 -
    5.69 -#
    5.70 -# options short descriptions
    5.71 -#
    5.72 -
    5.73 -MSG_ListModules=Prints the list of all modules, their versions and enablement status
    5.74 -MSG_InstallModules=Installs provided JAR files as modules
    5.75 -MSG_DisableModules=Disable modules for specified codebase names
    5.76 -MSG_EnableModules=Enable modules for specified codebase names
    5.77 -
     6.1 --- a/modulemanagement/src/org/netbeans/modules/modulemanagement/ModuleOptions.java	Tue Aug 28 22:07:58 2012 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,368 +0,0 @@
     6.4 -/*
     6.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 - *
     6.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     6.8 - *
     6.9 - * The contents of this file are subject to the terms of either the GNU
    6.10 - * General Public License Version 2 only ("GPL") or the Common
    6.11 - * Development and Distribution License("CDDL") (collectively, the
    6.12 - * "License"). You may not use this file except in compliance with the
    6.13 - * License. You can obtain a copy of the License at
    6.14 - * http://www.netbeans.org/cddl-gplv2.html
    6.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.16 - * specific language governing permissions and limitations under the
    6.17 - * License.  When distributing the software, include this License Header
    6.18 - * Notice in each file and include the License file at
    6.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    6.20 - * particular file as subject to the "Classpath" exception as provided
    6.21 - * by Sun in the GPL Version 2 section of the License file that
    6.22 - * accompanied this code. If applicable, add the following below the
    6.23 - * License Header, with the fields enclosed by brackets [] replaced by
    6.24 - * your own identifying information:
    6.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    6.26 - *
    6.27 - * Contributor(s):
    6.28 - *
    6.29 - * The Original Software is NetBeans. The Initial Developer of the Original
    6.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    6.31 - * Microsystems, Inc. All Rights Reserved.
    6.32 - *
    6.33 - * If you wish your version of this file to be governed by only the CDDL
    6.34 - * or only the GPL Version 2, indicate your decision by adding
    6.35 - * "[Contributor] elects to include this software in this distribution
    6.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.37 - * single choice of license, a recipient has the option to distribute
    6.38 - * your version of this file under either the CDDL, the GPL Version 2 or
    6.39 - * to extend the choice of license to its licensees as provided above.
    6.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    6.41 - * Version 2 license, then the option applies only if the new code is
    6.42 - * made subject to such option by the copyright holder.
    6.43 - */
    6.44 -
    6.45 -package org.netbeans.modules.modulemanagement;
    6.46 -
    6.47 -import java.io.IOException;
    6.48 -import java.io.PrintStream;
    6.49 -import java.util.Arrays;
    6.50 -import java.util.Collections;
    6.51 -import java.util.HashSet;
    6.52 -import java.util.List;
    6.53 -import java.util.Map;
    6.54 -import java.util.Set;
    6.55 -import java.util.logging.Logger;
    6.56 -import java.util.prefs.Preferences;
    6.57 -import java.util.regex.Pattern;
    6.58 -import java.util.regex.PatternSyntaxException;
    6.59 -import org.netbeans.api.autoupdate.*;
    6.60 -import org.netbeans.api.autoupdate.InstallSupport.Installer;
    6.61 -import org.netbeans.api.autoupdate.InstallSupport.Validator;
    6.62 -import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
    6.63 -import org.netbeans.api.autoupdate.OperationSupport.Restarter;
    6.64 -import org.netbeans.api.sendopts.CommandException;
    6.65 -import org.netbeans.spi.sendopts.Env;
    6.66 -import org.netbeans.spi.sendopts.Option;
    6.67 -import org.netbeans.spi.sendopts.OptionGroups;
    6.68 -import org.netbeans.spi.sendopts.OptionProcessor;
    6.69 -import org.openide.util.*;
    6.70 -
    6.71 -import static org.netbeans.modules.modulemanagement.Bundle.*;
    6.72 -
    6.73 -/**
    6.74 - *
    6.75 - * @author Jaroslav Tulach, Jiri Rechtacek
    6.76 - */
    6.77 -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.sendopts.OptionProcessor.class)
    6.78 -public class ModuleOptions extends OptionProcessor {
    6.79 -    private static final Logger LOG = Logger.getLogger(ModuleOptions.class.getName());
    6.80 -    
    6.81 -    private Option list;
    6.82 -    private Option install;
    6.83 -    private Option disable;
    6.84 -    private Option enable;
    6.85 -    private Option update;
    6.86 -    private Option refresh;
    6.87 -    private Option updateAll;
    6.88 -    private Option both;
    6.89 -    
    6.90 -    /** Creates a new instance of ModuleOptions */
    6.91 -    public ModuleOptions() {
    6.92 -    }
    6.93 -
    6.94 -    @NbBundle.Messages({
    6.95 -        "MSG_UpdateModules=Updates all or specified modules",
    6.96 -        "MSG_UpdateAll=Updates all modules",
    6.97 -        "MSG_Refresh=Refresh all catalogs"
    6.98 -    })
    6.99 -    private Option init() {
   6.100 -        if (both != null) {
   6.101 -            return both;
   6.102 -        }
   6.103 -
   6.104 -        String b = "org.netbeans.modules.modulemanagement.Bundle";
   6.105 -        list = Option.shortDescription(
   6.106 -            Option.withoutArgument(Option.NO_SHORT_NAME, "list"), b, "MSG_ListModules"); // NOI18N
   6.107 -        install = Option.shortDescription(
   6.108 -            Option.additionalArguments(Option.NO_SHORT_NAME, "install"), b, "MSG_InstallModules"); // NOI18N
   6.109 -        disable = Option.shortDescription(
   6.110 -            Option.additionalArguments(Option.NO_SHORT_NAME, "disable"), b, "MSG_DisableModules"); // NOI18N
   6.111 -        enable = Option.shortDescription(
   6.112 -            Option.additionalArguments(Option.NO_SHORT_NAME, "enable"), b, "MSG_EnableModules"); // NOI18N
   6.113 -        update = Option.shortDescription(
   6.114 -            Option.additionalArguments(Option.NO_SHORT_NAME, "update"), b, "MSG_UpdateModules"); // NOI18N
   6.115 -        refresh = Option.shortDescription(
   6.116 -            Option.withoutArgument(Option.NO_SHORT_NAME, "refresh"), b, "MSG_Refresh"); // NOI18N
   6.117 -        updateAll = Option.shortDescription(
   6.118 -            Option.withoutArgument(Option.NO_SHORT_NAME, "update-all"), b, "MSG_UpdateAll"); // NOI18N
   6.119 -        
   6.120 -        Option oper = OptionGroups.someOf(refresh, list, install, disable, enable, update, updateAll);
   6.121 -        Option modules = Option.withoutArgument(Option.NO_SHORT_NAME, "modules");
   6.122 -        both = OptionGroups.allOf(modules, oper);
   6.123 -        return both;
   6.124 -    }
   6.125 -
   6.126 -    public Set<Option> getOptions() {
   6.127 -        return Collections.singleton(init());
   6.128 -    }
   6.129 -    
   6.130 -    private void refresh(Env env) throws CommandException {
   6.131 -        for (UpdateUnitProvider p : UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true)) {
   6.132 -            try {
   6.133 -                env.getOutputStream().println("Refreshing " + p.getDisplayName());
   6.134 -                p.refresh(null, true);
   6.135 -            } catch (IOException ex) {
   6.136 -                throw (CommandException)new CommandException(33, ex.getMessage()).initCause(ex);
   6.137 -            }
   6.138 -        }
   6.139 -    }
   6.140 -
   6.141 -    @NbBundle.Messages({
   6.142 -        "MSG_ListHeader_CodeName=Code Name",
   6.143 -        "MSG_ListHeader_Version=Version",
   6.144 -        "MSG_ListHeader_State=State"
   6.145 -    })
   6.146 -    private void listAllModules(PrintStream out) {
   6.147 -        List<UpdateUnit> modules = UpdateManager.getDefault().getUpdateUnits();
   6.148 -        
   6.149 -        PrintTable table = new PrintTable(
   6.150 -            MSG_ListHeader_CodeName(), MSG_ListHeader_Version(), MSG_ListHeader_State()
   6.151 -        );
   6.152 -        table.setLimits(50, -1, -1);
   6.153 -        for (UpdateUnit uu : modules) {
   6.154 -            table.addRow(Status.toArray(uu));
   6.155 -        }
   6.156 -        table.write(out);
   6.157 -        out.flush();
   6.158 -    }
   6.159 -
   6.160 -    private static <T extends Throwable> T initCause(T t, Throwable cause) {
   6.161 -        t.initCause(cause);
   6.162 -        return t;
   6.163 -    }
   6.164 -
   6.165 -    protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
   6.166 -        if (optionValues.containsKey(refresh)) {
   6.167 -            refresh(env);
   6.168 -        }
   6.169 -        
   6.170 -        if (optionValues.containsKey(list)) {
   6.171 -            listAllModules(env.getOutputStream());
   6.172 -        }
   6.173 -    
   6.174 -        try {
   6.175 -            if (optionValues.containsKey(install)) {
   6.176 -                install(env, optionValues.get(install));
   6.177 -            }
   6.178 -
   6.179 -            if (optionValues.containsKey(disable)) {
   6.180 -                changeModuleState(optionValues.get(disable), false);
   6.181 -            }
   6.182 -
   6.183 -            if (optionValues.containsKey(enable)) {
   6.184 -                changeModuleState(optionValues.get(enable), true);
   6.185 -            }
   6.186 -        } catch (InterruptedException ex) {
   6.187 -            throw initCause(new CommandException(4), ex);
   6.188 -        } catch (IOException ex) {
   6.189 -            throw initCause(new CommandException(4), ex);
   6.190 -        } catch (OperationException ex) {
   6.191 -            throw initCause(new CommandException(4), ex);
   6.192 -        }
   6.193 -        if (optionValues.containsKey(updateAll)) {
   6.194 -            updateAll(env);
   6.195 -        }
   6.196 -        if (optionValues.containsKey(update)) {
   6.197 -            updateModules(env, optionValues.get(update));
   6.198 -        }
   6.199 -    }
   6.200 -
   6.201 -    private void changeModuleState(String[] cnbs, boolean enable) throws IOException, CommandException, InterruptedException, OperationException {
   6.202 -        for (String cnb : cnbs) {
   6.203 -            int slash = cnb.indexOf('/');
   6.204 -            if (slash >= 0) {
   6.205 -                cnb = cnb.substring(0, slash);
   6.206 -            }
   6.207 -        }
   6.208 -        
   6.209 -        Set<String> all = new HashSet<String>(Arrays.asList(cnbs));
   6.210 -
   6.211 -        List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits();
   6.212 -        OperationContainer<OperationSupport> operate = enable ? OperationContainer.createForEnable() : OperationContainer.createForDisable();
   6.213 -        for (UpdateUnit updateUnit : units) {
   6.214 -            if (all.contains(updateUnit.getCodeName())) {
   6.215 -                if (enable) {
   6.216 -                    operate.add(updateUnit, updateUnit.getInstalled());
   6.217 -                } else {
   6.218 -                    operate.add(updateUnit, updateUnit.getInstalled());
   6.219 -                }
   6.220 -            }
   6.221 -        }
   6.222 -        OperationSupport support = operate.getSupport();
   6.223 -        support.doOperation(null);
   6.224 -    }
   6.225 -
   6.226 -    @NbBundle.Messages({
   6.227 -        "MSG_UpdateNoMatch=Nothing to update. The pattern {0} has no match among available updates.",
   6.228 -        "MSG_Update=Will update {0}@{1} to version {2}"
   6.229 -    })
   6.230 -    private void updateModules(Env env, String... pattern) throws CommandException {
   6.231 -        if (! initialized()) {
   6.232 -            refresh(env);
   6.233 -        }
   6.234 -        Pattern[] pats = findMatcher(env, pattern);
   6.235 -        
   6.236 -        List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits();
   6.237 -        OperationContainer<InstallSupport> operate = OperationContainer.createForInternalUpdate();
   6.238 -        for (UpdateUnit uu : units) {
   6.239 -            if (uu.getInstalled() == null) {
   6.240 -                continue;
   6.241 -            }
   6.242 -            if (! uu.getInstalled().isEnabled()) {
   6.243 -                continue;
   6.244 -            }
   6.245 -            final List<UpdateElement> updates = uu.getAvailableUpdates();
   6.246 -            if (updates.isEmpty()) {
   6.247 -                continue;
   6.248 -            }
   6.249 -            if (pattern.length > 0 && !matches(uu.getCodeName(), pats)) {
   6.250 -                continue;
   6.251 -            }
   6.252 -            final UpdateElement ue = updates.get(0);
   6.253 -            env.getOutputStream().println(
   6.254 -                Bundle.MSG_Update(uu.getCodeName(), uu.getInstalled().getSpecificationVersion(), ue.getSpecificationVersion()
   6.255 -            ));
   6.256 -            if (operate.canBeAdded(uu, ue)) {
   6.257 -                LOG.fine("  ... update " + uu.getInstalled() + " -> " + ue);
   6.258 -                OperationInfo<InstallSupport> info = operate.add(ue);
   6.259 -                if (info != null) {
   6.260 -                    Set<UpdateElement> requiredElements = info.getRequiredElements();
   6.261 -                    LOG.fine("      ... add required elements: " + requiredElements);
   6.262 -                    operate.add(requiredElements);
   6.263 -                }
   6.264 -            }
   6.265 -        }
   6.266 -        final InstallSupport support = operate.getSupport();
   6.267 -        if (support == null) {
   6.268 -            env.getOutputStream().println(Bundle.MSG_UpdateNoMatch(pats == null ? null : Arrays.asList(pats)));
   6.269 -            return;
   6.270 -        }
   6.271 -        try {
   6.272 -            final Validator res1 = support.doDownload(null, null, false);
   6.273 -            Installer res2 = support.doValidate(res1, null);
   6.274 -            Restarter res3 = support.doInstall(res2, null);
   6.275 -            if (res3 != null) {
   6.276 -                support.doRestart(res3, null);
   6.277 -            }
   6.278 -        } catch (OperationException ex) {
   6.279 -            throw (CommandException)new CommandException(33, ex.getMessage()).initCause(ex);
   6.280 -        }
   6.281 -    }
   6.282 -
   6.283 -    @NbBundle.Messages({
   6.284 -        "MSG_CantCompileRegex=Cannot understand regular expession '{0}'"
   6.285 -    })
   6.286 -    private static Pattern[] findMatcher(Env env, String[] pattern) {
   6.287 -        Pattern[] arr = new Pattern[pattern.length];
   6.288 -        for (int i = 0; i < arr.length; i++) {
   6.289 -            try {
   6.290 -                arr[i] = Pattern.compile(pattern[i]);
   6.291 -            } catch (PatternSyntaxException e) {
   6.292 -                env.getErrorStream().println(Bundle.MSG_CantCompileRegex(pattern[i]));
   6.293 -            }
   6.294 -        }
   6.295 -        return arr;
   6.296 -    }
   6.297 -
   6.298 -    private static boolean matches(String txt, Pattern[] pats) {
   6.299 -        for (Pattern p : pats) {
   6.300 -            if (p == null) {
   6.301 -                continue;
   6.302 -            }
   6.303 -            if (p.matcher(txt).matches()) {
   6.304 -                return true;
   6.305 -            }
   6.306 -        }
   6.307 -        return false;
   6.308 -    }
   6.309 -
   6.310 -    @NbBundle.Messages({
   6.311 -        "MSG_Installing=Installing {0}@{1}",
   6.312 -        "MSG_InstallNoMatch=Cannot install. No match for {0}."
   6.313 -    })
   6.314 -    private void install(Env env, String... pattern) throws CommandException {
   6.315 -        if (! initialized()) {
   6.316 -            refresh(env);
   6.317 -        }
   6.318 -
   6.319 -        Pattern[] pats = findMatcher(env, pattern);
   6.320 -
   6.321 -        List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits();
   6.322 -        OperationContainer<InstallSupport> operate = OperationContainer.createForInstall();
   6.323 -        for (UpdateUnit uu : units) {
   6.324 -            if (uu.getInstalled() != null) {
   6.325 -                continue;
   6.326 -            }
   6.327 -            if (!matches(uu.getCodeName(), pats)) {
   6.328 -                continue;
   6.329 -            }
   6.330 -            if (uu.getAvailableUpdates().isEmpty()) {
   6.331 -                continue;
   6.332 -            }
   6.333 -            UpdateElement ue = uu.getAvailableUpdates().get(0);
   6.334 -            env.getOutputStream().println(
   6.335 -                    Bundle.MSG_Installing(uu.getCodeName(), ue.getSpecificationVersion()));
   6.336 -            operate.add(ue);
   6.337 -        }
   6.338 -        final InstallSupport support = operate.getSupport();
   6.339 -        if (support == null) {
   6.340 -            env.getOutputStream().println(Bundle.MSG_InstallNoMatch(Arrays.asList(pats)));
   6.341 -            return;
   6.342 -        }
   6.343 -        try {
   6.344 -            final Validator res1 = support.doDownload(null, null, false);
   6.345 -            Installer res2 = support.doValidate(res1, null);
   6.346 -            Restarter res3 = support.doInstall(res2, null);
   6.347 -            if (res3 != null) {
   6.348 -                support.doRestart(res3, null);
   6.349 -            }
   6.350 -        } catch (OperationException ex) {
   6.351 -            // a hack
   6.352 -            if (OperationException.ERROR_TYPE.INSTALL.equals(ex.getErrorType())) {
   6.353 -                // probably timeout of loading, don't report now
   6.354 -                env.getOutputStream().println(ex.getLocalizedMessage());
   6.355 -            } else {
   6.356 -                throw (CommandException) new CommandException(33, ex.getMessage()).initCause(ex);
   6.357 -            }
   6.358 -        }
   6.359 -    }
   6.360 -    
   6.361 -    private void updateAll(Env env) throws CommandException {
   6.362 -        updateModules(env);
   6.363 -    }
   6.364 -
   6.365 -    private boolean initialized() {
   6.366 -        Preferences pref = NbPreferences.root ().node ("/org/netbeans/modules/autoupdate");
   6.367 -        long last = pref.getLong("lastCheckTime", -1);
   6.368 -        return last != -1;
   6.369 -    }    
   6.370 -    
   6.371 -}
     7.1 --- a/modulemanagement/src/org/netbeans/modules/modulemanagement/PrintTable.java	Tue Aug 28 22:07:58 2012 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,128 +0,0 @@
     7.4 -/*
     7.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     7.6 - *
     7.7 - * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
     7.8 - *
     7.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    7.10 - * Other names may be trademarks of their respective owners.
    7.11 - *
    7.12 - * The contents of this file are subject to the terms of either the GNU
    7.13 - * General Public License Version 2 only ("GPL") or the Common
    7.14 - * Development and Distribution License("CDDL") (collectively, the
    7.15 - * "License"). You may not use this file except in compliance with the
    7.16 - * License. You can obtain a copy of the License at
    7.17 - * http://www.netbeans.org/cddl-gplv2.html
    7.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    7.19 - * specific language governing permissions and limitations under the
    7.20 - * License.  When distributing the software, include this License Header
    7.21 - * Notice in each file and include the License file at
    7.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    7.23 - * particular file as subject to the "Classpath" exception as provided
    7.24 - * by Oracle in the GPL Version 2 section of the License file that
    7.25 - * accompanied this code. If applicable, add the following below the
    7.26 - * License Header, with the fields enclosed by brackets [] replaced by
    7.27 - * your own identifying information:
    7.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    7.29 - *
    7.30 - * If you wish your version of this file to be governed by only the CDDL
    7.31 - * or only the GPL Version 2, indicate your decision by adding
    7.32 - * "[Contributor] elects to include this software in this distribution
    7.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    7.34 - * single choice of license, a recipient has the option to distribute
    7.35 - * your version of this file under either the CDDL, the GPL Version 2 or
    7.36 - * to extend the choice of license to its licensees as provided above.
    7.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    7.38 - * Version 2 license, then the option applies only if the new code is
    7.39 - * made subject to such option by the copyright holder.
    7.40 - *
    7.41 - * Contributor(s):
    7.42 - *
    7.43 - * Portions Copyrighted 2012 Sun Microsystems, Inc.
    7.44 - */
    7.45 -package org.netbeans.modules.modulemanagement;
    7.46 -
    7.47 -import java.io.PrintStream;
    7.48 -import java.util.ArrayList;
    7.49 -import java.util.List;
    7.50 -
    7.51 -/** Prints table formated for output stream.
    7.52 - *
    7.53 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    7.54 - */
    7.55 -final class PrintTable {
    7.56 -    private final String[] names;
    7.57 -    private final List<String[]> data;
    7.58 -    private int[] limits;
    7.59 -    
    7.60 -    public PrintTable(String... fieldNames) {
    7.61 -        names = fieldNames;
    7.62 -        data = new ArrayList<String[]>();
    7.63 -    }
    7.64 -    
    7.65 -    public void setLimits(int... limits) {
    7.66 -        assert limits.length == names.length;
    7.67 -        this.limits = limits;
    7.68 -    }
    7.69 -    
    7.70 -    public void addRow(String... fields) {
    7.71 -        data.add(fields);
    7.72 -    }
    7.73 -    
    7.74 -    public void write(PrintStream ps) {
    7.75 -        int[] lengths = new int[names.length];
    7.76 -        length(names, lengths, limits);
    7.77 -        for (String[] arr : data) {
    7.78 -            length(arr, lengths, limits);
    7.79 -        }
    7.80 -        
    7.81 -        printRow(ps, names, lengths, limits);
    7.82 -        printSeparator(ps, lengths);
    7.83 -        for (String[] arr : data) {
    7.84 -            printRow(ps, arr, lengths, limits);
    7.85 -        }
    7.86 -        printSeparator(ps, lengths);
    7.87 -    }
    7.88 -    
    7.89 -    private static void length(String[] data, int[] lengths, int[] limits) {
    7.90 -        assert data.length == lengths.length;
    7.91 -        for (int i = 0; i < data.length; i++) {
    7.92 -            int l = data[i].length();
    7.93 -            if (limits != null && limits[i] >= 0 && l > limits[i]) {
    7.94 -                l = limits[i];
    7.95 -            }
    7.96 -            if (lengths[i] < l) {
    7.97 -                lengths[i] = l;
    7.98 -            }
    7.99 -        }
   7.100 -    }
   7.101 -
   7.102 -    private static void printRow(PrintStream ps, String[] data, int[] lengths, int[] limits) {
   7.103 -        assert data.length == lengths.length;
   7.104 -        String sep = "";
   7.105 -        for (int i = 0; i < data.length; i++) {
   7.106 -            ps.print(sep);
   7.107 -            String d = data[i];
   7.108 -            if (limits != null && limits[i] >= 0 && d.length() > limits[i]) {
   7.109 -                d = d.substring(0, limits[i]);
   7.110 -            }
   7.111 -            ps.print(d);
   7.112 -            int missing = lengths[i] - d.length();
   7.113 -            while (missing-- > 0) {
   7.114 -                ps.print(' ');
   7.115 -            }
   7.116 -            sep = " ";
   7.117 -        }
   7.118 -        ps.println();
   7.119 -    }
   7.120 -    private static void printSeparator(PrintStream ps, int[] lengths) {
   7.121 -        String sep = "";
   7.122 -        for (int i = 0; i < lengths.length; i++) {
   7.123 -            ps.print(sep);
   7.124 -            for (int j = 0; j < lengths[i]; j++) {
   7.125 -                ps.print('-');
   7.126 -            }
   7.127 -            sep = " ";
   7.128 -        }
   7.129 -        ps.println();
   7.130 -    }
   7.131 -}
     8.1 --- a/modulemanagement/src/org/netbeans/modules/modulemanagement/Status.java	Tue Aug 28 22:07:58 2012 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,131 +0,0 @@
     8.4 -/*
     8.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     8.6 - *
     8.7 - * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
     8.8 - *
     8.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    8.10 - * Other names may be trademarks of their respective owners.
    8.11 - *
    8.12 - * The contents of this file are subject to the terms of either the GNU
    8.13 - * General Public License Version 2 only ("GPL") or the Common
    8.14 - * Development and Distribution License("CDDL") (collectively, the
    8.15 - * "License"). You may not use this file except in compliance with the
    8.16 - * License. You can obtain a copy of the License at
    8.17 - * http://www.netbeans.org/cddl-gplv2.html
    8.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    8.19 - * specific language governing permissions and limitations under the
    8.20 - * License.  When distributing the software, include this License Header
    8.21 - * Notice in each file and include the License file at
    8.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    8.23 - * particular file as subject to the "Classpath" exception as provided
    8.24 - * by Oracle in the GPL Version 2 section of the License file that
    8.25 - * accompanied this code. If applicable, add the following below the
    8.26 - * License Header, with the fields enclosed by brackets [] replaced by
    8.27 - * your own identifying information:
    8.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    8.29 - *
    8.30 - * If you wish your version of this file to be governed by only the CDDL
    8.31 - * or only the GPL Version 2, indicate your decision by adding
    8.32 - * "[Contributor] elects to include this software in this distribution
    8.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    8.34 - * single choice of license, a recipient has the option to distribute
    8.35 - * your version of this file under either the CDDL, the GPL Version 2 or
    8.36 - * to extend the choice of license to its licensees as provided above.
    8.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    8.38 - * Version 2 license, then the option applies only if the new code is
    8.39 - * made subject to such option by the copyright holder.
    8.40 - *
    8.41 - * Contributor(s):
    8.42 - *
    8.43 - * Portions Copyrighted 2012 Sun Microsystems, Inc.
    8.44 - */
    8.45 -package org.netbeans.modules.modulemanagement;
    8.46 -
    8.47 -import java.util.List;
    8.48 -import org.netbeans.api.autoupdate.UpdateElement;
    8.49 -import org.netbeans.api.autoupdate.UpdateUnit;
    8.50 -import org.openide.modules.ModuleInfo;
    8.51 -import org.openide.util.Lookup;
    8.52 -import org.openide.util.NbBundle;
    8.53 -
    8.54 -/**
    8.55 - *
    8.56 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    8.57 - */
    8.58 -final class Status {
    8.59 -
    8.60 -    static String[] toArray(UpdateUnit uu) {
    8.61 -        if (uu.getInstalled() != null) {
    8.62 -            return new String[] { 
    8.63 -                uu.getCodeName(),
    8.64 -                uu.getInstalled().getSpecificationVersion(), 
    8.65 -                Status.installed(uu).toString()
    8.66 -            };
    8.67 -        } else {
    8.68 -            List<UpdateElement> updates = uu.getAvailableUpdates();
    8.69 -            if (updates.isEmpty()) {
    8.70 -                return new String[] {
    8.71 -                    uu.getCodeName(),
    8.72 -                    "N/A", "N/A"
    8.73 -                };
    8.74 -            }
    8.75 -            UpdateElement first = updates.get(0);
    8.76 -            return new String[] { 
    8.77 -                uu.getCodeName(),
    8.78 -                first.getSpecificationVersion(), 
    8.79 -                Status.update(uu).toString()
    8.80 -            };
    8.81 -        }
    8.82 -    }
    8.83 -
    8.84 -    final String txt;
    8.85 -
    8.86 -    private Status(String txt) {
    8.87 -        this.txt = txt;
    8.88 -    }
    8.89 -    
    8.90 -    @NbBundle.Messages({
    8.91 -        "MSG_Enabled=Enabled",
    8.92 -        "MSG_Disabled=Installed",
    8.93 -        "MSG_UpdateAvailable=Upgrade to {0}",
    8.94 -        "MSG_Unknown=Unknown state"
    8.95 -    })
    8.96 -    private static Status installed(UpdateUnit uu) {
    8.97 -        assert uu.getInstalled() != null;
    8.98 -        String install;
    8.99 -        ModuleInfo mi = find(uu.getCodeName());
   8.100 -        List<UpdateElement> updates = uu.getAvailableUpdates();
   8.101 -        if (!updates.isEmpty()) {
   8.102 -            install = Bundle.MSG_UpdateAvailable(updates.get(0).getSpecificationVersion());
   8.103 -        } else {
   8.104 -            if (mi == null) {
   8.105 -                install = Bundle.MSG_Unknown();
   8.106 -            } else {
   8.107 -                install = mi.isEnabled() ? Bundle.MSG_Enabled() : Bundle.MSG_Disabled();
   8.108 -            }
   8.109 -        }
   8.110 -        
   8.111 -        return new Status(install);
   8.112 -    }
   8.113 -    @NbBundle.Messages({
   8.114 -        "MSG_Updateable=Available"
   8.115 -    })
   8.116 -    private static Status update(UpdateUnit uu) {
   8.117 -        assert uu.getInstalled() == null && !uu.getAvailableUpdates().isEmpty();
   8.118 -        return new Status(Bundle.MSG_Updateable());
   8.119 -    }
   8.120 -
   8.121 -    @Override
   8.122 -    public String toString() {
   8.123 -        return txt;
   8.124 -    }
   8.125 -    
   8.126 -    private static ModuleInfo find(String cnb) {
   8.127 -        for (ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
   8.128 -            if (cnb.equals(mi.getCodeNameBase())) {
   8.129 -                return mi;
   8.130 -            }
   8.131 -        }
   8.132 -        return null;
   8.133 -    }
   8.134 -}
     9.1 --- a/modulemanagement/test/unit/src/org/netbeans/modules/modulemanagement/EnableDisableTest.java	Tue Aug 28 22:07:58 2012 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,186 +0,0 @@
     9.4 -/*
     9.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     9.6 - *
     9.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     9.8 - *
     9.9 - * The contents of this file are subject to the terms of either the GNU
    9.10 - * General Public License Version 2 only ("GPL") or the Common
    9.11 - * Development and Distribution License("CDDL") (collectively, the
    9.12 - * "License"). You may not use this file except in compliance with the
    9.13 - * License. You can obtain a copy of the License at
    9.14 - * http://www.netbeans.org/cddl-gplv2.html
    9.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    9.16 - * specific language governing permissions and limitations under the
    9.17 - * License.  When distributing the software, include this License Header
    9.18 - * Notice in each file and include the License file at
    9.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    9.20 - * particular file as subject to the "Classpath" exception as provided
    9.21 - * by Sun in the GPL Version 2 section of the License file that
    9.22 - * accompanied this code. If applicable, add the following below the
    9.23 - * License Header, with the fields enclosed by brackets [] replaced by
    9.24 - * your own identifying information:
    9.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    9.26 - *
    9.27 - * Contributor(s):
    9.28 - *
    9.29 - * The Original Software is NetBeans. The Initial Developer of the Original
    9.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    9.31 - * Microsystems, Inc. All Rights Reserved.
    9.32 - *
    9.33 - * If you wish your version of this file to be governed by only the CDDL
    9.34 - * or only the GPL Version 2, indicate your decision by adding
    9.35 - * "[Contributor] elects to include this software in this distribution
    9.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    9.37 - * single choice of license, a recipient has the option to distribute
    9.38 - * your version of this file under either the CDDL, the GPL Version 2 or
    9.39 - * to extend the choice of license to its licensees as provided above.
    9.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    9.41 - * Version 2 license, then the option applies only if the new code is
    9.42 - * made subject to such option by the copyright holder.
    9.43 - */
    9.44 -
    9.45 -package org.netbeans.modules.modulemanagement;
    9.46 -
    9.47 -import java.io.ByteArrayOutputStream;
    9.48 -import java.io.File;
    9.49 -import java.io.FileOutputStream;
    9.50 -import java.io.IOException;
    9.51 -import java.util.jar.JarEntry;
    9.52 -import java.util.jar.JarOutputStream;
    9.53 -import java.util.jar.Manifest;
    9.54 -import java.util.logging.Level;
    9.55 -import java.util.logging.Logger;
    9.56 -import java.util.regex.Matcher;
    9.57 -import java.util.regex.Pattern;
    9.58 -import org.netbeans.api.sendopts.CommandLine;
    9.59 -import org.netbeans.junit.NbTestCase;
    9.60 -import org.openide.modules.ModuleInfo;
    9.61 -import org.openide.util.Lookup;
    9.62 -
    9.63 -/**
    9.64 - *
    9.65 - * @author Jaroslav Tulach
    9.66 - */
    9.67 -public class EnableDisableTest extends NbTestCase {
    9.68 -    private Logger LOG;
    9.69 -    
    9.70 -    public EnableDisableTest(String testName) {
    9.71 -        super(testName);
    9.72 -    }
    9.73 -    
    9.74 -    protected void setUp() throws Exception {
    9.75 -        clearWorkDir();
    9.76 -        
    9.77 -        LOG = Logger.getLogger("TEST-" + getName());
    9.78 -
    9.79 -        System.setProperty("netbeans.user", getWorkDirPath() + File.separator + "userdir");
    9.80 -
    9.81 -        // initialize whole infra
    9.82 -        Lookup.getDefault().lookup(ModuleInfo.class);
    9.83 -    }
    9.84 -    
    9.85 -    protected void tearDown() throws Exception {
    9.86 -    }
    9.87 -    
    9.88 -    protected Level logLevel() {
    9.89 -        return Level.FINE;
    9.90 -    }
    9.91 -    
    9.92 -    public void testAModuleIsPrinted() throws Exception {
    9.93 -        ByteArrayOutputStream os = new ByteArrayOutputStream();
    9.94 -        ByteArrayOutputStream err = new ByteArrayOutputStream();
    9.95 -
    9.96 -        CommandLine.getDefault().process(new String[] { "--listmodules" }, System.in, os, err, new File("."));
    9.97 -
    9.98 -        assertEquals("No error", 0, err.size());
    9.99 -
   9.100 -        if (os.toString().indexOf("org.netbeans.bootstrap") < 0) {
   9.101 -            fail("We want default module to be found: " + os.toString());
   9.102 -        }
   9.103 -        if (os.toString().indexOf("org.my.module") != -1) {
   9.104 -            fail("module not found yet: " + os.toString());
   9.105 -        }
   9.106 -
   9.107 -        Manifest m = new Manifest ();
   9.108 -        m.getMainAttributes ().putValue (java.util.jar.Attributes.Name.MANIFEST_VERSION.toString (), "1.0");
   9.109 -        m.getMainAttributes ().putValue ("OpenIDE-Module", "org.my.module/3");
   9.110 -        m.getMainAttributes ().putValue ("OpenIDE-Module-Specification-Version", "3.3");
   9.111 -        File simpleJar = generateJar (new String[0], m);
   9.112 -
   9.113 -        CommandLine.getDefault().process(new String[] { "--installmodules", simpleJar.toString() }, System.in, os, err, new File("."));
   9.114 -
   9.115 -        assertEquals("No error2", 0, err.size());
   9.116 -
   9.117 -        os.reset();
   9.118 -        CommandLine.getDefault().process(new String[] { "--listmodules" }, System.in, os, err, new File("."));
   9.119 -
   9.120 -        assertEquals("No error", 0, err.size());
   9.121 -
   9.122 -        if (os.toString().indexOf("org.my.module") < 0) {
   9.123 -            fail("our module should be found: " + os.toString());
   9.124 -        }
   9.125 -
   9.126 -        os.reset();
   9.127 -        
   9.128 -        Thread.sleep(1000);
   9.129 -        
   9.130 -        LOG.info("About to disable module");
   9.131 -        CommandLine.getDefault().process(new String[] { "--disablemodules", "org.my.module"}, System.in, os, err, new File("."));
   9.132 -        assertEquals("No error", 0, err.size());
   9.133 -        LOG.info("Disabling done");
   9.134 -
   9.135 -        os.reset();
   9.136 -        CommandLine.getDefault().process(new String[] { "--listmodules" }, System.in, os, err, new File("."));
   9.137 -        if (os.toString().indexOf("org.my.module") < 0) {
   9.138 -            fail("our module should be found: " + os.toString());
   9.139 -        }
   9.140 -
   9.141 -        Matcher mac = Pattern.compile("org.my.module/3[ 3\\.]*disabled").matcher(os.toString());
   9.142 -        if (!mac.find()) {
   9.143 -            fail("and should be disabled now: " + os.toString());
   9.144 -        }
   9.145 -
   9.146 -        Thread.sleep(1000);
   9.147 -        
   9.148 -        os.reset();
   9.149 -        CommandLine.getDefault().process(new String[] { "--enablemodules", "org.my.module"}, System.in, os, err, new File("."));
   9.150 -        assertEquals("No error", 0, err.size());
   9.151 -
   9.152 -        os.reset();
   9.153 -        CommandLine.getDefault().process(new String[] { "--listmodules" }, System.in, os, err, new File("."));
   9.154 -        if (os.toString().indexOf("org.my.module") < 0) {
   9.155 -            fail("our module should be found: " + os.toString());
   9.156 -        }
   9.157 -
   9.158 -        mac = Pattern.compile("org.my.module/3[ 3\\.]*enabled").matcher(os.toString());
   9.159 -        if (!mac.find()) {
   9.160 -            fail("and should be disabled now: " + os.toString());
   9.161 -        }
   9.162 -
   9.163 -    }
   9.164 -
   9.165 -    protected final File generateJar (String[] content, Manifest manifest) throws IOException {
   9.166 -        File f;
   9.167 -        int i = 0;
   9.168 -        for (;;) {
   9.169 -            f = new File (this.getWorkDir(), i++ + ".jar");
   9.170 -            if (!f.exists ()) break;
   9.171 -        }
   9.172 -        
   9.173 -        JarOutputStream os;
   9.174 -        if (manifest != null) {
   9.175 -            os = new JarOutputStream (new FileOutputStream (f), manifest);
   9.176 -        } else {
   9.177 -            os = new JarOutputStream (new FileOutputStream (f));
   9.178 -        }
   9.179 -        
   9.180 -        for (i = 0; i < content.length; i++) {
   9.181 -            os.putNextEntry(new JarEntry (content[i]));
   9.182 -            os.closeEntry();
   9.183 -        }
   9.184 -        os.closeEntry ();
   9.185 -        os.close();
   9.186 -        
   9.187 -        return f;
   9.188 -    }
   9.189 -}
    10.1 --- a/modulemanagement/test/unit/src/org/netbeans/modules/modulemanagement/ListModulesTest.java	Tue Aug 28 22:07:58 2012 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,181 +0,0 @@
    10.4 -/*
    10.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    10.6 - *
    10.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    10.8 - *
    10.9 - * The contents of this file are subject to the terms of either the GNU
   10.10 - * General Public License Version 2 only ("GPL") or the Common
   10.11 - * Development and Distribution License("CDDL") (collectively, the
   10.12 - * "License"). You may not use this file except in compliance with the
   10.13 - * License. You can obtain a copy of the License at
   10.14 - * http://www.netbeans.org/cddl-gplv2.html
   10.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   10.16 - * specific language governing permissions and limitations under the
   10.17 - * License.  When distributing the software, include this License Header
   10.18 - * Notice in each file and include the License file at
   10.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   10.20 - * particular file as subject to the "Classpath" exception as provided
   10.21 - * by Sun in the GPL Version 2 section of the License file that
   10.22 - * accompanied this code. If applicable, add the following below the
   10.23 - * License Header, with the fields enclosed by brackets [] replaced by
   10.24 - * your own identifying information:
   10.25 - * "Portions Copyrighted [year] [name of copyright owner]"
   10.26 - *
   10.27 - * Contributor(s):
   10.28 - *
   10.29 - * The Original Software is NetBeans. The Initial Developer of the Original
   10.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   10.31 - * Microsystems, Inc. All Rights Reserved.
   10.32 - *
   10.33 - * If you wish your version of this file to be governed by only the CDDL
   10.34 - * or only the GPL Version 2, indicate your decision by adding
   10.35 - * "[Contributor] elects to include this software in this distribution
   10.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
   10.37 - * single choice of license, a recipient has the option to distribute
   10.38 - * your version of this file under either the CDDL, the GPL Version 2 or
   10.39 - * to extend the choice of license to its licensees as provided above.
   10.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
   10.41 - * Version 2 license, then the option applies only if the new code is
   10.42 - * made subject to such option by the copyright holder.
   10.43 - */
   10.44 -package org.netbeans.modules.modulemanagement;
   10.45 -
   10.46 -import java.io.ByteArrayOutputStream;
   10.47 -import java.io.File;
   10.48 -import java.util.Collections;
   10.49 -import java.util.HashSet;
   10.50 -import java.util.Set;
   10.51 -import junit.framework.TestCase;
   10.52 -import junit.framework.*;
   10.53 -import org.netbeans.api.sendopts.CommandException;
   10.54 -import org.netbeans.api.sendopts.CommandLine;
   10.55 -import org.openide.modules.ModuleInfo;
   10.56 -import org.openide.modules.SpecificationVersion;
   10.57 -import org.openide.util.lookup.AbstractLookup;
   10.58 -import org.openide.util.lookup.InstanceContent;
   10.59 -
   10.60 -/**
   10.61 - *
   10.62 - * @author Jaroslav Tulach
   10.63 - */
   10.64 -public class ListModulesTest extends TestCase {
   10.65 -    static {
   10.66 -        System.setProperty("org.openide.util.Lookup", Lkp.class.getName());
   10.67 -    }
   10.68 -    
   10.69 -    public ListModulesTest(String testName) {
   10.70 -        super(testName);
   10.71 -    }
   10.72 -    
   10.73 -    protected void setUp() throws Exception {
   10.74 -        Lkp.ic.setPairs(Collections.<AbstractLookup.Pair>emptyList());
   10.75 -        Lkp.ic.add(new ModuleOptions());
   10.76 -    }
   10.77 -    
   10.78 -    protected void tearDown() throws Exception {
   10.79 -    }
   10.80 -    
   10.81 -    public static Test suite() {
   10.82 -        TestSuite suite = new TestSuite(ListModulesTest.class);
   10.83 -        
   10.84 -        return suite;
   10.85 -    }
   10.86 -
   10.87 -    public void testAModuleIsPrinted() throws CommandException {
   10.88 -        Lkp.ic.add(new MyModule("my.cnb", 5, new SpecificationVersion("1.3"), true));
   10.89 -        Lkp.ic.add(new MyModule("my.snd.cnb", -1, new SpecificationVersion("5.3.1"), false));
   10.90 -
   10.91 -        ByteArrayOutputStream os = new ByteArrayOutputStream();
   10.92 -        ByteArrayOutputStream err = new ByteArrayOutputStream();
   10.93 -
   10.94 -        CommandLine.getDefault().process(new String[] { "--listmodules" }, System.in, os, err, new File("."));
   10.95 -
   10.96 -        assertEquals("No errors", 0, err.size());
   10.97 -
   10.98 -        String out = os.toString();
   10.99 -        if (out.indexOf("my.cnb") == -1) {
  10.100 -            fail("my.cnb should be there: " + out);
  10.101 -        }
  10.102 -        if (out.indexOf("my.snd.cnb") == -1) {
  10.103 -            fail("snd should be there: " + out);
  10.104 -        }
  10.105 -        if (out.indexOf("disabled") == -1) {
  10.106 -            fail("disabled should be there: " + out);
  10.107 -        }
  10.108 -        if (out.indexOf("enabled") == -1) {
  10.109 -            fail("enabled should be there: " + out);
  10.110 -        }
  10.111 -        if (out.indexOf("/5") == -1) {
  10.112 -            fail("5 should be there: " + out);
  10.113 -        }
  10.114 -        if (out.indexOf("1.3") == -1) {
  10.115 -            fail("1.3 should be there: " + out);
  10.116 -        }
  10.117 -        if (out.indexOf("5.3.1") == -1) {
  10.118 -            fail("5.3.1 should be there: " + out);
  10.119 -        }
  10.120 -    }
  10.121 -    
  10.122 -    public static final class Lkp extends AbstractLookup {
  10.123 -        public static InstanceContent ic = new InstanceContent();
  10.124 -        
  10.125 -        public Lkp() {
  10.126 -            super(ic);
  10.127 -        }
  10.128 -    }
  10.129 -
  10.130 -    private static class MyModule extends ModuleInfo {
  10.131 -
  10.132 -        private boolean enabled;
  10.133 -        private String cnb;
  10.134 -        private int r;
  10.135 -        private SpecificationVersion specV;
  10.136 -
  10.137 -        MyModule(String cnb, int r, SpecificationVersion specV, boolean enabled) {
  10.138 -            this.cnb = cnb;
  10.139 -            this.r = r;
  10.140 -            this.specV = specV;
  10.141 -            this.enabled = enabled;
  10.142 -        }
  10.143 -
  10.144 -        public String getCodeNameBase() {
  10.145 -            return cnb;
  10.146 -        }
  10.147 -
  10.148 -        public int getCodeNameRelease() {
  10.149 -            return r;
  10.150 -        }
  10.151 -
  10.152 -        public String getCodeName() {
  10.153 -            if (r == -1) {
  10.154 -                return getCodeNameBase();
  10.155 -            }
  10.156 -            return getCodeNameBase() + '/' + r;
  10.157 -        }
  10.158 -
  10.159 -        public SpecificationVersion getSpecificationVersion() {
  10.160 -            return specV;
  10.161 -        }
  10.162 -
  10.163 -        public boolean isEnabled() {
  10.164 -            return enabled;
  10.165 -        }
  10.166 -
  10.167 -        public Object getAttribute(String attr) {
  10.168 -            return null;
  10.169 -        }
  10.170 -
  10.171 -        public Object getLocalizedAttribute(String attr) {
  10.172 -            return null;
  10.173 -        }
  10.174 -
  10.175 -        public Set getDependencies() {
  10.176 -            return new HashSet();
  10.177 -        }
  10.178 -
  10.179 -        public boolean owns(Class clazz) {
  10.180 -            return false;
  10.181 -        }
  10.182 -
  10.183 -    }
  10.184 -}