*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 332;
+ public static final int LAST_VERSION = 333;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('330');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('331');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('332');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('333');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"NAME" VARCHAR(100) NOT NULL,
"DEFAULT_PROFILE" BOOLEAN DEFAULT FALSE,
"PROVIDED" BOOLEAN NOT NULL DEFAULT FALSE,
- "LANGUAGE" VARCHAR(16),
+ "LANGUAGE" VARCHAR(20),
"PARENT_NAME" VARCHAR(100),
"VERSION" INTEGER DEFAULT 1,
"USED_PROFILE" BOOLEAN DEFAULT FALSE
"QUALIFIER" VARCHAR(10),
"KEE" VARCHAR(400),
"ROOT_ID" INTEGER,
- "LANGUAGE" VARCHAR(5),
+ "LANGUAGE" VARCHAR(20),
"COPY_RESOURCE_ID" INTEGER,
"LONG_NAME" VARCHAR(256),
"PERSON_ID" INTEGER,
@Column(name = "kee", updatable = false, nullable = false, length = KEY_SIZE)
private String key;
- @Column(name = "language", updatable = true, nullable = true, length = 5)
+ @Column(name = "language", updatable = true, nullable = true, length = 20)
private String languageKey;
@Column(name = "root_id", updatable = true, nullable = true)
}
ResourceModel other = (ResourceModel) obj;
return new EqualsBuilder()
- .append(key, other.key)
- .append(enabled, other.enabled)
- .append(rootId, other.rootId)
- .isEquals();
+ .append(key, other.key)
+ .append(enabled, other.enabled)
+ .append(rootId, other.rootId)
+ .isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
- .append(key)
- .append(enabled)
- .append(rootId)
- .toHashCode();
+ .append(key)
+ .append(enabled)
+ .append(rootId)
+ .toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
- .append("id", getId())
- .append("key", key)
- .append("scope", scope)
- .append("qualifier", qualifier)
- .append("name", name)
- .append("longName", longName)
- .append("lang", languageKey)
- .append("enabled", enabled)
- .append("rootId", rootId)
- .append("copyResourceId", copyResourceId)
- .append("personId", personId)
- .append("createdAt", createdAt)
- .toString();
+ .append("id", getId())
+ .append("key", key)
+ .append("scope", scope)
+ .append("qualifier", qualifier)
+ .append("name", name)
+ .append("longName", longName)
+ .append("lang", languageKey)
+ .append("enabled", enabled)
+ .append("rootId", rootId)
+ .append("copyResourceId", copyResourceId)
+ .append("personId", personId)
+ .append("createdAt", createdAt)
+ .toString();
}
@Override
@Column(name = "used_profile", updatable = true, nullable = false)
private Boolean used = Boolean.FALSE;
- @Column(name = "language", updatable = true, nullable = false)
+ @Column(name = "language", updatable = true, nullable = false, length = 20)
private String language;
@Column(name = "parent_name", updatable = true, nullable = true)
* @deprecated since 3.3. Always return true.
* @return
*/
-@Deprecated
+ @Deprecated
public boolean isEnabled() {
return true;
}
*/
package org.sonar.api.resources;
+import com.google.common.base.Preconditions;
+
import java.util.Locale;
/**
/**
* Better to use AbstractLanguage(key, name). In this case, key and name will be the same
+ *
+ * @param key The key of the language. Must not be more than 20 chars.
*/
public AbstractLanguage(String key) {
this(key, key);
/**
* Should be the constructor used to build an AbstractLanguage.
*
- * @param key the key that will be used to retrieve the language. This key is important as it will be used to teint rules repositories...
+ * @param key the key that will be used to retrieve the language. Must not be more than 20 chars. This key is important as it will be used to teint rules repositories...
* @param name the display name of the language in the interface
*/
public AbstractLanguage(String key, String name) {
+ Preconditions.checkArgument(key.length() < 21, "The following language key exceeds 20 characters: '" + key + "'");
this.key = key.toLowerCase(Locale.ENGLISH);
this.name = name;
}
public interface Language extends BatchExtension, ServerExtension {
/**
- * For example "java". Should not be more than 5 chars.
+ * For example "java". Should not be more than 20 chars.
*/
String getKey();
*/
package org.sonar.api.resources;
-import static org.junit.Assert.assertEquals;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.junit.Assert.assertEquals;
public class AbstractLanguageTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Test
public void aLanguageShouldEqualItselft() {
assertEquals(new Java(), new Java());
}
+ @Test
+ public void shouldNotDefineLanguageWithTooLongKey() {
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("The following language key exceeds 20 characters: 'aKeyWhichIsVeryVeryVeryVeryVeryLong'");
+
+ new TooLongKeyLanguage();
+ }
+
+ class TooLongKeyLanguage extends AbstractLanguage {
+ public TooLongKeyLanguage() {
+ super("aKeyWhichIsVeryVeryVeryVeryVeryLong");
+ }
+
+ public String[] getFileSuffixes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ }
+
}
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+#
+# Sonar 3.3
+#
+class UpdateLanguageKeyMaxSize < ActiveRecord::Migration
+
+ def self.up
+ change_column :projects, :language, :string, :null => true, :limit => 20
+ change_column :rules_profiles, :language, :string, :null => true, :limit => 20
+ end
+
+end