id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
16,300
|
SonarSource/sonarqube
|
server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java
|
EsJvmOptions.mandatoryOptions
|
private static Map<String, String> mandatoryOptions(System2 system2, EsInstallation esInstallation) {
Map<String, String> res = new LinkedHashMap<>(16);
// GC configuration
res.put("-XX:+UseConcMarkSweepGC", "");
res.put("-XX:CMSInitiatingOccupancyFraction=", "75");
res.put("-XX:+UseCMSInitiatingOccupancyOnly", "");
// DNS cache policy
// cache ttl in seconds for positive DNS lookups noting that this overrides the
// JDK security property networkaddress.cache.ttl; set to -1 to cache forever
res.put("-Des.networkaddress.cache.ttl=", "60");
// cache ttl in seconds for negative DNS lookups noting that this overrides the
// JDK security property networkaddress.cache.negative ttl; set to -1 to cache
// forever
res.put("-Des.networkaddress.cache.negative.ttl=", "10");
// optimizations
// pre-touch memory pages used by the JVM during initialization
res.put("-XX:+AlwaysPreTouch", "");
// basic
// explicitly set the stack size
res.put("-Xss1m", "");
// set to headless, just in case
res.put("-Djava.awt.headless=", "true");
// ensure UTF-8 encoding by default (e.g. filenames)
res.put("-Dfile.encoding=", "UTF-8");
// use our provided JNA always versus the system one
res.put("-Djna.nosys=", "true");
// turn off a JDK optimization that throws away stack traces for common
// exceptions because stack traces are important for debugging
res.put("-XX:-OmitStackTraceInFastThrow", "");
// flags to configure Netty
res.put("-Dio.netty.noUnsafe=", "true");
res.put("-Dio.netty.noKeySetOptimization=", "true");
res.put("-Dio.netty.recycler.maxCapacityPerThread=", "0");
// log4j 2
res.put("-Dlog4j.shutdownHookEnabled=", "false");
res.put("-Dlog4j2.disable.jmx=", "true");
// (by default ES 6.6.1 uses variable ${ES_TMPDIR} which is replaced by start scripts. Since we start JAR file
// directly on windows, we specify absolute file as URL (to support space in path) instead
res.put("-Djava.io.tmpdir=", esInstallation.getTmpDirectory().getAbsolutePath());
// heap dumps (enable by default in ES 6.6.1, we don't enable them, no one will analyze them anyway)
// generate a heap dump when an allocation from the Java heap fails
// heap dumps are created in the working directory of the JVM
// res.put("-XX:+HeapDumpOnOutOfMemoryError", "");
// specify an alternative path for heap dumps; ensure the directory exists and
// has sufficient space
// res.put("-XX:HeapDumpPath", "data");
// specify an alternative path for JVM fatal error logs (ES 6.6.1 default is "logs/hs_err_pid%p.log")
res.put("-XX:ErrorFile=", new File(esInstallation.getLogDirectory(), "es_hs_err_pid%p.log").getAbsolutePath());
// JDK 8 GC logging (by default ES 6.6.1 enables them, we don't want to do that in SQ, no one will analyze them anyway)
// res.put("8:-XX:+PrintGCDetails", "");
// res.put("8:-XX:+PrintGCDateStamps", "");
// res.put("8:-XX:+PrintTenuringDistribution", "");
// res.put("8:-XX:+PrintGCApplicationStoppedTime", "");
// res.put("8:-Xloggc:logs/gc.log", "");
// res.put("8:-XX:+UseGCLogFileRotation", "");
// res.put("8:-XX:NumberOfGCLogFiles", "32");
// res.put("8:-XX:GCLogFileSize", "64m");
// JDK 9+ GC logging
// res.put("9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m", "");
// due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
// time/date parsing will break in an incompatible way for some date patterns and locals
if (system2.isJava9()) {
res.put("-Djava.locale.providers=", "COMPAT");
}
if (system2.isJava10()) {
// temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
res.put("-XX:UseAVX=", "2");
}
return res;
}
|
java
|
private static Map<String, String> mandatoryOptions(System2 system2, EsInstallation esInstallation) {
Map<String, String> res = new LinkedHashMap<>(16);
// GC configuration
res.put("-XX:+UseConcMarkSweepGC", "");
res.put("-XX:CMSInitiatingOccupancyFraction=", "75");
res.put("-XX:+UseCMSInitiatingOccupancyOnly", "");
// DNS cache policy
// cache ttl in seconds for positive DNS lookups noting that this overrides the
// JDK security property networkaddress.cache.ttl; set to -1 to cache forever
res.put("-Des.networkaddress.cache.ttl=", "60");
// cache ttl in seconds for negative DNS lookups noting that this overrides the
// JDK security property networkaddress.cache.negative ttl; set to -1 to cache
// forever
res.put("-Des.networkaddress.cache.negative.ttl=", "10");
// optimizations
// pre-touch memory pages used by the JVM during initialization
res.put("-XX:+AlwaysPreTouch", "");
// basic
// explicitly set the stack size
res.put("-Xss1m", "");
// set to headless, just in case
res.put("-Djava.awt.headless=", "true");
// ensure UTF-8 encoding by default (e.g. filenames)
res.put("-Dfile.encoding=", "UTF-8");
// use our provided JNA always versus the system one
res.put("-Djna.nosys=", "true");
// turn off a JDK optimization that throws away stack traces for common
// exceptions because stack traces are important for debugging
res.put("-XX:-OmitStackTraceInFastThrow", "");
// flags to configure Netty
res.put("-Dio.netty.noUnsafe=", "true");
res.put("-Dio.netty.noKeySetOptimization=", "true");
res.put("-Dio.netty.recycler.maxCapacityPerThread=", "0");
// log4j 2
res.put("-Dlog4j.shutdownHookEnabled=", "false");
res.put("-Dlog4j2.disable.jmx=", "true");
// (by default ES 6.6.1 uses variable ${ES_TMPDIR} which is replaced by start scripts. Since we start JAR file
// directly on windows, we specify absolute file as URL (to support space in path) instead
res.put("-Djava.io.tmpdir=", esInstallation.getTmpDirectory().getAbsolutePath());
// heap dumps (enable by default in ES 6.6.1, we don't enable them, no one will analyze them anyway)
// generate a heap dump when an allocation from the Java heap fails
// heap dumps are created in the working directory of the JVM
// res.put("-XX:+HeapDumpOnOutOfMemoryError", "");
// specify an alternative path for heap dumps; ensure the directory exists and
// has sufficient space
// res.put("-XX:HeapDumpPath", "data");
// specify an alternative path for JVM fatal error logs (ES 6.6.1 default is "logs/hs_err_pid%p.log")
res.put("-XX:ErrorFile=", new File(esInstallation.getLogDirectory(), "es_hs_err_pid%p.log").getAbsolutePath());
// JDK 8 GC logging (by default ES 6.6.1 enables them, we don't want to do that in SQ, no one will analyze them anyway)
// res.put("8:-XX:+PrintGCDetails", "");
// res.put("8:-XX:+PrintGCDateStamps", "");
// res.put("8:-XX:+PrintTenuringDistribution", "");
// res.put("8:-XX:+PrintGCApplicationStoppedTime", "");
// res.put("8:-Xloggc:logs/gc.log", "");
// res.put("8:-XX:+UseGCLogFileRotation", "");
// res.put("8:-XX:NumberOfGCLogFiles", "32");
// res.put("8:-XX:GCLogFileSize", "64m");
// JDK 9+ GC logging
// res.put("9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m", "");
// due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
// time/date parsing will break in an incompatible way for some date patterns and locals
if (system2.isJava9()) {
res.put("-Djava.locale.providers=", "COMPAT");
}
if (system2.isJava10()) {
// temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
res.put("-XX:UseAVX=", "2");
}
return res;
}
|
[
"private",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"mandatoryOptions",
"(",
"System2",
"system2",
",",
"EsInstallation",
"esInstallation",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"res",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
"16",
")",
";",
"// GC configuration",
"res",
".",
"put",
"(",
"\"-XX:+UseConcMarkSweepGC\"",
",",
"\"\"",
")",
";",
"res",
".",
"put",
"(",
"\"-XX:CMSInitiatingOccupancyFraction=\"",
",",
"\"75\"",
")",
";",
"res",
".",
"put",
"(",
"\"-XX:+UseCMSInitiatingOccupancyOnly\"",
",",
"\"\"",
")",
";",
"// DNS cache policy",
"// cache ttl in seconds for positive DNS lookups noting that this overrides the",
"// JDK security property networkaddress.cache.ttl; set to -1 to cache forever",
"res",
".",
"put",
"(",
"\"-Des.networkaddress.cache.ttl=\"",
",",
"\"60\"",
")",
";",
"// cache ttl in seconds for negative DNS lookups noting that this overrides the",
"// JDK security property networkaddress.cache.negative ttl; set to -1 to cache",
"// forever",
"res",
".",
"put",
"(",
"\"-Des.networkaddress.cache.negative.ttl=\"",
",",
"\"10\"",
")",
";",
"// optimizations",
"// pre-touch memory pages used by the JVM during initialization",
"res",
".",
"put",
"(",
"\"-XX:+AlwaysPreTouch\"",
",",
"\"\"",
")",
";",
"// basic",
"// explicitly set the stack size",
"res",
".",
"put",
"(",
"\"-Xss1m\"",
",",
"\"\"",
")",
";",
"// set to headless, just in case",
"res",
".",
"put",
"(",
"\"-Djava.awt.headless=\"",
",",
"\"true\"",
")",
";",
"// ensure UTF-8 encoding by default (e.g. filenames)",
"res",
".",
"put",
"(",
"\"-Dfile.encoding=\"",
",",
"\"UTF-8\"",
")",
";",
"// use our provided JNA always versus the system one",
"res",
".",
"put",
"(",
"\"-Djna.nosys=\"",
",",
"\"true\"",
")",
";",
"// turn off a JDK optimization that throws away stack traces for common",
"// exceptions because stack traces are important for debugging",
"res",
".",
"put",
"(",
"\"-XX:-OmitStackTraceInFastThrow\"",
",",
"\"\"",
")",
";",
"// flags to configure Netty",
"res",
".",
"put",
"(",
"\"-Dio.netty.noUnsafe=\"",
",",
"\"true\"",
")",
";",
"res",
".",
"put",
"(",
"\"-Dio.netty.noKeySetOptimization=\"",
",",
"\"true\"",
")",
";",
"res",
".",
"put",
"(",
"\"-Dio.netty.recycler.maxCapacityPerThread=\"",
",",
"\"0\"",
")",
";",
"// log4j 2",
"res",
".",
"put",
"(",
"\"-Dlog4j.shutdownHookEnabled=\"",
",",
"\"false\"",
")",
";",
"res",
".",
"put",
"(",
"\"-Dlog4j2.disable.jmx=\"",
",",
"\"true\"",
")",
";",
"// (by default ES 6.6.1 uses variable ${ES_TMPDIR} which is replaced by start scripts. Since we start JAR file",
"// directly on windows, we specify absolute file as URL (to support space in path) instead",
"res",
".",
"put",
"(",
"\"-Djava.io.tmpdir=\"",
",",
"esInstallation",
".",
"getTmpDirectory",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// heap dumps (enable by default in ES 6.6.1, we don't enable them, no one will analyze them anyway)",
"// generate a heap dump when an allocation from the Java heap fails",
"// heap dumps are created in the working directory of the JVM",
"// res.put(\"-XX:+HeapDumpOnOutOfMemoryError\", \"\");",
"// specify an alternative path for heap dumps; ensure the directory exists and",
"// has sufficient space",
"// res.put(\"-XX:HeapDumpPath\", \"data\");",
"// specify an alternative path for JVM fatal error logs (ES 6.6.1 default is \"logs/hs_err_pid%p.log\")",
"res",
".",
"put",
"(",
"\"-XX:ErrorFile=\"",
",",
"new",
"File",
"(",
"esInstallation",
".",
"getLogDirectory",
"(",
")",
",",
"\"es_hs_err_pid%p.log\"",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// JDK 8 GC logging (by default ES 6.6.1 enables them, we don't want to do that in SQ, no one will analyze them anyway)",
"// res.put(\"8:-XX:+PrintGCDetails\", \"\");",
"// res.put(\"8:-XX:+PrintGCDateStamps\", \"\");",
"// res.put(\"8:-XX:+PrintTenuringDistribution\", \"\");",
"// res.put(\"8:-XX:+PrintGCApplicationStoppedTime\", \"\");",
"// res.put(\"8:-Xloggc:logs/gc.log\", \"\");",
"// res.put(\"8:-XX:+UseGCLogFileRotation\", \"\");",
"// res.put(\"8:-XX:NumberOfGCLogFiles\", \"32\");",
"// res.put(\"8:-XX:GCLogFileSize\", \"64m\");",
"// JDK 9+ GC logging",
"// res.put(\"9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m\", \"\");",
"// due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise",
"// time/date parsing will break in an incompatible way for some date patterns and locals",
"if",
"(",
"system2",
".",
"isJava9",
"(",
")",
")",
"{",
"res",
".",
"put",
"(",
"\"-Djava.locale.providers=\"",
",",
"\"COMPAT\"",
")",
";",
"}",
"if",
"(",
"system2",
".",
"isJava10",
"(",
")",
")",
"{",
"// temporary workaround for C2 bug with JDK 10 on hardware with AVX-512",
"res",
".",
"put",
"(",
"\"-XX:UseAVX=\"",
",",
"\"2\"",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
with some changes to fit running bundled in SQ
|
[
"with",
"some",
"changes",
"to",
"fit",
"running",
"bundled",
"in",
"SQ"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java#L49-L130
|
16,301
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
|
CloseableIterator.close
|
@Override
public final void close() {
try {
doClose();
isClosed = true;
} catch (Exception e) {
Throwables.propagate(e);
}
}
|
java
|
@Override
public final void close() {
try {
doClose();
isClosed = true;
} catch (Exception e) {
Throwables.propagate(e);
}
}
|
[
"@",
"Override",
"public",
"final",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"doClose",
"(",
")",
";",
"isClosed",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"}"
] |
Do not declare "throws IOException"
|
[
"Do",
"not",
"declare",
"throws",
"IOException"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java#L141-L149
|
16,302
|
SonarSource/sonarqube
|
sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
|
BlocksGroup.first
|
@CheckForNull
public Block first(String resourceId) {
for (Block block : blocks) {
if (resourceId.equals(block.getResourceId())) {
return block;
}
}
return null;
}
|
java
|
@CheckForNull
public Block first(String resourceId) {
for (Block block : blocks) {
if (resourceId.equals(block.getResourceId())) {
return block;
}
}
return null;
}
|
[
"@",
"CheckForNull",
"public",
"Block",
"first",
"(",
"String",
"resourceId",
")",
"{",
"for",
"(",
"Block",
"block",
":",
"blocks",
")",
"{",
"if",
"(",
"resourceId",
".",
"equals",
"(",
"block",
".",
"getResourceId",
"(",
")",
")",
")",
"{",
"return",
"block",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
First block from this group with specified resource id.
|
[
"First",
"block",
"from",
"this",
"group",
"with",
"specified",
"resource",
"id",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java#L76-L84
|
16,303
|
SonarSource/sonarqube
|
sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
|
BlocksGroup.intersect
|
private static BlocksGroup intersect(BlocksGroup group1, BlocksGroup group2) {
BlocksGroup intersection = new BlocksGroup();
List<Block> list1 = group1.blocks;
List<Block> list2 = group2.blocks;
int i = 0;
int j = 0;
while (i < list1.size() && j < list2.size()) {
Block block1 = list1.get(i);
Block block2 = list2.get(j);
int c = RESOURCE_ID_COMPARATOR.compare(block1.getResourceId(), block2.getResourceId());
if (c > 0) {
j++;
continue;
}
if (c < 0) {
i++;
continue;
}
if (c == 0) {
c = block1.getIndexInFile() + 1 - block2.getIndexInFile();
}
if (c == 0) {
// list1[i] == list2[j]
i++;
j++;
intersection.blocks.add(block2);
}
if (c > 0) {
// list1[i] > list2[j]
j++;
}
if (c < 0) {
// list1[i] < list2[j]
i++;
}
}
return intersection;
}
|
java
|
private static BlocksGroup intersect(BlocksGroup group1, BlocksGroup group2) {
BlocksGroup intersection = new BlocksGroup();
List<Block> list1 = group1.blocks;
List<Block> list2 = group2.blocks;
int i = 0;
int j = 0;
while (i < list1.size() && j < list2.size()) {
Block block1 = list1.get(i);
Block block2 = list2.get(j);
int c = RESOURCE_ID_COMPARATOR.compare(block1.getResourceId(), block2.getResourceId());
if (c > 0) {
j++;
continue;
}
if (c < 0) {
i++;
continue;
}
if (c == 0) {
c = block1.getIndexInFile() + 1 - block2.getIndexInFile();
}
if (c == 0) {
// list1[i] == list2[j]
i++;
j++;
intersection.blocks.add(block2);
}
if (c > 0) {
// list1[i] > list2[j]
j++;
}
if (c < 0) {
// list1[i] < list2[j]
i++;
}
}
return intersection;
}
|
[
"private",
"static",
"BlocksGroup",
"intersect",
"(",
"BlocksGroup",
"group1",
",",
"BlocksGroup",
"group2",
")",
"{",
"BlocksGroup",
"intersection",
"=",
"new",
"BlocksGroup",
"(",
")",
";",
"List",
"<",
"Block",
">",
"list1",
"=",
"group1",
".",
"blocks",
";",
"List",
"<",
"Block",
">",
"list2",
"=",
"group2",
".",
"blocks",
";",
"int",
"i",
"=",
"0",
";",
"int",
"j",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"list1",
".",
"size",
"(",
")",
"&&",
"j",
"<",
"list2",
".",
"size",
"(",
")",
")",
"{",
"Block",
"block1",
"=",
"list1",
".",
"get",
"(",
"i",
")",
";",
"Block",
"block2",
"=",
"list2",
".",
"get",
"(",
"j",
")",
";",
"int",
"c",
"=",
"RESOURCE_ID_COMPARATOR",
".",
"compare",
"(",
"block1",
".",
"getResourceId",
"(",
")",
",",
"block2",
".",
"getResourceId",
"(",
")",
")",
";",
"if",
"(",
"c",
">",
"0",
")",
"{",
"j",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"c",
"<",
"0",
")",
"{",
"i",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"c",
"=",
"block1",
".",
"getIndexInFile",
"(",
")",
"+",
"1",
"-",
"block2",
".",
"getIndexInFile",
"(",
")",
";",
"}",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"// list1[i] == list2[j]",
"i",
"++",
";",
"j",
"++",
";",
"intersection",
".",
"blocks",
".",
"add",
"(",
"block2",
")",
";",
"}",
"if",
"(",
"c",
">",
"0",
")",
"{",
"// list1[i] > list2[j]",
"j",
"++",
";",
"}",
"if",
"(",
"c",
"<",
"0",
")",
"{",
"// list1[i] < list2[j]",
"i",
"++",
";",
"}",
"}",
"return",
"intersection",
";",
"}"
] |
Intersection of two groups is a group, which contains blocks from second group that have corresponding block from first group
with same resource id and with corrected index.
|
[
"Intersection",
"of",
"two",
"groups",
"is",
"a",
"group",
"which",
"contains",
"blocks",
"from",
"second",
"group",
"that",
"have",
"corresponding",
"block",
"from",
"first",
"group",
"with",
"same",
"resource",
"id",
"and",
"with",
"corrected",
"index",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java#L95-L132
|
16,304
|
SonarSource/sonarqube
|
sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
|
BlocksGroup.subsumedBy
|
private static boolean subsumedBy(BlocksGroup group1, BlocksGroup group2, int indexCorrection) {
List<Block> list1 = group1.blocks;
List<Block> list2 = group2.blocks;
int i = 0;
int j = 0;
while (i < list1.size() && j < list2.size()) {
Block block1 = list1.get(i);
Block block2 = list2.get(j);
int c = RESOURCE_ID_COMPARATOR.compare(block1.getResourceId(), block2.getResourceId());
if (c != 0) {
j++;
continue;
}
c = block1.getIndexInFile() - indexCorrection - block2.getIndexInFile();
if (c < 0) {
// list1[i] < list2[j]
break;
}
if (c != 0) {
// list1[i] != list2[j]
j++;
}
if (c == 0) {
// list1[i] == list2[j]
i++;
j++;
}
}
return i == list1.size();
}
|
java
|
private static boolean subsumedBy(BlocksGroup group1, BlocksGroup group2, int indexCorrection) {
List<Block> list1 = group1.blocks;
List<Block> list2 = group2.blocks;
int i = 0;
int j = 0;
while (i < list1.size() && j < list2.size()) {
Block block1 = list1.get(i);
Block block2 = list2.get(j);
int c = RESOURCE_ID_COMPARATOR.compare(block1.getResourceId(), block2.getResourceId());
if (c != 0) {
j++;
continue;
}
c = block1.getIndexInFile() - indexCorrection - block2.getIndexInFile();
if (c < 0) {
// list1[i] < list2[j]
break;
}
if (c != 0) {
// list1[i] != list2[j]
j++;
}
if (c == 0) {
// list1[i] == list2[j]
i++;
j++;
}
}
return i == list1.size();
}
|
[
"private",
"static",
"boolean",
"subsumedBy",
"(",
"BlocksGroup",
"group1",
",",
"BlocksGroup",
"group2",
",",
"int",
"indexCorrection",
")",
"{",
"List",
"<",
"Block",
">",
"list1",
"=",
"group1",
".",
"blocks",
";",
"List",
"<",
"Block",
">",
"list2",
"=",
"group2",
".",
"blocks",
";",
"int",
"i",
"=",
"0",
";",
"int",
"j",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"list1",
".",
"size",
"(",
")",
"&&",
"j",
"<",
"list2",
".",
"size",
"(",
")",
")",
"{",
"Block",
"block1",
"=",
"list1",
".",
"get",
"(",
"i",
")",
";",
"Block",
"block2",
"=",
"list2",
".",
"get",
"(",
"j",
")",
";",
"int",
"c",
"=",
"RESOURCE_ID_COMPARATOR",
".",
"compare",
"(",
"block1",
".",
"getResourceId",
"(",
")",
",",
"block2",
".",
"getResourceId",
"(",
")",
")",
";",
"if",
"(",
"c",
"!=",
"0",
")",
"{",
"j",
"++",
";",
"continue",
";",
"}",
"c",
"=",
"block1",
".",
"getIndexInFile",
"(",
")",
"-",
"indexCorrection",
"-",
"block2",
".",
"getIndexInFile",
"(",
")",
";",
"if",
"(",
"c",
"<",
"0",
")",
"{",
"// list1[i] < list2[j]",
"break",
";",
"}",
"if",
"(",
"c",
"!=",
"0",
")",
"{",
"// list1[i] != list2[j]",
"j",
"++",
";",
"}",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"// list1[i] == list2[j]",
"i",
"++",
";",
"j",
"++",
";",
"}",
"}",
"return",
"i",
"==",
"list1",
".",
"size",
"(",
")",
";",
"}"
] |
One group is subsumed by another group, when each block from first group has corresponding block from second group
with same resource id and with corrected index.
|
[
"One",
"group",
"is",
"subsumed",
"by",
"another",
"group",
"when",
"each",
"block",
"from",
"first",
"group",
"has",
"corresponding",
"block",
"from",
"second",
"group",
"with",
"same",
"resource",
"id",
"and",
"with",
"corrected",
"index",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java#L138-L167
|
16,305
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java
|
AdHocRuleCreator.persistAndIndex
|
public RuleDto persistAndIndex(DbSession dbSession, NewAdHocRule adHoc, OrganizationDto organizationDto) {
RuleDao dao = dbClient.ruleDao();
Optional<RuleDto> existingRuleDtoOpt = dao.selectByKey(dbSession, organizationDto, adHoc.getKey());
RuleMetadataDto metadata;
long now = system2.now();
if (!existingRuleDtoOpt.isPresent()) {
RuleDefinitionDto dto = new RuleDefinitionDto()
.setRuleKey(adHoc.getKey())
.setIsExternal(true)
.setIsAdHoc(true)
.setName(adHoc.getEngineId() + ":" + adHoc.getRuleId())
.setScope(ALL)
.setStatus(READY)
.setCreatedAt(now)
.setUpdatedAt(now);
dao.insert(dbSession, dto);
metadata = new RuleMetadataDto()
.setRuleId(dto.getId())
.setOrganizationUuid(organizationDto.getUuid());
} else {
// No need to update the rule, only org specific metadata
RuleDto ruleDto = existingRuleDtoOpt.get();
Preconditions.checkState(ruleDto.isExternal() && ruleDto.isAdHoc());
metadata = ruleDto.getMetadata();
}
if (adHoc.hasDetails()) {
boolean changed = false;
if (!Objects.equals(metadata.getAdHocName(), adHoc.getName())) {
metadata.setAdHocName(substring(adHoc.getName(), 0, MAX_LENGTH_AD_HOC_NAME));
changed = true;
}
if (!Objects.equals(metadata.getAdHocDescription(), adHoc.getDescription())) {
metadata.setAdHocDescription(substring(adHoc.getDescription(), 0, MAX_LENGTH_AD_HOC_DESC));
changed = true;
}
if (!Objects.equals(metadata.getAdHocSeverity(), adHoc.getSeverity())) {
metadata.setAdHocSeverity(adHoc.getSeverity());
changed = true;
}
RuleType ruleType = requireNonNull(adHoc.getRuleType(), "Rule type should not be null");
if (!Objects.equals(metadata.getAdHocType(), ruleType.getDbConstant())) {
metadata.setAdHocType(ruleType);
changed = true;
}
if (changed) {
metadata.setUpdatedAt(now);
metadata.setCreatedAt(now);
dao.insertOrUpdate(dbSession, metadata);
}
}
RuleDto ruleDto = dao.selectOrFailByKey(dbSession, organizationDto, adHoc.getKey());
ruleIndexer.commitAndIndex(dbSession, ruleDto.getId());
return ruleDto;
}
|
java
|
public RuleDto persistAndIndex(DbSession dbSession, NewAdHocRule adHoc, OrganizationDto organizationDto) {
RuleDao dao = dbClient.ruleDao();
Optional<RuleDto> existingRuleDtoOpt = dao.selectByKey(dbSession, organizationDto, adHoc.getKey());
RuleMetadataDto metadata;
long now = system2.now();
if (!existingRuleDtoOpt.isPresent()) {
RuleDefinitionDto dto = new RuleDefinitionDto()
.setRuleKey(adHoc.getKey())
.setIsExternal(true)
.setIsAdHoc(true)
.setName(adHoc.getEngineId() + ":" + adHoc.getRuleId())
.setScope(ALL)
.setStatus(READY)
.setCreatedAt(now)
.setUpdatedAt(now);
dao.insert(dbSession, dto);
metadata = new RuleMetadataDto()
.setRuleId(dto.getId())
.setOrganizationUuid(organizationDto.getUuid());
} else {
// No need to update the rule, only org specific metadata
RuleDto ruleDto = existingRuleDtoOpt.get();
Preconditions.checkState(ruleDto.isExternal() && ruleDto.isAdHoc());
metadata = ruleDto.getMetadata();
}
if (adHoc.hasDetails()) {
boolean changed = false;
if (!Objects.equals(metadata.getAdHocName(), adHoc.getName())) {
metadata.setAdHocName(substring(adHoc.getName(), 0, MAX_LENGTH_AD_HOC_NAME));
changed = true;
}
if (!Objects.equals(metadata.getAdHocDescription(), adHoc.getDescription())) {
metadata.setAdHocDescription(substring(adHoc.getDescription(), 0, MAX_LENGTH_AD_HOC_DESC));
changed = true;
}
if (!Objects.equals(metadata.getAdHocSeverity(), adHoc.getSeverity())) {
metadata.setAdHocSeverity(adHoc.getSeverity());
changed = true;
}
RuleType ruleType = requireNonNull(adHoc.getRuleType(), "Rule type should not be null");
if (!Objects.equals(metadata.getAdHocType(), ruleType.getDbConstant())) {
metadata.setAdHocType(ruleType);
changed = true;
}
if (changed) {
metadata.setUpdatedAt(now);
metadata.setCreatedAt(now);
dao.insertOrUpdate(dbSession, metadata);
}
}
RuleDto ruleDto = dao.selectOrFailByKey(dbSession, organizationDto, adHoc.getKey());
ruleIndexer.commitAndIndex(dbSession, ruleDto.getId());
return ruleDto;
}
|
[
"public",
"RuleDto",
"persistAndIndex",
"(",
"DbSession",
"dbSession",
",",
"NewAdHocRule",
"adHoc",
",",
"OrganizationDto",
"organizationDto",
")",
"{",
"RuleDao",
"dao",
"=",
"dbClient",
".",
"ruleDao",
"(",
")",
";",
"Optional",
"<",
"RuleDto",
">",
"existingRuleDtoOpt",
"=",
"dao",
".",
"selectByKey",
"(",
"dbSession",
",",
"organizationDto",
",",
"adHoc",
".",
"getKey",
"(",
")",
")",
";",
"RuleMetadataDto",
"metadata",
";",
"long",
"now",
"=",
"system2",
".",
"now",
"(",
")",
";",
"if",
"(",
"!",
"existingRuleDtoOpt",
".",
"isPresent",
"(",
")",
")",
"{",
"RuleDefinitionDto",
"dto",
"=",
"new",
"RuleDefinitionDto",
"(",
")",
".",
"setRuleKey",
"(",
"adHoc",
".",
"getKey",
"(",
")",
")",
".",
"setIsExternal",
"(",
"true",
")",
".",
"setIsAdHoc",
"(",
"true",
")",
".",
"setName",
"(",
"adHoc",
".",
"getEngineId",
"(",
")",
"+",
"\":\"",
"+",
"adHoc",
".",
"getRuleId",
"(",
")",
")",
".",
"setScope",
"(",
"ALL",
")",
".",
"setStatus",
"(",
"READY",
")",
".",
"setCreatedAt",
"(",
"now",
")",
".",
"setUpdatedAt",
"(",
"now",
")",
";",
"dao",
".",
"insert",
"(",
"dbSession",
",",
"dto",
")",
";",
"metadata",
"=",
"new",
"RuleMetadataDto",
"(",
")",
".",
"setRuleId",
"(",
"dto",
".",
"getId",
"(",
")",
")",
".",
"setOrganizationUuid",
"(",
"organizationDto",
".",
"getUuid",
"(",
")",
")",
";",
"}",
"else",
"{",
"// No need to update the rule, only org specific metadata",
"RuleDto",
"ruleDto",
"=",
"existingRuleDtoOpt",
".",
"get",
"(",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"ruleDto",
".",
"isExternal",
"(",
")",
"&&",
"ruleDto",
".",
"isAdHoc",
"(",
")",
")",
";",
"metadata",
"=",
"ruleDto",
".",
"getMetadata",
"(",
")",
";",
"}",
"if",
"(",
"adHoc",
".",
"hasDetails",
"(",
")",
")",
"{",
"boolean",
"changed",
"=",
"false",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"metadata",
".",
"getAdHocName",
"(",
")",
",",
"adHoc",
".",
"getName",
"(",
")",
")",
")",
"{",
"metadata",
".",
"setAdHocName",
"(",
"substring",
"(",
"adHoc",
".",
"getName",
"(",
")",
",",
"0",
",",
"MAX_LENGTH_AD_HOC_NAME",
")",
")",
";",
"changed",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"metadata",
".",
"getAdHocDescription",
"(",
")",
",",
"adHoc",
".",
"getDescription",
"(",
")",
")",
")",
"{",
"metadata",
".",
"setAdHocDescription",
"(",
"substring",
"(",
"adHoc",
".",
"getDescription",
"(",
")",
",",
"0",
",",
"MAX_LENGTH_AD_HOC_DESC",
")",
")",
";",
"changed",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"metadata",
".",
"getAdHocSeverity",
"(",
")",
",",
"adHoc",
".",
"getSeverity",
"(",
")",
")",
")",
"{",
"metadata",
".",
"setAdHocSeverity",
"(",
"adHoc",
".",
"getSeverity",
"(",
")",
")",
";",
"changed",
"=",
"true",
";",
"}",
"RuleType",
"ruleType",
"=",
"requireNonNull",
"(",
"adHoc",
".",
"getRuleType",
"(",
")",
",",
"\"Rule type should not be null\"",
")",
";",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"metadata",
".",
"getAdHocType",
"(",
")",
",",
"ruleType",
".",
"getDbConstant",
"(",
")",
")",
")",
"{",
"metadata",
".",
"setAdHocType",
"(",
"ruleType",
")",
";",
"changed",
"=",
"true",
";",
"}",
"if",
"(",
"changed",
")",
"{",
"metadata",
".",
"setUpdatedAt",
"(",
"now",
")",
";",
"metadata",
".",
"setCreatedAt",
"(",
"now",
")",
";",
"dao",
".",
"insertOrUpdate",
"(",
"dbSession",
",",
"metadata",
")",
";",
"}",
"}",
"RuleDto",
"ruleDto",
"=",
"dao",
".",
"selectOrFailByKey",
"(",
"dbSession",
",",
"organizationDto",
",",
"adHoc",
".",
"getKey",
"(",
")",
")",
";",
"ruleIndexer",
".",
"commitAndIndex",
"(",
"dbSession",
",",
"ruleDto",
".",
"getId",
"(",
")",
")",
";",
"return",
"ruleDto",
";",
"}"
] |
Persists a new add hoc rule in the DB and indexes it.
@return the rule that was inserted in the DB, which <b>includes the generated ID</b>.
|
[
"Persists",
"a",
"new",
"add",
"hoc",
"rule",
"in",
"the",
"DB",
"and",
"indexes",
"it",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java#L59-L115
|
16,306
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/AesCipher.java
|
AesCipher.hasSecretKey
|
boolean hasSecretKey() {
String path = getPathToSecretKey();
if (StringUtils.isNotBlank(path)) {
File file = new File(path);
return file.exists() && file.isFile();
}
return false;
}
|
java
|
boolean hasSecretKey() {
String path = getPathToSecretKey();
if (StringUtils.isNotBlank(path)) {
File file = new File(path);
return file.exists() && file.isFile();
}
return false;
}
|
[
"boolean",
"hasSecretKey",
"(",
")",
"{",
"String",
"path",
"=",
"getPathToSecretKey",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"path",
")",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"return",
"file",
".",
"exists",
"(",
")",
"&&",
"file",
".",
"isFile",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
This method checks the existence of the file, but not the validity of the contained key.
|
[
"This",
"method",
"checks",
"the",
"existence",
"of",
"the",
"file",
"but",
"not",
"the",
"validity",
"of",
"the",
"contained",
"key",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/AesCipher.java#L86-L93
|
16,307
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
|
MyBatis.newScrollingSelectStatement
|
public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
}
|
java
|
public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
int fetchSize = database.getDialect().getScrollDefaultFetchSize();
return newScrollingSelectStatement(session, sql, fetchSize);
}
|
[
"public",
"PreparedStatement",
"newScrollingSelectStatement",
"(",
"DbSession",
"session",
",",
"String",
"sql",
")",
"{",
"int",
"fetchSize",
"=",
"database",
".",
"getDialect",
"(",
")",
".",
"getScrollDefaultFetchSize",
"(",
")",
";",
"return",
"newScrollingSelectStatement",
"(",
"session",
",",
"sql",
",",
"fetchSize",
")",
";",
"}"
] |
Create a PreparedStatement for SELECT requests with scrolling of results
|
[
"Create",
"a",
"PreparedStatement",
"for",
"SELECT",
"requests",
"with",
"scrolling",
"of",
"results"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java#L312-L315
|
16,308
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
|
QualityProfileDao.selectDescendants
|
public Collection<QProfileDto> selectDescendants(DbSession dbSession, Collection<QProfileDto> profiles) {
if (profiles.isEmpty()) {
return emptyList();
}
Collection<QProfileDto> children = selectChildren(dbSession, profiles);
List<QProfileDto> descendants = new ArrayList<>(children);
descendants.addAll(selectDescendants(dbSession, children));
return descendants;
}
|
java
|
public Collection<QProfileDto> selectDescendants(DbSession dbSession, Collection<QProfileDto> profiles) {
if (profiles.isEmpty()) {
return emptyList();
}
Collection<QProfileDto> children = selectChildren(dbSession, profiles);
List<QProfileDto> descendants = new ArrayList<>(children);
descendants.addAll(selectDescendants(dbSession, children));
return descendants;
}
|
[
"public",
"Collection",
"<",
"QProfileDto",
">",
"selectDescendants",
"(",
"DbSession",
"dbSession",
",",
"Collection",
"<",
"QProfileDto",
">",
"profiles",
")",
"{",
"if",
"(",
"profiles",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"emptyList",
"(",
")",
";",
"}",
"Collection",
"<",
"QProfileDto",
">",
"children",
"=",
"selectChildren",
"(",
"dbSession",
",",
"profiles",
")",
";",
"List",
"<",
"QProfileDto",
">",
"descendants",
"=",
"new",
"ArrayList",
"<>",
"(",
"children",
")",
";",
"descendants",
".",
"addAll",
"(",
"selectDescendants",
"(",
"dbSession",
",",
"children",
")",
")",
";",
"return",
"descendants",
";",
"}"
] |
All descendants, in any order. The specified profiles are not included into results.
|
[
"All",
"descendants",
"in",
"any",
"order",
".",
"The",
"specified",
"profiles",
"are",
"not",
"included",
"into",
"results",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java#L179-L187
|
16,309
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java
|
Rule.setParams
|
public Rule setParams(List<RuleParam> params) {
this.params.clear();
for (RuleParam param : params) {
param.setRule(this);
this.params.add(param);
}
return this;
}
|
java
|
public Rule setParams(List<RuleParam> params) {
this.params.clear();
for (RuleParam param : params) {
param.setRule(this);
this.params.add(param);
}
return this;
}
|
[
"public",
"Rule",
"setParams",
"(",
"List",
"<",
"RuleParam",
">",
"params",
")",
"{",
"this",
".",
"params",
".",
"clear",
"(",
")",
";",
"for",
"(",
"RuleParam",
"param",
":",
"params",
")",
"{",
"param",
".",
"setRule",
"(",
"this",
")",
";",
"this",
".",
"params",
".",
"add",
"(",
"param",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Sets the rule parameters
|
[
"Sets",
"the",
"rule",
"parameters"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java#L196-L203
|
16,310
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java
|
Rule.setTags
|
public Rule setTags(String[] tags) {
this.tags = tags == null ? null : StringUtils.join(tags, ',');
return this;
}
|
java
|
public Rule setTags(String[] tags) {
this.tags = tags == null ? null : StringUtils.join(tags, ',');
return this;
}
|
[
"public",
"Rule",
"setTags",
"(",
"String",
"[",
"]",
"tags",
")",
"{",
"this",
".",
"tags",
"=",
"tags",
"==",
"null",
"?",
"null",
":",
"StringUtils",
".",
"join",
"(",
"tags",
",",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
For definition of rule only
|
[
"For",
"definition",
"of",
"rule",
"only"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java#L391-L394
|
16,311
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/issue/tracking/LineHashSequence.java
|
LineHashSequence.getHashForLine
|
public String getHashForLine(int line) {
if (line > 0 && line <= hashes.size()) {
return Strings.nullToEmpty(hashes.get(line - 1));
}
return "";
}
|
java
|
public String getHashForLine(int line) {
if (line > 0 && line <= hashes.size()) {
return Strings.nullToEmpty(hashes.get(line - 1));
}
return "";
}
|
[
"public",
"String",
"getHashForLine",
"(",
"int",
"line",
")",
"{",
"if",
"(",
"line",
">",
"0",
"&&",
"line",
"<=",
"hashes",
".",
"size",
"(",
")",
")",
"{",
"return",
"Strings",
".",
"nullToEmpty",
"(",
"hashes",
".",
"get",
"(",
"line",
"-",
"1",
")",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Hash of the given line, which starts with 1. Return empty string
is the line does not exist.
|
[
"Hash",
"of",
"the",
"given",
"line",
"which",
"starts",
"with",
"1",
".",
"Return",
"empty",
"string",
"is",
"the",
"line",
"does",
"not",
"exist",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/issue/tracking/LineHashSequence.java#L79-L84
|
16,312
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
|
DefaultInputFile.newRange
|
public TextRange newRange(int startOffset, int endOffset) {
checkMetadata();
return newRangeValidPointers(newPointer(startOffset), newPointer(endOffset), false);
}
|
java
|
public TextRange newRange(int startOffset, int endOffset) {
checkMetadata();
return newRangeValidPointers(newPointer(startOffset), newPointer(endOffset), false);
}
|
[
"public",
"TextRange",
"newRange",
"(",
"int",
"startOffset",
",",
"int",
"endOffset",
")",
"{",
"checkMetadata",
"(",
")",
";",
"return",
"newRangeValidPointers",
"(",
"newPointer",
"(",
"startOffset",
")",
",",
"newPointer",
"(",
"endOffset",
")",
",",
"false",
")",
";",
"}"
] |
Create Range from global offsets. Used for backward compatibility with older API.
|
[
"Create",
"Range",
"from",
"global",
"offsets",
".",
"Used",
"for",
"backward",
"compatibility",
"with",
"older",
"API",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java#L309-L312
|
16,313
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
|
DefaultLanguagesRepository.get
|
@Override
@CheckForNull
public Language get(String languageKey) {
org.sonar.api.resources.Language language = languages.get(languageKey);
return language != null ? new Language(language.getKey(), language.getName(), language.getFileSuffixes()) : null;
}
|
java
|
@Override
@CheckForNull
public Language get(String languageKey) {
org.sonar.api.resources.Language language = languages.get(languageKey);
return language != null ? new Language(language.getKey(), language.getName(), language.getFileSuffixes()) : null;
}
|
[
"@",
"Override",
"@",
"CheckForNull",
"public",
"Language",
"get",
"(",
"String",
"languageKey",
")",
"{",
"org",
".",
"sonar",
".",
"api",
".",
"resources",
".",
"Language",
"language",
"=",
"languages",
".",
"get",
"(",
"languageKey",
")",
";",
"return",
"language",
"!=",
"null",
"?",
"new",
"Language",
"(",
"language",
".",
"getKey",
"(",
")",
",",
"language",
".",
"getName",
"(",
")",
",",
"language",
".",
"getFileSuffixes",
"(",
")",
")",
":",
"null",
";",
"}"
] |
Get language.
|
[
"Get",
"language",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java#L54-L59
|
16,314
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
|
DefaultLanguagesRepository.all
|
@Override
public Collection<Language> all() {
org.sonar.api.resources.Language[] all = languages.all();
Collection<Language> result = new ArrayList<>(all.length);
for (org.sonar.api.resources.Language language : all) {
result.add(new Language(language.getKey(), language.getName(), language.getFileSuffixes()));
}
return result;
}
|
java
|
@Override
public Collection<Language> all() {
org.sonar.api.resources.Language[] all = languages.all();
Collection<Language> result = new ArrayList<>(all.length);
for (org.sonar.api.resources.Language language : all) {
result.add(new Language(language.getKey(), language.getName(), language.getFileSuffixes()));
}
return result;
}
|
[
"@",
"Override",
"public",
"Collection",
"<",
"Language",
">",
"all",
"(",
")",
"{",
"org",
".",
"sonar",
".",
"api",
".",
"resources",
".",
"Language",
"[",
"]",
"all",
"=",
"languages",
".",
"all",
"(",
")",
";",
"Collection",
"<",
"Language",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"all",
".",
"length",
")",
";",
"for",
"(",
"org",
".",
"sonar",
".",
"api",
".",
"resources",
".",
"Language",
"language",
":",
"all",
")",
"{",
"result",
".",
"add",
"(",
"new",
"Language",
"(",
"language",
".",
"getKey",
"(",
")",
",",
"language",
".",
"getName",
"(",
")",
",",
"language",
".",
"getFileSuffixes",
"(",
")",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get list of all supported languages.
|
[
"Get",
"list",
"of",
"all",
"supported",
"languages",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java#L64-L72
|
16,315
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
|
NotificationDispatcherMetadata.setProperty
|
public NotificationDispatcherMetadata setProperty(String key, String value) {
properties.put(key, value);
return this;
}
|
java
|
public NotificationDispatcherMetadata setProperty(String key, String value) {
properties.put(key, value);
return this;
}
|
[
"public",
"NotificationDispatcherMetadata",
"setProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"properties",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Sets a property on this metadata object.
|
[
"Sets",
"a",
"property",
"on",
"this",
"metadata",
"object",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java#L62-L65
|
16,316
|
SonarSource/sonarqube
|
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java
|
TextLineNumber.setBorderGap
|
public void setBorderGap(int borderGap) {
this.borderGap = borderGap;
Border inner = new EmptyBorder(0, borderGap, 0, borderGap);
setBorder(new CompoundBorder(OUTER, inner));
lastDigits = 0;
setPreferredWidth();
}
|
java
|
public void setBorderGap(int borderGap) {
this.borderGap = borderGap;
Border inner = new EmptyBorder(0, borderGap, 0, borderGap);
setBorder(new CompoundBorder(OUTER, inner));
lastDigits = 0;
setPreferredWidth();
}
|
[
"public",
"void",
"setBorderGap",
"(",
"int",
"borderGap",
")",
"{",
"this",
".",
"borderGap",
"=",
"borderGap",
";",
"Border",
"inner",
"=",
"new",
"EmptyBorder",
"(",
"0",
",",
"borderGap",
",",
"0",
",",
"borderGap",
")",
";",
"setBorder",
"(",
"new",
"CompoundBorder",
"(",
"OUTER",
",",
"inner",
")",
")",
";",
"lastDigits",
"=",
"0",
";",
"setPreferredWidth",
"(",
")",
";",
"}"
] |
The border gap is used in calculating the left and right insets of the
border. Default value is 5.
@param borderGap the gap in pixels
|
[
"The",
"border",
"gap",
"is",
"used",
"in",
"calculating",
"the",
"left",
"and",
"right",
"insets",
"of",
"the",
"border",
".",
"Default",
"value",
"is",
"5",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java#L157-L163
|
16,317
|
SonarSource/sonarqube
|
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java
|
TextLineNumber.setPreferredWidth
|
private void setPreferredWidth() {
Element root = component.getDocument().getDefaultRootElement();
int lines = root.getElementCount();
int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits);
// Update sizes when number of digits in the line number changes
if (lastDigits != digits) {
lastDigits = digits;
FontMetrics fontMetrics = getFontMetrics(getFont());
int width = fontMetrics.charWidth('0') * digits;
Insets insets = getInsets();
int preferredWidth = insets.left + insets.right + width;
Dimension d = getPreferredSize();
d.setSize(preferredWidth, HEIGHT);
setPreferredSize(d);
setSize(d);
}
}
|
java
|
private void setPreferredWidth() {
Element root = component.getDocument().getDefaultRootElement();
int lines = root.getElementCount();
int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits);
// Update sizes when number of digits in the line number changes
if (lastDigits != digits) {
lastDigits = digits;
FontMetrics fontMetrics = getFontMetrics(getFont());
int width = fontMetrics.charWidth('0') * digits;
Insets insets = getInsets();
int preferredWidth = insets.left + insets.right + width;
Dimension d = getPreferredSize();
d.setSize(preferredWidth, HEIGHT);
setPreferredSize(d);
setSize(d);
}
}
|
[
"private",
"void",
"setPreferredWidth",
"(",
")",
"{",
"Element",
"root",
"=",
"component",
".",
"getDocument",
"(",
")",
".",
"getDefaultRootElement",
"(",
")",
";",
"int",
"lines",
"=",
"root",
".",
"getElementCount",
"(",
")",
";",
"int",
"digits",
"=",
"Math",
".",
"max",
"(",
"String",
".",
"valueOf",
"(",
"lines",
")",
".",
"length",
"(",
")",
",",
"minimumDisplayDigits",
")",
";",
"// Update sizes when number of digits in the line number changes",
"if",
"(",
"lastDigits",
"!=",
"digits",
")",
"{",
"lastDigits",
"=",
"digits",
";",
"FontMetrics",
"fontMetrics",
"=",
"getFontMetrics",
"(",
"getFont",
"(",
")",
")",
";",
"int",
"width",
"=",
"fontMetrics",
".",
"charWidth",
"(",
"'",
"'",
")",
"*",
"digits",
";",
"Insets",
"insets",
"=",
"getInsets",
"(",
")",
";",
"int",
"preferredWidth",
"=",
"insets",
".",
"left",
"+",
"insets",
".",
"right",
"+",
"width",
";",
"Dimension",
"d",
"=",
"getPreferredSize",
"(",
")",
";",
"d",
".",
"setSize",
"(",
"preferredWidth",
",",
"HEIGHT",
")",
";",
"setPreferredSize",
"(",
"d",
")",
";",
"setSize",
"(",
"d",
")",
";",
"}",
"}"
] |
Calculate the width needed to display the maximum line number
|
[
"Calculate",
"the",
"width",
"needed",
"to",
"display",
"the",
"maximum",
"line",
"number"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java#L229-L248
|
16,318
|
SonarSource/sonarqube
|
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java
|
TextLineNumber.paintComponent
|
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Determine the width of the space available to draw the line number
FontMetrics fontMetrics = component.getFontMetrics(component.getFont());
Insets insets = getInsets();
int availableWidth = getSize().width - insets.left - insets.right;
// Determine the rows to draw within the clipped bounds.
Rectangle clip = g.getClipBounds();
int rowStartOffset = component.viewToModel(new Point(0, clip.y));
int endOffset = component.viewToModel(new Point(0, clip.y + clip.height));
while (rowStartOffset <= endOffset) {
try {
if (isCurrentLine(rowStartOffset))
g.setColor(getCurrentLineForeground());
else
g.setColor(getForeground());
// Get the line number as a string and then determine the
// "X" and "Y" offsets for drawing the string.
String lineNumber = getTextLineNumber(rowStartOffset);
int stringWidth = fontMetrics.stringWidth(lineNumber);
int x = getOffsetX(availableWidth, stringWidth) + insets.left;
int y = getOffsetY(rowStartOffset, fontMetrics);
g.drawString(lineNumber, x, y);
// Move to the next row
rowStartOffset = Utilities.getRowEnd(component, rowStartOffset) + 1;
} catch (Exception e) {
break;
}
}
}
|
java
|
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Determine the width of the space available to draw the line number
FontMetrics fontMetrics = component.getFontMetrics(component.getFont());
Insets insets = getInsets();
int availableWidth = getSize().width - insets.left - insets.right;
// Determine the rows to draw within the clipped bounds.
Rectangle clip = g.getClipBounds();
int rowStartOffset = component.viewToModel(new Point(0, clip.y));
int endOffset = component.viewToModel(new Point(0, clip.y + clip.height));
while (rowStartOffset <= endOffset) {
try {
if (isCurrentLine(rowStartOffset))
g.setColor(getCurrentLineForeground());
else
g.setColor(getForeground());
// Get the line number as a string and then determine the
// "X" and "Y" offsets for drawing the string.
String lineNumber = getTextLineNumber(rowStartOffset);
int stringWidth = fontMetrics.stringWidth(lineNumber);
int x = getOffsetX(availableWidth, stringWidth) + insets.left;
int y = getOffsetY(rowStartOffset, fontMetrics);
g.drawString(lineNumber, x, y);
// Move to the next row
rowStartOffset = Utilities.getRowEnd(component, rowStartOffset) + 1;
} catch (Exception e) {
break;
}
}
}
|
[
"@",
"Override",
"public",
"void",
"paintComponent",
"(",
"Graphics",
"g",
")",
"{",
"super",
".",
"paintComponent",
"(",
"g",
")",
";",
"// Determine the width of the space available to draw the line number",
"FontMetrics",
"fontMetrics",
"=",
"component",
".",
"getFontMetrics",
"(",
"component",
".",
"getFont",
"(",
")",
")",
";",
"Insets",
"insets",
"=",
"getInsets",
"(",
")",
";",
"int",
"availableWidth",
"=",
"getSize",
"(",
")",
".",
"width",
"-",
"insets",
".",
"left",
"-",
"insets",
".",
"right",
";",
"// Determine the rows to draw within the clipped bounds.",
"Rectangle",
"clip",
"=",
"g",
".",
"getClipBounds",
"(",
")",
";",
"int",
"rowStartOffset",
"=",
"component",
".",
"viewToModel",
"(",
"new",
"Point",
"(",
"0",
",",
"clip",
".",
"y",
")",
")",
";",
"int",
"endOffset",
"=",
"component",
".",
"viewToModel",
"(",
"new",
"Point",
"(",
"0",
",",
"clip",
".",
"y",
"+",
"clip",
".",
"height",
")",
")",
";",
"while",
"(",
"rowStartOffset",
"<=",
"endOffset",
")",
"{",
"try",
"{",
"if",
"(",
"isCurrentLine",
"(",
"rowStartOffset",
")",
")",
"g",
".",
"setColor",
"(",
"getCurrentLineForeground",
"(",
")",
")",
";",
"else",
"g",
".",
"setColor",
"(",
"getForeground",
"(",
")",
")",
";",
"// Get the line number as a string and then determine the",
"// \"X\" and \"Y\" offsets for drawing the string.",
"String",
"lineNumber",
"=",
"getTextLineNumber",
"(",
"rowStartOffset",
")",
";",
"int",
"stringWidth",
"=",
"fontMetrics",
".",
"stringWidth",
"(",
"lineNumber",
")",
";",
"int",
"x",
"=",
"getOffsetX",
"(",
"availableWidth",
",",
"stringWidth",
")",
"+",
"insets",
".",
"left",
";",
"int",
"y",
"=",
"getOffsetY",
"(",
"rowStartOffset",
",",
"fontMetrics",
")",
";",
"g",
".",
"drawString",
"(",
"lineNumber",
",",
"x",
",",
"y",
")",
";",
"// Move to the next row",
"rowStartOffset",
"=",
"Utilities",
".",
"getRowEnd",
"(",
"component",
",",
"rowStartOffset",
")",
"+",
"1",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Draw the line numbers
|
[
"Draw",
"the",
"line",
"numbers"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/TextLineNumber.java#L253-L292
|
16,319
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java
|
NotificationService.hasProjectSubscribersForTypes
|
public boolean hasProjectSubscribersForTypes(String projectUuid, Set<Class<? extends Notification>> notificationTypes) {
Set<String> dispatcherKeys = handlers.stream()
.filter(handler -> notificationTypes.stream().anyMatch(notificationType -> handler.getNotificationClass() == notificationType))
.map(NotificationHandler::getMetadata)
.filter(Optional::isPresent)
.map(Optional::get)
.map(NotificationDispatcherMetadata::getDispatcherKey)
.collect(MoreCollectors.toSet(notificationTypes.size()));
return dbClient.propertiesDao().hasProjectNotificationSubscribersForDispatchers(projectUuid, dispatcherKeys);
}
|
java
|
public boolean hasProjectSubscribersForTypes(String projectUuid, Set<Class<? extends Notification>> notificationTypes) {
Set<String> dispatcherKeys = handlers.stream()
.filter(handler -> notificationTypes.stream().anyMatch(notificationType -> handler.getNotificationClass() == notificationType))
.map(NotificationHandler::getMetadata)
.filter(Optional::isPresent)
.map(Optional::get)
.map(NotificationDispatcherMetadata::getDispatcherKey)
.collect(MoreCollectors.toSet(notificationTypes.size()));
return dbClient.propertiesDao().hasProjectNotificationSubscribersForDispatchers(projectUuid, dispatcherKeys);
}
|
[
"public",
"boolean",
"hasProjectSubscribersForTypes",
"(",
"String",
"projectUuid",
",",
"Set",
"<",
"Class",
"<",
"?",
"extends",
"Notification",
">",
">",
"notificationTypes",
")",
"{",
"Set",
"<",
"String",
">",
"dispatcherKeys",
"=",
"handlers",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"handler",
"->",
"notificationTypes",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"notificationType",
"->",
"handler",
".",
"getNotificationClass",
"(",
")",
"==",
"notificationType",
")",
")",
".",
"map",
"(",
"NotificationHandler",
"::",
"getMetadata",
")",
".",
"filter",
"(",
"Optional",
"::",
"isPresent",
")",
".",
"map",
"(",
"Optional",
"::",
"get",
")",
".",
"map",
"(",
"NotificationDispatcherMetadata",
"::",
"getDispatcherKey",
")",
".",
"collect",
"(",
"MoreCollectors",
".",
"toSet",
"(",
"notificationTypes",
".",
"size",
"(",
")",
")",
")",
";",
"return",
"dbClient",
".",
"propertiesDao",
"(",
")",
".",
"hasProjectNotificationSubscribersForDispatchers",
"(",
"projectUuid",
",",
"dispatcherKeys",
")",
";",
"}"
] |
Returns true if at least one user is subscribed to at least one notification with given types.
Subscription can be global or on the specific project.
|
[
"Returns",
"true",
"if",
"at",
"least",
"one",
"user",
"is",
"subscribed",
"to",
"at",
"least",
"one",
"notification",
"with",
"given",
"types",
".",
"Subscription",
"can",
"be",
"global",
"or",
"on",
"the",
"specific",
"project",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java#L157-L167
|
16,320
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
|
ComponentDto.getKey
|
public String getKey() {
List<String> split = BRANCH_OR_PULL_REQUEST_SPLITTER.splitToList(kee);
return split.size() == 2 ? split.get(0) : kee;
}
|
java
|
public String getKey() {
List<String> split = BRANCH_OR_PULL_REQUEST_SPLITTER.splitToList(kee);
return split.size() == 2 ? split.get(0) : kee;
}
|
[
"public",
"String",
"getKey",
"(",
")",
"{",
"List",
"<",
"String",
">",
"split",
"=",
"BRANCH_OR_PULL_REQUEST_SPLITTER",
".",
"splitToList",
"(",
"kee",
")",
";",
"return",
"split",
".",
"size",
"(",
")",
"==",
"2",
"?",
"split",
".",
"get",
"(",
"0",
")",
":",
"kee",
";",
"}"
] |
The key to be displayed to user, doesn't contain information on branches
|
[
"The",
"key",
"to",
"be",
"displayed",
"to",
"user",
"doesn",
"t",
"contain",
"information",
"on",
"branches"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java#L225-L228
|
16,321
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
|
FileMetadata.readMetadata
|
public Metadata readMetadata(Reader reader) {
LineCounter lineCounter = new LineCounter("fromString", StandardCharsets.UTF_16);
FileHashComputer fileHashComputer = new FileHashComputer("fromString");
LineOffsetCounter lineOffsetCounter = new LineOffsetCounter();
CharHandler[] handlers = {lineCounter, fileHashComputer, lineOffsetCounter};
try {
read(reader, handlers);
} catch (IOException e) {
throw new IllegalStateException("Should never occur", e);
}
return new Metadata(lineCounter.lines(), lineCounter.nonBlankLines(), fileHashComputer.getHash(), lineOffsetCounter.getOriginalLineStartOffsets(),
lineOffsetCounter.getOriginalLineEndOffsets(),
lineOffsetCounter.getLastValidOffset());
}
|
java
|
public Metadata readMetadata(Reader reader) {
LineCounter lineCounter = new LineCounter("fromString", StandardCharsets.UTF_16);
FileHashComputer fileHashComputer = new FileHashComputer("fromString");
LineOffsetCounter lineOffsetCounter = new LineOffsetCounter();
CharHandler[] handlers = {lineCounter, fileHashComputer, lineOffsetCounter};
try {
read(reader, handlers);
} catch (IOException e) {
throw new IllegalStateException("Should never occur", e);
}
return new Metadata(lineCounter.lines(), lineCounter.nonBlankLines(), fileHashComputer.getHash(), lineOffsetCounter.getOriginalLineStartOffsets(),
lineOffsetCounter.getOriginalLineEndOffsets(),
lineOffsetCounter.getLastValidOffset());
}
|
[
"public",
"Metadata",
"readMetadata",
"(",
"Reader",
"reader",
")",
"{",
"LineCounter",
"lineCounter",
"=",
"new",
"LineCounter",
"(",
"\"fromString\"",
",",
"StandardCharsets",
".",
"UTF_16",
")",
";",
"FileHashComputer",
"fileHashComputer",
"=",
"new",
"FileHashComputer",
"(",
"\"fromString\"",
")",
";",
"LineOffsetCounter",
"lineOffsetCounter",
"=",
"new",
"LineOffsetCounter",
"(",
")",
";",
"CharHandler",
"[",
"]",
"handlers",
"=",
"{",
"lineCounter",
",",
"fileHashComputer",
",",
"lineOffsetCounter",
"}",
";",
"try",
"{",
"read",
"(",
"reader",
",",
"handlers",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Should never occur\"",
",",
"e",
")",
";",
"}",
"return",
"new",
"Metadata",
"(",
"lineCounter",
".",
"lines",
"(",
")",
",",
"lineCounter",
".",
"nonBlankLines",
"(",
")",
",",
"fileHashComputer",
".",
"getHash",
"(",
")",
",",
"lineOffsetCounter",
".",
"getOriginalLineStartOffsets",
"(",
")",
",",
"lineOffsetCounter",
".",
"getOriginalLineEndOffsets",
"(",
")",
",",
"lineOffsetCounter",
".",
"getLastValidOffset",
"(",
")",
")",
";",
"}"
] |
For testing purpose
|
[
"For",
"testing",
"purpose"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java#L75-L89
|
16,322
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
|
FileMetadata.computeLineHashesForIssueTracking
|
public static void computeLineHashesForIssueTracking(InputFile f, LineHashConsumer consumer) {
try {
readFile(f.inputStream(), f.charset(), f.absolutePath(), new CharHandler[] {new LineHashComputer(consumer, f.file())});
} catch (IOException e) {
throw new IllegalStateException("Failed to compute line hashes for " + f.absolutePath(), e);
}
}
|
java
|
public static void computeLineHashesForIssueTracking(InputFile f, LineHashConsumer consumer) {
try {
readFile(f.inputStream(), f.charset(), f.absolutePath(), new CharHandler[] {new LineHashComputer(consumer, f.file())});
} catch (IOException e) {
throw new IllegalStateException("Failed to compute line hashes for " + f.absolutePath(), e);
}
}
|
[
"public",
"static",
"void",
"computeLineHashesForIssueTracking",
"(",
"InputFile",
"f",
",",
"LineHashConsumer",
"consumer",
")",
"{",
"try",
"{",
"readFile",
"(",
"f",
".",
"inputStream",
"(",
")",
",",
"f",
".",
"charset",
"(",
")",
",",
"f",
".",
"absolutePath",
"(",
")",
",",
"new",
"CharHandler",
"[",
"]",
"{",
"new",
"LineHashComputer",
"(",
"consumer",
",",
"f",
".",
"file",
"(",
")",
")",
"}",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to compute line hashes for \"",
"+",
"f",
".",
"absolutePath",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Compute a MD5 hash of each line of the file after removing of all blank chars
|
[
"Compute",
"a",
"MD5",
"hash",
"of",
"each",
"line",
"of",
"the",
"file",
"after",
"removing",
"of",
"all",
"blank",
"chars"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java#L154-L160
|
16,323
|
SonarSource/sonarqube
|
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigration.java
|
ComponentUuidFactoryWithMigration.getOrCreateForKey
|
@Override
public String getOrCreateForKey(String key) {
return uuidsByDbKey.computeIfAbsent(key, k1 -> uuidsByMigratedKey.computeIfAbsent(k1, k2 -> Uuids.create()));
}
|
java
|
@Override
public String getOrCreateForKey(String key) {
return uuidsByDbKey.computeIfAbsent(key, k1 -> uuidsByMigratedKey.computeIfAbsent(k1, k2 -> Uuids.create()));
}
|
[
"@",
"Override",
"public",
"String",
"getOrCreateForKey",
"(",
"String",
"key",
")",
"{",
"return",
"uuidsByDbKey",
".",
"computeIfAbsent",
"(",
"key",
",",
"k1",
"->",
"uuidsByMigratedKey",
".",
"computeIfAbsent",
"(",
"k1",
",",
"k2",
"->",
"Uuids",
".",
"create",
"(",
")",
")",
")",
";",
"}"
] |
Get UUID from component having the same key in database if it exists, otherwise look for migrated keys, and finally generate a new one.
|
[
"Get",
"UUID",
"from",
"component",
"having",
"the",
"same",
"key",
"in",
"database",
"if",
"it",
"exists",
"otherwise",
"look",
"for",
"migrated",
"keys",
"and",
"finally",
"generate",
"a",
"new",
"one",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigration.java#L122-L125
|
16,324
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/permission/index/WebAuthorizationTypeSupport.java
|
WebAuthorizationTypeSupport.createQueryFilter
|
public QueryBuilder createQueryFilter() {
if (userSession.isRoot()) {
return QueryBuilders.matchAllQuery();
}
Integer userId = userSession.getUserId();
BoolQueryBuilder filter = boolQuery();
// anyone
filter.should(QueryBuilders.termQuery(FIELD_ALLOW_ANYONE, true));
// users
Optional.ofNullable(userId)
.map(Integer::longValue)
.ifPresent(id -> filter.should(termQuery(FIELD_USER_IDS, id)));
// groups
userSession.getGroups()
.stream()
.map(GroupDto::getId)
.forEach(groupId -> filter.should(termQuery(FIELD_GROUP_IDS, groupId)));
return JoinQueryBuilders.hasParentQuery(
TYPE_AUTHORIZATION,
QueryBuilders.boolQuery().filter(filter),
false);
}
|
java
|
public QueryBuilder createQueryFilter() {
if (userSession.isRoot()) {
return QueryBuilders.matchAllQuery();
}
Integer userId = userSession.getUserId();
BoolQueryBuilder filter = boolQuery();
// anyone
filter.should(QueryBuilders.termQuery(FIELD_ALLOW_ANYONE, true));
// users
Optional.ofNullable(userId)
.map(Integer::longValue)
.ifPresent(id -> filter.should(termQuery(FIELD_USER_IDS, id)));
// groups
userSession.getGroups()
.stream()
.map(GroupDto::getId)
.forEach(groupId -> filter.should(termQuery(FIELD_GROUP_IDS, groupId)));
return JoinQueryBuilders.hasParentQuery(
TYPE_AUTHORIZATION,
QueryBuilders.boolQuery().filter(filter),
false);
}
|
[
"public",
"QueryBuilder",
"createQueryFilter",
"(",
")",
"{",
"if",
"(",
"userSession",
".",
"isRoot",
"(",
")",
")",
"{",
"return",
"QueryBuilders",
".",
"matchAllQuery",
"(",
")",
";",
"}",
"Integer",
"userId",
"=",
"userSession",
".",
"getUserId",
"(",
")",
";",
"BoolQueryBuilder",
"filter",
"=",
"boolQuery",
"(",
")",
";",
"// anyone",
"filter",
".",
"should",
"(",
"QueryBuilders",
".",
"termQuery",
"(",
"FIELD_ALLOW_ANYONE",
",",
"true",
")",
")",
";",
"// users",
"Optional",
".",
"ofNullable",
"(",
"userId",
")",
".",
"map",
"(",
"Integer",
"::",
"longValue",
")",
".",
"ifPresent",
"(",
"id",
"->",
"filter",
".",
"should",
"(",
"termQuery",
"(",
"FIELD_USER_IDS",
",",
"id",
")",
")",
")",
";",
"// groups",
"userSession",
".",
"getGroups",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"GroupDto",
"::",
"getId",
")",
".",
"forEach",
"(",
"groupId",
"->",
"filter",
".",
"should",
"(",
"termQuery",
"(",
"FIELD_GROUP_IDS",
",",
"groupId",
")",
")",
")",
";",
"return",
"JoinQueryBuilders",
".",
"hasParentQuery",
"(",
"TYPE_AUTHORIZATION",
",",
"QueryBuilders",
".",
"boolQuery",
"(",
")",
".",
"filter",
"(",
"filter",
")",
",",
"false",
")",
";",
"}"
] |
Build a filter to restrict query to the documents on which
user has read access.
|
[
"Build",
"a",
"filter",
"to",
"restrict",
"query",
"to",
"the",
"documents",
"on",
"which",
"user",
"has",
"read",
"access",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/permission/index/WebAuthorizationTypeSupport.java#L51-L77
|
16,325
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionPrivilegeChecker.java
|
PermissionPrivilegeChecker.checkProjectAdmin
|
public static void checkProjectAdmin(UserSession userSession, String organizationUuid, Optional<ProjectId> projectId) {
userSession.checkLoggedIn();
if (userSession.hasPermission(OrganizationPermission.ADMINISTER, organizationUuid)) {
return;
}
if (projectId.isPresent()) {
userSession.checkComponentUuidPermission(UserRole.ADMIN, projectId.get().getUuid());
} else {
throw insufficientPrivilegesException();
}
}
|
java
|
public static void checkProjectAdmin(UserSession userSession, String organizationUuid, Optional<ProjectId> projectId) {
userSession.checkLoggedIn();
if (userSession.hasPermission(OrganizationPermission.ADMINISTER, organizationUuid)) {
return;
}
if (projectId.isPresent()) {
userSession.checkComponentUuidPermission(UserRole.ADMIN, projectId.get().getUuid());
} else {
throw insufficientPrivilegesException();
}
}
|
[
"public",
"static",
"void",
"checkProjectAdmin",
"(",
"UserSession",
"userSession",
",",
"String",
"organizationUuid",
",",
"Optional",
"<",
"ProjectId",
">",
"projectId",
")",
"{",
"userSession",
".",
"checkLoggedIn",
"(",
")",
";",
"if",
"(",
"userSession",
".",
"hasPermission",
"(",
"OrganizationPermission",
".",
"ADMINISTER",
",",
"organizationUuid",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"projectId",
".",
"isPresent",
"(",
")",
")",
"{",
"userSession",
".",
"checkComponentUuidPermission",
"(",
"UserRole",
".",
"ADMIN",
",",
"projectId",
".",
"get",
"(",
")",
".",
"getUuid",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"insufficientPrivilegesException",
"(",
")",
";",
"}",
"}"
] |
Checks that user is administrator of the specified project, or of the specified organization if project is not
defined.
@throws org.sonar.server.exceptions.ForbiddenException if user is not administrator
|
[
"Checks",
"that",
"user",
"is",
"administrator",
"of",
"the",
"specified",
"project",
"or",
"of",
"the",
"specified",
"organization",
"if",
"project",
"is",
"not",
"defined",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionPrivilegeChecker.java#L45-L57
|
16,326
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java
|
ClassLoaderUtils.listFiles
|
public static Collection<String> listFiles(ClassLoader classLoader, String rootPath) {
return listResources(classLoader, rootPath, path -> !StringUtils.endsWith(path, "/"));
}
|
java
|
public static Collection<String> listFiles(ClassLoader classLoader, String rootPath) {
return listResources(classLoader, rootPath, path -> !StringUtils.endsWith(path, "/"));
}
|
[
"public",
"static",
"Collection",
"<",
"String",
">",
"listFiles",
"(",
"ClassLoader",
"classLoader",
",",
"String",
"rootPath",
")",
"{",
"return",
"listResources",
"(",
"classLoader",
",",
"rootPath",
",",
"path",
"->",
"!",
"StringUtils",
".",
"endsWith",
"(",
"path",
",",
"\"/\"",
")",
")",
";",
"}"
] |
Finds files within a given directory and its subdirectories
@param classLoader
@param rootPath the root directory, for example org/sonar/sqale
@return a list of relative paths, for example {"org/sonar/sqale/foo/bar.txt}. Never null.
|
[
"Finds",
"files",
"within",
"a",
"given",
"directory",
"and",
"its",
"subdirectories"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java#L50-L52
|
16,327
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java
|
ClassLoaderUtils.listResources
|
public static Collection<String> listResources(ClassLoader classLoader, String rootPath, Predicate<String> predicate) {
String jarPath = null;
JarFile jar = null;
try {
Collection<String> paths = new ArrayList<>();
URL root = classLoader.getResource(rootPath);
if (root != null) {
checkJarFile(root);
// Path of the root directory
// Examples :
// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
// org/sonar/sqale -> rootDirectory is org/sonar/sqale
String rootDirectory = rootPath;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
// strip out only the JAR file
jarPath = root.getPath().substring(5, root.getPath().indexOf('!'));
jar = new JarFile(URLDecoder.decode(jarPath, UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(rootDirectory) && predicate.test(name)) {
paths.add(name);
}
}
}
return paths;
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
closeJar(jar, jarPath);
}
}
|
java
|
public static Collection<String> listResources(ClassLoader classLoader, String rootPath, Predicate<String> predicate) {
String jarPath = null;
JarFile jar = null;
try {
Collection<String> paths = new ArrayList<>();
URL root = classLoader.getResource(rootPath);
if (root != null) {
checkJarFile(root);
// Path of the root directory
// Examples :
// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
// org/sonar/sqale -> rootDirectory is org/sonar/sqale
String rootDirectory = rootPath;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
// strip out only the JAR file
jarPath = root.getPath().substring(5, root.getPath().indexOf('!'));
jar = new JarFile(URLDecoder.decode(jarPath, UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(rootDirectory) && predicate.test(name)) {
paths.add(name);
}
}
}
return paths;
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
closeJar(jar, jarPath);
}
}
|
[
"public",
"static",
"Collection",
"<",
"String",
">",
"listResources",
"(",
"ClassLoader",
"classLoader",
",",
"String",
"rootPath",
",",
"Predicate",
"<",
"String",
">",
"predicate",
")",
"{",
"String",
"jarPath",
"=",
"null",
";",
"JarFile",
"jar",
"=",
"null",
";",
"try",
"{",
"Collection",
"<",
"String",
">",
"paths",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"URL",
"root",
"=",
"classLoader",
".",
"getResource",
"(",
"rootPath",
")",
";",
"if",
"(",
"root",
"!=",
"null",
")",
"{",
"checkJarFile",
"(",
"root",
")",
";",
"// Path of the root directory",
"// Examples :",
"// org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale",
"// org/sonar/sqale/ -> rootDirectory is org/sonar/sqale",
"// org/sonar/sqale -> rootDirectory is org/sonar/sqale",
"String",
"rootDirectory",
"=",
"rootPath",
";",
"if",
"(",
"StringUtils",
".",
"substringAfterLast",
"(",
"rootPath",
",",
"\"/\"",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"{",
"rootDirectory",
"=",
"StringUtils",
".",
"substringBeforeLast",
"(",
"rootPath",
",",
"\"/\"",
")",
";",
"}",
"// strip out only the JAR file",
"jarPath",
"=",
"root",
".",
"getPath",
"(",
")",
".",
"substring",
"(",
"5",
",",
"root",
".",
"getPath",
"(",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
")",
";",
"jar",
"=",
"new",
"JarFile",
"(",
"URLDecoder",
".",
"decode",
"(",
"jarPath",
",",
"UTF_8",
".",
"name",
"(",
")",
")",
")",
";",
"Enumeration",
"<",
"JarEntry",
">",
"entries",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entries",
".",
"nextElement",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"rootDirectory",
")",
"&&",
"predicate",
".",
"test",
"(",
"name",
")",
")",
"{",
"paths",
".",
"add",
"(",
"name",
")",
";",
"}",
"}",
"}",
"return",
"paths",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeJar",
"(",
"jar",
",",
"jarPath",
")",
";",
"}",
"}"
] |
Finds directories and files within a given directory and its subdirectories.
@param classLoader
@param rootPath the root directory, for example org/sonar/sqale, or a file in this root directory, for example org/sonar/sqale/index.txt
@param predicate
@return a list of relative paths, for example {"org/sonar/sqale", "org/sonar/sqale/foo", "org/sonar/sqale/foo/bar.txt}. Never null.
|
[
"Finds",
"directories",
"and",
"files",
"within",
"a",
"given",
"directory",
"and",
"its",
"subdirectories",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/util/ClassLoaderUtils.java#L62-L97
|
16,328
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionI18nLoader.java
|
RulesDefinitionI18nLoader.load
|
public void load(RulesDefinition.NewRepository repo) {
for (RulesDefinition.NewRule rule : repo.rules()) {
String name = i18n.getName(repo.key(), rule.key());
if (StringUtils.isNotBlank(name)) {
rule.setName(name);
}
String desc = i18n.getDescription(repo.key(), rule.key());
if (StringUtils.isNotBlank(desc)) {
rule.setHtmlDescription(desc);
}
for (RulesDefinition.NewParam param : rule.params()) {
String paramDesc = i18n.getParamDescription(repo.key(), rule.key(), param.key());
if (StringUtils.isNotBlank(paramDesc)) {
param.setDescription(paramDesc);
}
}
}
}
|
java
|
public void load(RulesDefinition.NewRepository repo) {
for (RulesDefinition.NewRule rule : repo.rules()) {
String name = i18n.getName(repo.key(), rule.key());
if (StringUtils.isNotBlank(name)) {
rule.setName(name);
}
String desc = i18n.getDescription(repo.key(), rule.key());
if (StringUtils.isNotBlank(desc)) {
rule.setHtmlDescription(desc);
}
for (RulesDefinition.NewParam param : rule.params()) {
String paramDesc = i18n.getParamDescription(repo.key(), rule.key(), param.key());
if (StringUtils.isNotBlank(paramDesc)) {
param.setDescription(paramDesc);
}
}
}
}
|
[
"public",
"void",
"load",
"(",
"RulesDefinition",
".",
"NewRepository",
"repo",
")",
"{",
"for",
"(",
"RulesDefinition",
".",
"NewRule",
"rule",
":",
"repo",
".",
"rules",
"(",
")",
")",
"{",
"String",
"name",
"=",
"i18n",
".",
"getName",
"(",
"repo",
".",
"key",
"(",
")",
",",
"rule",
".",
"key",
"(",
")",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"name",
")",
")",
"{",
"rule",
".",
"setName",
"(",
"name",
")",
";",
"}",
"String",
"desc",
"=",
"i18n",
".",
"getDescription",
"(",
"repo",
".",
"key",
"(",
")",
",",
"rule",
".",
"key",
"(",
")",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"desc",
")",
")",
"{",
"rule",
".",
"setHtmlDescription",
"(",
"desc",
")",
";",
"}",
"for",
"(",
"RulesDefinition",
".",
"NewParam",
"param",
":",
"rule",
".",
"params",
"(",
")",
")",
"{",
"String",
"paramDesc",
"=",
"i18n",
".",
"getParamDescription",
"(",
"repo",
".",
"key",
"(",
")",
",",
"rule",
".",
"key",
"(",
")",
",",
"param",
".",
"key",
"(",
")",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"paramDesc",
")",
")",
"{",
"param",
".",
"setDescription",
"(",
"paramDesc",
")",
";",
"}",
"}",
"}",
"}"
] |
Loads descriptions of rules and related rule parameters. Existing descriptions
are overridden if English labels exist in bundles.
|
[
"Loads",
"descriptions",
"of",
"rules",
"and",
"related",
"rule",
"parameters",
".",
"Existing",
"descriptions",
"are",
"overridden",
"if",
"English",
"labels",
"exist",
"in",
"bundles",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionI18nLoader.java#L49-L68
|
16,329
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java
|
AutoDbMigration.hackFixForProjectMeasureTreeQueries
|
private static void hackFixForProjectMeasureTreeQueries(Connection connection) {
int metricId = 1;
try (PreparedStatement preparedStatement = connection.prepareStatement("insert into PROJECT_MEASURES (METRIC_ID,COMPONENT_UUID,ANALYSIS_UUID) values (?,?,?);")) {
batchExecute(
1, 1000,
preparedStatement, connection,
(stmt, counter) -> {
preparedStatement.setInt(1, metricId);
preparedStatement.setString(2, "foo_" + counter);
preparedStatement.setString(3, "bar_" + counter);
});
} catch (SQLException e) {
throw new RuntimeException("Failed to insert fake rows into table PROJECT_MEASURES", e);
}
}
|
java
|
private static void hackFixForProjectMeasureTreeQueries(Connection connection) {
int metricId = 1;
try (PreparedStatement preparedStatement = connection.prepareStatement("insert into PROJECT_MEASURES (METRIC_ID,COMPONENT_UUID,ANALYSIS_UUID) values (?,?,?);")) {
batchExecute(
1, 1000,
preparedStatement, connection,
(stmt, counter) -> {
preparedStatement.setInt(1, metricId);
preparedStatement.setString(2, "foo_" + counter);
preparedStatement.setString(3, "bar_" + counter);
});
} catch (SQLException e) {
throw new RuntimeException("Failed to insert fake rows into table PROJECT_MEASURES", e);
}
}
|
[
"private",
"static",
"void",
"hackFixForProjectMeasureTreeQueries",
"(",
"Connection",
"connection",
")",
"{",
"int",
"metricId",
"=",
"1",
";",
"try",
"(",
"PreparedStatement",
"preparedStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"insert into PROJECT_MEASURES (METRIC_ID,COMPONENT_UUID,ANALYSIS_UUID) values (?,?,?);\"",
")",
")",
"{",
"batchExecute",
"(",
"1",
",",
"1000",
",",
"preparedStatement",
",",
"connection",
",",
"(",
"stmt",
",",
"counter",
")",
"->",
"{",
"preparedStatement",
".",
"setInt",
"(",
"1",
",",
"metricId",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"2",
",",
"\"foo_\"",
"+",
"counter",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"3",
",",
"\"bar_\"",
"+",
"counter",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to insert fake rows into table PROJECT_MEASURES\"",
",",
"e",
")",
";",
"}",
"}"
] |
see SONAR-8586
|
[
"see",
"SONAR",
"-",
"8586"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java#L102-L116
|
16,330
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
|
ProjectReactor.collectProjects
|
private static List<ProjectDefinition> collectProjects(ProjectDefinition def, List<ProjectDefinition> collected) {
collected.add(def);
for (ProjectDefinition child : def.getSubProjects()) {
collectProjects(child, collected);
}
return collected;
}
|
java
|
private static List<ProjectDefinition> collectProjects(ProjectDefinition def, List<ProjectDefinition> collected) {
collected.add(def);
for (ProjectDefinition child : def.getSubProjects()) {
collectProjects(child, collected);
}
return collected;
}
|
[
"private",
"static",
"List",
"<",
"ProjectDefinition",
">",
"collectProjects",
"(",
"ProjectDefinition",
"def",
",",
"List",
"<",
"ProjectDefinition",
">",
"collected",
")",
"{",
"collected",
".",
"add",
"(",
"def",
")",
";",
"for",
"(",
"ProjectDefinition",
"child",
":",
"def",
".",
"getSubProjects",
"(",
")",
")",
"{",
"collectProjects",
"(",
"child",
",",
"collected",
")",
";",
"}",
"return",
"collected",
";",
"}"
] |
Populates list of projects from hierarchy.
|
[
"Populates",
"list",
"of",
"projects",
"from",
"hierarchy",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java#L53-L59
|
16,331
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
|
SourceService.getLines
|
public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
return getLines(dbSession, fileUuid, from, toInclusive, Function.identity());
}
|
java
|
public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
return getLines(dbSession, fileUuid, from, toInclusive, Function.identity());
}
|
[
"public",
"Optional",
"<",
"Iterable",
"<",
"DbFileSources",
".",
"Line",
">",
">",
"getLines",
"(",
"DbSession",
"dbSession",
",",
"String",
"fileUuid",
",",
"int",
"from",
",",
"int",
"toInclusive",
")",
"{",
"return",
"getLines",
"(",
"dbSession",
",",
"fileUuid",
",",
"from",
",",
"toInclusive",
",",
"Function",
".",
"identity",
"(",
")",
")",
";",
"}"
] |
Returns a range of lines as raw db data. User permission is not verified.
@param from starts from 1
@param toInclusive starts from 1, must be greater than or equal param {@code from}
|
[
"Returns",
"a",
"range",
"of",
"lines",
"as",
"raw",
"db",
"data",
".",
"User",
"permission",
"is",
"not",
"verified",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java#L49-L51
|
16,332
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
|
SourceService.getLinesAsRawText
|
public Optional<Iterable<String>> getLinesAsRawText(DbSession dbSession, String fileUuid, int from, int toInclusive) {
return getLines(dbSession, fileUuid, from, toInclusive, DbFileSources.Line::getSource);
}
|
java
|
public Optional<Iterable<String>> getLinesAsRawText(DbSession dbSession, String fileUuid, int from, int toInclusive) {
return getLines(dbSession, fileUuid, from, toInclusive, DbFileSources.Line::getSource);
}
|
[
"public",
"Optional",
"<",
"Iterable",
"<",
"String",
">",
">",
"getLinesAsRawText",
"(",
"DbSession",
"dbSession",
",",
"String",
"fileUuid",
",",
"int",
"from",
",",
"int",
"toInclusive",
")",
"{",
"return",
"getLines",
"(",
"dbSession",
",",
"fileUuid",
",",
"from",
",",
"toInclusive",
",",
"DbFileSources",
".",
"Line",
"::",
"getSource",
")",
";",
"}"
] |
Returns a range of lines as raw text.
@see #getLines(DbSession, String, int, int)
|
[
"Returns",
"a",
"range",
"of",
"lines",
"as",
"raw",
"text",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java#L57-L59
|
16,333
|
SonarSource/sonarqube
|
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java
|
MetadataGenerator.setMetadata
|
public void setMetadata(String moduleKeyWithBranch, final DefaultInputFile inputFile, Charset defaultEncoding) {
CharsetDetector charsetDetector = new CharsetDetector(inputFile.path(), defaultEncoding);
try {
Charset charset;
if (charsetDetector.run()) {
charset = charsetDetector.charset();
} else {
LOG.debug("Failed to detect a valid charset for file '{}'. Using default charset.", inputFile);
charset = defaultEncoding;
}
InputStream is = charsetDetector.inputStream();
inputFile.setCharset(charset);
Metadata metadata = fileMetadata.readMetadata(is, charset, inputFile.absolutePath(), exclusionsScanner.createCharHandlerFor(inputFile));
inputFile.setMetadata(metadata);
inputFile.setStatus(statusDetection.status(moduleKeyWithBranch, inputFile, metadata.hash()));
LOG.debug("'{}' generated metadata{} with charset '{}'", inputFile, inputFile.type() == Type.TEST ? " as test " : "", charset);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
|
java
|
public void setMetadata(String moduleKeyWithBranch, final DefaultInputFile inputFile, Charset defaultEncoding) {
CharsetDetector charsetDetector = new CharsetDetector(inputFile.path(), defaultEncoding);
try {
Charset charset;
if (charsetDetector.run()) {
charset = charsetDetector.charset();
} else {
LOG.debug("Failed to detect a valid charset for file '{}'. Using default charset.", inputFile);
charset = defaultEncoding;
}
InputStream is = charsetDetector.inputStream();
inputFile.setCharset(charset);
Metadata metadata = fileMetadata.readMetadata(is, charset, inputFile.absolutePath(), exclusionsScanner.createCharHandlerFor(inputFile));
inputFile.setMetadata(metadata);
inputFile.setStatus(statusDetection.status(moduleKeyWithBranch, inputFile, metadata.hash()));
LOG.debug("'{}' generated metadata{} with charset '{}'", inputFile, inputFile.type() == Type.TEST ? " as test " : "", charset);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
|
[
"public",
"void",
"setMetadata",
"(",
"String",
"moduleKeyWithBranch",
",",
"final",
"DefaultInputFile",
"inputFile",
",",
"Charset",
"defaultEncoding",
")",
"{",
"CharsetDetector",
"charsetDetector",
"=",
"new",
"CharsetDetector",
"(",
"inputFile",
".",
"path",
"(",
")",
",",
"defaultEncoding",
")",
";",
"try",
"{",
"Charset",
"charset",
";",
"if",
"(",
"charsetDetector",
".",
"run",
"(",
")",
")",
"{",
"charset",
"=",
"charsetDetector",
".",
"charset",
"(",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"Failed to detect a valid charset for file '{}'. Using default charset.\"",
",",
"inputFile",
")",
";",
"charset",
"=",
"defaultEncoding",
";",
"}",
"InputStream",
"is",
"=",
"charsetDetector",
".",
"inputStream",
"(",
")",
";",
"inputFile",
".",
"setCharset",
"(",
"charset",
")",
";",
"Metadata",
"metadata",
"=",
"fileMetadata",
".",
"readMetadata",
"(",
"is",
",",
"charset",
",",
"inputFile",
".",
"absolutePath",
"(",
")",
",",
"exclusionsScanner",
".",
"createCharHandlerFor",
"(",
"inputFile",
")",
")",
";",
"inputFile",
".",
"setMetadata",
"(",
"metadata",
")",
";",
"inputFile",
".",
"setStatus",
"(",
"statusDetection",
".",
"status",
"(",
"moduleKeyWithBranch",
",",
"inputFile",
",",
"metadata",
".",
"hash",
"(",
")",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"'{}' generated metadata{} with charset '{}'\"",
",",
"inputFile",
",",
"inputFile",
".",
"type",
"(",
")",
"==",
"Type",
".",
"TEST",
"?",
"\" as test \"",
":",
"\"\"",
",",
"charset",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] |
Sets all metadata in the file, including charset and status.
It is an expensive computation, reading the entire file.
|
[
"Sets",
"all",
"metadata",
"in",
"the",
"file",
"including",
"charset",
"and",
"status",
".",
"It",
"is",
"an",
"expensive",
"computation",
"reading",
"the",
"entire",
"file",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java#L55-L74
|
16,334
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
|
Request.mandatoryParam
|
public String mandatoryParam(String key) {
String value = param(key);
checkArgument(value != null && !value.isEmpty(), format(MSG_PARAMETER_MISSING, key));
return value;
}
|
java
|
public String mandatoryParam(String key) {
String value = param(key);
checkArgument(value != null && !value.isEmpty(), format(MSG_PARAMETER_MISSING, key));
return value;
}
|
[
"public",
"String",
"mandatoryParam",
"(",
"String",
"key",
")",
"{",
"String",
"value",
"=",
"param",
"(",
"key",
")",
";",
"checkArgument",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isEmpty",
"(",
")",
",",
"format",
"(",
"MSG_PARAMETER_MISSING",
",",
"key",
")",
")",
";",
"return",
"value",
";",
"}"
] |
Returns a non-null value. To be used when parameter is required or has a default value.
@throws java.lang.IllegalArgumentException is value is null or blank
|
[
"Returns",
"a",
"non",
"-",
"null",
"value",
".",
"To",
"be",
"used",
"when",
"parameter",
"is",
"required",
"or",
"has",
"a",
"default",
"value",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java#L78-L82
|
16,335
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
|
Request.mandatoryParamAsBoolean
|
public boolean mandatoryParamAsBoolean(String key) {
String s = mandatoryParam(key);
return parseBoolean(key, s);
}
|
java
|
public boolean mandatoryParamAsBoolean(String key) {
String s = mandatoryParam(key);
return parseBoolean(key, s);
}
|
[
"public",
"boolean",
"mandatoryParamAsBoolean",
"(",
"String",
"key",
")",
"{",
"String",
"s",
"=",
"mandatoryParam",
"(",
"key",
")",
";",
"return",
"parseBoolean",
"(",
"key",
",",
"s",
")",
";",
"}"
] |
Returns a boolean value. To be used when parameter is required or has a default value.
@throws java.lang.IllegalArgumentException is value is null or blank
|
[
"Returns",
"a",
"boolean",
"value",
".",
"To",
"be",
"used",
"when",
"parameter",
"is",
"required",
"or",
"has",
"a",
"default",
"value",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java#L89-L92
|
16,336
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
|
Request.mandatoryParamAsInt
|
public int mandatoryParamAsInt(String key) {
String s = mandatoryParam(key);
return parseInt(key, s);
}
|
java
|
public int mandatoryParamAsInt(String key) {
String s = mandatoryParam(key);
return parseInt(key, s);
}
|
[
"public",
"int",
"mandatoryParamAsInt",
"(",
"String",
"key",
")",
"{",
"String",
"s",
"=",
"mandatoryParam",
"(",
"key",
")",
";",
"return",
"parseInt",
"(",
"key",
",",
"s",
")",
";",
"}"
] |
Returns an int value. To be used when parameter is required or has a default value.
@throws java.lang.IllegalArgumentException is value is null or blank
|
[
"Returns",
"an",
"int",
"value",
".",
"To",
"be",
"used",
"when",
"parameter",
"is",
"required",
"or",
"has",
"a",
"default",
"value",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java#L99-L102
|
16,337
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
|
Request.mandatoryParamAsLong
|
public long mandatoryParamAsLong(String key) {
String s = mandatoryParam(key);
return parseLong(key, s);
}
|
java
|
public long mandatoryParamAsLong(String key) {
String s = mandatoryParam(key);
return parseLong(key, s);
}
|
[
"public",
"long",
"mandatoryParamAsLong",
"(",
"String",
"key",
")",
"{",
"String",
"s",
"=",
"mandatoryParam",
"(",
"key",
")",
";",
"return",
"parseLong",
"(",
"key",
",",
"s",
")",
";",
"}"
] |
Returns a long value. To be used when parameter is required or has a default value.
@throws java.lang.IllegalArgumentException is value is null or blank
|
[
"Returns",
"a",
"long",
"value",
".",
"To",
"be",
"used",
"when",
"parameter",
"is",
"required",
"or",
"has",
"a",
"default",
"value",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java#L109-L112
|
16,338
|
SonarSource/sonarqube
|
sonar-core/src/main/java/org/sonar/core/config/Logback.java
|
Logback.configure
|
private static void configure(InputStream input, Map<String, String> substitutionVariables) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(configureContext(lc, substitutionVariables));
configurator.doConfigure(input);
} catch (JoranException e) {
// StatusPrinter will handle this
} finally {
IOUtils.closeQuietly(input);
}
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
|
java
|
private static void configure(InputStream input, Map<String, String> substitutionVariables) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(configureContext(lc, substitutionVariables));
configurator.doConfigure(input);
} catch (JoranException e) {
// StatusPrinter will handle this
} finally {
IOUtils.closeQuietly(input);
}
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
|
[
"private",
"static",
"void",
"configure",
"(",
"InputStream",
"input",
",",
"Map",
"<",
"String",
",",
"String",
">",
"substitutionVariables",
")",
"{",
"LoggerContext",
"lc",
"=",
"(",
"LoggerContext",
")",
"LoggerFactory",
".",
"getILoggerFactory",
"(",
")",
";",
"try",
"{",
"JoranConfigurator",
"configurator",
"=",
"new",
"JoranConfigurator",
"(",
")",
";",
"configurator",
".",
"setContext",
"(",
"configureContext",
"(",
"lc",
",",
"substitutionVariables",
")",
")",
";",
"configurator",
".",
"doConfigure",
"(",
"input",
")",
";",
"}",
"catch",
"(",
"JoranException",
"e",
")",
"{",
"// StatusPrinter will handle this",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"input",
")",
";",
"}",
"StatusPrinter",
".",
"printInCaseOfErrorsOrWarnings",
"(",
"lc",
")",
";",
"}"
] |
Note that this method closes the input stream
|
[
"Note",
"that",
"this",
"method",
"closes",
"the",
"input",
"stream"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/config/Logback.java#L66-L78
|
16,339
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
|
PermissionTemplateService.applyAndCommit
|
public void applyAndCommit(DbSession dbSession, PermissionTemplateDto template, Collection<ComponentDto> projects) {
if (projects.isEmpty()) {
return;
}
for (ComponentDto project : projects) {
copyPermissions(dbSession, template, project, null);
}
projectIndexers.commitAndIndex(dbSession, projects, ProjectIndexer.Cause.PERMISSION_CHANGE);
}
|
java
|
public void applyAndCommit(DbSession dbSession, PermissionTemplateDto template, Collection<ComponentDto> projects) {
if (projects.isEmpty()) {
return;
}
for (ComponentDto project : projects) {
copyPermissions(dbSession, template, project, null);
}
projectIndexers.commitAndIndex(dbSession, projects, ProjectIndexer.Cause.PERMISSION_CHANGE);
}
|
[
"public",
"void",
"applyAndCommit",
"(",
"DbSession",
"dbSession",
",",
"PermissionTemplateDto",
"template",
",",
"Collection",
"<",
"ComponentDto",
">",
"projects",
")",
"{",
"if",
"(",
"projects",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"ComponentDto",
"project",
":",
"projects",
")",
"{",
"copyPermissions",
"(",
"dbSession",
",",
"template",
",",
"project",
",",
"null",
")",
";",
"}",
"projectIndexers",
".",
"commitAndIndex",
"(",
"dbSession",
",",
"projects",
",",
"ProjectIndexer",
".",
"Cause",
".",
"PERMISSION_CHANGE",
")",
";",
"}"
] |
Apply a permission template to a set of projects. Authorization to administrate these projects
is not verified. The projects must exist, so the "project creator" permissions defined in the
template are ignored.
|
[
"Apply",
"a",
"permission",
"template",
"to",
"a",
"set",
"of",
"projects",
".",
"Authorization",
"to",
"administrate",
"these",
"projects",
"is",
"not",
"verified",
".",
"The",
"projects",
"must",
"exist",
"so",
"the",
"project",
"creator",
"permissions",
"defined",
"in",
"the",
"template",
"are",
"ignored",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java#L92-L101
|
16,340
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
|
PermissionTemplateService.findTemplate
|
@CheckForNull
private PermissionTemplateDto findTemplate(DbSession dbSession, ComponentDto component) {
String organizationUuid = component.getOrganizationUuid();
List<PermissionTemplateDto> allPermissionTemplates = dbClient.permissionTemplateDao().selectAll(dbSession, organizationUuid, null);
List<PermissionTemplateDto> matchingTemplates = new ArrayList<>();
for (PermissionTemplateDto permissionTemplateDto : allPermissionTemplates) {
String keyPattern = permissionTemplateDto.getKeyPattern();
if (StringUtils.isNotBlank(keyPattern) && component.getDbKey().matches(keyPattern)) {
matchingTemplates.add(permissionTemplateDto);
}
}
checkAtMostOneMatchForComponentKey(component.getDbKey(), matchingTemplates);
if (matchingTemplates.size() == 1) {
return matchingTemplates.get(0);
}
DefaultTemplates defaultTemplates = dbClient.organizationDao().getDefaultTemplates(dbSession, organizationUuid)
.orElseThrow(() -> new IllegalStateException(
format("No Default templates defined for organization with uuid '%s'", organizationUuid)));
String qualifier = component.qualifier();
DefaultTemplatesResolverImpl.ResolvedDefaultTemplates resolvedDefaultTemplates = defaultTemplatesResolver.resolve(defaultTemplates);
switch (qualifier) {
case Qualifiers.PROJECT:
return dbClient.permissionTemplateDao().selectByUuid(dbSession, resolvedDefaultTemplates.getProject());
case Qualifiers.VIEW:
String portDefaultTemplateUuid = resolvedDefaultTemplates.getPortfolio().orElseThrow(
() -> new IllegalStateException("Attempt to create a view when Governance plugin is not installed"));
return dbClient.permissionTemplateDao().selectByUuid(dbSession, portDefaultTemplateUuid);
case Qualifiers.APP:
String appDefaultTemplateUuid = resolvedDefaultTemplates.getApplication().orElseThrow(
() -> new IllegalStateException("Attempt to create a view when Governance plugin is not installed"));
return dbClient.permissionTemplateDao().selectByUuid(dbSession, appDefaultTemplateUuid);
default:
throw new IllegalArgumentException(format("Qualifier '%s' is not supported", qualifier));
}
}
|
java
|
@CheckForNull
private PermissionTemplateDto findTemplate(DbSession dbSession, ComponentDto component) {
String organizationUuid = component.getOrganizationUuid();
List<PermissionTemplateDto> allPermissionTemplates = dbClient.permissionTemplateDao().selectAll(dbSession, organizationUuid, null);
List<PermissionTemplateDto> matchingTemplates = new ArrayList<>();
for (PermissionTemplateDto permissionTemplateDto : allPermissionTemplates) {
String keyPattern = permissionTemplateDto.getKeyPattern();
if (StringUtils.isNotBlank(keyPattern) && component.getDbKey().matches(keyPattern)) {
matchingTemplates.add(permissionTemplateDto);
}
}
checkAtMostOneMatchForComponentKey(component.getDbKey(), matchingTemplates);
if (matchingTemplates.size() == 1) {
return matchingTemplates.get(0);
}
DefaultTemplates defaultTemplates = dbClient.organizationDao().getDefaultTemplates(dbSession, organizationUuid)
.orElseThrow(() -> new IllegalStateException(
format("No Default templates defined for organization with uuid '%s'", organizationUuid)));
String qualifier = component.qualifier();
DefaultTemplatesResolverImpl.ResolvedDefaultTemplates resolvedDefaultTemplates = defaultTemplatesResolver.resolve(defaultTemplates);
switch (qualifier) {
case Qualifiers.PROJECT:
return dbClient.permissionTemplateDao().selectByUuid(dbSession, resolvedDefaultTemplates.getProject());
case Qualifiers.VIEW:
String portDefaultTemplateUuid = resolvedDefaultTemplates.getPortfolio().orElseThrow(
() -> new IllegalStateException("Attempt to create a view when Governance plugin is not installed"));
return dbClient.permissionTemplateDao().selectByUuid(dbSession, portDefaultTemplateUuid);
case Qualifiers.APP:
String appDefaultTemplateUuid = resolvedDefaultTemplates.getApplication().orElseThrow(
() -> new IllegalStateException("Attempt to create a view when Governance plugin is not installed"));
return dbClient.permissionTemplateDao().selectByUuid(dbSession, appDefaultTemplateUuid);
default:
throw new IllegalArgumentException(format("Qualifier '%s' is not supported", qualifier));
}
}
|
[
"@",
"CheckForNull",
"private",
"PermissionTemplateDto",
"findTemplate",
"(",
"DbSession",
"dbSession",
",",
"ComponentDto",
"component",
")",
"{",
"String",
"organizationUuid",
"=",
"component",
".",
"getOrganizationUuid",
"(",
")",
";",
"List",
"<",
"PermissionTemplateDto",
">",
"allPermissionTemplates",
"=",
"dbClient",
".",
"permissionTemplateDao",
"(",
")",
".",
"selectAll",
"(",
"dbSession",
",",
"organizationUuid",
",",
"null",
")",
";",
"List",
"<",
"PermissionTemplateDto",
">",
"matchingTemplates",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"PermissionTemplateDto",
"permissionTemplateDto",
":",
"allPermissionTemplates",
")",
"{",
"String",
"keyPattern",
"=",
"permissionTemplateDto",
".",
"getKeyPattern",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"keyPattern",
")",
"&&",
"component",
".",
"getDbKey",
"(",
")",
".",
"matches",
"(",
"keyPattern",
")",
")",
"{",
"matchingTemplates",
".",
"add",
"(",
"permissionTemplateDto",
")",
";",
"}",
"}",
"checkAtMostOneMatchForComponentKey",
"(",
"component",
".",
"getDbKey",
"(",
")",
",",
"matchingTemplates",
")",
";",
"if",
"(",
"matchingTemplates",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"matchingTemplates",
".",
"get",
"(",
"0",
")",
";",
"}",
"DefaultTemplates",
"defaultTemplates",
"=",
"dbClient",
".",
"organizationDao",
"(",
")",
".",
"getDefaultTemplates",
"(",
"dbSession",
",",
"organizationUuid",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"format",
"(",
"\"No Default templates defined for organization with uuid '%s'\"",
",",
"organizationUuid",
")",
")",
")",
";",
"String",
"qualifier",
"=",
"component",
".",
"qualifier",
"(",
")",
";",
"DefaultTemplatesResolverImpl",
".",
"ResolvedDefaultTemplates",
"resolvedDefaultTemplates",
"=",
"defaultTemplatesResolver",
".",
"resolve",
"(",
"defaultTemplates",
")",
";",
"switch",
"(",
"qualifier",
")",
"{",
"case",
"Qualifiers",
".",
"PROJECT",
":",
"return",
"dbClient",
".",
"permissionTemplateDao",
"(",
")",
".",
"selectByUuid",
"(",
"dbSession",
",",
"resolvedDefaultTemplates",
".",
"getProject",
"(",
")",
")",
";",
"case",
"Qualifiers",
".",
"VIEW",
":",
"String",
"portDefaultTemplateUuid",
"=",
"resolvedDefaultTemplates",
".",
"getPortfolio",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"\"Attempt to create a view when Governance plugin is not installed\"",
")",
")",
";",
"return",
"dbClient",
".",
"permissionTemplateDao",
"(",
")",
".",
"selectByUuid",
"(",
"dbSession",
",",
"portDefaultTemplateUuid",
")",
";",
"case",
"Qualifiers",
".",
"APP",
":",
"String",
"appDefaultTemplateUuid",
"=",
"resolvedDefaultTemplates",
".",
"getApplication",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"\"Attempt to create a view when Governance plugin is not installed\"",
")",
")",
";",
"return",
"dbClient",
".",
"permissionTemplateDao",
"(",
")",
".",
"selectByUuid",
"(",
"dbSession",
",",
"appDefaultTemplateUuid",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\"Qualifier '%s' is not supported\"",
",",
"qualifier",
")",
")",
";",
"}",
"}"
] |
Return the permission template for the given component. If no template key pattern match then consider default
template for the component qualifier.
|
[
"Return",
"the",
"permission",
"template",
"for",
"the",
"given",
"component",
".",
"If",
"no",
"template",
"key",
"pattern",
"match",
"then",
"consider",
"default",
"template",
"for",
"the",
"component",
"qualifier",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java#L181-L217
|
16,341
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
|
RuleIndex.searchAll
|
public Iterator<Integer> searchAll(RuleQuery query) {
SearchRequestBuilder esSearch = client
.prepareSearch(TYPE_RULE)
.setScroll(TimeValue.timeValueMinutes(SCROLL_TIME_IN_MINUTES));
optimizeScrollRequest(esSearch);
QueryBuilder qb = buildQuery(query);
Map<String, QueryBuilder> filters = buildFilters(query);
BoolQueryBuilder fb = boolQuery();
for (QueryBuilder filterBuilder : filters.values()) {
fb.must(filterBuilder);
}
esSearch.setQuery(boolQuery().must(qb).filter(fb));
SearchResponse response = esSearch.get();
return scrollIds(client, response, Integer::parseInt);
}
|
java
|
public Iterator<Integer> searchAll(RuleQuery query) {
SearchRequestBuilder esSearch = client
.prepareSearch(TYPE_RULE)
.setScroll(TimeValue.timeValueMinutes(SCROLL_TIME_IN_MINUTES));
optimizeScrollRequest(esSearch);
QueryBuilder qb = buildQuery(query);
Map<String, QueryBuilder> filters = buildFilters(query);
BoolQueryBuilder fb = boolQuery();
for (QueryBuilder filterBuilder : filters.values()) {
fb.must(filterBuilder);
}
esSearch.setQuery(boolQuery().must(qb).filter(fb));
SearchResponse response = esSearch.get();
return scrollIds(client, response, Integer::parseInt);
}
|
[
"public",
"Iterator",
"<",
"Integer",
">",
"searchAll",
"(",
"RuleQuery",
"query",
")",
"{",
"SearchRequestBuilder",
"esSearch",
"=",
"client",
".",
"prepareSearch",
"(",
"TYPE_RULE",
")",
".",
"setScroll",
"(",
"TimeValue",
".",
"timeValueMinutes",
"(",
"SCROLL_TIME_IN_MINUTES",
")",
")",
";",
"optimizeScrollRequest",
"(",
"esSearch",
")",
";",
"QueryBuilder",
"qb",
"=",
"buildQuery",
"(",
"query",
")",
";",
"Map",
"<",
"String",
",",
"QueryBuilder",
">",
"filters",
"=",
"buildFilters",
"(",
"query",
")",
";",
"BoolQueryBuilder",
"fb",
"=",
"boolQuery",
"(",
")",
";",
"for",
"(",
"QueryBuilder",
"filterBuilder",
":",
"filters",
".",
"values",
"(",
")",
")",
"{",
"fb",
".",
"must",
"(",
"filterBuilder",
")",
";",
"}",
"esSearch",
".",
"setQuery",
"(",
"boolQuery",
"(",
")",
".",
"must",
"(",
"qb",
")",
".",
"filter",
"(",
"fb",
")",
")",
";",
"SearchResponse",
"response",
"=",
"esSearch",
".",
"get",
"(",
")",
";",
"return",
"scrollIds",
"(",
"client",
",",
"response",
",",
"Integer",
"::",
"parseInt",
")",
";",
"}"
] |
Return all rule ids matching the search query, without pagination nor facets
|
[
"Return",
"all",
"rule",
"ids",
"matching",
"the",
"search",
"query",
"without",
"pagination",
"nor",
"facets"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java#L172-L189
|
16,342
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java
|
StartupMetadataProvider.load
|
private static StartupMetadata load(DbClient dbClient) {
try (DbSession dbSession = dbClient.openSession(false)) {
String startedAt = selectProperty(dbClient, dbSession, SERVER_STARTTIME);
return new StartupMetadata(DateUtils.parseDateTime(startedAt).getTime());
}
}
|
java
|
private static StartupMetadata load(DbClient dbClient) {
try (DbSession dbSession = dbClient.openSession(false)) {
String startedAt = selectProperty(dbClient, dbSession, SERVER_STARTTIME);
return new StartupMetadata(DateUtils.parseDateTime(startedAt).getTime());
}
}
|
[
"private",
"static",
"StartupMetadata",
"load",
"(",
"DbClient",
"dbClient",
")",
"{",
"try",
"(",
"DbSession",
"dbSession",
"=",
"dbClient",
".",
"openSession",
"(",
"false",
")",
")",
"{",
"String",
"startedAt",
"=",
"selectProperty",
"(",
"dbClient",
",",
"dbSession",
",",
"SERVER_STARTTIME",
")",
";",
"return",
"new",
"StartupMetadata",
"(",
"DateUtils",
".",
"parseDateTime",
"(",
"startedAt",
")",
".",
"getTime",
"(",
")",
")",
";",
"}",
"}"
] |
Load from database
|
[
"Load",
"from",
"database"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java#L68-L73
|
16,343
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
|
Platform.startLevel34Containers
|
private void startLevel34Containers() {
level3 = start(new PlatformLevel3(level2));
level4 = start(new PlatformLevel4(level3, level4AddedComponents));
}
|
java
|
private void startLevel34Containers() {
level3 = start(new PlatformLevel3(level2));
level4 = start(new PlatformLevel4(level3, level4AddedComponents));
}
|
[
"private",
"void",
"startLevel34Containers",
"(",
")",
"{",
"level3",
"=",
"start",
"(",
"new",
"PlatformLevel3",
"(",
"level2",
")",
")",
";",
"level4",
"=",
"start",
"(",
"new",
"PlatformLevel4",
"(",
"level3",
",",
"level4AddedComponents",
")",
")",
";",
"}"
] |
Starts level 3 and 4
|
[
"Starts",
"level",
"3",
"and",
"4"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java#L183-L186
|
16,344
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
|
Platform.doStop
|
public void doStop() {
try {
stopAutoStarter();
stopSafeModeContainer();
stopLevel234Containers();
stopLevel1Container();
currentLevel = null;
dbConnected = false;
started = false;
} catch (Exception e) {
LOGGER.error("Fail to stop server - ignored", e);
}
}
|
java
|
public void doStop() {
try {
stopAutoStarter();
stopSafeModeContainer();
stopLevel234Containers();
stopLevel1Container();
currentLevel = null;
dbConnected = false;
started = false;
} catch (Exception e) {
LOGGER.error("Fail to stop server - ignored", e);
}
}
|
[
"public",
"void",
"doStop",
"(",
")",
"{",
"try",
"{",
"stopAutoStarter",
"(",
")",
";",
"stopSafeModeContainer",
"(",
")",
";",
"stopLevel234Containers",
"(",
")",
";",
"stopLevel1Container",
"(",
")",
";",
"currentLevel",
"=",
"null",
";",
"dbConnected",
"=",
"false",
";",
"started",
"=",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Fail to stop server - ignored\"",
",",
"e",
")",
";",
"}",
"}"
] |
Do not rename "stop"
|
[
"Do",
"not",
"rename",
"stop"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java#L261-L273
|
16,345
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/Jmx.java
|
Jmx.register
|
public static void register(String name, Object instance) {
try {
Class<Object> mbeanInterface = guessMBeanInterface(instance);
ManagementFactory.getPlatformMBeanServer().registerMBean(new StandardMBean(instance, mbeanInterface), new ObjectName(name));
} catch (MalformedObjectNameException | NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new IllegalStateException("Can not register MBean [" + name + "]", e);
}
}
|
java
|
public static void register(String name, Object instance) {
try {
Class<Object> mbeanInterface = guessMBeanInterface(instance);
ManagementFactory.getPlatformMBeanServer().registerMBean(new StandardMBean(instance, mbeanInterface), new ObjectName(name));
} catch (MalformedObjectNameException | NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new IllegalStateException("Can not register MBean [" + name + "]", e);
}
}
|
[
"public",
"static",
"void",
"register",
"(",
"String",
"name",
",",
"Object",
"instance",
")",
"{",
"try",
"{",
"Class",
"<",
"Object",
">",
"mbeanInterface",
"=",
"guessMBeanInterface",
"(",
"instance",
")",
";",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"registerMBean",
"(",
"new",
"StandardMBean",
"(",
"instance",
",",
"mbeanInterface",
")",
",",
"new",
"ObjectName",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"|",
"NotCompliantMBeanException",
"|",
"InstanceAlreadyExistsException",
"|",
"MBeanRegistrationException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Can not register MBean [\"",
"+",
"name",
"+",
"\"]\"",
",",
"e",
")",
";",
"}",
"}"
] |
Register a MBean to JMX server
|
[
"Register",
"a",
"MBean",
"to",
"JMX",
"server"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/Jmx.java#L43-L51
|
16,346
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/Jmx.java
|
Jmx.unregister
|
public static void unregister(String name) {
try {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
} catch (Exception e) {
LoggerFactory.getLogger(Jmx.class).warn("Can not unregister MBean [{}]", name, e);
}
}
|
java
|
public static void unregister(String name) {
try {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
} catch (Exception e) {
LoggerFactory.getLogger(Jmx.class).warn("Can not unregister MBean [{}]", name, e);
}
}
|
[
"public",
"static",
"void",
"unregister",
"(",
"String",
"name",
")",
"{",
"try",
"{",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"unregisterMBean",
"(",
"new",
"ObjectName",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LoggerFactory",
".",
"getLogger",
"(",
"Jmx",
".",
"class",
")",
".",
"warn",
"(",
"\"Can not unregister MBean [{}]\"",
",",
"name",
",",
"e",
")",
";",
"}",
"}"
] |
Unregister a MBean from JMX server. Errors are ignored and logged as warnings.
|
[
"Unregister",
"a",
"MBean",
"from",
"JMX",
"server",
".",
"Errors",
"are",
"ignored",
"and",
"logged",
"as",
"warnings",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/Jmx.java#L80-L86
|
16,347
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
|
BackendCleanup.clearIndex
|
public void clearIndex(Index index) {
BulkIndexer.delete(esClient, IndexType.main(index, index.getName()), esClient.prepareSearch(index).setQuery(matchAllQuery()));
}
|
java
|
public void clearIndex(Index index) {
BulkIndexer.delete(esClient, IndexType.main(index, index.getName()), esClient.prepareSearch(index).setQuery(matchAllQuery()));
}
|
[
"public",
"void",
"clearIndex",
"(",
"Index",
"index",
")",
"{",
"BulkIndexer",
".",
"delete",
"(",
"esClient",
",",
"IndexType",
".",
"main",
"(",
"index",
",",
"index",
".",
"getName",
"(",
")",
")",
",",
"esClient",
".",
"prepareSearch",
"(",
"index",
")",
".",
"setQuery",
"(",
"matchAllQuery",
"(",
")",
")",
")",
";",
"}"
] |
Completely remove a index with all types
|
[
"Completely",
"remove",
"a",
"index",
"with",
"all",
"types"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java#L171-L173
|
16,348
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
|
BackendCleanup.truncateOrganizations
|
private static void truncateOrganizations(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from organizations where kee <> ?")) {
preparedStatement.setString(1, "default-organization");
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
java
|
private static void truncateOrganizations(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from organizations where kee <> ?")) {
preparedStatement.setString(1, "default-organization");
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
[
"private",
"static",
"void",
"truncateOrganizations",
"(",
"String",
"tableName",
",",
"Statement",
"ddlStatement",
",",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"PreparedStatement",
"preparedStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"delete from organizations where kee <> ?\"",
")",
")",
"{",
"preparedStatement",
".",
"setString",
"(",
"1",
",",
"\"default-organization\"",
")",
";",
"preparedStatement",
".",
"execute",
"(",
")",
";",
"// commit is useless on some databases",
"connection",
".",
"commit",
"(",
")",
";",
"}",
"}"
] |
Default organization must never be deleted
|
[
"Default",
"organization",
"must",
"never",
"be",
"deleted"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java#L189-L196
|
16,349
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
|
BackendCleanup.truncateUsers
|
private static void truncateUsers(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from users where login <> ?")) {
preparedStatement.setString(1, "admin");
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
// "admin" is not flagged as root by default
try (PreparedStatement preparedStatement = connection.prepareStatement("update users set is_root=?")) {
preparedStatement.setBoolean(1, false);
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
java
|
private static void truncateUsers(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from users where login <> ?")) {
preparedStatement.setString(1, "admin");
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
// "admin" is not flagged as root by default
try (PreparedStatement preparedStatement = connection.prepareStatement("update users set is_root=?")) {
preparedStatement.setBoolean(1, false);
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
[
"private",
"static",
"void",
"truncateUsers",
"(",
"String",
"tableName",
",",
"Statement",
"ddlStatement",
",",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"PreparedStatement",
"preparedStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"delete from users where login <> ?\"",
")",
")",
"{",
"preparedStatement",
".",
"setString",
"(",
"1",
",",
"\"admin\"",
")",
";",
"preparedStatement",
".",
"execute",
"(",
")",
";",
"// commit is useless on some databases",
"connection",
".",
"commit",
"(",
")",
";",
"}",
"// \"admin\" is not flagged as root by default",
"try",
"(",
"PreparedStatement",
"preparedStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"update users set is_root=?\"",
")",
")",
"{",
"preparedStatement",
".",
"setBoolean",
"(",
"1",
",",
"false",
")",
";",
"preparedStatement",
".",
"execute",
"(",
")",
";",
"// commit is useless on some databases",
"connection",
".",
"commit",
"(",
")",
";",
"}",
"}"
] |
User admin must never be deleted.
|
[
"User",
"admin",
"must",
"never",
"be",
"deleted",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java#L201-L215
|
16,350
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/DeleteTemplateAction.java
|
DeleteTemplateAction.updateViewDefaultTemplateWhenGovernanceIsNotInstalled
|
private void updateViewDefaultTemplateWhenGovernanceIsNotInstalled(DbSession dbSession, PermissionTemplateDto template, DefaultTemplates defaultTemplates) {
String viewDefaultTemplateUuid = defaultTemplates.getApplicationsUuid();
if (viewDefaultTemplateUuid != null && viewDefaultTemplateUuid.equals(template.getUuid())) {
defaultTemplates.setApplicationsUuid(null);
dbClient.organizationDao().setDefaultTemplates(dbSession, template.getOrganizationUuid(), defaultTemplates);
}
}
|
java
|
private void updateViewDefaultTemplateWhenGovernanceIsNotInstalled(DbSession dbSession, PermissionTemplateDto template, DefaultTemplates defaultTemplates) {
String viewDefaultTemplateUuid = defaultTemplates.getApplicationsUuid();
if (viewDefaultTemplateUuid != null && viewDefaultTemplateUuid.equals(template.getUuid())) {
defaultTemplates.setApplicationsUuid(null);
dbClient.organizationDao().setDefaultTemplates(dbSession, template.getOrganizationUuid(), defaultTemplates);
}
}
|
[
"private",
"void",
"updateViewDefaultTemplateWhenGovernanceIsNotInstalled",
"(",
"DbSession",
"dbSession",
",",
"PermissionTemplateDto",
"template",
",",
"DefaultTemplates",
"defaultTemplates",
")",
"{",
"String",
"viewDefaultTemplateUuid",
"=",
"defaultTemplates",
".",
"getApplicationsUuid",
"(",
")",
";",
"if",
"(",
"viewDefaultTemplateUuid",
"!=",
"null",
"&&",
"viewDefaultTemplateUuid",
".",
"equals",
"(",
"template",
".",
"getUuid",
"(",
")",
")",
")",
"{",
"defaultTemplates",
".",
"setApplicationsUuid",
"(",
"null",
")",
";",
"dbClient",
".",
"organizationDao",
"(",
")",
".",
"setDefaultTemplates",
"(",
"dbSession",
",",
"template",
".",
"getOrganizationUuid",
"(",
")",
",",
"defaultTemplates",
")",
";",
"}",
"}"
] |
The default template for view can be removed when Governance is not installed. To avoid keeping a reference
to a non existing template, we update the default templates.
|
[
"The",
"default",
"template",
"for",
"view",
"can",
"be",
"removed",
"when",
"Governance",
"is",
"not",
"installed",
".",
"To",
"avoid",
"keeping",
"a",
"reference",
"to",
"a",
"non",
"existing",
"template",
"we",
"update",
"the",
"default",
"templates",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/DeleteTemplateAction.java#L103-L109
|
16,351
|
SonarSource/sonarqube
|
server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
|
ClusterSettings.shouldStartHazelcast
|
public static boolean shouldStartHazelcast(AppSettings appSettings) {
return isClusterEnabled(appSettings.getProps()) && toNodeType(appSettings.getProps()).equals(NodeType.APPLICATION);
}
|
java
|
public static boolean shouldStartHazelcast(AppSettings appSettings) {
return isClusterEnabled(appSettings.getProps()) && toNodeType(appSettings.getProps()).equals(NodeType.APPLICATION);
}
|
[
"public",
"static",
"boolean",
"shouldStartHazelcast",
"(",
"AppSettings",
"appSettings",
")",
"{",
"return",
"isClusterEnabled",
"(",
"appSettings",
".",
"getProps",
"(",
")",
")",
"&&",
"toNodeType",
"(",
"appSettings",
".",
"getProps",
"(",
")",
")",
".",
"equals",
"(",
"NodeType",
".",
"APPLICATION",
")",
";",
"}"
] |
Hazelcast must be started when cluster is activated on all nodes but search ones
|
[
"Hazelcast",
"must",
"be",
"started",
"when",
"cluster",
"is",
"activated",
"on",
"all",
"nodes",
"but",
"search",
"ones"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java#L159-L161
|
16,352
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
|
ComponentUpdateDto.copyFrom
|
public static ComponentUpdateDto copyFrom(ComponentDto from) {
return new ComponentUpdateDto()
.setUuid(from.uuid())
.setBChanged(false)
.setBKey(from.getDbKey())
.setBCopyComponentUuid(from.getCopyResourceUuid())
.setBDescription(from.description())
.setBEnabled(from.isEnabled())
.setBUuidPath(from.getUuidPath())
.setBLanguage(from.language())
.setBLongName(from.longName())
.setBModuleUuid(from.moduleUuid())
.setBModuleUuidPath(from.moduleUuidPath())
.setBName(from.name())
.setBPath(from.path())
// We don't have a b_scope. The applyBChangesForRootComponentUuid query is using a case ... when to infer scope from the qualifier
.setBQualifier(from.qualifier());
}
|
java
|
public static ComponentUpdateDto copyFrom(ComponentDto from) {
return new ComponentUpdateDto()
.setUuid(from.uuid())
.setBChanged(false)
.setBKey(from.getDbKey())
.setBCopyComponentUuid(from.getCopyResourceUuid())
.setBDescription(from.description())
.setBEnabled(from.isEnabled())
.setBUuidPath(from.getUuidPath())
.setBLanguage(from.language())
.setBLongName(from.longName())
.setBModuleUuid(from.moduleUuid())
.setBModuleUuidPath(from.moduleUuidPath())
.setBName(from.name())
.setBPath(from.path())
// We don't have a b_scope. The applyBChangesForRootComponentUuid query is using a case ... when to infer scope from the qualifier
.setBQualifier(from.qualifier());
}
|
[
"public",
"static",
"ComponentUpdateDto",
"copyFrom",
"(",
"ComponentDto",
"from",
")",
"{",
"return",
"new",
"ComponentUpdateDto",
"(",
")",
".",
"setUuid",
"(",
"from",
".",
"uuid",
"(",
")",
")",
".",
"setBChanged",
"(",
"false",
")",
".",
"setBKey",
"(",
"from",
".",
"getDbKey",
"(",
")",
")",
".",
"setBCopyComponentUuid",
"(",
"from",
".",
"getCopyResourceUuid",
"(",
")",
")",
".",
"setBDescription",
"(",
"from",
".",
"description",
"(",
")",
")",
".",
"setBEnabled",
"(",
"from",
".",
"isEnabled",
"(",
")",
")",
".",
"setBUuidPath",
"(",
"from",
".",
"getUuidPath",
"(",
")",
")",
".",
"setBLanguage",
"(",
"from",
".",
"language",
"(",
")",
")",
".",
"setBLongName",
"(",
"from",
".",
"longName",
"(",
")",
")",
".",
"setBModuleUuid",
"(",
"from",
".",
"moduleUuid",
"(",
")",
")",
".",
"setBModuleUuidPath",
"(",
"from",
".",
"moduleUuidPath",
"(",
")",
")",
".",
"setBName",
"(",
"from",
".",
"name",
"(",
")",
")",
".",
"setBPath",
"(",
"from",
".",
"path",
"(",
")",
")",
"// We don't have a b_scope. The applyBChangesForRootComponentUuid query is using a case ... when to infer scope from the qualifier",
".",
"setBQualifier",
"(",
"from",
".",
"qualifier",
"(",
")",
")",
";",
"}"
] |
Copy the A-fields to B-fields. The field bChanged is kept to false.
|
[
"Copy",
"the",
"A",
"-",
"fields",
"to",
"B",
"-",
"fields",
".",
"The",
"field",
"bChanged",
"is",
"kept",
"to",
"false",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java#L187-L204
|
16,353
|
SonarSource/sonarqube
|
server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
|
HazelcastMemberBuilder.setMembers
|
public HazelcastMemberBuilder setMembers(Collection<String> c) {
this.members = c.stream()
.map(host -> host.contains(":") ? host : format("%s:%s", host, CLUSTER_NODE_HZ_PORT.getDefaultValue()))
.collect(Collectors.toList());
return this;
}
|
java
|
public HazelcastMemberBuilder setMembers(Collection<String> c) {
this.members = c.stream()
.map(host -> host.contains(":") ? host : format("%s:%s", host, CLUSTER_NODE_HZ_PORT.getDefaultValue()))
.collect(Collectors.toList());
return this;
}
|
[
"public",
"HazelcastMemberBuilder",
"setMembers",
"(",
"Collection",
"<",
"String",
">",
"c",
")",
"{",
"this",
".",
"members",
"=",
"c",
".",
"stream",
"(",
")",
".",
"map",
"(",
"host",
"->",
"host",
".",
"contains",
"(",
"\":\"",
")",
"?",
"host",
":",
"format",
"(",
"\"%s:%s\"",
",",
"host",
",",
"CLUSTER_NODE_HZ_PORT",
".",
"getDefaultValue",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Adds references to cluster members. If port is missing, then default
port is automatically added.
|
[
"Adds",
"references",
"to",
"cluster",
"members",
".",
"If",
"port",
"is",
"missing",
"then",
"default",
"port",
"is",
"automatically",
"added",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java#L80-L85
|
16,354
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java
|
ManifestUtils.getPropertyValues
|
public static List<String> getPropertyValues(ClassLoader classloader, String key) {
List<String> values = new ArrayList<>();
try {
Enumeration<URL> resources = classloader.getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attributes = manifest.getMainAttributes();
String value = attributes.getValue(key);
if (value != null) {
values.add(value);
}
}
} catch (IOException e) {
throw new SonarException("Fail to load manifests from classloader: " + classloader, e);
}
return values;
}
|
java
|
public static List<String> getPropertyValues(ClassLoader classloader, String key) {
List<String> values = new ArrayList<>();
try {
Enumeration<URL> resources = classloader.getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attributes = manifest.getMainAttributes();
String value = attributes.getValue(key);
if (value != null) {
values.add(value);
}
}
} catch (IOException e) {
throw new SonarException("Fail to load manifests from classloader: " + classloader, e);
}
return values;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getPropertyValues",
"(",
"ClassLoader",
"classloader",
",",
"String",
"key",
")",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"Enumeration",
"<",
"URL",
">",
"resources",
"=",
"classloader",
".",
"getResources",
"(",
"\"META-INF/MANIFEST.MF\"",
")",
";",
"while",
"(",
"resources",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Manifest",
"manifest",
"=",
"new",
"Manifest",
"(",
"resources",
".",
"nextElement",
"(",
")",
".",
"openStream",
"(",
")",
")",
";",
"Attributes",
"attributes",
"=",
"manifest",
".",
"getMainAttributes",
"(",
")",
";",
"String",
"value",
"=",
"attributes",
".",
"getValue",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"values",
".",
"add",
"(",
"value",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SonarException",
"(",
"\"Fail to load manifests from classloader: \"",
"+",
"classloader",
",",
"e",
")",
";",
"}",
"return",
"values",
";",
"}"
] |
Search for a property in all the manifests found in the classloader
@return the values, an empty list if the property is not found.
|
[
"Search",
"for",
"a",
"property",
"in",
"all",
"the",
"manifests",
"found",
"in",
"the",
"classloader"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java#L43-L59
|
16,355
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/property/InternalPropertiesDao.java
|
InternalPropertiesDao.saveAsEmpty
|
public void saveAsEmpty(DbSession dbSession, String key) {
checkKey(key);
InternalPropertiesMapper mapper = getMapper(dbSession);
mapper.deleteByKey(key);
mapper.insertAsEmpty(key, system2.now());
}
|
java
|
public void saveAsEmpty(DbSession dbSession, String key) {
checkKey(key);
InternalPropertiesMapper mapper = getMapper(dbSession);
mapper.deleteByKey(key);
mapper.insertAsEmpty(key, system2.now());
}
|
[
"public",
"void",
"saveAsEmpty",
"(",
"DbSession",
"dbSession",
",",
"String",
"key",
")",
"{",
"checkKey",
"(",
"key",
")",
";",
"InternalPropertiesMapper",
"mapper",
"=",
"getMapper",
"(",
"dbSession",
")",
";",
"mapper",
".",
"deleteByKey",
"(",
"key",
")",
";",
"mapper",
".",
"insertAsEmpty",
"(",
"key",
",",
"system2",
".",
"now",
"(",
")",
")",
";",
"}"
] |
Save a property which value is empty.
|
[
"Save",
"a",
"property",
"which",
"value",
"is",
"empty",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/property/InternalPropertiesDao.java#L84-L90
|
16,356
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/property/InternalPropertiesDao.java
|
InternalPropertiesDao.selectByKey
|
public Optional<String> selectByKey(DbSession dbSession, String key) {
checkKey(key);
InternalPropertiesMapper mapper = getMapper(dbSession);
InternalPropertyDto res = enforceSingleElement(key, mapper.selectAsText(singletonList(key)));
if (res == null) {
return Optional.empty();
}
if (res.isEmpty()) {
return OPTIONAL_OF_EMPTY_STRING;
}
if (res.getValue() != null) {
return Optional.of(res.getValue());
}
res = enforceSingleElement(key, mapper.selectAsClob(singletonList(key)));
if (res == null) {
Loggers.get(InternalPropertiesDao.class)
.debug("Internal property {} has been found in db but has neither text value nor is empty. " +
"Still it couldn't be retrieved with clob value. Ignoring the property.", key);
return Optional.empty();
}
return Optional.of(res.getValue());
}
|
java
|
public Optional<String> selectByKey(DbSession dbSession, String key) {
checkKey(key);
InternalPropertiesMapper mapper = getMapper(dbSession);
InternalPropertyDto res = enforceSingleElement(key, mapper.selectAsText(singletonList(key)));
if (res == null) {
return Optional.empty();
}
if (res.isEmpty()) {
return OPTIONAL_OF_EMPTY_STRING;
}
if (res.getValue() != null) {
return Optional.of(res.getValue());
}
res = enforceSingleElement(key, mapper.selectAsClob(singletonList(key)));
if (res == null) {
Loggers.get(InternalPropertiesDao.class)
.debug("Internal property {} has been found in db but has neither text value nor is empty. " +
"Still it couldn't be retrieved with clob value. Ignoring the property.", key);
return Optional.empty();
}
return Optional.of(res.getValue());
}
|
[
"public",
"Optional",
"<",
"String",
">",
"selectByKey",
"(",
"DbSession",
"dbSession",
",",
"String",
"key",
")",
"{",
"checkKey",
"(",
"key",
")",
";",
"InternalPropertiesMapper",
"mapper",
"=",
"getMapper",
"(",
"dbSession",
")",
";",
"InternalPropertyDto",
"res",
"=",
"enforceSingleElement",
"(",
"key",
",",
"mapper",
".",
"selectAsText",
"(",
"singletonList",
"(",
"key",
")",
")",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"if",
"(",
"res",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"OPTIONAL_OF_EMPTY_STRING",
";",
"}",
"if",
"(",
"res",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"res",
".",
"getValue",
"(",
")",
")",
";",
"}",
"res",
"=",
"enforceSingleElement",
"(",
"key",
",",
"mapper",
".",
"selectAsClob",
"(",
"singletonList",
"(",
"key",
")",
")",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"Loggers",
".",
"get",
"(",
"InternalPropertiesDao",
".",
"class",
")",
".",
"debug",
"(",
"\"Internal property {} has been found in db but has neither text value nor is empty. \"",
"+",
"\"Still it couldn't be retrieved with clob value. Ignoring the property.\"",
",",
"key",
")",
";",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"return",
"Optional",
".",
"of",
"(",
"res",
".",
"getValue",
"(",
")",
")",
";",
"}"
] |
No streaming of value
|
[
"No",
"streaming",
"of",
"value"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/property/InternalPropertiesDao.java#L143-L165
|
16,357
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
|
UserDao.selectByIds
|
public List<UserDto> selectByIds(DbSession session, Collection<Integer> ids) {
return executeLargeInputs(ids, mapper(session)::selectByIds);
}
|
java
|
public List<UserDto> selectByIds(DbSession session, Collection<Integer> ids) {
return executeLargeInputs(ids, mapper(session)::selectByIds);
}
|
[
"public",
"List",
"<",
"UserDto",
">",
"selectByIds",
"(",
"DbSession",
"session",
",",
"Collection",
"<",
"Integer",
">",
"ids",
")",
"{",
"return",
"executeLargeInputs",
"(",
"ids",
",",
"mapper",
"(",
"session",
")",
"::",
"selectByIds",
")",
";",
"}"
] |
Select users by ids, including disabled users. An empty list is returned
if list of ids is empty, without any db round trips.
Used by the Governance plugin
|
[
"Select",
"users",
"by",
"ids",
"including",
"disabled",
"users",
".",
"An",
"empty",
"list",
"is",
"returned",
"if",
"list",
"of",
"ids",
"is",
"empty",
"without",
"any",
"db",
"round",
"trips",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java#L71-L73
|
16,358
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
|
UserDao.selectByLogins
|
public List<UserDto> selectByLogins(DbSession session, Collection<String> logins) {
return executeLargeInputs(logins, mapper(session)::selectByLogins);
}
|
java
|
public List<UserDto> selectByLogins(DbSession session, Collection<String> logins) {
return executeLargeInputs(logins, mapper(session)::selectByLogins);
}
|
[
"public",
"List",
"<",
"UserDto",
">",
"selectByLogins",
"(",
"DbSession",
"session",
",",
"Collection",
"<",
"String",
">",
"logins",
")",
"{",
"return",
"executeLargeInputs",
"(",
"logins",
",",
"mapper",
"(",
"session",
")",
"::",
"selectByLogins",
")",
";",
"}"
] |
Select users by logins, including disabled users. An empty list is returned
if list of logins is empty, without any db round trips.
|
[
"Select",
"users",
"by",
"logins",
"including",
"disabled",
"users",
".",
"An",
"empty",
"list",
"is",
"returned",
"if",
"list",
"of",
"logins",
"is",
"empty",
"without",
"any",
"db",
"round",
"trips",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java#L85-L87
|
16,359
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
|
UserDao.selectByUuids
|
public List<UserDto> selectByUuids(DbSession session, Collection<String> uuids) {
return executeLargeInputs(uuids, mapper(session)::selectByUuids);
}
|
java
|
public List<UserDto> selectByUuids(DbSession session, Collection<String> uuids) {
return executeLargeInputs(uuids, mapper(session)::selectByUuids);
}
|
[
"public",
"List",
"<",
"UserDto",
">",
"selectByUuids",
"(",
"DbSession",
"session",
",",
"Collection",
"<",
"String",
">",
"uuids",
")",
"{",
"return",
"executeLargeInputs",
"(",
"uuids",
",",
"mapper",
"(",
"session",
")",
"::",
"selectByUuids",
")",
";",
"}"
] |
Select users by uuids, including disabled users. An empty list is returned
if list of uuids is empty, without any db round trips.
|
[
"Select",
"users",
"by",
"uuids",
"including",
"disabled",
"users",
".",
"An",
"empty",
"list",
"is",
"returned",
"if",
"list",
"of",
"uuids",
"is",
"empty",
"without",
"any",
"db",
"round",
"trips",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java#L93-L95
|
16,360
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
|
UserDao.selectByEmail
|
public List<UserDto> selectByEmail(DbSession dbSession, String emailCaseInsensitive) {
return mapper(dbSession).selectByEmail(emailCaseInsensitive.toLowerCase(ENGLISH));
}
|
java
|
public List<UserDto> selectByEmail(DbSession dbSession, String emailCaseInsensitive) {
return mapper(dbSession).selectByEmail(emailCaseInsensitive.toLowerCase(ENGLISH));
}
|
[
"public",
"List",
"<",
"UserDto",
">",
"selectByEmail",
"(",
"DbSession",
"dbSession",
",",
"String",
"emailCaseInsensitive",
")",
"{",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectByEmail",
"(",
"emailCaseInsensitive",
".",
"toLowerCase",
"(",
"ENGLISH",
")",
")",
";",
"}"
] |
Search for an active user with the given emailCaseInsensitive exits in database
Select is case insensitive. Result for searching 'mail@emailCaseInsensitive.com' or 'Mail@Email.com' is the same
|
[
"Search",
"for",
"an",
"active",
"user",
"with",
"the",
"given",
"emailCaseInsensitive",
"exits",
"in",
"database"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java#L167-L169
|
16,361
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/issue/NoSonarFilter.java
|
NoSonarFilter.noSonarInFile
|
public NoSonarFilter noSonarInFile(InputFile inputFile, Set<Integer> noSonarLines) {
((DefaultInputFile) inputFile).noSonarAt(noSonarLines);
return this;
}
|
java
|
public NoSonarFilter noSonarInFile(InputFile inputFile, Set<Integer> noSonarLines) {
((DefaultInputFile) inputFile).noSonarAt(noSonarLines);
return this;
}
|
[
"public",
"NoSonarFilter",
"noSonarInFile",
"(",
"InputFile",
"inputFile",
",",
"Set",
"<",
"Integer",
">",
"noSonarLines",
")",
"{",
"(",
"(",
"DefaultInputFile",
")",
"inputFile",
")",
".",
"noSonarAt",
"(",
"noSonarLines",
")",
";",
"return",
"this",
";",
"}"
] |
Register lines in a file that contains the NOSONAR flag.
@param inputFile
@param noSonarLines Line number starts at 1 in a file
@since 5.0
@since 7.6 the method can be called multiple times by different sensors, and NOSONAR lines are merged
|
[
"Register",
"lines",
"in",
"a",
"file",
"that",
"contains",
"the",
"NOSONAR",
"flag",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/issue/NoSonarFilter.java#L47-L50
|
16,362
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
|
IssueIndex.configureRouting
|
private static void configureRouting(IssueQuery query, SearchOptions options, SearchRequestBuilder requestBuilder) {
Collection<String> uuids = query.projectUuids();
if (!uuids.isEmpty() && options.getFacets().isEmpty()) {
requestBuilder.setRouting(uuids.stream().map(AuthorizationDoc::idOf).toArray(String[]::new));
}
}
|
java
|
private static void configureRouting(IssueQuery query, SearchOptions options, SearchRequestBuilder requestBuilder) {
Collection<String> uuids = query.projectUuids();
if (!uuids.isEmpty() && options.getFacets().isEmpty()) {
requestBuilder.setRouting(uuids.stream().map(AuthorizationDoc::idOf).toArray(String[]::new));
}
}
|
[
"private",
"static",
"void",
"configureRouting",
"(",
"IssueQuery",
"query",
",",
"SearchOptions",
"options",
",",
"SearchRequestBuilder",
"requestBuilder",
")",
"{",
"Collection",
"<",
"String",
">",
"uuids",
"=",
"query",
".",
"projectUuids",
"(",
")",
";",
"if",
"(",
"!",
"uuids",
".",
"isEmpty",
"(",
")",
"&&",
"options",
".",
"getFacets",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"requestBuilder",
".",
"setRouting",
"(",
"uuids",
".",
"stream",
"(",
")",
".",
"map",
"(",
"AuthorizationDoc",
"::",
"idOf",
")",
".",
"toArray",
"(",
"String",
"[",
"]",
"::",
"new",
")",
")",
";",
"}",
"}"
] |
Optimization - do not send ES request to all shards when scope is restricted
to a set of projects. Because project UUID is used for routing, the request
can be sent to only the shards containing the specified projects.
Note that sticky facets may involve all projects, so this optimization must be
disabled when facets are enabled.
|
[
"Optimization",
"-",
"do",
"not",
"send",
"ES",
"request",
"to",
"all",
"shards",
"when",
"scope",
"is",
"restricted",
"to",
"a",
"set",
"of",
"projects",
".",
"Because",
"project",
"UUID",
"is",
"used",
"for",
"routing",
"the",
"request",
"can",
"be",
"sent",
"to",
"only",
"the",
"shards",
"containing",
"the",
"specified",
"projects",
".",
"Note",
"that",
"sticky",
"facets",
"may",
"involve",
"all",
"projects",
"so",
"this",
"optimization",
"must",
"be",
"disabled",
"when",
"facets",
"are",
"enabled",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java#L319-L324
|
16,363
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
|
ProjectDefinition.setProperties
|
@Deprecated
public ProjectDefinition setProperties(Properties properties) {
for (Entry<Object, Object> entry : properties.entrySet()) {
this.properties.put(entry.getKey().toString(), entry.getValue().toString());
}
return this;
}
|
java
|
@Deprecated
public ProjectDefinition setProperties(Properties properties) {
for (Entry<Object, Object> entry : properties.entrySet()) {
this.properties.put(entry.getKey().toString(), entry.getValue().toString());
}
return this;
}
|
[
"@",
"Deprecated",
"public",
"ProjectDefinition",
"setProperties",
"(",
"Properties",
"properties",
")",
"{",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"this",
".",
"properties",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Copies specified properties into this object.
@since 2.12
@deprecated since 5.0 use {@link #setProperties(Map)}
|
[
"Copies",
"specified",
"properties",
"into",
"this",
"object",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java#L127-L133
|
16,364
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java
|
OrganizationUpdaterImpl.insertOwnersGroup
|
private GroupDto insertOwnersGroup(DbSession dbSession, OrganizationDto organization) {
GroupDto group = dbClient.groupDao().insert(dbSession, new GroupDto()
.setOrganizationUuid(organization.getUuid())
.setName(OWNERS_GROUP_NAME)
.setDescription(format(OWNERS_GROUP_DESCRIPTION_PATTERN, organization.getName())));
permissionService.getAllOrganizationPermissions().forEach(p -> addPermissionToGroup(dbSession, group, p));
return group;
}
|
java
|
private GroupDto insertOwnersGroup(DbSession dbSession, OrganizationDto organization) {
GroupDto group = dbClient.groupDao().insert(dbSession, new GroupDto()
.setOrganizationUuid(organization.getUuid())
.setName(OWNERS_GROUP_NAME)
.setDescription(format(OWNERS_GROUP_DESCRIPTION_PATTERN, organization.getName())));
permissionService.getAllOrganizationPermissions().forEach(p -> addPermissionToGroup(dbSession, group, p));
return group;
}
|
[
"private",
"GroupDto",
"insertOwnersGroup",
"(",
"DbSession",
"dbSession",
",",
"OrganizationDto",
"organization",
")",
"{",
"GroupDto",
"group",
"=",
"dbClient",
".",
"groupDao",
"(",
")",
".",
"insert",
"(",
"dbSession",
",",
"new",
"GroupDto",
"(",
")",
".",
"setOrganizationUuid",
"(",
"organization",
".",
"getUuid",
"(",
")",
")",
".",
"setName",
"(",
"OWNERS_GROUP_NAME",
")",
".",
"setDescription",
"(",
"format",
"(",
"OWNERS_GROUP_DESCRIPTION_PATTERN",
",",
"organization",
".",
"getName",
"(",
")",
")",
")",
")",
";",
"permissionService",
".",
"getAllOrganizationPermissions",
"(",
")",
".",
"forEach",
"(",
"p",
"->",
"addPermissionToGroup",
"(",
"dbSession",
",",
"group",
",",
"p",
")",
")",
";",
"return",
"group",
";",
"}"
] |
Owners group has an hard coded name, a description based on the organization's name and has all global permissions.
|
[
"Owners",
"group",
"has",
"an",
"hard",
"coded",
"name",
"a",
"description",
"based",
"on",
"the",
"organization",
"s",
"name",
"and",
"has",
"all",
"global",
"permissions",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java#L322-L329
|
16,365
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
|
PluginDownloader.start
|
@Override
public void start() {
try {
forceMkdir(downloadDir);
for (File tempFile : listTempFile(this.downloadDir)) {
deleteQuietly(tempFile);
}
} catch (IOException e) {
throw new IllegalStateException("Fail to create the directory: " + downloadDir, e);
}
}
|
java
|
@Override
public void start() {
try {
forceMkdir(downloadDir);
for (File tempFile : listTempFile(this.downloadDir)) {
deleteQuietly(tempFile);
}
} catch (IOException e) {
throw new IllegalStateException("Fail to create the directory: " + downloadDir, e);
}
}
|
[
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"try",
"{",
"forceMkdir",
"(",
"downloadDir",
")",
";",
"for",
"(",
"File",
"tempFile",
":",
"listTempFile",
"(",
"this",
".",
"downloadDir",
")",
")",
"{",
"deleteQuietly",
"(",
"tempFile",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Fail to create the directory: \"",
"+",
"downloadDir",
",",
"e",
")",
";",
"}",
"}"
] |
Deletes the temporary files remaining from previous downloads
|
[
"Deletes",
"the",
"temporary",
"files",
"remaining",
"from",
"previous",
"downloads"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java#L74-L84
|
16,366
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
|
Settings.getDefinition
|
public Optional<PropertyDefinition> getDefinition(String key) {
return Optional.ofNullable(definitions.get(key));
}
|
java
|
public Optional<PropertyDefinition> getDefinition(String key) {
return Optional.ofNullable(definitions.get(key));
}
|
[
"public",
"Optional",
"<",
"PropertyDefinition",
">",
"getDefinition",
"(",
"String",
"key",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"definitions",
".",
"get",
"(",
"key",
")",
")",
";",
"}"
] |
The definition related to the specified property. It may
be empty.
@since 6.1
|
[
"The",
"definition",
"related",
"to",
"the",
"specified",
"property",
".",
"It",
"may",
"be",
"empty",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java#L111-L113
|
16,367
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
|
Settings.getStringLines
|
public String[] getStringLines(String key) {
String value = getString(key);
if (StringUtils.isEmpty(value)) {
return new String[0];
}
return value.split("\r?\n|\r", -1);
}
|
java
|
public String[] getStringLines(String key) {
String value = getString(key);
if (StringUtils.isEmpty(value)) {
return new String[0];
}
return value.split("\r?\n|\r", -1);
}
|
[
"public",
"String",
"[",
"]",
"getStringLines",
"(",
"String",
"key",
")",
"{",
"String",
"value",
"=",
"getString",
"(",
"key",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"}",
"return",
"value",
".",
"split",
"(",
"\"\\r?\\n|\\r\"",
",",
"-",
"1",
")",
";",
"}"
] |
Value is split by carriage returns.
@return non-null array of lines. The line termination characters are excluded.
@since 3.2
|
[
"Value",
"is",
"split",
"by",
"carriage",
"returns",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java#L297-L303
|
16,368
|
SonarSource/sonarqube
|
sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
|
Settings.getStringArrayBySeparator
|
public String[] getStringArrayBySeparator(String key, String separator) {
String value = getString(key);
if (value != null) {
String[] strings = StringUtils.splitByWholeSeparator(value, separator);
String[] result = new String[strings.length];
for (int index = 0; index < strings.length; index++) {
result[index] = trim(strings[index]);
}
return result;
}
return ArrayUtils.EMPTY_STRING_ARRAY;
}
|
java
|
public String[] getStringArrayBySeparator(String key, String separator) {
String value = getString(key);
if (value != null) {
String[] strings = StringUtils.splitByWholeSeparator(value, separator);
String[] result = new String[strings.length];
for (int index = 0; index < strings.length; index++) {
result[index] = trim(strings[index]);
}
return result;
}
return ArrayUtils.EMPTY_STRING_ARRAY;
}
|
[
"public",
"String",
"[",
"]",
"getStringArrayBySeparator",
"(",
"String",
"key",
",",
"String",
"separator",
")",
"{",
"String",
"value",
"=",
"getString",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"strings",
"=",
"StringUtils",
".",
"splitByWholeSeparator",
"(",
"value",
",",
"separator",
")",
";",
"String",
"[",
"]",
"result",
"=",
"new",
"String",
"[",
"strings",
".",
"length",
"]",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"strings",
".",
"length",
";",
"index",
"++",
")",
"{",
"result",
"[",
"index",
"]",
"=",
"trim",
"(",
"strings",
"[",
"index",
"]",
")",
";",
"}",
"return",
"result",
";",
"}",
"return",
"ArrayUtils",
".",
"EMPTY_STRING_ARRAY",
";",
"}"
] |
Value is split and trimmed.
|
[
"Value",
"is",
"split",
"and",
"trimmed",
"."
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java#L308-L319
|
16,369
|
SonarSource/sonarqube
|
server/sonar-server-common/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java
|
DefaultNotificationManager.getFromQueue
|
public <T extends Notification> T getFromQueue() {
int batchSize = 1;
List<NotificationQueueDto> notificationDtos = dbClient.notificationQueueDao().selectOldest(batchSize);
if (notificationDtos.isEmpty()) {
return null;
}
dbClient.notificationQueueDao().delete(notificationDtos);
return convertToNotification(notificationDtos);
}
|
java
|
public <T extends Notification> T getFromQueue() {
int batchSize = 1;
List<NotificationQueueDto> notificationDtos = dbClient.notificationQueueDao().selectOldest(batchSize);
if (notificationDtos.isEmpty()) {
return null;
}
dbClient.notificationQueueDao().delete(notificationDtos);
return convertToNotification(notificationDtos);
}
|
[
"public",
"<",
"T",
"extends",
"Notification",
">",
"T",
"getFromQueue",
"(",
")",
"{",
"int",
"batchSize",
"=",
"1",
";",
"List",
"<",
"NotificationQueueDto",
">",
"notificationDtos",
"=",
"dbClient",
".",
"notificationQueueDao",
"(",
")",
".",
"selectOldest",
"(",
"batchSize",
")",
";",
"if",
"(",
"notificationDtos",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"dbClient",
".",
"notificationQueueDao",
"(",
")",
".",
"delete",
"(",
"notificationDtos",
")",
";",
"return",
"convertToNotification",
"(",
"notificationDtos",
")",
";",
"}"
] |
Give the notification queue so that it can be processed
|
[
"Give",
"the",
"notification",
"queue",
"so",
"that",
"it",
"can",
"be",
"processed"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server-common/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java#L85-L94
|
16,370
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java
|
CeActivityDao.selectByQuery
|
public List<CeActivityDto> selectByQuery(DbSession dbSession, CeTaskQuery query, Pagination pagination) {
if (query.isShortCircuitedByMainComponentUuids()) {
return Collections.emptyList();
}
return mapper(dbSession).selectByQuery(query, pagination);
}
|
java
|
public List<CeActivityDto> selectByQuery(DbSession dbSession, CeTaskQuery query, Pagination pagination) {
if (query.isShortCircuitedByMainComponentUuids()) {
return Collections.emptyList();
}
return mapper(dbSession).selectByQuery(query, pagination);
}
|
[
"public",
"List",
"<",
"CeActivityDto",
">",
"selectByQuery",
"(",
"DbSession",
"dbSession",
",",
"CeTaskQuery",
"query",
",",
"Pagination",
"pagination",
")",
"{",
"if",
"(",
"query",
".",
"isShortCircuitedByMainComponentUuids",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"mapper",
"(",
"dbSession",
")",
".",
"selectByQuery",
"(",
"query",
",",
"pagination",
")",
";",
"}"
] |
Ordered by id desc -> newest to oldest
|
[
"Ordered",
"by",
"id",
"desc",
"-",
">",
"newest",
"to",
"oldest"
] |
2fffa4c2f79ae3714844d7742796e82822b6a98a
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java#L71-L77
|
16,371
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/process/ProcessDefinitionImpl.java
|
ProcessDefinitionImpl.createProcessInstanceForInitial
|
public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
ensureNotNull("Cannot start process instance, initial activity where the process instance should start is null", "initial", initial);
PvmExecutionImpl processInstance = newProcessInstance();
processInstance.setProcessDefinition(this);
processInstance.setProcessInstance(processInstance);
// always set the process instance to the initial activity, no matter how deeply it is nested;
// this is required for firing history events (cf start activity) and persisting the initial activity
// on async start
processInstance.setActivity(initial);
return processInstance;
}
|
java
|
public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
ensureNotNull("Cannot start process instance, initial activity where the process instance should start is null", "initial", initial);
PvmExecutionImpl processInstance = newProcessInstance();
processInstance.setProcessDefinition(this);
processInstance.setProcessInstance(processInstance);
// always set the process instance to the initial activity, no matter how deeply it is nested;
// this is required for firing history events (cf start activity) and persisting the initial activity
// on async start
processInstance.setActivity(initial);
return processInstance;
}
|
[
"public",
"PvmProcessInstance",
"createProcessInstanceForInitial",
"(",
"ActivityImpl",
"initial",
")",
"{",
"ensureNotNull",
"(",
"\"Cannot start process instance, initial activity where the process instance should start is null\"",
",",
"\"initial\"",
",",
"initial",
")",
";",
"PvmExecutionImpl",
"processInstance",
"=",
"newProcessInstance",
"(",
")",
";",
"processInstance",
".",
"setProcessDefinition",
"(",
"this",
")",
";",
"processInstance",
".",
"setProcessInstance",
"(",
"processInstance",
")",
";",
"// always set the process instance to the initial activity, no matter how deeply it is nested;",
"// this is required for firing history events (cf start activity) and persisting the initial activity",
"// on async start",
"processInstance",
".",
"setActivity",
"(",
"initial",
")",
";",
"return",
"processInstance",
";",
"}"
] |
creates a process instance using the provided activity as initial
|
[
"creates",
"a",
"process",
"instance",
"using",
"the",
"provided",
"activity",
"as",
"initial"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/process/ProcessDefinitionImpl.java#L90-L105
|
16,372
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/HalRelation.java
|
HalRelation.build
|
public static HalRelation build(String relName, Class<?> resourceType, UriBuilder urlTemplate) {
HalRelation relation = new HalRelation();
relation.relName = relName;
relation.uriTemplate = urlTemplate;
relation.resourceType = resourceType;
return relation;
}
|
java
|
public static HalRelation build(String relName, Class<?> resourceType, UriBuilder urlTemplate) {
HalRelation relation = new HalRelation();
relation.relName = relName;
relation.uriTemplate = urlTemplate;
relation.resourceType = resourceType;
return relation;
}
|
[
"public",
"static",
"HalRelation",
"build",
"(",
"String",
"relName",
",",
"Class",
"<",
"?",
">",
"resourceType",
",",
"UriBuilder",
"urlTemplate",
")",
"{",
"HalRelation",
"relation",
"=",
"new",
"HalRelation",
"(",
")",
";",
"relation",
".",
"relName",
"=",
"relName",
";",
"relation",
".",
"uriTemplate",
"=",
"urlTemplate",
";",
"relation",
".",
"resourceType",
"=",
"resourceType",
";",
"return",
"relation",
";",
"}"
] |
Build a relation to a resource.
@param relName the name of the relation.
@param resourceType the type of the resource
@return the relation
|
[
"Build",
"a",
"relation",
"to",
"a",
"resource",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/HalRelation.java#L43-L49
|
16,373
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/cmd/StartProcessInstanceAtActivitiesCmd.java
|
StartProcessInstanceAtActivitiesCmd.determineFirstActivity
|
protected ActivityImpl determineFirstActivity(ProcessDefinitionImpl processDefinition,
ProcessInstanceModificationBuilderImpl modificationBuilder) {
AbstractProcessInstanceModificationCommand firstInstruction = modificationBuilder.getModificationOperations().get(0);
if (firstInstruction instanceof AbstractInstantiationCmd) {
AbstractInstantiationCmd instantiationInstruction = (AbstractInstantiationCmd) firstInstruction;
CoreModelElement targetElement = instantiationInstruction.getTargetElement(processDefinition);
ensureNotNull(NotValidException.class,
"Element '" + instantiationInstruction.getTargetElementId() + "' does not exist in process " + processDefinition.getId(),
"targetElement",
targetElement);
if (targetElement instanceof ActivityImpl) {
return (ActivityImpl) targetElement;
}
else if (targetElement instanceof TransitionImpl) {
return (ActivityImpl) ((TransitionImpl) targetElement).getDestination();
}
}
return null;
}
|
java
|
protected ActivityImpl determineFirstActivity(ProcessDefinitionImpl processDefinition,
ProcessInstanceModificationBuilderImpl modificationBuilder) {
AbstractProcessInstanceModificationCommand firstInstruction = modificationBuilder.getModificationOperations().get(0);
if (firstInstruction instanceof AbstractInstantiationCmd) {
AbstractInstantiationCmd instantiationInstruction = (AbstractInstantiationCmd) firstInstruction;
CoreModelElement targetElement = instantiationInstruction.getTargetElement(processDefinition);
ensureNotNull(NotValidException.class,
"Element '" + instantiationInstruction.getTargetElementId() + "' does not exist in process " + processDefinition.getId(),
"targetElement",
targetElement);
if (targetElement instanceof ActivityImpl) {
return (ActivityImpl) targetElement;
}
else if (targetElement instanceof TransitionImpl) {
return (ActivityImpl) ((TransitionImpl) targetElement).getDestination();
}
}
return null;
}
|
[
"protected",
"ActivityImpl",
"determineFirstActivity",
"(",
"ProcessDefinitionImpl",
"processDefinition",
",",
"ProcessInstanceModificationBuilderImpl",
"modificationBuilder",
")",
"{",
"AbstractProcessInstanceModificationCommand",
"firstInstruction",
"=",
"modificationBuilder",
".",
"getModificationOperations",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"firstInstruction",
"instanceof",
"AbstractInstantiationCmd",
")",
"{",
"AbstractInstantiationCmd",
"instantiationInstruction",
"=",
"(",
"AbstractInstantiationCmd",
")",
"firstInstruction",
";",
"CoreModelElement",
"targetElement",
"=",
"instantiationInstruction",
".",
"getTargetElement",
"(",
"processDefinition",
")",
";",
"ensureNotNull",
"(",
"NotValidException",
".",
"class",
",",
"\"Element '\"",
"+",
"instantiationInstruction",
".",
"getTargetElementId",
"(",
")",
"+",
"\"' does not exist in process \"",
"+",
"processDefinition",
".",
"getId",
"(",
")",
",",
"\"targetElement\"",
",",
"targetElement",
")",
";",
"if",
"(",
"targetElement",
"instanceof",
"ActivityImpl",
")",
"{",
"return",
"(",
"ActivityImpl",
")",
"targetElement",
";",
"}",
"else",
"if",
"(",
"targetElement",
"instanceof",
"TransitionImpl",
")",
"{",
"return",
"(",
"ActivityImpl",
")",
"(",
"(",
"TransitionImpl",
")",
"targetElement",
")",
".",
"getDestination",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
get the activity that is started by the first instruction, if exists;
return null if the first instruction is a start-transition instruction
|
[
"get",
"the",
"activity",
"that",
"is",
"started",
"by",
"the",
"first",
"instruction",
"if",
"exists",
";",
"return",
"null",
"if",
"the",
"first",
"instruction",
"is",
"a",
"start",
"-",
"transition",
"instruction"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/cmd/StartProcessInstanceAtActivitiesCmd.java#L126-L149
|
16,374
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java
|
MultiInstanceActivityBehavior.getInnerActivity
|
public ActivityImpl getInnerActivity(PvmActivity miBodyActivity) {
for (PvmActivity activity : miBodyActivity.getActivities()) {
ActivityImpl innerActivity = (ActivityImpl) activity;
// note that miBody can contains also a compensation handler
if (!innerActivity.isCompensationHandler()) {
return innerActivity;
}
}
throw new ProcessEngineException("inner activity of multi instance body activity '" + miBodyActivity.getId() + "' not found");
}
|
java
|
public ActivityImpl getInnerActivity(PvmActivity miBodyActivity) {
for (PvmActivity activity : miBodyActivity.getActivities()) {
ActivityImpl innerActivity = (ActivityImpl) activity;
// note that miBody can contains also a compensation handler
if (!innerActivity.isCompensationHandler()) {
return innerActivity;
}
}
throw new ProcessEngineException("inner activity of multi instance body activity '" + miBodyActivity.getId() + "' not found");
}
|
[
"public",
"ActivityImpl",
"getInnerActivity",
"(",
"PvmActivity",
"miBodyActivity",
")",
"{",
"for",
"(",
"PvmActivity",
"activity",
":",
"miBodyActivity",
".",
"getActivities",
"(",
")",
")",
"{",
"ActivityImpl",
"innerActivity",
"=",
"(",
"ActivityImpl",
")",
"activity",
";",
"// note that miBody can contains also a compensation handler",
"if",
"(",
"!",
"innerActivity",
".",
"isCompensationHandler",
"(",
")",
")",
"{",
"return",
"innerActivity",
";",
"}",
"}",
"throw",
"new",
"ProcessEngineException",
"(",
"\"inner activity of multi instance body activity '\"",
"+",
"miBodyActivity",
".",
"getId",
"(",
")",
"+",
"\"' not found\"",
")",
";",
"}"
] |
Get the inner activity of the multi instance execution.
@param execution
of multi instance activity
@return inner activity
|
[
"Get",
"the",
"inner",
"activity",
"of",
"the",
"multi",
"instance",
"execution",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java#L180-L189
|
16,375
|
camunda/camunda-bpm-platform
|
engine-spring/core/src/main/java/org/camunda/bpm/engine/spring/components/registry/ActivitiStateHandlerRegistry.java
|
ActivitiStateHandlerRegistry.registerActivitiStateHandler
|
public void registerActivitiStateHandler(
ActivitiStateHandlerRegistration registration) {
String regKey = registrationKey(registration.getProcessName(),
registration.getStateName());
this.registrations.put(regKey, registration);
}
|
java
|
public void registerActivitiStateHandler(
ActivitiStateHandlerRegistration registration) {
String regKey = registrationKey(registration.getProcessName(),
registration.getStateName());
this.registrations.put(regKey, registration);
}
|
[
"public",
"void",
"registerActivitiStateHandler",
"(",
"ActivitiStateHandlerRegistration",
"registration",
")",
"{",
"String",
"regKey",
"=",
"registrationKey",
"(",
"registration",
".",
"getProcessName",
"(",
")",
",",
"registration",
".",
"getStateName",
"(",
")",
")",
";",
"this",
".",
"registrations",
".",
"put",
"(",
"regKey",
",",
"registration",
")",
";",
"}"
] |
used at runtime to register state handlers as they are registered with the spring context
@param registration the {@link org.camunda.bpm.engine.test.spring.components.registry.ActivitiStateHandlerRegistration}
|
[
"used",
"at",
"runtime",
"to",
"register",
"state",
"handlers",
"as",
"they",
"are",
"registered",
"with",
"the",
"spring",
"context"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-spring/core/src/main/java/org/camunda/bpm/engine/spring/components/registry/ActivitiStateHandlerRegistry.java#L80-L85
|
16,376
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java
|
DefaultPriorityProvider.evaluateValueProvider
|
protected Long evaluateValueProvider(ParameterValueProvider valueProvider, ExecutionEntity execution, String errorMessageHeading) {
Object value;
try {
value = valueProvider.getValue(execution);
} catch (ProcessEngineException e) {
if (Context.getProcessEngineConfiguration().isEnableGracefulDegradationOnContextSwitchFailure()
&& isSymptomOfContextSwitchFailure(e, execution)) {
value = getDefaultPriorityOnResolutionFailure();
logNotDeterminingPriority(execution, value, e);
}
else {
throw e;
}
}
if (!(value instanceof Number)) {
throw new ProcessEngineException(errorMessageHeading + ": Priority value is not an Integer");
}
else {
Number numberValue = (Number) value;
if (isValidLongValue(numberValue)) {
return numberValue.longValue();
}
else {
throw new ProcessEngineException(errorMessageHeading + ": Priority value must be either Short, Integer, or Long");
}
}
}
|
java
|
protected Long evaluateValueProvider(ParameterValueProvider valueProvider, ExecutionEntity execution, String errorMessageHeading) {
Object value;
try {
value = valueProvider.getValue(execution);
} catch (ProcessEngineException e) {
if (Context.getProcessEngineConfiguration().isEnableGracefulDegradationOnContextSwitchFailure()
&& isSymptomOfContextSwitchFailure(e, execution)) {
value = getDefaultPriorityOnResolutionFailure();
logNotDeterminingPriority(execution, value, e);
}
else {
throw e;
}
}
if (!(value instanceof Number)) {
throw new ProcessEngineException(errorMessageHeading + ": Priority value is not an Integer");
}
else {
Number numberValue = (Number) value;
if (isValidLongValue(numberValue)) {
return numberValue.longValue();
}
else {
throw new ProcessEngineException(errorMessageHeading + ": Priority value must be either Short, Integer, or Long");
}
}
}
|
[
"protected",
"Long",
"evaluateValueProvider",
"(",
"ParameterValueProvider",
"valueProvider",
",",
"ExecutionEntity",
"execution",
",",
"String",
"errorMessageHeading",
")",
"{",
"Object",
"value",
";",
"try",
"{",
"value",
"=",
"valueProvider",
".",
"getValue",
"(",
"execution",
")",
";",
"}",
"catch",
"(",
"ProcessEngineException",
"e",
")",
"{",
"if",
"(",
"Context",
".",
"getProcessEngineConfiguration",
"(",
")",
".",
"isEnableGracefulDegradationOnContextSwitchFailure",
"(",
")",
"&&",
"isSymptomOfContextSwitchFailure",
"(",
"e",
",",
"execution",
")",
")",
"{",
"value",
"=",
"getDefaultPriorityOnResolutionFailure",
"(",
")",
";",
"logNotDeterminingPriority",
"(",
"execution",
",",
"value",
",",
"e",
")",
";",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"}",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"Number",
")",
")",
"{",
"throw",
"new",
"ProcessEngineException",
"(",
"errorMessageHeading",
"+",
"\": Priority value is not an Integer\"",
")",
";",
"}",
"else",
"{",
"Number",
"numberValue",
"=",
"(",
"Number",
")",
"value",
";",
"if",
"(",
"isValidLongValue",
"(",
"numberValue",
")",
")",
"{",
"return",
"numberValue",
".",
"longValue",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ProcessEngineException",
"(",
"errorMessageHeading",
"+",
"\": Priority value must be either Short, Integer, or Long\"",
")",
";",
"}",
"}",
"}"
] |
Evaluates a given value provider with the given execution entity to determine
the correct value. The error message heading is used for the error message
if the validation fails because the value is no valid priority.
@param valueProvider the provider which contains the value
@param execution the execution entity
@param errorMessageHeading the heading which is used for the error message
@return the valid priority value
|
[
"Evaluates",
"a",
"given",
"value",
"provider",
"with",
"the",
"given",
"execution",
"entity",
"to",
"determine",
"the",
"correct",
"value",
".",
"The",
"error",
"message",
"heading",
"is",
"used",
"for",
"the",
"error",
"message",
"if",
"the",
"validation",
"fails",
"because",
"the",
"value",
"is",
"no",
"valid",
"priority",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java#L73-L103
|
16,377
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java
|
DefaultPriorityProvider.getProcessDefinedPriority
|
protected Long getProcessDefinedPriority(ProcessDefinitionImpl processDefinition, String propertyKey, ExecutionEntity execution, String errorMsgHead) {
if (processDefinition != null) {
ParameterValueProvider priorityProvider = (ParameterValueProvider) processDefinition.getProperty(propertyKey);
if (priorityProvider != null) {
return evaluateValueProvider(priorityProvider, execution, errorMsgHead);
}
}
return null;
}
|
java
|
protected Long getProcessDefinedPriority(ProcessDefinitionImpl processDefinition, String propertyKey, ExecutionEntity execution, String errorMsgHead) {
if (processDefinition != null) {
ParameterValueProvider priorityProvider = (ParameterValueProvider) processDefinition.getProperty(propertyKey);
if (priorityProvider != null) {
return evaluateValueProvider(priorityProvider, execution, errorMsgHead);
}
}
return null;
}
|
[
"protected",
"Long",
"getProcessDefinedPriority",
"(",
"ProcessDefinitionImpl",
"processDefinition",
",",
"String",
"propertyKey",
",",
"ExecutionEntity",
"execution",
",",
"String",
"errorMsgHead",
")",
"{",
"if",
"(",
"processDefinition",
"!=",
"null",
")",
"{",
"ParameterValueProvider",
"priorityProvider",
"=",
"(",
"ParameterValueProvider",
")",
"processDefinition",
".",
"getProperty",
"(",
"propertyKey",
")",
";",
"if",
"(",
"priorityProvider",
"!=",
"null",
")",
"{",
"return",
"evaluateValueProvider",
"(",
"priorityProvider",
",",
"execution",
",",
"errorMsgHead",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the priority which is defined in the given process definition.
The priority value is identified with the given propertyKey.
Returns null if the process definition is null or no priority was defined.
@param processDefinition the process definition that should contains the priority
@param propertyKey the key which identifies the property
@param execution the current execution
@param errorMsgHead the error message header which is used if the evaluation fails
@return the priority defined in the given process
|
[
"Returns",
"the",
"priority",
"which",
"is",
"defined",
"in",
"the",
"given",
"process",
"definition",
".",
"The",
"priority",
"value",
"is",
"identified",
"with",
"the",
"given",
"propertyKey",
".",
"Returns",
"null",
"if",
"the",
"process",
"definition",
"is",
"null",
"or",
"no",
"priority",
"was",
"defined",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java#L154-L162
|
16,378
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/AbstractDefinitionDeployer.java
|
AbstractDefinitionDeployer.getDiagramResourceForDefinition
|
protected String getDiagramResourceForDefinition(DeploymentEntity deployment, String resourceName, DefinitionEntity definition, Map<String, ResourceEntity> resources) {
for (String diagramSuffix: getDiagramSuffixes()) {
String definitionDiagramResource = getDefinitionDiagramResourceName(resourceName, definition, diagramSuffix);
String diagramForFileResource = getGeneralDiagramResourceName(resourceName, definition, diagramSuffix);
if (resources.containsKey(definitionDiagramResource)) {
return definitionDiagramResource;
} else if (resources.containsKey(diagramForFileResource)) {
return diagramForFileResource;
}
}
// no matching diagram found
return null;
}
|
java
|
protected String getDiagramResourceForDefinition(DeploymentEntity deployment, String resourceName, DefinitionEntity definition, Map<String, ResourceEntity> resources) {
for (String diagramSuffix: getDiagramSuffixes()) {
String definitionDiagramResource = getDefinitionDiagramResourceName(resourceName, definition, diagramSuffix);
String diagramForFileResource = getGeneralDiagramResourceName(resourceName, definition, diagramSuffix);
if (resources.containsKey(definitionDiagramResource)) {
return definitionDiagramResource;
} else if (resources.containsKey(diagramForFileResource)) {
return diagramForFileResource;
}
}
// no matching diagram found
return null;
}
|
[
"protected",
"String",
"getDiagramResourceForDefinition",
"(",
"DeploymentEntity",
"deployment",
",",
"String",
"resourceName",
",",
"DefinitionEntity",
"definition",
",",
"Map",
"<",
"String",
",",
"ResourceEntity",
">",
"resources",
")",
"{",
"for",
"(",
"String",
"diagramSuffix",
":",
"getDiagramSuffixes",
"(",
")",
")",
"{",
"String",
"definitionDiagramResource",
"=",
"getDefinitionDiagramResourceName",
"(",
"resourceName",
",",
"definition",
",",
"diagramSuffix",
")",
";",
"String",
"diagramForFileResource",
"=",
"getGeneralDiagramResourceName",
"(",
"resourceName",
",",
"definition",
",",
"diagramSuffix",
")",
";",
"if",
"(",
"resources",
".",
"containsKey",
"(",
"definitionDiagramResource",
")",
")",
"{",
"return",
"definitionDiagramResource",
";",
"}",
"else",
"if",
"(",
"resources",
".",
"containsKey",
"(",
"diagramForFileResource",
")",
")",
"{",
"return",
"diagramForFileResource",
";",
"}",
"}",
"// no matching diagram found",
"return",
"null",
";",
"}"
] |
Returns the default name of the image resource for a certain definition.
It will first look for an image resource which matches the definition
specifically, before resorting to an image resource which matches the file
containing the definition.
Example: if the deployment contains a BPMN 2.0 xml resource called
'abc.bpmn20.xml' containing only one process with key 'myProcess', then
this method will look for an image resources called 'abc.myProcess.png'
(or .jpg, or .gif, etc.) or 'abc.png' if the previous one wasn't found.
Example 2: if the deployment contains a BPMN 2.0 xml resource called
'abc.bpmn20.xml' containing three processes (with keys a, b and c),
then this method will first look for an image resource called 'abc.a.png'
before looking for 'abc.png' (likewise for b and c).
Note that if abc.a.png, abc.b.png and abc.c.png don't exist, all
processes will have the same image: abc.png.
@return null if no matching image resource is found.
|
[
"Returns",
"the",
"default",
"name",
"of",
"the",
"image",
"resource",
"for",
"a",
"certain",
"definition",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractDefinitionDeployer.java#L144-L156
|
16,379
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java
|
HalCachingLinkResolver.resolveLinks
|
public List<HalResource<?>> resolveLinks(String[] linkedIds, ProcessEngine processEngine) {
Cache cache = getCache();
if (cache == null) {
return resolveNotCachedLinks(linkedIds, processEngine);
}
else {
ArrayList<String> notCachedLinkedIds = new ArrayList<String>();
List<HalResource<?>> resolvedResources = resolveCachedLinks(linkedIds, cache, notCachedLinkedIds);
if (!notCachedLinkedIds.isEmpty()) {
List<HalResource<?>> notCachedResources = resolveNotCachedLinks(notCachedLinkedIds.toArray(new String[notCachedLinkedIds.size()]), processEngine);
resolvedResources.addAll(notCachedResources);
putIntoCache(notCachedResources);
}
sortResolvedResources(resolvedResources);
return resolvedResources;
}
}
|
java
|
public List<HalResource<?>> resolveLinks(String[] linkedIds, ProcessEngine processEngine) {
Cache cache = getCache();
if (cache == null) {
return resolveNotCachedLinks(linkedIds, processEngine);
}
else {
ArrayList<String> notCachedLinkedIds = new ArrayList<String>();
List<HalResource<?>> resolvedResources = resolveCachedLinks(linkedIds, cache, notCachedLinkedIds);
if (!notCachedLinkedIds.isEmpty()) {
List<HalResource<?>> notCachedResources = resolveNotCachedLinks(notCachedLinkedIds.toArray(new String[notCachedLinkedIds.size()]), processEngine);
resolvedResources.addAll(notCachedResources);
putIntoCache(notCachedResources);
}
sortResolvedResources(resolvedResources);
return resolvedResources;
}
}
|
[
"public",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"resolveLinks",
"(",
"String",
"[",
"]",
"linkedIds",
",",
"ProcessEngine",
"processEngine",
")",
"{",
"Cache",
"cache",
"=",
"getCache",
"(",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"return",
"resolveNotCachedLinks",
"(",
"linkedIds",
",",
"processEngine",
")",
";",
"}",
"else",
"{",
"ArrayList",
"<",
"String",
">",
"notCachedLinkedIds",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"resolvedResources",
"=",
"resolveCachedLinks",
"(",
"linkedIds",
",",
"cache",
",",
"notCachedLinkedIds",
")",
";",
"if",
"(",
"!",
"notCachedLinkedIds",
".",
"isEmpty",
"(",
")",
")",
"{",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"notCachedResources",
"=",
"resolveNotCachedLinks",
"(",
"notCachedLinkedIds",
".",
"toArray",
"(",
"new",
"String",
"[",
"notCachedLinkedIds",
".",
"size",
"(",
")",
"]",
")",
",",
"processEngine",
")",
";",
"resolvedResources",
".",
"addAll",
"(",
"notCachedResources",
")",
";",
"putIntoCache",
"(",
"notCachedResources",
")",
";",
"}",
"sortResolvedResources",
"(",
"resolvedResources",
")",
";",
"return",
"resolvedResources",
";",
"}",
"}"
] |
Resolve resources for linked ids, if configured uses a cache.
|
[
"Resolve",
"resources",
"for",
"linked",
"ids",
"if",
"configured",
"uses",
"a",
"cache",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java#L35-L55
|
16,380
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java
|
HalCachingLinkResolver.sortResolvedResources
|
protected void sortResolvedResources(List<HalResource<?>> resolvedResources) {
Comparator<HalResource<?>> comparator = getResourceComparator();
if (comparator != null) {
Collections.sort(resolvedResources, comparator);
}
}
|
java
|
protected void sortResolvedResources(List<HalResource<?>> resolvedResources) {
Comparator<HalResource<?>> comparator = getResourceComparator();
if (comparator != null) {
Collections.sort(resolvedResources, comparator);
}
}
|
[
"protected",
"void",
"sortResolvedResources",
"(",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"resolvedResources",
")",
"{",
"Comparator",
"<",
"HalResource",
"<",
"?",
">",
">",
"comparator",
"=",
"getResourceComparator",
"(",
")",
";",
"if",
"(",
"comparator",
"!=",
"null",
")",
"{",
"Collections",
".",
"sort",
"(",
"resolvedResources",
",",
"comparator",
")",
";",
"}",
"}"
] |
Sort the resolved resources to ensure consistent order of resolved resources.
|
[
"Sort",
"the",
"resolved",
"resources",
"to",
"ensure",
"consistent",
"order",
"of",
"resolved",
"resources",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java#L60-L65
|
16,381
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java
|
HalCachingLinkResolver.resolveCachedLinks
|
protected List<HalResource<?>> resolveCachedLinks(String[] linkedIds, Cache cache, List<String> notCachedLinkedIds) {
ArrayList<HalResource<?>> resolvedResources = new ArrayList<HalResource<?>>();
for (String linkedId : linkedIds) {
HalResource<?> resource = (HalResource<?>) cache.get(linkedId);
if (resource != null) {
resolvedResources.add(resource);
}
else {
notCachedLinkedIds.add(linkedId);
}
}
return resolvedResources;
}
|
java
|
protected List<HalResource<?>> resolveCachedLinks(String[] linkedIds, Cache cache, List<String> notCachedLinkedIds) {
ArrayList<HalResource<?>> resolvedResources = new ArrayList<HalResource<?>>();
for (String linkedId : linkedIds) {
HalResource<?> resource = (HalResource<?>) cache.get(linkedId);
if (resource != null) {
resolvedResources.add(resource);
}
else {
notCachedLinkedIds.add(linkedId);
}
}
return resolvedResources;
}
|
[
"protected",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"resolveCachedLinks",
"(",
"String",
"[",
"]",
"linkedIds",
",",
"Cache",
"cache",
",",
"List",
"<",
"String",
">",
"notCachedLinkedIds",
")",
"{",
"ArrayList",
"<",
"HalResource",
"<",
"?",
">",
">",
"resolvedResources",
"=",
"new",
"ArrayList",
"<",
"HalResource",
"<",
"?",
">",
">",
"(",
")",
";",
"for",
"(",
"String",
"linkedId",
":",
"linkedIds",
")",
"{",
"HalResource",
"<",
"?",
">",
"resource",
"=",
"(",
"HalResource",
"<",
"?",
">",
")",
"cache",
".",
"get",
"(",
"linkedId",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"resolvedResources",
".",
"add",
"(",
"resource",
")",
";",
"}",
"else",
"{",
"notCachedLinkedIds",
".",
"add",
"(",
"linkedId",
")",
";",
"}",
"}",
"return",
"resolvedResources",
";",
"}"
] |
Returns a list with all resources which are cached.
@param linkedIds the ids to resolve
@param cache the cache to use
@param notCachedLinkedIds a list with ids which are not found in the cache
@return the cached resources
|
[
"Returns",
"a",
"list",
"with",
"all",
"resources",
"which",
"are",
"cached",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java#L82-L96
|
16,382
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java
|
HalCachingLinkResolver.putIntoCache
|
protected void putIntoCache(List<HalResource<?>> notCachedResources) {
Cache cache = getCache();
for (HalResource<?> notCachedResource : notCachedResources) {
cache.put(getResourceId(notCachedResource), notCachedResource);
}
}
|
java
|
protected void putIntoCache(List<HalResource<?>> notCachedResources) {
Cache cache = getCache();
for (HalResource<?> notCachedResource : notCachedResources) {
cache.put(getResourceId(notCachedResource), notCachedResource);
}
}
|
[
"protected",
"void",
"putIntoCache",
"(",
"List",
"<",
"HalResource",
"<",
"?",
">",
">",
"notCachedResources",
")",
"{",
"Cache",
"cache",
"=",
"getCache",
"(",
")",
";",
"for",
"(",
"HalResource",
"<",
"?",
">",
"notCachedResource",
":",
"notCachedResources",
")",
"{",
"cache",
".",
"put",
"(",
"getResourceId",
"(",
"notCachedResource",
")",
",",
"notCachedResource",
")",
";",
"}",
"}"
] |
Put a resource into the cache.
|
[
"Put",
"a",
"resource",
"into",
"the",
"cache",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/cache/HalCachingLinkResolver.java#L101-L106
|
16,383
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionEntity.java
|
ProcessDefinitionEntity.updateModifiableFieldsFromEntity
|
@Override
public void updateModifiableFieldsFromEntity(ProcessDefinitionEntity updatingProcessDefinition) {
if (this.key.equals(updatingProcessDefinition.key) && this.deploymentId.equals(updatingProcessDefinition.deploymentId)) {
// TODO: add a guard once the mismatch between revisions in deployment cache and database has been resolved
this.revision = updatingProcessDefinition.revision;
this.suspensionState = updatingProcessDefinition.suspensionState;
this.historyTimeToLive = updatingProcessDefinition.historyTimeToLive;
}
else {
LOG.logUpdateUnrelatedProcessDefinitionEntity(this.key, updatingProcessDefinition.key, this.deploymentId, updatingProcessDefinition.deploymentId);
}
}
|
java
|
@Override
public void updateModifiableFieldsFromEntity(ProcessDefinitionEntity updatingProcessDefinition) {
if (this.key.equals(updatingProcessDefinition.key) && this.deploymentId.equals(updatingProcessDefinition.deploymentId)) {
// TODO: add a guard once the mismatch between revisions in deployment cache and database has been resolved
this.revision = updatingProcessDefinition.revision;
this.suspensionState = updatingProcessDefinition.suspensionState;
this.historyTimeToLive = updatingProcessDefinition.historyTimeToLive;
}
else {
LOG.logUpdateUnrelatedProcessDefinitionEntity(this.key, updatingProcessDefinition.key, this.deploymentId, updatingProcessDefinition.deploymentId);
}
}
|
[
"@",
"Override",
"public",
"void",
"updateModifiableFieldsFromEntity",
"(",
"ProcessDefinitionEntity",
"updatingProcessDefinition",
")",
"{",
"if",
"(",
"this",
".",
"key",
".",
"equals",
"(",
"updatingProcessDefinition",
".",
"key",
")",
"&&",
"this",
".",
"deploymentId",
".",
"equals",
"(",
"updatingProcessDefinition",
".",
"deploymentId",
")",
")",
"{",
"// TODO: add a guard once the mismatch between revisions in deployment cache and database has been resolved",
"this",
".",
"revision",
"=",
"updatingProcessDefinition",
".",
"revision",
";",
"this",
".",
"suspensionState",
"=",
"updatingProcessDefinition",
".",
"suspensionState",
";",
"this",
".",
"historyTimeToLive",
"=",
"updatingProcessDefinition",
".",
"historyTimeToLive",
";",
"}",
"else",
"{",
"LOG",
".",
"logUpdateUnrelatedProcessDefinitionEntity",
"(",
"this",
".",
"key",
",",
"updatingProcessDefinition",
".",
"key",
",",
"this",
".",
"deploymentId",
",",
"updatingProcessDefinition",
".",
"deploymentId",
")",
";",
"}",
"}"
] |
Updates all modifiable fields from another process definition entity.
@param updatingProcessDefinition
|
[
"Updates",
"all",
"modifiable",
"fields",
"from",
"another",
"process",
"definition",
"entity",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionEntity.java#L200-L211
|
16,384
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
|
ScriptUtil.isDynamicScriptExpression
|
public static boolean isDynamicScriptExpression(String language, String value) {
return StringUtil.isExpression(value) && (language != null && !JuelScriptEngineFactory.names.contains(language.toLowerCase()));
}
|
java
|
public static boolean isDynamicScriptExpression(String language, String value) {
return StringUtil.isExpression(value) && (language != null && !JuelScriptEngineFactory.names.contains(language.toLowerCase()));
}
|
[
"public",
"static",
"boolean",
"isDynamicScriptExpression",
"(",
"String",
"language",
",",
"String",
"value",
")",
"{",
"return",
"StringUtil",
".",
"isExpression",
"(",
"value",
")",
"&&",
"(",
"language",
"!=",
"null",
"&&",
"!",
"JuelScriptEngineFactory",
".",
"names",
".",
"contains",
"(",
"language",
".",
"toLowerCase",
"(",
")",
")",
")",
";",
"}"
] |
Checks if the value is an expression for a dynamic script source or resource.
@param language the language of the script
@param value the value to check
@return true if the value is an expression for a dynamic script source/resource, otherwise false
|
[
"Checks",
"if",
"the",
"value",
"is",
"an",
"expression",
"for",
"a",
"dynamic",
"script",
"source",
"or",
"resource",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java#L192-L194
|
16,385
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
|
ScriptUtil.getScriptFactory
|
public static ScriptFactory getScriptFactory() {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
if (processEngineConfiguration != null) {
return processEngineConfiguration.getScriptFactory();
}
else {
return new ScriptFactory();
}
}
|
java
|
public static ScriptFactory getScriptFactory() {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
if (processEngineConfiguration != null) {
return processEngineConfiguration.getScriptFactory();
}
else {
return new ScriptFactory();
}
}
|
[
"public",
"static",
"ScriptFactory",
"getScriptFactory",
"(",
")",
"{",
"ProcessEngineConfigurationImpl",
"processEngineConfiguration",
"=",
"Context",
".",
"getProcessEngineConfiguration",
"(",
")",
";",
"if",
"(",
"processEngineConfiguration",
"!=",
"null",
")",
"{",
"return",
"processEngineConfiguration",
".",
"getScriptFactory",
"(",
")",
";",
"}",
"else",
"{",
"return",
"new",
"ScriptFactory",
"(",
")",
";",
"}",
"}"
] |
Returns the configured script factory in the context or a new one.
|
[
"Returns",
"the",
"configured",
"script",
"factory",
"in",
"the",
"context",
"or",
"a",
"new",
"one",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java#L199-L207
|
16,386
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/cmd/DeployCmd.java
|
DeployCmd.resumePreviousByProcessDefinitionKey
|
protected Set<String> resumePreviousByProcessDefinitionKey(CommandContext commandContext, DeploymentEntity deployment, Set<String> processKeysToRegisterFor) {
Set<String> processDefinitionKeys = new HashSet<String>(processKeysToRegisterFor);
List<? extends ProcessDefinition> deployedProcesses = getDeployedProcesses(deployment);
for (ProcessDefinition deployedProcess : deployedProcesses) {
if (deployedProcess.getVersion() > 1) {
processDefinitionKeys.add(deployedProcess.getKey());
}
}
return findDeploymentIdsForProcessDefinitions(commandContext, processDefinitionKeys);
}
|
java
|
protected Set<String> resumePreviousByProcessDefinitionKey(CommandContext commandContext, DeploymentEntity deployment, Set<String> processKeysToRegisterFor) {
Set<String> processDefinitionKeys = new HashSet<String>(processKeysToRegisterFor);
List<? extends ProcessDefinition> deployedProcesses = getDeployedProcesses(deployment);
for (ProcessDefinition deployedProcess : deployedProcesses) {
if (deployedProcess.getVersion() > 1) {
processDefinitionKeys.add(deployedProcess.getKey());
}
}
return findDeploymentIdsForProcessDefinitions(commandContext, processDefinitionKeys);
}
|
[
"protected",
"Set",
"<",
"String",
">",
"resumePreviousByProcessDefinitionKey",
"(",
"CommandContext",
"commandContext",
",",
"DeploymentEntity",
"deployment",
",",
"Set",
"<",
"String",
">",
"processKeysToRegisterFor",
")",
"{",
"Set",
"<",
"String",
">",
"processDefinitionKeys",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"processKeysToRegisterFor",
")",
";",
"List",
"<",
"?",
"extends",
"ProcessDefinition",
">",
"deployedProcesses",
"=",
"getDeployedProcesses",
"(",
"deployment",
")",
";",
"for",
"(",
"ProcessDefinition",
"deployedProcess",
":",
"deployedProcesses",
")",
"{",
"if",
"(",
"deployedProcess",
".",
"getVersion",
"(",
")",
">",
"1",
")",
"{",
"processDefinitionKeys",
".",
"add",
"(",
"deployedProcess",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"return",
"findDeploymentIdsForProcessDefinitions",
"(",
"commandContext",
",",
"processDefinitionKeys",
")",
";",
"}"
] |
Searches in previous deployments for the same processes and retrieves the deployment ids.
@param commandContext
@param deployment
the current deployment
@param processKeysToRegisterFor
the process keys this process application wants to register
@param deployment
the set where to add further deployments this process application
should be registered for
@return a set of deployment ids that contain versions of the
processKeysToRegisterFor
|
[
"Searches",
"in",
"previous",
"deployments",
"for",
"the",
"same",
"processes",
"and",
"retrieves",
"the",
"deployment",
"ids",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/cmd/DeployCmd.java#L552-L563
|
16,387
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/cmd/DeployCmd.java
|
DeployCmd.resumePreviousByDeploymentName
|
protected Set<String> resumePreviousByDeploymentName(CommandContext commandContext, DeploymentEntity deployment) {
List<Deployment> previousDeployments = new DeploymentQueryImpl().deploymentName(deployment.getName()).list();
Set<String> deploymentIds = new HashSet<String>(previousDeployments.size());
for (Deployment d : previousDeployments) {
deploymentIds.add(d.getId());
}
return deploymentIds;
}
|
java
|
protected Set<String> resumePreviousByDeploymentName(CommandContext commandContext, DeploymentEntity deployment) {
List<Deployment> previousDeployments = new DeploymentQueryImpl().deploymentName(deployment.getName()).list();
Set<String> deploymentIds = new HashSet<String>(previousDeployments.size());
for (Deployment d : previousDeployments) {
deploymentIds.add(d.getId());
}
return deploymentIds;
}
|
[
"protected",
"Set",
"<",
"String",
">",
"resumePreviousByDeploymentName",
"(",
"CommandContext",
"commandContext",
",",
"DeploymentEntity",
"deployment",
")",
"{",
"List",
"<",
"Deployment",
">",
"previousDeployments",
"=",
"new",
"DeploymentQueryImpl",
"(",
")",
".",
"deploymentName",
"(",
"deployment",
".",
"getName",
"(",
")",
")",
".",
"list",
"(",
")",
";",
"Set",
"<",
"String",
">",
"deploymentIds",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"previousDeployments",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Deployment",
"d",
":",
"previousDeployments",
")",
"{",
"deploymentIds",
".",
"add",
"(",
"d",
".",
"getId",
"(",
")",
")",
";",
"}",
"return",
"deploymentIds",
";",
"}"
] |
Searches for previous deployments with the same name.
@param commandContext
@param deployment the current deployment
@return a set of deployment ids
|
[
"Searches",
"for",
"previous",
"deployments",
"with",
"the",
"same",
"name",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/cmd/DeployCmd.java#L571-L578
|
16,388
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/cmmn/execution/CmmnExecution.java
|
CmmnExecution.getSatisfiedSentries
|
protected List<String> getSatisfiedSentries(List<String> sentryIds) {
List<String> result = new ArrayList<String>();
if (sentryIds != null) {
for (String sentryId : sentryIds) {
if (isSentrySatisfied(sentryId)) {
result.add(sentryId);
}
}
}
return result;
}
|
java
|
protected List<String> getSatisfiedSentries(List<String> sentryIds) {
List<String> result = new ArrayList<String>();
if (sentryIds != null) {
for (String sentryId : sentryIds) {
if (isSentrySatisfied(sentryId)) {
result.add(sentryId);
}
}
}
return result;
}
|
[
"protected",
"List",
"<",
"String",
">",
"getSatisfiedSentries",
"(",
"List",
"<",
"String",
">",
"sentryIds",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sentryIds",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"sentryId",
":",
"sentryIds",
")",
"{",
"if",
"(",
"isSentrySatisfied",
"(",
"sentryId",
")",
")",
"{",
"result",
".",
"add",
"(",
"sentryId",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Checks for each given sentry id whether the corresponding
sentry is satisfied.
|
[
"Checks",
"for",
"each",
"given",
"sentry",
"id",
"whether",
"the",
"corresponding",
"sentry",
"is",
"satisfied",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/cmmn/execution/CmmnExecution.java#L497-L511
|
16,389
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/cmmn/execution/CmmnExecution.java
|
CmmnExecution.getSatisfiedSentriesInExecutionTree
|
protected List<String> getSatisfiedSentriesInExecutionTree(List<String> sentryIds, Map<String, List<CmmnSentryPart>> allSentries) {
List<String> result = new ArrayList<String>();
if (sentryIds != null) {
for (String sentryId : sentryIds) {
List<CmmnSentryPart> sentryParts = allSentries.get(sentryId);
if (isSentryPartsSatisfied(sentryId, sentryParts)) {
result.add(sentryId);
}
}
}
return result;
}
|
java
|
protected List<String> getSatisfiedSentriesInExecutionTree(List<String> sentryIds, Map<String, List<CmmnSentryPart>> allSentries) {
List<String> result = new ArrayList<String>();
if (sentryIds != null) {
for (String sentryId : sentryIds) {
List<CmmnSentryPart> sentryParts = allSentries.get(sentryId);
if (isSentryPartsSatisfied(sentryId, sentryParts)) {
result.add(sentryId);
}
}
}
return result;
}
|
[
"protected",
"List",
"<",
"String",
">",
"getSatisfiedSentriesInExecutionTree",
"(",
"List",
"<",
"String",
">",
"sentryIds",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"CmmnSentryPart",
">",
">",
"allSentries",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sentryIds",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"sentryId",
":",
"sentryIds",
")",
"{",
"List",
"<",
"CmmnSentryPart",
">",
"sentryParts",
"=",
"allSentries",
".",
"get",
"(",
"sentryId",
")",
";",
"if",
"(",
"isSentryPartsSatisfied",
"(",
"sentryId",
",",
"sentryParts",
")",
")",
"{",
"result",
".",
"add",
"(",
"sentryId",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Checks for each given sentry id in the execution tree whether the corresponding
sentry is satisfied.
|
[
"Checks",
"for",
"each",
"given",
"sentry",
"id",
"in",
"the",
"execution",
"tree",
"whether",
"the",
"corresponding",
"sentry",
"is",
"satisfied",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/cmmn/execution/CmmnExecution.java#L517-L531
|
16,390
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ArrayELResolver.java
|
ArrayELResolver.getValue
|
@Override
public Object getValue(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException("context is null");
}
Object result = null;
if (isResolvable(base)) {
int index = toIndex(null, property);
result = index < 0 || index >= Array.getLength(base) ? null : Array.get(base, index);
context.setPropertyResolved(true);
}
return result;
}
|
java
|
@Override
public Object getValue(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException("context is null");
}
Object result = null;
if (isResolvable(base)) {
int index = toIndex(null, property);
result = index < 0 || index >= Array.getLength(base) ? null : Array.get(base, index);
context.setPropertyResolved(true);
}
return result;
}
|
[
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"context is null\"",
")",
";",
"}",
"Object",
"result",
"=",
"null",
";",
"if",
"(",
"isResolvable",
"(",
"base",
")",
")",
"{",
"int",
"index",
"=",
"toIndex",
"(",
"null",
",",
"property",
")",
";",
"result",
"=",
"index",
"<",
"0",
"||",
"index",
">=",
"Array",
".",
"getLength",
"(",
"base",
")",
"?",
"null",
":",
"Array",
".",
"get",
"(",
"base",
",",
"index",
")",
";",
"context",
".",
"setPropertyResolved",
"(",
"true",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
If the base object is a Java language array, returns the value at the given index. The index
is specified by the property argument, and coerced into an integer. If the coercion could not
be performed, an IllegalArgumentException is thrown. If the index is out of bounds, null is
returned. If the base is a Java language array, the propertyResolved property of the
ELContext object must be set to true by this resolver, before returning. If this property is
not true after this method is called, the caller should ignore the return value.
@param context
The context of this evaluation.
@param base
The array to analyze. Only bases that are a Java language array are handled by
this resolver.
@param property
The index of the element in the array to return the acceptable type for. Will be
coerced into an integer, but otherwise ignored by this resolver.
@return If the propertyResolved property of ELContext was set to true, then the value at the
given index or null if the index was out of bounds. Otherwise, undefined.
@throws PropertyNotFoundException
if the given index is out of bounds for this array.
@throws NullPointerException
if context is null
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available.
|
[
"If",
"the",
"base",
"object",
"is",
"a",
"Java",
"language",
"array",
"returns",
"the",
"value",
"at",
"the",
"given",
"index",
".",
"The",
"index",
"is",
"specified",
"by",
"the",
"property",
"argument",
"and",
"coerced",
"into",
"an",
"integer",
".",
"If",
"the",
"coercion",
"could",
"not",
"be",
"performed",
"an",
"IllegalArgumentException",
"is",
"thrown",
".",
"If",
"the",
"index",
"is",
"out",
"of",
"bounds",
"null",
"is",
"returned",
".",
"If",
"the",
"base",
"is",
"a",
"Java",
"language",
"array",
"the",
"propertyResolved",
"property",
"of",
"the",
"ELContext",
"object",
"must",
"be",
"set",
"to",
"true",
"by",
"this",
"resolver",
"before",
"returning",
".",
"If",
"this",
"property",
"is",
"not",
"true",
"after",
"this",
"method",
"is",
"called",
"the",
"caller",
"should",
"ignore",
"the",
"return",
"value",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ArrayELResolver.java#L155-L167
|
16,391
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ArrayELResolver.java
|
ArrayELResolver.setValue
|
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
if (context == null) {
throw new NullPointerException("context is null");
}
if (isResolvable(base)) {
if (readOnly) {
throw new PropertyNotWritableException("resolver is read-only");
}
Array.set(base, toIndex(base, property), value);
context.setPropertyResolved(true);
}
}
|
java
|
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
if (context == null) {
throw new NullPointerException("context is null");
}
if (isResolvable(base)) {
if (readOnly) {
throw new PropertyNotWritableException("resolver is read-only");
}
Array.set(base, toIndex(base, property), value);
context.setPropertyResolved(true);
}
}
|
[
"@",
"Override",
"public",
"void",
"setValue",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"context is null\"",
")",
";",
"}",
"if",
"(",
"isResolvable",
"(",
"base",
")",
")",
"{",
"if",
"(",
"readOnly",
")",
"{",
"throw",
"new",
"PropertyNotWritableException",
"(",
"\"resolver is read-only\"",
")",
";",
"}",
"Array",
".",
"set",
"(",
"base",
",",
"toIndex",
"(",
"base",
",",
"property",
")",
",",
"value",
")",
";",
"context",
".",
"setPropertyResolved",
"(",
"true",
")",
";",
"}",
"}"
] |
If the base object is a Java language array, attempts to set the value at the given index
with the given value. The index is specified by the property argument, and coerced into an
integer. If the coercion could not be performed, an IllegalArgumentException is thrown. If
the index is out of bounds, a PropertyNotFoundException is thrown. If the base is a Java
language array, the propertyResolved property of the ELContext object must be set to true by
this resolver, before returning. If this property is not true after this method is called,
the caller can safely assume no value was set. If this resolver was constructed in read-only
mode, this method will always throw PropertyNotWritableException.
@param context
The context of this evaluation.
@param base
The array to analyze. Only bases that are a Java language array are handled by
this resolver.
@param property
The index of the element in the array to return the acceptable type for. Will be
coerced into an integer, but otherwise ignored by this resolver.
@param value
The value to be set at the given index.
@throws PropertyNotFoundException
if the given index is out of bounds for this array.
@throws ClassCastException
if the class of the specified element prevents it from being added to this array.
@throws NullPointerException
if context is null
@throws IllegalArgumentException
if the property could not be coerced into an integer, or if some aspect of the
specified element prevents it from being added to this array.
@throws PropertyNotWritableException
if this resolver was constructed in read-only mode.
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available.
|
[
"If",
"the",
"base",
"object",
"is",
"a",
"Java",
"language",
"array",
"attempts",
"to",
"set",
"the",
"value",
"at",
"the",
"given",
"index",
"with",
"the",
"given",
"value",
".",
"The",
"index",
"is",
"specified",
"by",
"the",
"property",
"argument",
"and",
"coerced",
"into",
"an",
"integer",
".",
"If",
"the",
"coercion",
"could",
"not",
"be",
"performed",
"an",
"IllegalArgumentException",
"is",
"thrown",
".",
"If",
"the",
"index",
"is",
"out",
"of",
"bounds",
"a",
"PropertyNotFoundException",
"is",
"thrown",
".",
"If",
"the",
"base",
"is",
"a",
"Java",
"language",
"array",
"the",
"propertyResolved",
"property",
"of",
"the",
"ELContext",
"object",
"must",
"be",
"set",
"to",
"true",
"by",
"this",
"resolver",
"before",
"returning",
".",
"If",
"this",
"property",
"is",
"not",
"true",
"after",
"this",
"method",
"is",
"called",
"the",
"caller",
"can",
"safely",
"assume",
"no",
"value",
"was",
"set",
".",
"If",
"this",
"resolver",
"was",
"constructed",
"in",
"read",
"-",
"only",
"mode",
"this",
"method",
"will",
"always",
"throw",
"PropertyNotWritableException",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ArrayELResolver.java#L245-L257
|
16,392
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/util/ParseUtil.java
|
ParseUtil.parseHistoryTimeToLive
|
public static Integer parseHistoryTimeToLive(String historyTimeToLive) {
Integer timeToLive = null;
if (historyTimeToLive != null && !historyTimeToLive.isEmpty()) {
Matcher matISO = REGEX_TTL_ISO.matcher(historyTimeToLive);
if (matISO.find()) {
historyTimeToLive = matISO.group(1);
}
timeToLive = parseIntegerAttribute("historyTimeToLive", historyTimeToLive);
}
if (timeToLive != null && timeToLive < 0) {
throw new NotValidException("Cannot parse historyTimeToLive: negative value is not allowed");
}
return timeToLive;
}
|
java
|
public static Integer parseHistoryTimeToLive(String historyTimeToLive) {
Integer timeToLive = null;
if (historyTimeToLive != null && !historyTimeToLive.isEmpty()) {
Matcher matISO = REGEX_TTL_ISO.matcher(historyTimeToLive);
if (matISO.find()) {
historyTimeToLive = matISO.group(1);
}
timeToLive = parseIntegerAttribute("historyTimeToLive", historyTimeToLive);
}
if (timeToLive != null && timeToLive < 0) {
throw new NotValidException("Cannot parse historyTimeToLive: negative value is not allowed");
}
return timeToLive;
}
|
[
"public",
"static",
"Integer",
"parseHistoryTimeToLive",
"(",
"String",
"historyTimeToLive",
")",
"{",
"Integer",
"timeToLive",
"=",
"null",
";",
"if",
"(",
"historyTimeToLive",
"!=",
"null",
"&&",
"!",
"historyTimeToLive",
".",
"isEmpty",
"(",
")",
")",
"{",
"Matcher",
"matISO",
"=",
"REGEX_TTL_ISO",
".",
"matcher",
"(",
"historyTimeToLive",
")",
";",
"if",
"(",
"matISO",
".",
"find",
"(",
")",
")",
"{",
"historyTimeToLive",
"=",
"matISO",
".",
"group",
"(",
"1",
")",
";",
"}",
"timeToLive",
"=",
"parseIntegerAttribute",
"(",
"\"historyTimeToLive\"",
",",
"historyTimeToLive",
")",
";",
"}",
"if",
"(",
"timeToLive",
"!=",
"null",
"&&",
"timeToLive",
"<",
"0",
")",
"{",
"throw",
"new",
"NotValidException",
"(",
"\"Cannot parse historyTimeToLive: negative value is not allowed\"",
")",
";",
"}",
"return",
"timeToLive",
";",
"}"
] |
Parse History Time To Live in ISO-8601 format to integer and set into the given entity
@param historyTimeToLive
|
[
"Parse",
"History",
"Time",
"To",
"Live",
"in",
"ISO",
"-",
"8601",
"format",
"to",
"integer",
"and",
"set",
"into",
"the",
"given",
"entity"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/util/ParseUtil.java#L42-L58
|
16,393
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/form/validator/FormValidators.java
|
FormValidators.createValidator
|
public FormFieldValidator createValidator(Element constraint, BpmnParse bpmnParse, ExpressionManager expressionManager) {
String name = constraint.attribute("name");
String config = constraint.attribute("config");
if("validator".equals(name)) {
// custom validators
if(config == null || config.isEmpty()) {
bpmnParse.addError("validator configuration needs to provide either a fully " +
"qualified classname or an expression resolving to a custom FormFieldValidator implementation.",
constraint);
} else {
if(StringUtil.isExpression(config)) {
// expression
Expression validatorExpression = expressionManager.createExpression(config);
return new DelegateFormFieldValidator(validatorExpression);
} else {
// classname
return new DelegateFormFieldValidator(config);
}
}
} else {
// built-in validators
Class<? extends FormFieldValidator> validator = validators.get(name);
if(validator != null) {
FormFieldValidator validatorInstance = createValidatorInstance(validator);
return validatorInstance;
} else {
bpmnParse.addError("Cannot find validator implementation for name '"+name+"'.", constraint);
}
}
return null;
}
|
java
|
public FormFieldValidator createValidator(Element constraint, BpmnParse bpmnParse, ExpressionManager expressionManager) {
String name = constraint.attribute("name");
String config = constraint.attribute("config");
if("validator".equals(name)) {
// custom validators
if(config == null || config.isEmpty()) {
bpmnParse.addError("validator configuration needs to provide either a fully " +
"qualified classname or an expression resolving to a custom FormFieldValidator implementation.",
constraint);
} else {
if(StringUtil.isExpression(config)) {
// expression
Expression validatorExpression = expressionManager.createExpression(config);
return new DelegateFormFieldValidator(validatorExpression);
} else {
// classname
return new DelegateFormFieldValidator(config);
}
}
} else {
// built-in validators
Class<? extends FormFieldValidator> validator = validators.get(name);
if(validator != null) {
FormFieldValidator validatorInstance = createValidatorInstance(validator);
return validatorInstance;
} else {
bpmnParse.addError("Cannot find validator implementation for name '"+name+"'.", constraint);
}
}
return null;
}
|
[
"public",
"FormFieldValidator",
"createValidator",
"(",
"Element",
"constraint",
",",
"BpmnParse",
"bpmnParse",
",",
"ExpressionManager",
"expressionManager",
")",
"{",
"String",
"name",
"=",
"constraint",
".",
"attribute",
"(",
"\"name\"",
")",
";",
"String",
"config",
"=",
"constraint",
".",
"attribute",
"(",
"\"config\"",
")",
";",
"if",
"(",
"\"validator\"",
".",
"equals",
"(",
"name",
")",
")",
"{",
"// custom validators",
"if",
"(",
"config",
"==",
"null",
"||",
"config",
".",
"isEmpty",
"(",
")",
")",
"{",
"bpmnParse",
".",
"addError",
"(",
"\"validator configuration needs to provide either a fully \"",
"+",
"\"qualified classname or an expression resolving to a custom FormFieldValidator implementation.\"",
",",
"constraint",
")",
";",
"}",
"else",
"{",
"if",
"(",
"StringUtil",
".",
"isExpression",
"(",
"config",
")",
")",
"{",
"// expression",
"Expression",
"validatorExpression",
"=",
"expressionManager",
".",
"createExpression",
"(",
"config",
")",
";",
"return",
"new",
"DelegateFormFieldValidator",
"(",
"validatorExpression",
")",
";",
"}",
"else",
"{",
"// classname",
"return",
"new",
"DelegateFormFieldValidator",
"(",
"config",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// built-in validators",
"Class",
"<",
"?",
"extends",
"FormFieldValidator",
">",
"validator",
"=",
"validators",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"validator",
"!=",
"null",
")",
"{",
"FormFieldValidator",
"validatorInstance",
"=",
"createValidatorInstance",
"(",
"validator",
")",
";",
"return",
"validatorInstance",
";",
"}",
"else",
"{",
"bpmnParse",
".",
"addError",
"(",
"\"Cannot find validator implementation for name '\"",
"+",
"name",
"+",
"\"'.\"",
",",
"constraint",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
factory method for creating validator instances
|
[
"factory",
"method",
"for",
"creating",
"validator",
"instances"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/form/validator/FormValidators.java#L47-L91
|
16,394
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/application/impl/EmbeddedProcessApplication.java
|
EmbeddedProcessApplication.execute
|
public <T> T execute(Callable<T> callable) throws ProcessApplicationExecutionException {
try {
return callable.call();
}
catch (Exception e) {
throw LOG.processApplicationExecutionException(e);
}
}
|
java
|
public <T> T execute(Callable<T> callable) throws ProcessApplicationExecutionException {
try {
return callable.call();
}
catch (Exception e) {
throw LOG.processApplicationExecutionException(e);
}
}
|
[
"public",
"<",
"T",
">",
"T",
"execute",
"(",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"ProcessApplicationExecutionException",
"{",
"try",
"{",
"return",
"callable",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"LOG",
".",
"processApplicationExecutionException",
"(",
"e",
")",
";",
"}",
"}"
] |
Since the process engine is loaded by the same classloader
as the process application, nothing needs to be done.
|
[
"Since",
"the",
"process",
"engine",
"is",
"loaded",
"by",
"the",
"same",
"classloader",
"as",
"the",
"process",
"application",
"nothing",
"needs",
"to",
"be",
"done",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/application/impl/EmbeddedProcessApplication.java#L53-L60
|
16,395
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
|
PvmExecutionImpl.startWithoutExecuting
|
public void startWithoutExecuting(Map<String, Object> variables) {
initialize();
initializeTimerDeclarations();
fireHistoricProcessStartEvent();
performOperation(PvmAtomicOperation.FIRE_PROCESS_START);
setActivity(null);
setActivityInstanceId(getId());
// set variables
setVariables(variables);
}
|
java
|
public void startWithoutExecuting(Map<String, Object> variables) {
initialize();
initializeTimerDeclarations();
fireHistoricProcessStartEvent();
performOperation(PvmAtomicOperation.FIRE_PROCESS_START);
setActivity(null);
setActivityInstanceId(getId());
// set variables
setVariables(variables);
}
|
[
"public",
"void",
"startWithoutExecuting",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
")",
"{",
"initialize",
"(",
")",
";",
"initializeTimerDeclarations",
"(",
")",
";",
"fireHistoricProcessStartEvent",
"(",
")",
";",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"FIRE_PROCESS_START",
")",
";",
"setActivity",
"(",
"null",
")",
";",
"setActivityInstanceId",
"(",
"getId",
"(",
")",
")",
";",
"// set variables",
"setVariables",
"(",
"variables",
")",
";",
"}"
] |
perform starting behavior but don't execute the initial activity
@param variables the variables which are used for the start
|
[
"perform",
"starting",
"behavior",
"but",
"don",
"t",
"execute",
"the",
"initial",
"activity"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java#L255-L266
|
16,396
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
|
PvmExecutionImpl.end
|
@Override
public void end(boolean completeScope) {
setCompleteScope(completeScope);
isActive = false;
isEnded = true;
if (hasReplacedParent()) {
getParent().replacedBy = null;
}
performOperation(PvmAtomicOperation.ACTIVITY_NOTIFY_LISTENER_END);
}
|
java
|
@Override
public void end(boolean completeScope) {
setCompleteScope(completeScope);
isActive = false;
isEnded = true;
if (hasReplacedParent()) {
getParent().replacedBy = null;
}
performOperation(PvmAtomicOperation.ACTIVITY_NOTIFY_LISTENER_END);
}
|
[
"@",
"Override",
"public",
"void",
"end",
"(",
"boolean",
"completeScope",
")",
"{",
"setCompleteScope",
"(",
"completeScope",
")",
";",
"isActive",
"=",
"false",
";",
"isEnded",
"=",
"true",
";",
"if",
"(",
"hasReplacedParent",
"(",
")",
")",
"{",
"getParent",
"(",
")",
".",
"replacedBy",
"=",
"null",
";",
"}",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"ACTIVITY_NOTIFY_LISTENER_END",
")",
";",
"}"
] |
Ends an execution. Invokes end listeners for the current activity and notifies the flow scope execution
of this happening which may result in the flow scope ending.
@param completeScope true if ending the execution contributes to completing the BPMN 2.0 scope
|
[
"Ends",
"an",
"execution",
".",
"Invokes",
"end",
"listeners",
"for",
"the",
"current",
"activity",
"and",
"notifies",
"the",
"flow",
"scope",
"execution",
"of",
"this",
"happening",
"which",
"may",
"result",
"in",
"the",
"flow",
"scope",
"ending",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java#L340-L354
|
16,397
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
|
PvmExecutionImpl.executeActivitiesConcurrent
|
public void executeActivitiesConcurrent(List<PvmActivity> activityStack, PvmActivity targetActivity,
PvmTransition targetTransition, Map<String, Object> variables, Map<String, Object> localVariables,
boolean skipCustomListeners, boolean skipIoMappings) {
ScopeImpl flowScope = null;
if (!activityStack.isEmpty()) {
flowScope = activityStack.get(0).getFlowScope();
} else if (targetActivity != null) {
flowScope = targetActivity.getFlowScope();
} else if (targetTransition != null) {
flowScope = targetTransition.getSource().getFlowScope();
}
PvmExecutionImpl propagatingExecution = null;
if (flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
ModificationObserverBehavior flowScopeBehavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
propagatingExecution = (PvmExecutionImpl) flowScopeBehavior.createInnerInstance(this);
} else {
propagatingExecution = createConcurrentExecution();
}
propagatingExecution.executeActivities(activityStack, targetActivity, targetTransition, variables, localVariables,
skipCustomListeners, skipIoMappings);
}
|
java
|
public void executeActivitiesConcurrent(List<PvmActivity> activityStack, PvmActivity targetActivity,
PvmTransition targetTransition, Map<String, Object> variables, Map<String, Object> localVariables,
boolean skipCustomListeners, boolean skipIoMappings) {
ScopeImpl flowScope = null;
if (!activityStack.isEmpty()) {
flowScope = activityStack.get(0).getFlowScope();
} else if (targetActivity != null) {
flowScope = targetActivity.getFlowScope();
} else if (targetTransition != null) {
flowScope = targetTransition.getSource().getFlowScope();
}
PvmExecutionImpl propagatingExecution = null;
if (flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
ModificationObserverBehavior flowScopeBehavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
propagatingExecution = (PvmExecutionImpl) flowScopeBehavior.createInnerInstance(this);
} else {
propagatingExecution = createConcurrentExecution();
}
propagatingExecution.executeActivities(activityStack, targetActivity, targetTransition, variables, localVariables,
skipCustomListeners, skipIoMappings);
}
|
[
"public",
"void",
"executeActivitiesConcurrent",
"(",
"List",
"<",
"PvmActivity",
">",
"activityStack",
",",
"PvmActivity",
"targetActivity",
",",
"PvmTransition",
"targetTransition",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"localVariables",
",",
"boolean",
"skipCustomListeners",
",",
"boolean",
"skipIoMappings",
")",
"{",
"ScopeImpl",
"flowScope",
"=",
"null",
";",
"if",
"(",
"!",
"activityStack",
".",
"isEmpty",
"(",
")",
")",
"{",
"flowScope",
"=",
"activityStack",
".",
"get",
"(",
"0",
")",
".",
"getFlowScope",
"(",
")",
";",
"}",
"else",
"if",
"(",
"targetActivity",
"!=",
"null",
")",
"{",
"flowScope",
"=",
"targetActivity",
".",
"getFlowScope",
"(",
")",
";",
"}",
"else",
"if",
"(",
"targetTransition",
"!=",
"null",
")",
"{",
"flowScope",
"=",
"targetTransition",
".",
"getSource",
"(",
")",
".",
"getFlowScope",
"(",
")",
";",
"}",
"PvmExecutionImpl",
"propagatingExecution",
"=",
"null",
";",
"if",
"(",
"flowScope",
".",
"getActivityBehavior",
"(",
")",
"instanceof",
"ModificationObserverBehavior",
")",
"{",
"ModificationObserverBehavior",
"flowScopeBehavior",
"=",
"(",
"ModificationObserverBehavior",
")",
"flowScope",
".",
"getActivityBehavior",
"(",
")",
";",
"propagatingExecution",
"=",
"(",
"PvmExecutionImpl",
")",
"flowScopeBehavior",
".",
"createInnerInstance",
"(",
"this",
")",
";",
"}",
"else",
"{",
"propagatingExecution",
"=",
"createConcurrentExecution",
"(",
")",
";",
"}",
"propagatingExecution",
".",
"executeActivities",
"(",
"activityStack",
",",
"targetActivity",
",",
"targetTransition",
",",
"variables",
",",
"localVariables",
",",
"skipCustomListeners",
",",
"skipIoMappings",
")",
";",
"}"
] |
Instantiates the given activity stack under this execution.
Sets the variables for the execution responsible to execute the most deeply nested
activity.
@param activityStack The most deeply nested activity is the last element in the list
|
[
"Instantiates",
"the",
"given",
"activity",
"stack",
"under",
"this",
"execution",
".",
"Sets",
"the",
"variables",
"for",
"the",
"execution",
"responsible",
"to",
"execute",
"the",
"most",
"deeply",
"nested",
"activity",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java#L812-L836
|
16,398
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
|
PvmExecutionImpl.instantiateScopes
|
public Map<PvmActivity, PvmExecutionImpl> instantiateScopes(List<PvmActivity> activityStack,
boolean skipCustomListeners,
boolean skipIoMappings) {
if (activityStack.isEmpty()) {
return Collections.emptyMap();
}
this.skipCustomListeners = skipCustomListeners;
this.skipIoMapping = skipIoMappings;
ExecutionStartContext executionStartContext = new ExecutionStartContext(false);
InstantiationStack instantiationStack = new InstantiationStack(new LinkedList<>(activityStack));
executionStartContext.setInstantiationStack(instantiationStack);
setStartContext(executionStartContext);
performOperation(PvmAtomicOperation.ACTIVITY_INIT_STACK_AND_RETURN);
Map<PvmActivity, PvmExecutionImpl> createdExecutions = new HashMap<>();
PvmExecutionImpl currentExecution = this;
for (PvmActivity instantiatedActivity : activityStack) {
// there must exactly one child execution
currentExecution = currentExecution.getNonEventScopeExecutions().get(0);
if (currentExecution.isConcurrent()) {
// there may be a non-scope execution that we have to skip (e.g. multi-instance)
currentExecution = currentExecution.getNonEventScopeExecutions().get(0);
}
createdExecutions.put(instantiatedActivity, currentExecution);
}
return createdExecutions;
}
|
java
|
public Map<PvmActivity, PvmExecutionImpl> instantiateScopes(List<PvmActivity> activityStack,
boolean skipCustomListeners,
boolean skipIoMappings) {
if (activityStack.isEmpty()) {
return Collections.emptyMap();
}
this.skipCustomListeners = skipCustomListeners;
this.skipIoMapping = skipIoMappings;
ExecutionStartContext executionStartContext = new ExecutionStartContext(false);
InstantiationStack instantiationStack = new InstantiationStack(new LinkedList<>(activityStack));
executionStartContext.setInstantiationStack(instantiationStack);
setStartContext(executionStartContext);
performOperation(PvmAtomicOperation.ACTIVITY_INIT_STACK_AND_RETURN);
Map<PvmActivity, PvmExecutionImpl> createdExecutions = new HashMap<>();
PvmExecutionImpl currentExecution = this;
for (PvmActivity instantiatedActivity : activityStack) {
// there must exactly one child execution
currentExecution = currentExecution.getNonEventScopeExecutions().get(0);
if (currentExecution.isConcurrent()) {
// there may be a non-scope execution that we have to skip (e.g. multi-instance)
currentExecution = currentExecution.getNonEventScopeExecutions().get(0);
}
createdExecutions.put(instantiatedActivity, currentExecution);
}
return createdExecutions;
}
|
[
"public",
"Map",
"<",
"PvmActivity",
",",
"PvmExecutionImpl",
">",
"instantiateScopes",
"(",
"List",
"<",
"PvmActivity",
">",
"activityStack",
",",
"boolean",
"skipCustomListeners",
",",
"boolean",
"skipIoMappings",
")",
"{",
"if",
"(",
"activityStack",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"this",
".",
"skipCustomListeners",
"=",
"skipCustomListeners",
";",
"this",
".",
"skipIoMapping",
"=",
"skipIoMappings",
";",
"ExecutionStartContext",
"executionStartContext",
"=",
"new",
"ExecutionStartContext",
"(",
"false",
")",
";",
"InstantiationStack",
"instantiationStack",
"=",
"new",
"InstantiationStack",
"(",
"new",
"LinkedList",
"<>",
"(",
"activityStack",
")",
")",
";",
"executionStartContext",
".",
"setInstantiationStack",
"(",
"instantiationStack",
")",
";",
"setStartContext",
"(",
"executionStartContext",
")",
";",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"ACTIVITY_INIT_STACK_AND_RETURN",
")",
";",
"Map",
"<",
"PvmActivity",
",",
"PvmExecutionImpl",
">",
"createdExecutions",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"PvmExecutionImpl",
"currentExecution",
"=",
"this",
";",
"for",
"(",
"PvmActivity",
"instantiatedActivity",
":",
"activityStack",
")",
"{",
"// there must exactly one child execution",
"currentExecution",
"=",
"currentExecution",
".",
"getNonEventScopeExecutions",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"currentExecution",
".",
"isConcurrent",
"(",
")",
")",
"{",
"// there may be a non-scope execution that we have to skip (e.g. multi-instance)",
"currentExecution",
"=",
"currentExecution",
".",
"getNonEventScopeExecutions",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"createdExecutions",
".",
"put",
"(",
"instantiatedActivity",
",",
"currentExecution",
")",
";",
"}",
"return",
"createdExecutions",
";",
"}"
] |
Instantiates the given set of activities and returns the execution for the bottom-most activity
|
[
"Instantiates",
"the",
"given",
"set",
"of",
"activities",
"and",
"returns",
"the",
"execution",
"for",
"the",
"bottom",
"-",
"most",
"activity"
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java#L841-L875
|
16,399
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
|
PvmExecutionImpl.executeActivities
|
public void executeActivities(List<PvmActivity> activityStack, PvmActivity targetActivity,
PvmTransition targetTransition, Map<String, Object> variables, Map<String, Object> localVariables,
boolean skipCustomListeners, boolean skipIoMappings) {
this.skipCustomListeners = skipCustomListeners;
this.skipIoMapping = skipIoMappings;
this.activityInstanceId = null;
this.isEnded = false;
if (!activityStack.isEmpty()) {
ExecutionStartContext executionStartContext = new ExecutionStartContext(false);
InstantiationStack instantiationStack = new InstantiationStack(activityStack, targetActivity, targetTransition);
executionStartContext.setInstantiationStack(instantiationStack);
executionStartContext.setVariables(variables);
executionStartContext.setVariablesLocal(localVariables);
setStartContext(executionStartContext);
performOperation(PvmAtomicOperation.ACTIVITY_INIT_STACK);
} else if (targetActivity != null) {
setVariables(variables);
setVariablesLocal(localVariables);
setActivity(targetActivity);
performOperation(PvmAtomicOperation.ACTIVITY_START_CREATE_SCOPE);
} else if (targetTransition != null) {
setVariables(variables);
setVariablesLocal(localVariables);
setActivity(targetTransition.getSource());
setTransition(targetTransition);
performOperation(PvmAtomicOperation.TRANSITION_START_NOTIFY_LISTENER_TAKE);
}
}
|
java
|
public void executeActivities(List<PvmActivity> activityStack, PvmActivity targetActivity,
PvmTransition targetTransition, Map<String, Object> variables, Map<String, Object> localVariables,
boolean skipCustomListeners, boolean skipIoMappings) {
this.skipCustomListeners = skipCustomListeners;
this.skipIoMapping = skipIoMappings;
this.activityInstanceId = null;
this.isEnded = false;
if (!activityStack.isEmpty()) {
ExecutionStartContext executionStartContext = new ExecutionStartContext(false);
InstantiationStack instantiationStack = new InstantiationStack(activityStack, targetActivity, targetTransition);
executionStartContext.setInstantiationStack(instantiationStack);
executionStartContext.setVariables(variables);
executionStartContext.setVariablesLocal(localVariables);
setStartContext(executionStartContext);
performOperation(PvmAtomicOperation.ACTIVITY_INIT_STACK);
} else if (targetActivity != null) {
setVariables(variables);
setVariablesLocal(localVariables);
setActivity(targetActivity);
performOperation(PvmAtomicOperation.ACTIVITY_START_CREATE_SCOPE);
} else if (targetTransition != null) {
setVariables(variables);
setVariablesLocal(localVariables);
setActivity(targetTransition.getSource());
setTransition(targetTransition);
performOperation(PvmAtomicOperation.TRANSITION_START_NOTIFY_LISTENER_TAKE);
}
}
|
[
"public",
"void",
"executeActivities",
"(",
"List",
"<",
"PvmActivity",
">",
"activityStack",
",",
"PvmActivity",
"targetActivity",
",",
"PvmTransition",
"targetTransition",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"localVariables",
",",
"boolean",
"skipCustomListeners",
",",
"boolean",
"skipIoMappings",
")",
"{",
"this",
".",
"skipCustomListeners",
"=",
"skipCustomListeners",
";",
"this",
".",
"skipIoMapping",
"=",
"skipIoMappings",
";",
"this",
".",
"activityInstanceId",
"=",
"null",
";",
"this",
".",
"isEnded",
"=",
"false",
";",
"if",
"(",
"!",
"activityStack",
".",
"isEmpty",
"(",
")",
")",
"{",
"ExecutionStartContext",
"executionStartContext",
"=",
"new",
"ExecutionStartContext",
"(",
"false",
")",
";",
"InstantiationStack",
"instantiationStack",
"=",
"new",
"InstantiationStack",
"(",
"activityStack",
",",
"targetActivity",
",",
"targetTransition",
")",
";",
"executionStartContext",
".",
"setInstantiationStack",
"(",
"instantiationStack",
")",
";",
"executionStartContext",
".",
"setVariables",
"(",
"variables",
")",
";",
"executionStartContext",
".",
"setVariablesLocal",
"(",
"localVariables",
")",
";",
"setStartContext",
"(",
"executionStartContext",
")",
";",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"ACTIVITY_INIT_STACK",
")",
";",
"}",
"else",
"if",
"(",
"targetActivity",
"!=",
"null",
")",
"{",
"setVariables",
"(",
"variables",
")",
";",
"setVariablesLocal",
"(",
"localVariables",
")",
";",
"setActivity",
"(",
"targetActivity",
")",
";",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"ACTIVITY_START_CREATE_SCOPE",
")",
";",
"}",
"else",
"if",
"(",
"targetTransition",
"!=",
"null",
")",
"{",
"setVariables",
"(",
"variables",
")",
";",
"setVariablesLocal",
"(",
"localVariables",
")",
";",
"setActivity",
"(",
"targetTransition",
".",
"getSource",
"(",
")",
")",
";",
"setTransition",
"(",
"targetTransition",
")",
";",
"performOperation",
"(",
"PvmAtomicOperation",
".",
"TRANSITION_START_NOTIFY_LISTENER_TAKE",
")",
";",
"}",
"}"
] |
Instantiates the given activity stack. Uses this execution to execute the
highest activity in the stack.
Sets the variables for the execution responsible to execute the most deeply nested
activity.
@param activityStack The most deeply nested activity is the last element in the list
|
[
"Instantiates",
"the",
"given",
"activity",
"stack",
".",
"Uses",
"this",
"execution",
"to",
"execute",
"the",
"highest",
"activity",
"in",
"the",
"stack",
".",
"Sets",
"the",
"variables",
"for",
"the",
"execution",
"responsible",
"to",
"execute",
"the",
"most",
"deeply",
"nested",
"activity",
"."
] |
1a464fc887ef3760e53d6f91b9e5b871a0d77cc0
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java#L885-L919
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.