This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 223317
Collapse All | Expand All

(-)a/j2ee.core/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.j2ee.core/0
2
OpenIDE-Module: org.netbeans.modules.j2ee.core/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/j2ee/core/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/j2ee/core/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.15
4
OpenIDE-Module-Specification-Version: 1.16
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
(-)a/j2ee.core/src/org/netbeans/api/j2ee/core/Profile.java (-4 / +53 lines)
Lines 79-104 Link Here
79
    public static final Profile JAVA_EE_7_FULL  = new Profile(6, "1.7", null, "JavaEE7Full.displayName");
79
    public static final Profile JAVA_EE_7_FULL  = new Profile(6, "1.7", null, "JavaEE7Full.displayName");
80
80
81
    public static final Profile JAVA_EE_7_WEB  = new Profile(7, "1.7", "web", "JavaEE7Web.displayName");
81
    public static final Profile JAVA_EE_7_WEB  = new Profile(7, "1.7", "web", "JavaEE7Web.displayName");
82
    
82
83
    private final int order;
83
    private final int order;
84
84
85
    private final String canonicalName;
86
87
    private final String profileType;
88
85
    // cache
89
    // cache
86
    private final String propertiesString;
90
    private final String propertiesString;
87
91
88
    private final String bundleKey;
92
    private final String bundleKey;
89
93
90
    private Profile(int order, String canonicalName, String profile, String bundleKey) {
94
    private Profile(int order, String canonicalName, String profileType, String bundleKey) {
91
        this.order = order;
95
        this.order = order;
96
        this.canonicalName = canonicalName;
97
        this.profileType = profileType;
92
        this.bundleKey = bundleKey;
98
        this.bundleKey = bundleKey;
93
99
94
        StringBuilder builder = new StringBuilder(canonicalName);
100
        StringBuilder builder = new StringBuilder(canonicalName);
95
        if (profile != null) {
101
        if (profileType != null) {
96
            builder.append("-").append(profile); // NOI18N
102
            builder.append("-").append(profileType); // NOI18N
97
        }
103
        }
98
        this.propertiesString = builder.toString();
104
        this.propertiesString = builder.toString();
99
    }
105
    }
100
106
101
    /**
107
    /**
108
     * Finds out if the current profile version is the same or higher in comparison
109
     * to the one from parameter.
110
     *
111
     * @since 1.16
112
     * @param profile which we are comparing with
113
     * @return true if the profile version is equal or higher than the given one, false otherwise
114
     */
115
    public boolean isEqualOrHigher(Profile profile) {
116
        int comparison = UI_COMPARATOR.compare(this, profile);
117
        if (comparison < 0) {
118
            // This version is lower than profile version
119
            return false;
120
121
        } else if (comparison == 0) {
122
            // The same version for both
123
            return true;
124
125
        } else {
126
            // If the canonicalName is the same value we have to differ between Web and Full profile
127
            if (canonicalName.equals(profile.canonicalName)) {
128
                boolean isThisFullProfile = isFullProfile(this);
129
                boolean isParamFullProfile = isFullProfile(profile);
130
131
                if (isThisFullProfile && isParamFullProfile) {
132
                    // Both profiles are Java EE Full
133
                    return true;
134
                }
135
                if (!isThisFullProfile && !isParamFullProfile) {
136
                    // Both profiles are Java EE Web
137
                    return true;
138
                }
139
                return false;
140
            } else {
141
                return true;
142
            }
143
        }
144
    }
145
146
    private boolean isFullProfile(Profile profile) {
147
        return profile.profileType == null;
148
    }
149
150
    /**
102
     * Returns the UI visible description of the profile.
151
     * Returns the UI visible description of the profile.
103
     *
152
     *
104
     * @return the UI visible description of the profile
153
     * @return the UI visible description of the profile
(-)a/j2ee.core/test/unit/src/org/netbeans/api/j2ee/core/ProfileTest.java (-1 / +22 lines)
Lines 39-45 Link Here
39
 *
39
 *
40
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
41
 */
41
 */
42
43
package org.netbeans.api.j2ee.core;
42
package org.netbeans.api.j2ee.core;
44
43
45
import org.netbeans.junit.NbTestCase;
44
import org.netbeans.junit.NbTestCase;
Lines 64-67 Link Here
64
        assertEquals(Profile.JAVA_EE_6_WEB, Profile.fromPropertiesString("EE_6_WEB"));
63
        assertEquals(Profile.JAVA_EE_6_WEB, Profile.fromPropertiesString("EE_6_WEB"));
65
        assertNull(Profile.fromPropertiesString("something"));
64
        assertNull(Profile.fromPropertiesString("something"));
66
    }
65
    }
66
67
    public void testIsEqualOrHigherJavaEE5() {
68
        assertFalse(Profile.JAVA_EE_5.isEqualOrHigher(Profile.J2EE_13));
69
        assertFalse(Profile.JAVA_EE_5.isEqualOrHigher(Profile.J2EE_14));
70
71
        assertTrue(Profile.JAVA_EE_5.isEqualOrHigher(Profile.JAVA_EE_5));
72
        assertTrue(Profile.JAVA_EE_5.isEqualOrHigher(Profile.JAVA_EE_6_FULL));
73
        assertTrue(Profile.JAVA_EE_5.isEqualOrHigher(Profile.JAVA_EE_6_WEB));
74
        assertTrue(Profile.JAVA_EE_5.isEqualOrHigher(Profile.JAVA_EE_7_FULL));
75
        assertTrue(Profile.JAVA_EE_5.isEqualOrHigher(Profile.JAVA_EE_7_WEB));
76
    }
77
78
    public void testIsEqualOrHigherJavaEE6full() {
79
        assertFalse(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.J2EE_13));
80
        assertFalse(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.J2EE_14));
81
        assertFalse(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.JAVA_EE_5));
82
        assertFalse(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.JAVA_EE_6_WEB));
83
84
        assertTrue(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.JAVA_EE_6_FULL));
85
        assertTrue(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.JAVA_EE_7_FULL));
86
        assertTrue(Profile.JAVA_EE_6_FULL.isEqualOrHigher(Profile.JAVA_EE_7_WEB));
87
    }
67
}
88
}

Return to bug 223317