sb.append("Project: ").append(projectName).append("\n\n");
sb.append(notification.getFieldValue("count")).append(" new issues").append("\n\n");
sb.append(" ");
- for (Iterator<String> severityIterator = Lists.reverse(Severity.ALL).iterator(); severityIterator.hasNext(); ) {
+ for (Iterator<String> severityIterator = Lists.reverse(Severity.ALL).iterator(); severityIterator.hasNext();) {
String severity = severityIterator.next();
- String severityLabel = i18n.message(getLocale(), "severity."+ severity, severity);
- sb.append(severityLabel).append(": ").append(notification.getFieldValue("count-"+ severity));
+ String severityLabel = i18n.message(getLocale(), "severity." + severity, severity);
+ sb.append(severityLabel).append(": ").append(notification.getFieldValue("count-" + severity));
if (severityIterator.hasNext()) {
sb.append(" ");
}
appendFooter(sb, notification);
- EmailMessage message = new EmailMessage()
+ return new EmailMessage()
.setMessageId("new-issues/" + notification.getFieldValue(FIELD_PROJECT_KEY))
.setSubject(projectName + ": new issues")
.setMessage(sb.toString());
-
- return message;
}
private void appendFooter(StringBuilder sb, Notification notification) {
public File pluginFile(final RemotePlugin remote) {
try {
final RemotePluginFile file = remote.file();
- File cachedFile = fileCache.get(file.getFilename(), file.getHash(), new FileCache.Downloader() {
+ return fileCache.get(file.getFilename(), file.getHash(), new FileCache.Downloader() {
public void download(String filename, File toFile) throws IOException {
String url = "/deploy/plugins/" + remote.getKey() + "/" + file.getFilename();
if (LOG.isDebugEnabled()) {
server.download(url, toFile);
}
});
- return cachedFile;
} catch (Exception e) {
throw new IllegalStateException("Fail to download plugin: " + remote.getKey(), e);
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.languages;
\ No newline at end of file
+package org.sonar.batch.languages;
import org.sonar.core.graph.graphson.GraphsonWriter;
import org.sonar.core.graph.jdbc.GraphDto;
import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.persistence.BatchSession;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.rules;
\ No newline at end of file
+package org.sonar.batch.rules;
/**
* Used by scan2
*/
- public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, ProjectDefinition def, Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer) {
+ public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, ProjectDefinition def, Settings settings,
+ FileIndexer indexer, ModuleFileSystemInitializer initializer) {
this(moduleInputFileCache, def.getKey(), settings, indexer, initializer, null);
}
- public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, ProjectDefinition def, Project project, Settings settings, FileIndexer indexer,
+ public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, ProjectDefinition def, Project project,
+ Settings settings, FileIndexer indexer,
ModuleFileSystemInitializer initializer,
ComponentIndexer componentIndexer) {
this(moduleInputFileCache, project.getKey(), settings, indexer, initializer, componentIndexer);
}
- private DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, String moduleKey, Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer,
+ private DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, String moduleKey, Settings settings,
+ FileIndexer indexer, ModuleFileSystemInitializer initializer,
@Nullable ComponentIndexer componentIndexer) {
super(moduleInputFileCache);
this.componentIndexer = componentIndexer;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.scan2;
\ No newline at end of file
+package org.sonar.batch.scan2;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.settings;
\ No newline at end of file
+package org.sonar.batch.settings;
* A GraphSONUtility that includes the specified properties.
*/
GraphsonUtil(GraphsonMode mode, ElementFactory factory,
- Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys) {
+ Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys) {
this(mode, factory, ElementPropertyConfig.includeProperties(vertexPropertyKeys, edgePropertyKeys));
}
GraphsonUtil(GraphsonMode mode, ElementFactory factory,
- ElementPropertyConfig config) {
+ ElementPropertyConfig config) {
this.vertexPropertyKeys = config.getVertexPropertyKeys();
this.edgePropertyKeys = config.getEdgePropertyKeys();
this.vertexPropertiesRule = config.getVertexPropertiesRule();
*/
static JSONObject jsonFromElement(Element element, @Nullable Set<String> propertyKeys, GraphsonMode mode) {
GraphsonUtil graphson = element instanceof Edge ? new GraphsonUtil(mode, null, null, propertyKeys)
- : new GraphsonUtil(mode, null, propertyKeys, null);
+ : new GraphsonUtil(mode, null, propertyKeys, null);
return graphson.jsonFromElement(element);
}
* @param propertyKeys a list of keys to include on reading of element properties
*/
static Vertex vertexFromJson(JSONObject json, ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws IOException {
+ Set<String> propertyKeys) throws IOException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
}
* @param propertyKeys a list of keys to include on reading of element properties
*/
static Vertex vertexFromJson(String json, ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws ParseException {
+ Set<String> propertyKeys) throws ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
}
* @param propertyKeys a list of keys to include on reading of element properties
*/
static Vertex vertexFromJson(InputStream json, ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws IOException, ParseException {
+ Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
}
private static boolean includeReservedKey(GraphsonMode mode, String key,
- Set<String> propertyKeys,
- ElementPropertiesRule rule) {
- // the key is always included in modes other than compact. if it is compact, then validate that the
+ Set<String> propertyKeys,
+ ElementPropertiesRule rule) {
+ // the key is always included in modes other than compact. if it is compact, then validate that the
// key is in the property key list
return mode != GraphsonMode.COMPACT || includeKey(key, propertyKeys, rule);
}
private static boolean includeKey(String key, Set<String> propertyKeys,
- ElementPropertiesRule rule) {
+ ElementPropertiesRule rule) {
if (propertyKeys == null) {
// when null always include the key and shortcut this piece
return true;
}
- // default the key situation. if it's included then it should be explicitly defined in the
+ // default the key situation. if it's included then it should be explicitly defined in the
// property keys list to be included or the reverse otherwise
boolean keySituation = rule == ElementPropertiesRule.INCLUDE;
- switch (rule) {
- case INCLUDE:
- keySituation = propertyKeys.contains(key);
- break;
- case EXCLUDE:
- keySituation = !propertyKeys.contains(key);
- break;
+ if (rule == ElementPropertiesRule.INCLUDE) {
+ keySituation = propertyKeys.contains(key);
+ } else if (rule == ElementPropertiesRule.EXCLUDE) {
+ keySituation = !propertyKeys.contains(key);
}
-
return keySituation;
}
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(String json, Vertex out, Vertex in,
- ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws IOException, ParseException {
+ ElementFactory factory, GraphsonMode mode,
+ Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
}
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(InputStream json, Vertex out, Vertex in,
- ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws IOException, ParseException {
+ ElementFactory factory, GraphsonMode mode,
+ Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
}
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(JSONObject json, Vertex out, Vertex in,
- ElementFactory factory, GraphsonMode mode,
- Set<String> propertyKeys) throws IOException {
+ ElementFactory factory, GraphsonMode mode,
+ Set<String> propertyKeys) throws IOException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
}
private static boolean isReservedKey(String key) {
return key.equals(GraphsonTokens._ID) || key.equals(GraphsonTokens._TYPE) || key.equals(GraphsonTokens._LABEL)
- || key.equals(GraphsonTokens._OUT_V) || key.equals(GraphsonTokens._IN_V);
+ || key.equals(GraphsonTokens._OUT_V) || key.equals(GraphsonTokens._IN_V);
}
private static JSONArray createJSONList(List list, Set<String> propertyKeys, boolean showTypes) {
value = createJSONMap((Map) value, propertyKeys, showTypes);
} else if (value instanceof Element) {
value = jsonFromElement((Element) value, propertyKeys,
- showTypes ? GraphsonMode.EXTENDED : GraphsonMode.NORMAL);
+ showTypes ? GraphsonMode.EXTENDED : GraphsonMode.NORMAL);
} else if (value.getClass().isArray()) {
value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
}
} else if (type.equals(GraphsonTokens.TYPE_MAP)) {
- // maps are converted to a ObjectNode. called recursively to traverse
+ // maps are converted to a ObjectNode. called recursively to traverse
// the entire object graph within the map.
JSONObject convertedMap = new JSONObject();
JSONObject jsonObject = (JSONObject) value;
} else {
- // this must be a primitive value or a complex object. if a complex
+ // this must be a primitive value or a complex object. if a complex
// object it will be handled by a call to toString and stored as a
// string value
putObject(valueAndType, GraphsonTokens.VALUE, value);
putObject(jsonElement, GraphsonTokens._ID, element.getId());
}
- // it's important to keep the order of these straight. check Edge first and then Vertex because there
+ // it's important to keep the order of these straight. check Edge first and then Vertex because there
// are graph implementations that have Edge extend from Vertex
if (element instanceof Edge) {
Edge edge = (Edge) element;
import org.apache.ibatis.session.SqlSession;
import org.sonar.core.cluster.WorkQueue;
-import java.sql.Connection;
import java.util.List;
import java.util.Map;
private final int batchSize;
private int count = 0;
-
BatchSession(WorkQueue queue, SqlSession session) {
this(queue, session, MAX_BATCH_SIZE);
}
this.batchSize = batchSize;
}
+ @Override
public void select(String statement, Object parameter, ResultHandler handler) {
reset();
super.select(statement, parameter, handler);
}
+ @Override
public void select(String statement, ResultHandler handler) {
reset();
super.select(statement, handler);
}
+ @Override
public <T> T selectOne(String statement) {
reset();
return (T) super.selectOne(statement);
}
+ @Override
public <T> T selectOne(String statement, Object parameter) {
reset();
return (T) super.selectOne(statement, parameter);
}
+ @Override
public <E> List<E> selectList(String statement) {
reset();
return super.selectList(statement);
}
+ @Override
public <E> List<E> selectList(String statement, Object parameter) {
reset();
return super.selectList(statement, parameter);
}
+ @Override
public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds) {
reset();
return super.selectList(statement, parameter, rowBounds);
}
+ @Override
public <K, V> Map<K, V> selectMap(String statement, String mapKey) {
reset();
return super.selectMap(statement, mapKey);
}
+ @Override
public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey) {
reset();
return super.selectMap(statement, parameter, mapKey);
}
+ @Override
public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) {
reset();
return super.selectMap(statement, parameter, mapKey, rowBounds);
}
+ @Override
public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
reset();
super.select(statement, parameter, rowBounds, handler);
}
+ @Override
public int insert(String statement) {
makeSureGeneratedKeysAreNotUsedInBatchInserts(statement);
increment();
return super.insert(statement);
}
+ @Override
public int insert(String statement, Object parameter) {
makeSureGeneratedKeysAreNotUsedInBatchInserts(statement);
increment();
}
}
+ @Override
public int update(String statement) {
increment();
return super.update(statement);
}
+ @Override
public int update(String statement, Object parameter) {
increment();
return super.update(statement, parameter);
}
+ @Override
public int delete(String statement) {
increment();
return super.delete(statement);
}
+ @Override
public int delete(String statement, Object parameter) {
increment();
return super.delete(statement, parameter);
}
+ @Override
public void commit() {
super.commit();
reset();
}
+ @Override
public void commit(boolean force) {
super.commit(force);
reset();
}
+ @Override
public void rollback() {
super.rollback();
reset();
}
+ @Override
public void rollback(boolean force) {
super.rollback(force);
reset();
}
+ @Override
public List<BatchResult> flushStatements() {
List<BatchResult> batchResults = super.flushStatements();
reset();
return batchResults;
}
- public void close() {
- super.close();
- }
-
- public void clearCache() {
- super.clearCache();
- }
-
- public Configuration getConfiguration() {
- return super.getConfiguration();
- }
-
+ @Override
public <T> T getMapper(Class<T> type) {
return getConfiguration().getMapper(type, this);
}
- public Connection getConnection() {
- return super.getConnection();
- }
-
private BatchSession increment() {
count += 1;
if (count >= batchSize) {
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer.internal;
\ No newline at end of file
+package org.sonar.api.batch.analyzer.internal;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer.issue.internal;
\ No newline at end of file
+package org.sonar.api.batch.analyzer.issue.internal;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer.issue;
\ No newline at end of file
+package org.sonar.api.batch.analyzer.issue;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer.measure.internal;
\ No newline at end of file
+package org.sonar.api.batch.analyzer.measure.internal;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer.measure;
\ No newline at end of file
+package org.sonar.api.batch.analyzer.measure;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.analyzer;
\ No newline at end of file
+package org.sonar.api.batch.analyzer;
// nothing to do by default
}
- public static abstract class Cache {
+ public abstract static class Cache {
protected abstract Iterable<InputFile> inputFiles();
@CheckForNull
public static final class LogFields extends Indexable {
- public final static IndexField KEY = add(IndexField.Type.STRING, "key");
- public final static IndexField TYPE = addSortable(IndexField.Type.STRING, "type");
- public final static IndexField ACTION = addSortable(IndexField.Type.STRING, "action");
- public final static IndexField CREATED_AT = addSortable(IndexField.Type.DATE, "createdAt");
- public final static IndexField UPDATED_AT = addSortable(IndexField.Type.DATE, BaseNormalizer.UPDATED_AT_FIELD);
- public final static IndexField LOGIN = addSearchable(IndexField.Type.STRING, "login");
- public final static IndexField DETAILS = addSearchable(IndexField.Type.OBJECT, "details");
- public final static IndexField MESSAGE = addSearchable(IndexField.Type.STRING, "message");
+ public static final IndexField KEY = add(IndexField.Type.STRING, "key");
+ public static final IndexField TYPE = addSortable(IndexField.Type.STRING, "type");
+ public static final IndexField ACTION = addSortable(IndexField.Type.STRING, "action");
+ public static final IndexField CREATED_AT = addSortable(IndexField.Type.DATE, "createdAt");
+ public static final IndexField UPDATED_AT = addSortable(IndexField.Type.DATE, BaseNormalizer.UPDATED_AT_FIELD);
+ public static final IndexField LOGIN = addSearchable(IndexField.Type.STRING, "login");
+ public static final IndexField DETAILS = addSearchable(IndexField.Type.OBJECT, "details");
+ public static final IndexField MESSAGE = addSearchable(IndexField.Type.STRING, "message");
public static Set<IndexField> ALL_FIELDS = getAllFields();
package org.sonar.server.db.migrations.v43;
-import com.google.common.annotations.VisibleForTesting;
import org.sonar.api.issue.Issue;
import org.sonar.api.utils.System2;
import org.sonar.core.persistence.Database;
return true;
}
}
- );
+ );
}
private static class Row {
* when its schema is up-to-date.
*/
Collection level3Components() {
- List components = Lists.newArrayList(
+ return Lists.newArrayList(
PersistentSettings.class,
DefaultDatabaseConnector.class,
ThreadLocalDatabaseSessionFactory.class,
UriReader.class,
ServerIdGenerator.class
);
- return components;
}
*/
public class RuleDoc extends BaseDoc implements Rule {
- public final static String MANUAL_REPOSITORY = "manual";
+ public static final String MANUAL_REPOSITORY = "manual";
RuleDoc(@Nullable Map<String, Object> fields) {
super(fields);
import org.sonar.server.search.QueryOptions;
import javax.annotation.Nullable;
+
import java.util.Arrays;
import java.util.List;
import java.util.Set;
void write(JsonWriter json, D doc);
}
- public static abstract class IndexField<D> implements Field<D> {
+ public abstract static class IndexField<D> implements Field<D> {
protected final String[] indexFields;
protected IndexField(String... indexFields) {
@Override
public void write(JsonWriter json, BaseDoc doc) {
Object val = doc.getNullableField(indexFields[0]);
- if (val == null && indexFields.length == 2) { // There is an alternative value
+ if (val == null && indexFields.length == 2) {
+ // There is an alternative value
val = doc.getNullableField(indexFields[1]);
}
json.prop(key, val != null ? val.toString() : null);
public ServerSetup toModel(String json) {
WSUtils utils = WSUtils.getINSTANCE();
Object map = utils.parse(json);
- ServerSetup server = new ServerSetup()
- .setStatus(utils.getString(map, "status"))
- .setMessage(utils.getString(map, "msg"));
- return server;
+ return new ServerSetup()
+ .setStatus(utils.getString(map, "status"))
+ .setMessage(utils.getString(map, "msg"));
}
public List<ServerSetup> toModels(String json) {