mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Replace some guava methods with native jdk methods or with Apache libs
This commit is contained in:
parent
f6a2d33ecd
commit
b180bfc7bf
60 changed files with 288 additions and 345 deletions
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.elasticsearch.client;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
|
@ -68,7 +67,7 @@ public class HttpBasedClient implements ElasticsearchClient {
|
|||
this.password = props.getProperty(ElasticsearchInterpreter.ELASTICSEARCH_BASIC_AUTH_PASSWORD);
|
||||
}
|
||||
|
||||
private boolean isSucceeded(HttpResponse response) {
|
||||
private boolean isSucceeded(HttpResponse<?> response) {
|
||||
return response.getStatus() >= 200 && response.getStatus() < 300;
|
||||
}
|
||||
|
||||
|
|
@ -135,8 +134,8 @@ public class HttpBasedClient implements ElasticsearchClient {
|
|||
}
|
||||
|
||||
private String getUrl(String[] indices, String[] types) {
|
||||
final String inds = indices == null ? null : Joiner.on(",").join(indices);
|
||||
final String typs = types == null ? null : Joiner.on(",").join(types);
|
||||
final String inds = indices == null ? null : String.join(",", indices);
|
||||
final String typs = types == null ? null : String.join(",", types);
|
||||
return getUrl(inds, typs, null, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.zeppelin.flink;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
|
@ -43,6 +42,7 @@ import org.slf4j.LoggerFactory;
|
|||
import javax.annotation.Nullable;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
|
@ -430,7 +430,7 @@ public abstract class FlinkSqlInterpreter extends AbstractInterpreter {
|
|||
|
||||
private void callShowTables(InterpreterContext context) throws IOException {
|
||||
List<String> tables =
|
||||
Lists.newArrayList(this.tbenv.listTables()).stream()
|
||||
Arrays.asList(this.tbenv.listTables()).stream()
|
||||
.filter(tbl -> !tbl.startsWith("UnnamedTable")).collect(Collectors.toList());
|
||||
context.out.write(
|
||||
"%table table\n" + StringUtils.join(tables, "\n") + "\n");
|
||||
|
|
|
|||
|
|
@ -452,13 +452,13 @@ public class SqlCompleter {
|
|||
String column;
|
||||
|
||||
if (cursorArgument.getSchema() == null) { // process all
|
||||
List<CharSequence> keywordsCandidates = new ArrayList();
|
||||
List<CharSequence> keywordsCandidates = new ArrayList<>();
|
||||
List<CharSequence> schemaCandidates = new ArrayList<>();
|
||||
int keywordsRes = completeKeyword(buffer, cursor, keywordsCandidates);
|
||||
int schemaRes = completeSchema(buffer, cursor, schemaCandidates);
|
||||
addCompletions(candidates, keywordsCandidates, CompletionType.keyword.name());
|
||||
addCompletions(candidates, schemaCandidates, CompletionType.schema.name());
|
||||
return NumberUtils.max(new int[]{keywordsRes, schemaRes});
|
||||
return NumberUtils.max(keywordsRes, schemaRes);
|
||||
} else {
|
||||
schema = cursorArgument.getSchema();
|
||||
if (aliases.containsKey(schema)) { // process alias case
|
||||
|
|
@ -467,20 +467,20 @@ public class SqlCompleter {
|
|||
schema = alias.substring(0, pointPos);
|
||||
table = alias.substring(pointPos + 1);
|
||||
column = cursorArgument.getColumn();
|
||||
List<CharSequence> columnCandidates = new ArrayList();
|
||||
List<CharSequence> columnCandidates = new ArrayList<>();
|
||||
int columnRes = completeColumn(schema, table, column, cursorArgument.getCursorPosition(),
|
||||
columnCandidates);
|
||||
addCompletions(candidates, columnCandidates, CompletionType.column.name());
|
||||
// process schema.table case
|
||||
} else if (cursorArgument.getTable() != null && cursorArgument.getColumn() == null) {
|
||||
List<CharSequence> tableCandidates = new ArrayList();
|
||||
List<CharSequence> tableCandidates = new ArrayList<>();
|
||||
table = cursorArgument.getTable();
|
||||
int tableRes = completeTable(schema, table, cursorArgument.getCursorPosition(),
|
||||
tableCandidates);
|
||||
addCompletions(candidates, tableCandidates, CompletionType.table.name());
|
||||
return tableRes;
|
||||
} else {
|
||||
List<CharSequence> columnCandidates = new ArrayList();
|
||||
List<CharSequence> columnCandidates = new ArrayList<>();
|
||||
table = cursorArgument.getTable();
|
||||
column = cursorArgument.getColumn();
|
||||
int columnRes = completeColumn(schema, table, column, cursorArgument.getCursorPosition(),
|
||||
|
|
@ -572,24 +572,15 @@ public class SqlCompleter {
|
|||
}
|
||||
|
||||
public boolean needLoadSchemas() {
|
||||
if (table == null && column == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return table == null && column == null;
|
||||
}
|
||||
|
||||
public boolean needLoadTables() {
|
||||
if (schema != null && table != null && column == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return schema != null && table != null && column == null;
|
||||
}
|
||||
|
||||
public boolean needLoadColumns() {
|
||||
if (schema != null && table != null && column != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return schema != null && table != null && column != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
package org.apache.zeppelin.jdbc.hive;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||
import org.apache.hadoop.yarn.client.api.YarnClient;
|
||||
|
|
@ -26,7 +24,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -56,10 +56,8 @@ public class YarnUtil {
|
|||
if (yarnClient == null) {
|
||||
return null;
|
||||
}
|
||||
Set<String> applicationTypes = Sets.newHashSet("MAPREDUCE", "TEZ");
|
||||
EnumSet<YarnApplicationState> yarnStates =
|
||||
Sets.newEnumSet(Lists.newArrayList(YarnApplicationState.RUNNING),
|
||||
YarnApplicationState.class);
|
||||
Set<String> applicationTypes = new HashSet<>(Arrays.asList("MAPREDUCE", "TEZ"));
|
||||
EnumSet<YarnApplicationState> yarnStates = EnumSet.of(YarnApplicationState.RUNNING);
|
||||
|
||||
try {
|
||||
List<ApplicationReport> apps =
|
||||
|
|
|
|||
|
|
@ -14,13 +14,9 @@
|
|||
*/
|
||||
package org.apache.zeppelin.jdbc;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
@ -31,6 +27,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -99,7 +96,7 @@ public class SqlCompleterTest {
|
|||
logger.info(explain);
|
||||
|
||||
Assert.assertEquals("Buffer [" + buffer.replace(" ", ".") + "] and Cursor[" + cursor + "] "
|
||||
+ explain, expected, newHashSet(candidates));
|
||||
+ explain, expected, new HashSet<>(candidates));
|
||||
}
|
||||
|
||||
private String explain(String buffer, int cursor, List<InterpreterCompletion> candidates) {
|
||||
|
|
@ -126,7 +123,7 @@ public class SqlCompleterTest {
|
|||
sb.append(")");
|
||||
}
|
||||
}
|
||||
sb.append(" >> [").append(Joiner.on(",").join(cndidateStrings)).append("]");
|
||||
sb.append(" >> [").append(String.join(",", cndidateStrings)).append("]");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
@ -134,8 +131,6 @@ public class SqlCompleterTest {
|
|||
|
||||
private Logger logger = LoggerFactory.getLogger(SqlCompleterTest.class);
|
||||
|
||||
private static final Set<String> EMPTY = new HashSet<>();
|
||||
|
||||
private CompleterTester tester;
|
||||
|
||||
private ArgumentCompleter.WhitespaceArgumentDelimiter delimiter =
|
||||
|
|
@ -325,20 +320,20 @@ public class SqlCompleterTest {
|
|||
@Test
|
||||
public void testSchemaAndTable() {
|
||||
String buffer = "select * from prod_emart.fi";
|
||||
tester.buffer(buffer).from(20).to(23).expect(newHashSet(
|
||||
tester.buffer(buffer).from(20).to(23).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("prod_emart", "prod_emart",
|
||||
CompletionType.schema.name()))).test();
|
||||
tester.buffer(buffer).from(25).to(27).expect(newHashSet(
|
||||
CompletionType.schema.name())))).test();
|
||||
tester.buffer(buffer).from(25).to(27).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("financial_account", "financial_account",
|
||||
CompletionType.table.name()))).test();
|
||||
CompletionType.table.name())))).test();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEdges() {
|
||||
String buffer = " ORDER ";
|
||||
tester.buffer(buffer).from(3).to(7).expect(newHashSet(
|
||||
new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(0).to(1).expect(newHashSet(
|
||||
tester.buffer(buffer).from(3).to(7).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name())))).test();
|
||||
tester.buffer(buffer).from(0).to(1).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name()),
|
||||
new InterpreterCompletion("SUBCLASS_ORIGIN", "SUBCLASS_ORIGIN",
|
||||
CompletionType.keyword.name()),
|
||||
|
|
@ -349,38 +344,38 @@ public class SqlCompleterTest {
|
|||
new InterpreterCompletion("prod_dds", "prod_dds", CompletionType.schema.name()),
|
||||
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name()),
|
||||
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name())
|
||||
)).test();
|
||||
))).test();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleWords() {
|
||||
String buffer = "SELE FRO LIM";
|
||||
tester.buffer(buffer).from(2).to(4).expect(newHashSet(
|
||||
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(6).to(8).expect(newHashSet(
|
||||
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(10).to(12).expect(newHashSet(
|
||||
new InterpreterCompletion("LIMIT", "LIMIT", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(2).to(4).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name())))).test();
|
||||
tester.buffer(buffer).from(6).to(8).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name())))).test();
|
||||
tester.buffer(buffer).from(10).to(12).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("LIMIT", "LIMIT", CompletionType.keyword.name())))).test();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiLineBuffer() {
|
||||
String buffer = " \n SELE\nFRO";
|
||||
tester.buffer(buffer).from(5).to(7).expect(newHashSet(
|
||||
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(9).to(11).expect(newHashSet(
|
||||
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name()))).test();
|
||||
tester.buffer(buffer).from(5).to(7).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name())))).test();
|
||||
tester.buffer(buffer).from(9).to(11).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name())))).test();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCompletionSuggestions() {
|
||||
String buffer = "SU";
|
||||
tester.buffer(buffer).from(2).to(2).expect(newHashSet(
|
||||
tester.buffer(buffer).from(2).to(2).expect(new HashSet<>(Arrays.asList(
|
||||
new InterpreterCompletion("SUBCLASS_ORIGIN", "SUBCLASS_ORIGIN",
|
||||
CompletionType.keyword.name()),
|
||||
new InterpreterCompletion("SUM", "SUM", CompletionType.keyword.name()),
|
||||
new InterpreterCompletion("SUBSTRING", "SUBSTRING", CompletionType.keyword.name()))
|
||||
).test();
|
||||
)).test();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.python;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.ExecuteException;
|
||||
|
|
@ -44,6 +43,7 @@ import py4j.GatewayServer;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -182,7 +182,7 @@ public class PythonInterpreter extends Interpreter {
|
|||
if (System.getProperty("os.name", "").contains("Mac")) {
|
||||
System.setProperty("java.io.tmpdir", "/tmp");
|
||||
}
|
||||
this.pythonWorkDir = Files.createTempDir();
|
||||
this.pythonWorkDir = Files.createTempDirectory("python").toFile();
|
||||
this.pythonWorkDir.deleteOnExit();
|
||||
LOGGER.info("Create Python working dir: " + pythonWorkDir.getAbsolutePath());
|
||||
copyResourceToPythonWorkDir("python/zeppelin_python.py", "zeppelin_python.py");
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.python;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
import org.apache.zeppelin.interpreter.InterpreterException;
|
||||
|
|
@ -107,7 +106,8 @@ public class PythonInterpreterPandasSqlTest {
|
|||
pandasSqlInterpreter.setInterpreterGroup(intpGroup);
|
||||
|
||||
List<Interpreter> interpreters =
|
||||
Lists.newArrayList(pythonInterpreter, ipythonInterpreter, pandasSqlInterpreter);
|
||||
Arrays.asList(pythonInterpreter, ipythonInterpreter, pandasSqlInterpreter);
|
||||
|
||||
|
||||
intpGroup.put("session_1", interpreters);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.zeppelin.spark;
|
||||
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
|
|
@ -35,6 +34,7 @@ import org.apache.zeppelin.python.IPythonInterpreterTest;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -62,7 +62,12 @@ public class IPySparkInterpreterTest extends IPythonInterpreterTest {
|
|||
p.setProperty("zeppelin.spark.maxResult", "3");
|
||||
p.setProperty("zeppelin.spark.importImplicit", "true");
|
||||
p.setProperty("zeppelin.pyspark.python", "python");
|
||||
p.setProperty("zeppelin.dep.localrepo", Files.createTempDir().getAbsolutePath());
|
||||
try {
|
||||
p.setProperty("zeppelin.dep.localrepo", Files.createTempDirectory("localrepo").toAbsolutePath().toString());
|
||||
} catch (IOException e) {
|
||||
fail(ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
|
||||
p.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
|
||||
p.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
|
||||
return p;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.zeppelin.spark;
|
||||
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
|
|
@ -31,6 +30,7 @@ import org.apache.zeppelin.python.PythonInterpreterTest;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Properties;
|
||||
|
||||
|
|
@ -52,7 +52,12 @@ public class PySparkInterpreterTest extends PythonInterpreterTest {
|
|||
properties.setProperty("zeppelin.spark.maxResult", "3");
|
||||
properties.setProperty("zeppelin.spark.importImplicit", "true");
|
||||
properties.setProperty("zeppelin.pyspark.python", "python");
|
||||
properties.setProperty("zeppelin.dep.localrepo", Files.createTempDir().getAbsolutePath());
|
||||
try {
|
||||
properties.setProperty("zeppelin.dep.localrepo", Files.createTempDirectory("localrepo").toAbsolutePath().toString());
|
||||
} catch (IOException e) {
|
||||
fail(ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
|
||||
properties.setProperty("zeppelin.pyspark.useIPython", "false");
|
||||
properties.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
|
||||
properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.integration;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.dep.Dependency;
|
||||
import org.apache.zeppelin.interpreter.ExecutionContext;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
|
|
@ -33,6 +32,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
@ -68,7 +68,7 @@ public class JdbcIntegrationTest {
|
|||
interpreterSetting.setProperty("default.password", "root");
|
||||
|
||||
Dependency dependency = new Dependency("mysql:mysql-connector-java:5.1.46");
|
||||
interpreterSetting.setDependencies(Lists.newArrayList(dependency));
|
||||
interpreterSetting.setDependencies(Arrays.asList(dependency));
|
||||
interpreterSettingManager.restart(interpreterSetting.getId());
|
||||
interpreterSetting.waitForReady(60 * 1000);
|
||||
Interpreter jdbcInterpreter = interpreterFactory.getInterpreter("jdbc", new ExecutionContext("user1", "note1", "test"));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.integration;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
|
||||
|
|
@ -34,13 +33,13 @@ import org.apache.zeppelin.interpreter.InterpreterSetting;
|
|||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -113,7 +112,7 @@ public class YarnInterpreterLauncherIntegrationTest {
|
|||
jdbcInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
|
||||
|
||||
Dependency dependency = new Dependency("mysql:mysql-connector-java:5.1.46");
|
||||
jdbcInterpreterSetting.setDependencies(Lists.newArrayList(dependency));
|
||||
jdbcInterpreterSetting.setDependencies(Arrays.asList(dependency));
|
||||
interpreterSettingManager.restart(jdbcInterpreterSetting.getId());
|
||||
jdbcInterpreterSetting.waitForReady(60 * 1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.integration;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.interpreter.integration.DownloadUtils;
|
||||
|
|
@ -30,11 +29,12 @@ import org.apache.zeppelin.user.AuthenticationInfo;
|
|||
import org.apache.zeppelin.utils.TestUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -72,7 +72,7 @@ public abstract class ZeppelinFlinkClusterTest extends AbstractTestRestApi {
|
|||
note = TestUtils.getInstance(Notebook.class).createNote("note1", AuthenticationInfo.ANONYMOUS);
|
||||
|
||||
// run p0 for %flink.conf
|
||||
String checkpointPath = Files.createTempDir().getAbsolutePath();
|
||||
String checkpointPath = Files.createTempDirectory("checkpoint").toAbsolutePath().toString();
|
||||
Paragraph p0 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
StringBuilder builder = new StringBuilder("%flink.conf\n");
|
||||
builder.append("FLINK_HOME " + flinkHome + "\n");
|
||||
|
|
@ -127,7 +127,7 @@ public abstract class ZeppelinFlinkClusterTest extends AbstractTestRestApi {
|
|||
note = TestUtils.getInstance(Notebook.class).createNote("note2", AuthenticationInfo.ANONYMOUS);
|
||||
|
||||
// run p0 for %flink.conf
|
||||
String checkpointPath = Files.createTempDir().getAbsolutePath();
|
||||
String checkpointPath = Files.createTempDirectory("checkpoint").toAbsolutePath().toString();
|
||||
Paragraph p0 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
StringBuilder builder = new StringBuilder("%flink.conf\n");
|
||||
builder.append("FLINK_HOME " + flinkHome + "\n");
|
||||
|
|
@ -170,7 +170,7 @@ public abstract class ZeppelinFlinkClusterTest extends AbstractTestRestApi {
|
|||
}
|
||||
|
||||
public static String getInitStreamScript(int sleep_interval) throws IOException {
|
||||
return IOUtils.toString(FlinkIntegrationTest.class.getResource("/init_stream.scala"))
|
||||
return IOUtils.toString(FlinkIntegrationTest.class.getResource("/init_stream.scala"), StandardCharsets.UTF_8)
|
||||
.replace("{{sleep_interval}}", sleep_interval + "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.zeppelin.integration;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.display.AngularObject;
|
||||
|
|
@ -49,12 +48,14 @@ import java.io.File;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -694,7 +695,7 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void verifySparkVersionNumber() throws IOException {
|
||||
Note note = null;
|
||||
try {
|
||||
|
|
@ -927,8 +928,8 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
assertTrue(input instanceof CheckBox);
|
||||
CheckBox checkbox = (CheckBox) input;
|
||||
assertEquals("languages", checkbox.getDisplayName());
|
||||
assertEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Lists.newArrayList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
assertArrayEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Arrays.asList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${checkbox:languages}");
|
||||
|
|
@ -991,8 +992,8 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
assertTrue(input instanceof CheckBox);
|
||||
CheckBox checkbox = (CheckBox) input;
|
||||
assertEquals("languages", checkbox.getDisplayName());
|
||||
assertEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Lists.newArrayList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
assertArrayEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Arrays.asList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${checkbox:languages}");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.zeppelin.common.JsonSerializable;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -43,7 +42,7 @@ public class AuthenticationInfo implements JsonSerializable {
|
|||
Set<String> roles;
|
||||
String ticket;
|
||||
UserCredentials userCredentials;
|
||||
public static final AuthenticationInfo ANONYMOUS = new AuthenticationInfo("anonymous", Sets.newHashSet(),
|
||||
public static final AuthenticationInfo ANONYMOUS = new AuthenticationInfo("anonymous", new HashSet<>(),
|
||||
"anonymous");
|
||||
|
||||
public AuthenticationInfo() {}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@
|
|||
|
||||
package org.apache.zeppelin.interpreter;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -28,7 +29,7 @@ public class SingleRowInterpreterResultTest {
|
|||
|
||||
@Test
|
||||
public void testHtml() {
|
||||
List list = Lists.newArrayList("2020-01-01", 10);
|
||||
List<Serializable> list = Arrays.asList("2020-01-01", 10);
|
||||
String template = "Total count:{1} for {0}";
|
||||
InterpreterContext context = InterpreterContext.builder().build();
|
||||
SingleRowInterpreterResult singleRowInterpreterResult = new SingleRowInterpreterResult(list, template, context);
|
||||
|
|
@ -38,7 +39,7 @@ public class SingleRowInterpreterResultTest {
|
|||
|
||||
@Test
|
||||
public void testAngular() {
|
||||
List list = Lists.newArrayList("2020-01-01", 10);
|
||||
List<Serializable> list = Arrays.asList("2020-01-01", 10);
|
||||
String template = "Total count:{1} for {0}";
|
||||
InterpreterContext context = InterpreterContext.builder().build();
|
||||
SingleRowInterpreterResult singleRowInterpreterResult = new SingleRowInterpreterResult(list, template, context);
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package org.apache.zeppelin.tabledata;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TableDataUtilsTest {
|
||||
|
||||
@Test
|
||||
|
|
@ -36,10 +37,10 @@ public class TableDataUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testColumns() {
|
||||
assertEquals(Lists.newArrayList("hello world", "hello world"),
|
||||
assertEquals(Arrays.asList("hello world", "hello world"),
|
||||
TableDataUtils.normalizeColumns(new Object[]{"hello\tworld", "hello\nworld"}));
|
||||
|
||||
assertEquals(Lists.newArrayList("hello world", "null"),
|
||||
assertEquals(Arrays.asList("hello world", "null"),
|
||||
TableDataUtils.normalizeColumns(new String[]{"hello\tworld", null}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
package org.apache.zeppelin.interpreter.launcher;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -30,6 +28,8 @@ import java.net.SocketException;
|
|||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
|
@ -184,7 +184,7 @@ public class DockerInterpreterProcess extends RemoteInterpreterProcess {
|
|||
DockerSpecTemplate specTemplate = new DockerSpecTemplate();
|
||||
specTemplate.loadProperties(getTemplateBindings());
|
||||
URL urlTemplate = this.getClass().getResource(DOCKER_INTP_JINJA);
|
||||
String template = Resources.toString(urlTemplate, Charsets.UTF_8);
|
||||
String template = Resources.toString(urlTemplate, StandardCharsets.UTF_8);
|
||||
String dockerCommand = specTemplate.render(template);
|
||||
int firstLineIsNewline = dockerCommand.indexOf("\n");
|
||||
if (firstLineIsNewline == 0) {
|
||||
|
|
@ -593,7 +593,7 @@ public class DockerInterpreterProcess extends RemoteInterpreterProcess {
|
|||
}
|
||||
|
||||
private String file2Tar(HashMap<String, String> copyFiles) throws IOException {
|
||||
File tmpDir = Files.createTempDir();
|
||||
File tmpDir = Files.createTempDirectory("file2Tar").toFile();
|
||||
|
||||
Date date = new Date();
|
||||
String tarFileName = tmpDir.getPath() + date.getTime() + ".tar";
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.interpreter.launcher;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
|
|
@ -59,7 +57,9 @@ import java.io.IOException;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -372,8 +372,8 @@ public class YarnRemoteInterpreterProcess extends RemoteInterpreterProcess {
|
|||
* classpath specified through the Hadoop and Yarn configurations.
|
||||
*/
|
||||
private void populateHadoopClasspath(Map<String, String> envs) {
|
||||
List<String> yarnClassPath = Lists.newArrayList(getYarnAppClasspath());
|
||||
List<String> mrClassPath = Lists.newArrayList(getMRAppClasspath());
|
||||
List<String> yarnClassPath = Arrays.asList(getYarnAppClasspath());
|
||||
List<String> mrClassPath = Arrays.asList(getMRAppClasspath());
|
||||
yarnClassPath.addAll(mrClassPath);
|
||||
LOGGER.info("Adding hadoop classpath: {}", StringUtils.join(yarnClassPath, ":"));
|
||||
for (String path : yarnClassPath) {
|
||||
|
|
@ -468,7 +468,7 @@ public class YarnRemoteInterpreterProcess extends RemoteInterpreterProcess {
|
|||
}
|
||||
} else {
|
||||
zos.putNextEntry(new ZipEntry(zipEntryName));
|
||||
Files.copy(srcFile, zos);
|
||||
Files.copy(srcFile.toPath(), zos);
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import com.google.cloud.storage.BlobId;
|
|||
import com.google.cloud.storage.BlobInfo;
|
||||
import com.google.cloud.storage.Storage;
|
||||
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -33,6 +31,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
|
|
@ -61,8 +60,8 @@ public class GCSNotebookRepoTest {
|
|||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ "bucketname", Optional.absent(), "gs://bucketname" },
|
||||
{ "bucketname-with-slash", Optional.absent(), "gs://bucketname-with-slash/" },
|
||||
{ "bucketname", Optional.empty(), "gs://bucketname" },
|
||||
{ "bucketname-with-slash", Optional.empty(), "gs://bucketname-with-slash/" },
|
||||
{ "bucketname", Optional.of("path/to/dir"), "gs://bucketname/path/to/dir" },
|
||||
{ "bucketname", Optional.of("trailing/slash"), "gs://bucketname/trailing/slash/" }
|
||||
});
|
||||
|
|
@ -121,7 +120,7 @@ public class GCSNotebookRepoTest {
|
|||
noteIds.add(info.getId());
|
||||
}
|
||||
// Only valid paths are gs://bucketname/path/<noteid>/note.json
|
||||
assertThat(noteIds).containsExactlyElementsIn(ImmutableList.of("12", "123"));
|
||||
assertThat(noteIds).containsExactlyElementsIn(Arrays.asList("12", "123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
|
|
@ -82,18 +81,18 @@ public class GitHubNotebookRepoTest {
|
|||
localZeppelinDir.mkdirs();
|
||||
|
||||
// Notebooks directory (for both the remote and local directories)
|
||||
localNotebooksDir = Joiner.on(File.separator).join(localRepositoryPath, "notebook");
|
||||
remoteNotebooksDir = Joiner.on(File.separator).join(remoteRepositoryPath, "notebook");
|
||||
localNotebooksDir = String.join(File.separator, localRepositoryPath, "notebook");
|
||||
remoteNotebooksDir = String.join(File.separator, remoteRepositoryPath, "notebook");
|
||||
|
||||
File notebookDir = new File(localNotebooksDir);
|
||||
notebookDir.mkdirs();
|
||||
|
||||
|
||||
FileUtils.copyDirectory(
|
||||
new File(GitHubNotebookRepoTest.class.getResource("/notebook").getFile()),
|
||||
new File(remoteNotebooksDir));
|
||||
|
||||
// Create the fake remote Git repository
|
||||
Repository remoteRepository = new FileRepository(Joiner.on(File.separator).join(remoteNotebooksDir, ".git"));
|
||||
Repository remoteRepository = new FileRepository(String.join(File.separator, remoteNotebooksDir, ".git"));
|
||||
remoteRepository.create();
|
||||
|
||||
remoteGit = new Git(remoteRepository);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.apache.zeppelin.notebook.repo;
|
|||
|
||||
import static com.mongodb.client.model.Filters.and;
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bson.Document;
|
||||
|
|
@ -28,7 +27,6 @@ import org.bson.types.ObjectId;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -122,7 +120,7 @@ public class MongoNotebookRepo implements NotebookRepo {
|
|||
.append("as", Fields.FULL_PATH));
|
||||
|
||||
try (AutoLock autoLock = lock.lockForRead()) {
|
||||
ArrayList<Document> list = Lists.newArrayList(match, graphLookup);
|
||||
List<Document> list = Arrays.asList(match, graphLookup);
|
||||
AggregateIterable<Document> aggregate = folders.aggregate(list);
|
||||
for (Document document : aggregate) {
|
||||
String id = document.getString(Fields.ID);
|
||||
|
|
@ -311,7 +309,7 @@ public class MongoNotebookRepo implements NotebookRepo {
|
|||
Boolean isDir = node.getBoolean(Fields.IS_DIR);
|
||||
String nodeName = node.getString(Fields.NAME);
|
||||
|
||||
if (isDir) {
|
||||
if (isDir.booleanValue()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : pathArray) {
|
||||
sb.append("/").append(s);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
*/
|
||||
package org.apache.zeppelin.notebook.repo.zeppelinhub;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -40,7 +38,9 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ public class OldZeppelinHubRepo implements OldNotebookRepoWithVersionControl {
|
|||
port = (scheme != null && scheme.equals("https")) ? 443 : 80;
|
||||
}
|
||||
}
|
||||
String ws = scheme.equals("https") ? "wss://" : "ws://";
|
||||
String ws = "https".equals(scheme) ? "wss://" : "ws://";
|
||||
return ws + apiRoot.getHost() + ":" + port + "/async";
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ public class OldZeppelinHubRepo implements OldNotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || !isSubjectValid(subject)) {
|
||||
return Revision.EMPTY;
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint");
|
||||
String endpoint = String.join("/", noteId, "checkpoint");
|
||||
String content = GSON.toJson(ImmutableMap.of("message", checkpointMsg));
|
||||
|
||||
String token = getUserToken(subject.getUser());
|
||||
|
|
@ -250,7 +250,7 @@ public class OldZeppelinHubRepo implements OldNotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || StringUtils.isBlank(revId) || !isSubjectValid(subject)) {
|
||||
return EMPTY_NOTE;
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint", revId);
|
||||
String endpoint = String.join("/", noteId, "checkpoint", revId);
|
||||
String token = getUserToken(subject.getUser());
|
||||
String response = restApiClient.get(token, endpoint);
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ public class OldZeppelinHubRepo implements OldNotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || !isSubjectValid(subject)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint");
|
||||
String endpoint = String.join("/", noteId, "checkpoint");
|
||||
List<Revision> history = Collections.emptyList();
|
||||
try {
|
||||
String token = getUserToken(subject.getUser());
|
||||
|
|
@ -289,12 +289,12 @@ public class OldZeppelinHubRepo implements OldNotebookRepoWithVersionControl {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
|
||||
List<NotebookRepoSettingsInfo> settings = new ArrayList<>();
|
||||
String user = subject.getUser();
|
||||
String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
|
||||
String userToken = getUserToken(user);
|
||||
List<Instance> instances;
|
||||
List<Map<String, String>> values = Lists.newLinkedList();
|
||||
List<Map<String, String>> values = new LinkedList<>();
|
||||
|
||||
try {
|
||||
instances = tokenManager.getUserInstances(zeppelinHubUserSession);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ package org.apache.zeppelin.notebook.repo.zeppelinhub;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -40,9 +42,7 @@ import org.apache.zeppelin.user.AuthenticationInfo;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ public class ZeppelinHubRepo implements NotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || !isSubjectValid(subject)) {
|
||||
return Revision.EMPTY;
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint");
|
||||
String endpoint = String.join("/", noteId, "checkpoint");
|
||||
String content = GSON.toJson(ImmutableMap.of("message", checkpointMsg));
|
||||
|
||||
String token = getUserToken(subject.getUser());
|
||||
|
|
@ -271,7 +271,7 @@ public class ZeppelinHubRepo implements NotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || StringUtils.isBlank(revId) || !isSubjectValid(subject)) {
|
||||
return EMPTY_NOTE;
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint", revId);
|
||||
String endpoint = String.join("/", noteId, "checkpoint", revId);
|
||||
String token = getUserToken(subject.getUser());
|
||||
String response = restApiClient.get(token, endpoint);
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ public class ZeppelinHubRepo implements NotebookRepoWithVersionControl {
|
|||
if (StringUtils.isBlank(noteId) || !isSubjectValid(subject)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String endpoint = Joiner.on("/").join(noteId, "checkpoint");
|
||||
String endpoint = String.join("/", noteId, "checkpoint");
|
||||
List<Revision> history = Collections.emptyList();
|
||||
try {
|
||||
String token = getUserToken(subject.getUser());
|
||||
|
|
@ -310,12 +310,12 @@ public class ZeppelinHubRepo implements NotebookRepoWithVersionControl {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
|
||||
List<NotebookRepoSettingsInfo> settings = new ArrayList<>();
|
||||
String user = subject.getUser();
|
||||
String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
|
||||
String userToken = getUserToken(user);
|
||||
List<Instance> instances;
|
||||
List<Map<String, String>> values = Lists.newLinkedList();
|
||||
List<Map<String, String>> values = new LinkedList<>();
|
||||
|
||||
try {
|
||||
instances = tokenManager.getUserInstances(zeppelinHubUserSession);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public class AbstractRestApi {
|
|||
|
||||
protected ServiceContext getServiceContext() {
|
||||
AuthenticationInfo authInfo = new AuthenticationInfo(authenticationService.getPrincipal());
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
return new ServiceContext(authInfo, userAndRoles);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -59,7 +59,7 @@ public class AdminRestApi {
|
|||
logger.debug("name: {}", name);
|
||||
return null == name || name.isEmpty()
|
||||
? adminService.getLoggers()
|
||||
: Lists.newArrayList(adminService.getLogger(name));
|
||||
: Arrays.asList(adminService.getLogger(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,6 +81,6 @@ public class AdminRestApi {
|
|||
|
||||
adminService.setLoggerLevel(loggerRequest);
|
||||
|
||||
return Lists.newArrayList(adminService.getLogger(loggerRequest.getName()));
|
||||
return Arrays.asList(adminService.getLogger(loggerRequest.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.IOException;
|
||||
|
|
@ -32,6 +31,8 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.zeppelin.server.JsonResponse;
|
||||
import org.apache.zeppelin.service.AuthenticationService;
|
||||
import org.apache.zeppelin.user.Credentials;
|
||||
|
|
@ -70,9 +71,9 @@ public class CredentialRestApi {
|
|||
String username = messageMap.get("username");
|
||||
String password = messageMap.get("password");
|
||||
|
||||
if (Strings.isNullOrEmpty(entity)
|
||||
|| Strings.isNullOrEmpty(username)
|
||||
|| Strings.isNullOrEmpty(password)) {
|
||||
if (StringUtils.isEmpty(entity)
|
||||
|| StringUtils.isEmpty(username)
|
||||
|| StringUtils.isEmpty(password)) {
|
||||
return new JsonResponse<>(Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.zeppelin.annotation.ZeppelinApi;
|
||||
import org.apache.zeppelin.dep.Repository;
|
||||
|
|
@ -55,6 +55,7 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -316,7 +317,7 @@ public class InterpreterRestApi {
|
|||
@Override
|
||||
public void onStart(String message, ServiceContext context) {
|
||||
Message m = new Message(OP.INTERPRETER_INSTALL_STARTED);
|
||||
Map<String, Object> data = Maps.newHashMap();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("result", "Starting");
|
||||
data.put("message", message);
|
||||
m.data = data;
|
||||
|
|
@ -326,7 +327,7 @@ public class InterpreterRestApi {
|
|||
@Override
|
||||
public void onSuccess(String message, ServiceContext context) {
|
||||
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
|
||||
Map<String, Object> data = Maps.newHashMap();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("result", "Succeed");
|
||||
data.put("message", message);
|
||||
m.data = data;
|
||||
|
|
@ -336,7 +337,7 @@ public class InterpreterRestApi {
|
|||
@Override
|
||||
public void onFailure(Exception ex, ServiceContext context) {
|
||||
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
|
||||
Map<String, Object> data = Maps.newHashMap();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("result", "Failed");
|
||||
data.put("message", ex.getMessage());
|
||||
m.data = data;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -30,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ public class NotebookRepoRestApi {
|
|||
|
||||
private ServiceContext getServiceContext() {
|
||||
AuthenticationInfo authInfo = new AuthenticationInfo(authenticationService.getPrincipal());
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
return new ServiceContext(authInfo, userAndRoles);
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -168,7 +168,7 @@ public class NotebookRestApi extends AbstractRestApi {
|
|||
* Check if the current user own the given note.
|
||||
*/
|
||||
private void checkIfUserIsOwner(String noteId, String errorMsg) {
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
if (!authorizationService.isOwner(userAndRoles, noteId)) {
|
||||
|
|
@ -180,7 +180,7 @@ public class NotebookRestApi extends AbstractRestApi {
|
|||
* Check if the current user is either Owner or Writer for the given note.
|
||||
*/
|
||||
private void checkIfUserCanWrite(String noteId, String errorMsg) {
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
if (!authorizationService.hasWritePermission(userAndRoles, noteId)) {
|
||||
|
|
@ -192,7 +192,7 @@ public class NotebookRestApi extends AbstractRestApi {
|
|||
* Check if the current user can access (at least he have to be reader) the given note.
|
||||
*/
|
||||
private void checkIfUserCanRead(String noteId, String errorMsg) {
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
if (!authorizationService.hasReadPermission(userAndRoles, noteId)) {
|
||||
|
|
@ -204,7 +204,7 @@ public class NotebookRestApi extends AbstractRestApi {
|
|||
* Check if the current user can run the given note.
|
||||
*/
|
||||
private void checkIfUserCanRun(String noteId, String errorMsg) {
|
||||
Set<String> userAndRoles = Sets.newHashSet();
|
||||
Set<String> userAndRoles = new HashSet<>();
|
||||
userAndRoles.add(authenticationService.getPrincipal());
|
||||
userAndRoles.addAll(authenticationService.getAssociatedRoles());
|
||||
if (!authorizationService.hasRunPermission(userAndRoles, noteId)) {
|
||||
|
|
@ -267,28 +267,28 @@ public class NotebookRestApi extends AbstractRestApi {
|
|||
// Set readers, if runners, writers and owners is empty -> set to user requesting the change
|
||||
if (readers != null && !readers.isEmpty()) {
|
||||
if (runners.isEmpty()) {
|
||||
runners = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
runners = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
if (writers.isEmpty()) {
|
||||
writers = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
writers = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
if (owners.isEmpty()) {
|
||||
owners = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
owners = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
}
|
||||
// Set runners, if writers and owners is empty -> set to user requesting the change
|
||||
if (runners != null && !runners.isEmpty()) {
|
||||
if (writers.isEmpty()) {
|
||||
writers = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
writers = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
if (owners.isEmpty()) {
|
||||
owners = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
owners = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
}
|
||||
// Set writers, if owners is empty -> set to user requesting the change
|
||||
if (writers != null && !writers.isEmpty()) {
|
||||
if (owners.isEmpty()) {
|
||||
owners = Sets.newHashSet(authenticationService.getPrincipal());
|
||||
owners = new HashSet<>(Arrays.asList(authenticationService.getPrincipal()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,24 +16,21 @@
|
|||
*/
|
||||
package org.apache.zeppelin.server;
|
||||
|
||||
import static com.google.common.base.Charsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* Resource for enabling html addons in index.html.
|
||||
|
|
@ -59,10 +56,7 @@ public class HtmlAddonResource extends Resource {
|
|||
this.indexResource = indexResource;
|
||||
try {
|
||||
// read original content from resource
|
||||
String content;
|
||||
try (final Reader reader = new InputStreamReader(indexResource.getInputStream())) {
|
||||
content = CharStreams.toString(reader);
|
||||
}
|
||||
String content = IOUtils.toString(indexResource.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
// process body addon
|
||||
if (bodyAddon != null) {
|
||||
|
|
@ -86,14 +80,14 @@ public class HtmlAddonResource extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
this.alteredContent = content.getBytes(UTF_8);
|
||||
this.alteredContent = content.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
// only relevant in development mode: create altered temp file (as zeppelin web archives are addressed via local
|
||||
// filesystem folders)
|
||||
if (indexResource.getFile() != null) {
|
||||
this.alteredTempFile = File.createTempFile(HTML_ADDON_IDENTIFIER, ".html");
|
||||
this.alteredTempFile.deleteOnExit();
|
||||
Files.write(this.alteredContent, this.alteredTempFile);
|
||||
FileUtils.writeByteArrayToFile(this.alteredTempFile, this.alteredContent);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package org.apache.zeppelin.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -74,7 +74,7 @@ public class InterpreterService {
|
|||
final DependencyResolver dependencyResolver = new DependencyResolver(localRepoPath);
|
||||
|
||||
// TODO(jl): Make a rule between an interpreter name and an installation directory
|
||||
List<String> possibleInterpreterDirectories = Lists.newArrayList();
|
||||
List<String> possibleInterpreterDirectories = new ArrayList<>();
|
||||
possibleInterpreterDirectories.add(interpreterName);
|
||||
if (interpreterName.startsWith(ZEPPELIN_ARTIFACT_PREFIX)) {
|
||||
possibleInterpreterDirectories.add(interpreterName.replace(ZEPPELIN_ARTIFACT_PREFIX, ""));
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
package org.apache.zeppelin.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -45,7 +45,7 @@ public class NoAuthenticationService implements AuthenticationService {
|
|||
|
||||
@Override
|
||||
public Set<String> getAssociatedRoles() {
|
||||
return Sets.newHashSet();
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -60,11 +60,11 @@ public class NoAuthenticationService implements AuthenticationService {
|
|||
|
||||
@Override
|
||||
public List<String> getMatchedUsers(String searchText, int numUsersToFetch) {
|
||||
return Lists.newArrayList();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedRoles() {
|
||||
return Lists.newArrayList();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import static org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars.ZEPPELIN_N
|
|||
import static org.apache.zeppelin.interpreter.InterpreterResult.Code.ERROR;
|
||||
import static org.apache.zeppelin.scheduler.Job.Status.ABORT;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -1166,8 +1165,8 @@ public class NotebookService {
|
|||
private void addNewParagraphIfLastParagraphIsExecuted(Note note, Paragraph p) {
|
||||
// if it's the last paragraph and not empty, let's add a new one
|
||||
boolean isTheLastParagraph = note.isLastParagraph(p.getId());
|
||||
if (!(Strings.isNullOrEmpty(p.getText()) ||
|
||||
Strings.isNullOrEmpty(p.getScriptText())) &&
|
||||
if (!(StringUtils.isEmpty(p.getText()) ||
|
||||
StringUtils.isEmpty(p.getScriptText())) &&
|
||||
isTheLastParagraph) {
|
||||
note.addNewParagraph(p.getAuthenticationInfo());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.zeppelin.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.security.Principal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -438,7 +437,7 @@ public class ShiroAuthenticationService implements AuthenticationService {
|
|||
userquery = String.format("SELECT %s FROM %s", username, tablename);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.error("Error while accessing dataSource for JDBC Realm", e);
|
||||
return Lists.newArrayList();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
package org.apache.zeppelin.socket;
|
||||
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -77,7 +75,7 @@ public class ConnectionManager {
|
|||
* noteSocketMap. This can be used to get information about websocket traffic and watch what
|
||||
* is going on.
|
||||
*/
|
||||
final Queue<NotebookSocket> watcherSockets = Queues.newConcurrentLinkedQueue();
|
||||
final Queue<NotebookSocket> watcherSockets = new ConcurrentLinkedQueue<>();
|
||||
|
||||
private final HashSet<String> collaborativeModeList = new HashSet<>();
|
||||
private final Boolean collaborativeModeEnable = ZeppelinConfiguration
|
||||
|
|
@ -311,7 +309,7 @@ public class ConnectionManager {
|
|||
}
|
||||
|
||||
public Set<String> getConnectedUsers() {
|
||||
Set<String> connectedUsers = Sets.newHashSet();
|
||||
Set<String> connectedUsers = new HashSet<>();
|
||||
for (NotebookSocket notebookSocket : connectedSockets) {
|
||||
connectedUsers.add(notebookSocket.getUser());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.zeppelin.socket;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
|
@ -29,7 +28,6 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -1586,8 +1584,8 @@ public class NotebookServer extends WebSocketServlet
|
|||
|
||||
// if it's the last paragraph and not empty, let's add a new one
|
||||
boolean isTheLastParagraph = p.getNote().isLastParagraph(paragraphId);
|
||||
if (!(Strings.isNullOrEmpty(p.getText()) ||
|
||||
Strings.isNullOrEmpty(p.getScriptText())) &&
|
||||
if (!(StringUtils.isEmpty(p.getText()) ||
|
||||
StringUtils.isEmpty(p.getScriptText())) &&
|
||||
isTheLastParagraph) {
|
||||
Paragraph newPara = p.getNote().addNewParagraph(p.getAuthenticationInfo());
|
||||
broadcastNewParagraph(p.getNote(), newPara);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.zeppelin.cluster;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
|
|
@ -440,7 +439,7 @@ public class ClusterEventTest extends ZeppelinServerMock {
|
|||
Thread.sleep(1000);
|
||||
checkClusterAuthEventListener();
|
||||
|
||||
Set<String> roles = Sets.newHashSet("admin");
|
||||
Set<String> roles = new HashSet<>(Arrays.asList("admin"));
|
||||
// set admin roles for both user1 and user2
|
||||
authorizationService.setRoles(user2Id, roles);
|
||||
// wait cluster sync event
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.zeppelin.recovery;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
|
@ -42,6 +41,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -61,7 +61,7 @@ public class RecoveryTest extends AbstractTestRestApi {
|
|||
public void init() throws Exception {
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_STORAGE_CLASS.getVarName(),
|
||||
FileSystemRecoveryStorage.class.getName());
|
||||
recoveryDir = Files.createTempDir();
|
||||
recoveryDir = Files.createTempDirectory("recovery").toFile();
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_DIR.getVarName(),
|
||||
recoveryDir.getAbsolutePath());
|
||||
startUp(RecoveryTest.class.getSimpleName());
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package org.apache.zeppelin.rest;
|
|||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
|
|
@ -54,13 +52,9 @@ public class ConfigurationsRestApiTest extends AbstractTestRestApi {
|
|||
Map<String, String> body = (Map<String, String>) resp.get("body");
|
||||
assertTrue(body.size() > 0);
|
||||
// it shouldn't have key/value pair which key contains "password"
|
||||
assertTrue(Iterators.all(body.keySet().iterator(), new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String key) {
|
||||
return !key.contains("password");
|
||||
}
|
||||
}
|
||||
));
|
||||
for (String key : body.keySet()) {
|
||||
assertTrue(!key.contains("password"));
|
||||
}
|
||||
get.close();
|
||||
}
|
||||
|
||||
|
|
@ -72,13 +66,9 @@ public class ConfigurationsRestApiTest extends AbstractTestRestApi {
|
|||
new TypeToken<Map<String, Object>>(){}.getType());
|
||||
Map<String, String> body = (Map<String, String>) resp.get("body");
|
||||
assertTrue(body.size() > 0);
|
||||
assertTrue(Iterators.all(body.keySet().iterator(), new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String key) {
|
||||
return !key.contains("password") && key.startsWith(prefix);
|
||||
}
|
||||
}
|
||||
));
|
||||
for (String key : body.keySet()) {
|
||||
assertTrue(!key.contains("password") && key.startsWith(prefix));
|
||||
}
|
||||
get.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,11 @@
|
|||
package org.apache.zeppelin.rest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
|
|
@ -33,7 +31,6 @@ import org.apache.http.util.EntityUtils;
|
|||
import org.apache.zeppelin.notebook.AuthorizationService;
|
||||
import org.apache.zeppelin.notebook.Notebook;
|
||||
import org.apache.zeppelin.rest.message.NoteJobStatus;
|
||||
import org.apache.zeppelin.service.AuthenticationService;
|
||||
import org.apache.zeppelin.utils.TestUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
|
@ -45,6 +42,7 @@ import org.junit.runners.MethodSorters;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -53,7 +51,6 @@ import java.util.Map;
|
|||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.notebook.Paragraph;
|
||||
import org.apache.zeppelin.server.ZeppelinServer;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
|
||||
/**
|
||||
|
|
@ -425,7 +422,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
|
|||
new TypeToken<Map<String, Object>>() {}.getType());
|
||||
List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body");
|
||||
//TODO(khalid): anonymous or specific user notes?
|
||||
HashSet<String> anonymous = Sets.newHashSet("anonymous");
|
||||
HashSet<String> anonymous = new HashSet<>(Arrays.asList("anonymous"));
|
||||
AuthorizationService authorizationService = TestUtils.getInstance(AuthorizationService.class);
|
||||
assertEquals("List notes are equal", TestUtils.getInstance(Notebook.class)
|
||||
.getAllNotes(note -> authorizationService.isReader(note.getId(), anonymous))
|
||||
|
|
|
|||
|
|
@ -21,15 +21,13 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
|
||||
public class HtmlAddonResourceTest {
|
||||
|
||||
private final static String TEST_BODY_ADDON = "<!-- foo -->";
|
||||
|
|
@ -42,10 +40,7 @@ public class HtmlAddonResourceTest {
|
|||
public void testZeppelinWebHtmlAddon() throws IOException {
|
||||
final Resource addonResource = getHtmlAddonResource(FILE_PATH_INDEX_HTML_ZEPPELIN_WEB);
|
||||
|
||||
final String content;
|
||||
try (final Reader reader = new InputStreamReader(addonResource.getInputStream())) {
|
||||
content = CharStreams.toString(reader);
|
||||
}
|
||||
final String content = IOUtils.toString(addonResource.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(content, containsString(TEST_BODY_ADDON));
|
||||
assertThat(content, containsString(TEST_HEAD_ADDON));
|
||||
|
|
@ -57,10 +52,7 @@ public class HtmlAddonResourceTest {
|
|||
public void testZeppelinWebAngularHtmlAddon() throws IOException {
|
||||
final Resource addonResource = getHtmlAddonResource(FILE_PATH_INDEX_HTML_ZEPPELIN_WEB_ANGULAR);
|
||||
|
||||
final String content;
|
||||
try (final Reader reader = new InputStreamReader(addonResource.getInputStream())) {
|
||||
content = CharStreams.toString(reader);
|
||||
}
|
||||
final String content = IOUtils.toString(addonResource.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(content, containsString(TEST_BODY_ADDON));
|
||||
assertThat(content, containsString(TEST_HEAD_ADDON));
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.zeppelin.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -30,20 +29,19 @@ import static org.mockito.Mockito.doCallRealMethod;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
|
|
@ -61,11 +59,9 @@ import org.apache.zeppelin.notebook.NoteManager;
|
|||
import org.apache.zeppelin.notebook.Notebook;
|
||||
import org.apache.zeppelin.notebook.Paragraph;
|
||||
import org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException;
|
||||
import org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepo;
|
||||
import org.apache.zeppelin.notebook.repo.VFSNotebookRepo;
|
||||
import org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService;
|
||||
import org.apache.zeppelin.notebook.scheduler.SchedulerService;
|
||||
import org.apache.zeppelin.search.LuceneSearch;
|
||||
import org.apache.zeppelin.search.SearchService;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
|
|
@ -76,7 +72,6 @@ import org.junit.Test;
|
|||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class NotebookServiceTest {
|
||||
|
||||
|
|
@ -94,7 +89,7 @@ public class NotebookServiceTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
notebookDir = Files.createTempDir().getAbsoluteFile();
|
||||
notebookDir = Files.createTempDirectory("notebookDir").toAbsolutePath().toFile();
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(),
|
||||
notebookDir.getAbsolutePath());
|
||||
ZeppelinConfiguration zeppelinConfiguration = ZeppelinConfiguration.create();
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ package org.apache.zeppelin.interpreter;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
|
@ -34,6 +32,7 @@ import java.util.Arrays;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -94,6 +93,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -123,15 +123,15 @@ public class InterpreterSettingManager implements NoteEventListener, ClusterEven
|
|||
* name --> InterpreterSetting
|
||||
*/
|
||||
private final Map<String, InterpreterSetting> interpreterSettingTemplates =
|
||||
Maps.newConcurrentMap();
|
||||
new ConcurrentHashMap<>();
|
||||
/**
|
||||
* This is used by creating and running Interpreters
|
||||
* id --> InterpreterSetting
|
||||
* TODO(zjffdu) change it to name --> InterpreterSetting
|
||||
*/
|
||||
private final Map<String, InterpreterSetting> interpreterSettings = Metrics.gaugeMapSize("interpreter.amount", Tags.empty(),
|
||||
Maps.newConcurrentMap());
|
||||
private final Map<String, List<Meter>> interpreterSettingsMeters = Maps.newConcurrentMap();
|
||||
new ConcurrentHashMap<>());
|
||||
private final Map<String, List<Meter>> interpreterSettingsMeters = new ConcurrentHashMap<>();
|
||||
|
||||
private final List<RemoteRepository> interpreterRepositories;
|
||||
private InterpreterOption defaultOption;
|
||||
|
|
@ -205,12 +205,12 @@ public class InterpreterSettingManager implements NoteEventListener, ClusterEven
|
|||
}
|
||||
|
||||
public void refreshInterpreterTemplates() {
|
||||
Set<String> installedInterpreters = Sets.newHashSet(interpreterSettingTemplates.keySet());
|
||||
Set<String> installedInterpreters = new HashSet<>(interpreterSettingTemplates.keySet());
|
||||
|
||||
try {
|
||||
LOGGER.info("Refreshing interpreter list");
|
||||
loadInterpreterSettingFromDefaultDir(false);
|
||||
Set<String> newlyAddedInterpreters = Sets.newHashSet(interpreterSettingTemplates.keySet());
|
||||
Set<String> newlyAddedInterpreters = new HashSet<>(interpreterSettingTemplates.keySet());
|
||||
newlyAddedInterpreters.removeAll(installedInterpreters);
|
||||
if(!newlyAddedInterpreters.isEmpty()) {
|
||||
saveToFile();
|
||||
|
|
@ -345,7 +345,7 @@ public class InterpreterSettingManager implements NoteEventListener, ClusterEven
|
|||
|
||||
public void saveToFile() throws IOException {
|
||||
InterpreterInfoSaving info = new InterpreterInfoSaving();
|
||||
info.interpreterSettings = Maps.newHashMap(interpreterSettings);
|
||||
info.interpreterSettings = new HashMap<>(interpreterSettings);
|
||||
info.interpreterRepositories = interpreterRepositories;
|
||||
configStorage.save(info);
|
||||
}
|
||||
|
|
@ -1104,7 +1104,7 @@ public class InterpreterSettingManager implements NoteEventListener, ClusterEven
|
|||
|
||||
@ManagedAttribute
|
||||
public Set<String> getRunningInterpreters() {
|
||||
Set<String> runningInterpreters = Sets.newHashSet();
|
||||
Set<String> runningInterpreters = new HashSet<>();
|
||||
for (Map.Entry<String, InterpreterSetting> entry : interpreterSettings.entrySet()) {
|
||||
for (ManagedInterpreterGroup mig : entry.getValue().getAllInterpreterGroups()) {
|
||||
if (null != mig.getRemoteInterpreterProcess()) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -214,10 +213,10 @@ public class AuthorizationService implements ClusterEventListener {
|
|||
if (noteAuth == null) {
|
||||
throw new IOException("No noteAuth found for noteId: " + noteId);
|
||||
}
|
||||
noteAuth.setReaders(Sets.newHashSet());
|
||||
noteAuth.setRunners(Sets.newHashSet());
|
||||
noteAuth.setWriters(Sets.newHashSet());
|
||||
noteAuth.setOwners(Sets.newHashSet());
|
||||
noteAuth.setReaders(new HashSet<>());
|
||||
noteAuth.setRunners(new HashSet<>());
|
||||
noteAuth.setWriters(new HashSet<>());
|
||||
noteAuth.setOwners(new HashSet<>());
|
||||
|
||||
if (broadcast) {
|
||||
broadcastClusterEvent(ClusterEvent.CLEAR_PERMISSION, noteId, null, null);
|
||||
|
|
@ -261,7 +260,7 @@ public class AuthorizationService implements ClusterEventListener {
|
|||
}
|
||||
|
||||
public Set<String> getRoles(String user) {
|
||||
return userRoles.getOrDefault(user, Sets.newHashSet());
|
||||
return userRoles.getOrDefault(user, new HashSet<>());
|
||||
}
|
||||
|
||||
public boolean isOwner(String noteId, Set<String> entities) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
|
|
@ -55,6 +54,7 @@ import java.io.IOException;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -908,8 +908,8 @@ public class Note implements JsonSerializable {
|
|||
private void snapshotAngularObjectRegistry(String user) {
|
||||
angularObjects = new HashMap<>();
|
||||
|
||||
List<InterpreterSetting> settings = getBindedInterpreterSettings(Lists.newArrayList(user));
|
||||
if (settings == null || settings.size() == 0) {
|
||||
List<InterpreterSetting> settings = getBindedInterpreterSettings(Arrays.asList(user));
|
||||
if (settings == null || settings.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -925,7 +925,7 @@ public class Note implements JsonSerializable {
|
|||
private void removeAllAngularObjectInParagraph(String user, String paragraphId) {
|
||||
angularObjects = new HashMap<>();
|
||||
|
||||
List<InterpreterSetting> settings = getBindedInterpreterSettings(Lists.newArrayList(user));
|
||||
List<InterpreterSetting> settings = getBindedInterpreterSettings(Arrays.asList(user));
|
||||
if (settings == null || settings.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
|
|
@ -53,10 +52,10 @@ public class NoteAuth {
|
|||
|
||||
public NoteAuth(String noteId, Map<String, Set<String>> permissions) {
|
||||
this.noteId = noteId;
|
||||
this.readers = permissions.getOrDefault("readers", Sets.newHashSet());
|
||||
this.writers = permissions.getOrDefault("writers", Sets.newHashSet());
|
||||
this.runners = permissions.getOrDefault("runners", Sets.newHashSet());
|
||||
this.owners = permissions.getOrDefault("owners", Sets.newHashSet());
|
||||
this.readers = permissions.getOrDefault("readers", new HashSet<>());
|
||||
this.writers = permissions.getOrDefault("writers", new HashSet<>());
|
||||
this.runners = permissions.getOrDefault("runners", new HashSet<>());
|
||||
this.owners = permissions.getOrDefault("owners", new HashSet<>());
|
||||
}
|
||||
|
||||
// used when creating new note
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.zeppelin.common.JsonSerializable;
|
||||
import org.apache.zeppelin.display.AngularObject;
|
||||
|
|
@ -62,8 +62,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Paragraph is a representation of an execution unit.
|
||||
|
|
@ -121,9 +119,9 @@ public class Paragraph extends JobWithProgressPoller<InterpreterResult> implemen
|
|||
public Paragraph(Paragraph p2) {
|
||||
super(p2.getId(), null);
|
||||
this.note = p2.note;
|
||||
this.settings.setParams(Maps.newHashMap(p2.settings.getParams()));
|
||||
this.settings.setForms(Maps.newLinkedHashMap(p2.settings.getForms()));
|
||||
this.setConfig(Maps.newHashMap(p2.getConfig()));
|
||||
this.settings.setParams(new HashMap<>(p2.settings.getParams()));
|
||||
this.settings.setForms(new LinkedHashMap<>(p2.settings.getForms()));
|
||||
this.setConfig(new HashMap<>(p2.getConfig()));
|
||||
this.setAuthenticationInfo(p2.getAuthenticationInfo());
|
||||
this.title = p2.title;
|
||||
this.text = p2.text;
|
||||
|
|
@ -319,7 +317,7 @@ public class Paragraph extends JobWithProgressPoller<InterpreterResult> implemen
|
|||
(Boolean) config.getOrDefault(InterpreterSetting.PARAGRAPH_CONFIG_CHECK_EMTPY, true);
|
||||
// don't skip paragraph when local properties is not empty.
|
||||
// local properties can customize the behavior of interpreter. e.g. %r.shiny(type=run)
|
||||
return checkEmptyConfig && Strings.isNullOrEmpty(scriptText) && localProperties.isEmpty();
|
||||
return checkEmptyConfig && StringUtils.isEmpty(scriptText) && localProperties.isEmpty();
|
||||
}
|
||||
|
||||
public boolean execute(boolean blocking) {
|
||||
|
|
@ -581,7 +579,7 @@ public class Paragraph extends JobWithProgressPoller<InterpreterResult> implemen
|
|||
// NOTE: function setConfig(...) will overwrite all configuration
|
||||
// Merge configuration, you need to use function mergeConfig(...)
|
||||
public void setConfig(Map<String, Object> config) {
|
||||
this.config = Maps.newHashMap(config);
|
||||
this.config = new HashMap<>(config);
|
||||
}
|
||||
|
||||
// [ZEPPELIN-3919] Paragraph config default value can be customized
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
|
|
@ -39,6 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -75,8 +74,7 @@ public class GitNotebookRepo extends VFSNotebookRepo implements NotebookRepoWith
|
|||
setNotebookDirectory(conf.getNotebookDir());
|
||||
|
||||
LOGGER.info("Opening a git repo at '{}'", this.rootNotebookFolder);
|
||||
Repository localRepo = new FileRepository(Joiner.on(File.separator)
|
||||
.join(this.rootNotebookFolder, ".git"));
|
||||
Repository localRepo = new FileRepository(String.join(File.separator, this.rootNotebookFolder, ".git"));
|
||||
if (!localRepo.getDirectory().exists()) {
|
||||
LOGGER.info("Git repo {} does not exist, creating a new one", localRepo.getDirectory());
|
||||
localRepo.create();
|
||||
|
|
@ -196,7 +194,7 @@ public class GitNotebookRepo extends VFSNotebookRepo implements NotebookRepoWith
|
|||
public List<Revision> revisionHistory(String noteId,
|
||||
String notePath,
|
||||
AuthenticationInfo subject) throws IOException {
|
||||
List<Revision> history = Lists.newArrayList();
|
||||
List<Revision> history = new ArrayList<>();
|
||||
String noteFileName = buildNoteFileName(noteId, notePath);
|
||||
LOGGER.debug("Listing history for {}:", noteFileName);
|
||||
try {
|
||||
|
|
@ -224,7 +222,7 @@ public class GitNotebookRepo extends VFSNotebookRepo implements NotebookRepoWith
|
|||
}
|
||||
return revisionNote;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
git.getRepository().close();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
|
|
@ -148,7 +147,7 @@ public class NotebookRepoSync implements NotebookRepoWithVersionControl {
|
|||
}
|
||||
|
||||
public List<NotebookRepoWithSettings> getNotebookRepos(AuthenticationInfo subject) {
|
||||
List<NotebookRepoWithSettings> reposSetting = Lists.newArrayList();
|
||||
List<NotebookRepoWithSettings> reposSetting = new ArrayList<>();
|
||||
|
||||
NotebookRepoWithSettings repoWithSettings;
|
||||
for (NotebookRepo repo : repos) {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
|
|
@ -39,6 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -78,7 +77,7 @@ public class OldGitNotebookRepo extends OldVFSNotebookRepo
|
|||
|
||||
localPath = getRootDir().getName().getPath();
|
||||
LOG.info("Opening a git repo at '{}'", localPath);
|
||||
Repository localRepo = new FileRepository(Joiner.on(File.separator).join(localPath, ".git"));
|
||||
Repository localRepo = new FileRepository(String.join(File.separator, localPath, ".git"));
|
||||
if (!localRepo.getDirectory().exists()) {
|
||||
LOG.info("Git repo {} does not exist, creating a new one", localRepo.getDirectory());
|
||||
localRepo.create();
|
||||
|
|
@ -161,7 +160,7 @@ public class OldGitNotebookRepo extends OldVFSNotebookRepo
|
|||
|
||||
@Override
|
||||
public List<Revision> revisionHistory(String noteId, AuthenticationInfo subject) {
|
||||
List<Revision> history = Lists.newArrayList();
|
||||
List<Revision> history = new ArrayList<>();
|
||||
LOG.debug("Listing history for {}:", noteId);
|
||||
try {
|
||||
Iterable<RevCommit> logs = git.log().addPath(noteId).call();
|
||||
|
|
@ -187,7 +186,7 @@ public class OldGitNotebookRepo extends OldVFSNotebookRepo
|
|||
}
|
||||
return revisionNote;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
git.getRepository().close();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.zeppelin.notebook.repo.zeppelinhub.websocket;
|
|||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -47,7 +48,6 @@ import org.eclipse.jetty.websocket.client.WebSocketClient;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ public class ZeppelinhubClient {
|
|||
|
||||
private ClientUpgradeRequest getConnectionRequest(String token) {
|
||||
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
||||
request.setCookies(Lists.newArrayList(new HttpCookie(TOKEN_HEADER, token)));
|
||||
request.setCookies(Arrays.asList(new HttpCookie(TOKEN_HEADER, token)));
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.protocol;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -25,7 +26,6 @@ import org.apache.zeppelin.common.Message.OP;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class ZeppelinhubMessage implements JsonSerializable {
|
|||
|
||||
public Object op;
|
||||
public Object data;
|
||||
public Map<String, String> meta = Maps.newHashMap();
|
||||
public Map<String, String> meta = new HashMap<>();
|
||||
|
||||
private ZeppelinhubMessage() {
|
||||
this.op = OP.LIST_NOTES;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.zeppelin.plugin;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.interpreter.launcher.InterpreterLauncher;
|
||||
import org.apache.zeppelin.interpreter.launcher.SparkInterpreterLauncher;
|
||||
|
|
@ -39,6 +38,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -57,13 +57,13 @@ public class PluginManager {
|
|||
|
||||
private Map<String, InterpreterLauncher> cachedLaunchers = new HashMap<>();
|
||||
|
||||
private List<String> builtinLauncherClassNames = Lists.newArrayList(
|
||||
private List<String> builtinLauncherClassNames = Arrays.asList(
|
||||
StandardInterpreterLauncher.class.getName(),
|
||||
SparkInterpreterLauncher.class.getName());
|
||||
private List<String> builtinNotebookRepoClassNames = Lists.newArrayList(
|
||||
private List<String> builtinNotebookRepoClassNames = Arrays.asList(
|
||||
VFSNotebookRepo.class.getName(),
|
||||
GitNotebookRepo.class.getName());
|
||||
private List<String> builtinOldNotebookRepoClassNames = Lists.newArrayList(
|
||||
private List<String> builtinOldNotebookRepoClassNames = Arrays.asList(
|
||||
OldVFSNotebookRepo.class.getName(),
|
||||
OldGitNotebookRepo.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -39,7 +38,7 @@ public class TicketContainer {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TicketContainer.class);
|
||||
|
||||
public static final Entry ANONYMOUS_ENTRY = new Entry("anonymous", "anonymous", Sets.newHashSet());
|
||||
public static final Entry ANONYMOUS_ENTRY = new Entry("anonymous", "anonymous", new HashSet<>());
|
||||
|
||||
public static class Entry {
|
||||
private final String ticket;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.zeppelin.interpreter.recovery;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
|
||||
|
|
@ -36,6 +35,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
@ -44,11 +44,12 @@ public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
|
|||
|
||||
private File recoveryDir = null;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_STORAGE_CLASS.getVarName(),
|
||||
FileSystemRecoveryStorage.class.getName());
|
||||
recoveryDir = Files.createTempDir();
|
||||
recoveryDir = Files.createTempDirectory("recoveryDir").toFile();
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_DIR.getVarName(), recoveryDir.getAbsolutePath());
|
||||
super.setUp();
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
|
|||
when(mockNotebook.getNote("note2")).thenReturn(note2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.zeppelin.display.AngularObject;
|
||||
import org.apache.zeppelin.display.ui.TextBox;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
|
|
@ -40,6 +39,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -197,7 +197,7 @@ public class NoteTest {
|
|||
p.setResult(new InterpreterResult(InterpreterResult.Code.SUCCESS, "1.6.2"));
|
||||
p.settings.getForms().put("textbox_1", new TextBox("name", "default_name"));
|
||||
p.settings.getParams().put("textbox_1", "my_name");
|
||||
note.getAngularObjects().put("ao_1", Lists.newArrayList(new AngularObject("name_1", "value_1", note.getId(), p.getId(), null)));
|
||||
note.getAngularObjects().put("ao_1", Arrays.asList(new AngularObject("name_1", "value_1", note.getId(), p.getId(), null)));
|
||||
|
||||
// test Paragraph Json
|
||||
Paragraph p2 = Paragraph.fromJson(p.toJson());
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.display.AngularObjectRegistry;
|
||||
|
|
@ -1090,7 +1089,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
new HashSet<>(Arrays.asList("user1"))));
|
||||
|
||||
// Test clearing of permissions
|
||||
authorizationService.setReaders(note.getId(), Sets.<String>newHashSet());
|
||||
authorizationService.setReaders(note.getId(), new HashSet<>());
|
||||
assertTrue(authorizationService.isReader(note.getId(),
|
||||
new HashSet<>(Arrays.asList("user2"))));
|
||||
assertTrue(authorizationService.isReader(note.getId(),
|
||||
|
|
@ -1103,7 +1102,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
public void testAuthorizationRoles() throws IOException {
|
||||
String user1 = "user1";
|
||||
String user2 = "user2";
|
||||
Set<String> roles = Sets.newHashSet("admin");
|
||||
Set<String> roles = new HashSet<>(Arrays.asList("admin"));
|
||||
// set admin roles for both user1 and user2
|
||||
authorizationService.setRoles(user1, roles);
|
||||
authorizationService.setRoles(user2, roles);
|
||||
|
|
@ -1112,23 +1111,23 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
|
||||
// check that user1 is owner, reader, runner and writer
|
||||
assertTrue(authorizationService.isOwner(note.getId(),
|
||||
Sets.newHashSet(user1)));
|
||||
new HashSet<>(Arrays.asList(user1))));
|
||||
assertTrue(authorizationService.isReader(note.getId(),
|
||||
Sets.newHashSet(user1)));
|
||||
new HashSet<>(Arrays.asList(user1))));
|
||||
assertTrue(authorizationService.isRunner(note.getId(),
|
||||
Sets.newHashSet(user2)));
|
||||
new HashSet<>(Arrays.asList(user2))));
|
||||
assertTrue(authorizationService.isWriter(note.getId(),
|
||||
Sets.newHashSet(user1)));
|
||||
new HashSet<>(Arrays.asList(user1))));
|
||||
|
||||
// since user1 and user2 both have admin role, user2 will be reader and writer as well
|
||||
assertFalse(authorizationService.isOwner(note.getId(),
|
||||
Sets.newHashSet(user2)));
|
||||
new HashSet<>(Arrays.asList(user2))));
|
||||
assertTrue(authorizationService.isReader(note.getId(),
|
||||
Sets.newHashSet(user2)));
|
||||
new HashSet<>(Arrays.asList(user2))));
|
||||
assertTrue(authorizationService.isRunner(note.getId(),
|
||||
Sets.newHashSet(user2)));
|
||||
new HashSet<>(Arrays.asList(user2))));
|
||||
assertTrue(authorizationService.isWriter(note.getId(),
|
||||
Sets.newHashSet(user2)));
|
||||
new HashSet<>(Arrays.asList(user2))));
|
||||
|
||||
// check that user1 has note listed in his workbench
|
||||
Set<String> user1AndRoles = authorizationService.getRoles(user1);
|
||||
|
|
@ -1431,22 +1430,22 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
public void testGetAllNotes() throws Exception {
|
||||
Note note1 = notebook.createNote("note1", anonymous);
|
||||
Note note2 = notebook.createNote("note2", anonymous);
|
||||
assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size());
|
||||
assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("anonymous")))).size());
|
||||
|
||||
authorizationService.setOwners(note1.getId(), Sets.newHashSet("user1"));
|
||||
authorizationService.setWriters(note1.getId(), Sets.newHashSet("user1"));
|
||||
authorizationService.setRunners(note1.getId(), Sets.newHashSet("user1"));
|
||||
authorizationService.setReaders(note1.getId(), Sets.newHashSet("user1"));
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size());
|
||||
assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1"))).size());
|
||||
authorizationService.setOwners(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
authorizationService.setWriters(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
authorizationService.setRunners(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
authorizationService.setReaders(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("anonymous")))).size());
|
||||
assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1")))).size());
|
||||
|
||||
authorizationService.setOwners(note2.getId(), Sets.newHashSet("user2"));
|
||||
authorizationService.setWriters(note2.getId(), Sets.newHashSet("user2"));
|
||||
authorizationService.setReaders(note2.getId(), Sets.newHashSet("user2"));
|
||||
authorizationService.setRunners(note2.getId(), Sets.newHashSet("user2"));
|
||||
assertEquals(0, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size());
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1"))).size());
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2"))).size());
|
||||
authorizationService.setOwners(note2.getId(), new HashSet<>(Arrays.asList("user2")));
|
||||
authorizationService.setWriters(note2.getId(), new HashSet<>(Arrays.asList("user2")));
|
||||
authorizationService.setReaders(note2.getId(), new HashSet<>(Arrays.asList("user2")));
|
||||
authorizationService.setRunners(note2.getId(), new HashSet<>(Arrays.asList("user2")));
|
||||
assertEquals(0, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("anonymous")))).size());
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1")))).size());
|
||||
assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2")))).size());
|
||||
notebook.removeNote(note1, AuthenticationInfo.ANONYMOUS);
|
||||
notebook.removeNote(note2, AuthenticationInfo.ANONYMOUS);
|
||||
}
|
||||
|
|
@ -1466,8 +1465,8 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
|
||||
@Test
|
||||
public void testGetAllNotesWithDifferentPermissions() throws IOException {
|
||||
List<Note> notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
List<Note> notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
List<Note> notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
List<Note> notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(0, notes1.size());
|
||||
assertEquals(0, notes2.size());
|
||||
|
||||
|
|
@ -1475,27 +1474,27 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
Note note1 = notebook.createNote("note1", new AuthenticationInfo("user1"));
|
||||
|
||||
// note is public since readers and writers empty
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
|
||||
authorizationService.setReaders(note1.getId(), Sets.newHashSet("user1"));
|
||||
authorizationService.setReaders(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
//note is public since writers empty
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
|
||||
authorizationService.setRunners(note1.getId(), Sets.newHashSet("user1"));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
authorizationService.setRunners(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
|
||||
authorizationService.setWriters(note1.getId(), Sets.newHashSet("user1"));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
authorizationService.setWriters(note1.getId(), new HashSet<>(Arrays.asList("user1")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(0, notes2.size());
|
||||
}
|
||||
|
|
@ -1506,8 +1505,8 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
assertTrue(conf.isNotebookPublic());
|
||||
assertTrue(authorizationService.isPublic());
|
||||
|
||||
List<Note> notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
List<Note> notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
List<Note> notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
List<Note> notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(0, notes1.size());
|
||||
assertEquals(0, notes2.size());
|
||||
|
||||
|
|
@ -1515,8 +1514,8 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
Note notePublic = notebook.createNote("note1", new AuthenticationInfo("user1"));
|
||||
|
||||
// both users have note
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
assertEquals(notes1.get(0).getId(), notePublic.getId());
|
||||
|
|
@ -1536,8 +1535,8 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
assertFalse(authorizationService.isPublic());
|
||||
|
||||
// check that still 1 note per user
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(1, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
|
||||
|
|
@ -1545,8 +1544,8 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
|
|||
Note notePrivate = notebook.createNote("note2", new AuthenticationInfo("user1"));
|
||||
|
||||
// only user1 have notePrivate right after creation
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1")));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2")));
|
||||
notes1 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user1"))));
|
||||
notes2 = notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), new HashSet<>(Arrays.asList("user2"))));
|
||||
assertEquals(2, notes1.size());
|
||||
assertEquals(1, notes2.size());
|
||||
assertEquals(true, notes1.contains(notePrivate));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import static org.mockito.Mockito.spy;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -65,8 +66,6 @@ import org.junit.rules.ExpectedException;
|
|||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class ParagraphTest extends AbstractInterpreterTest {
|
||||
|
||||
@Test
|
||||
|
|
@ -271,7 +270,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
when(mockInterpreterGroup.getAngularObjectRegistry()).thenReturn(mock(AngularObjectRegistry.class));
|
||||
when(mockInterpreterGroup.getResourcePool()).thenReturn(mock(ResourcePool.class));
|
||||
|
||||
List<InterpreterSetting> spyInterpreterSettingList = spy(Lists.<InterpreterSetting>newArrayList());
|
||||
List<InterpreterSetting> spyInterpreterSettingList = spy(new ArrayList<>());
|
||||
InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
|
||||
when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
|
||||
InterpreterOption mockInterpreterOption = mock(InterpreterOption.class);
|
||||
|
|
@ -294,7 +293,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
when(mockInterpreterResult.code()).thenReturn(Code.SUCCESS);
|
||||
|
||||
// Actual test
|
||||
List<InterpreterResultMessage> result1 = Lists.newArrayList();
|
||||
List<InterpreterResultMessage> result1 = new ArrayList<>();
|
||||
result1.add(new InterpreterResultMessage(Type.TEXT, "result1"));
|
||||
when(mockInterpreterResult.message()).thenReturn(result1);
|
||||
|
||||
|
|
@ -307,7 +306,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
when(mockInterpreter.interpret(anyString(), Mockito.<InterpreterContext>any())).thenReturn(mockInterpreterResult);
|
||||
when(mockInterpreterResult.code()).thenReturn(Code.SUCCESS);
|
||||
|
||||
List<InterpreterResultMessage> result2 = Lists.newArrayList();
|
||||
List<InterpreterResultMessage> result2 = new ArrayList<>();
|
||||
result2.add(new InterpreterResultMessage(Type.TEXT, "result2"));
|
||||
when(mockInterpreterResult.message()).thenReturn(result2);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class GitNotebookRepoTest {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GitNotebookRepoTest.class);
|
||||
|
||||
|
|
@ -68,7 +66,7 @@ public class GitNotebookRepoTest {
|
|||
zeppelinDir.mkdirs();
|
||||
new File(zeppelinDir, "conf").mkdirs();
|
||||
|
||||
notebooksDir = Joiner.on(File.separator).join(zpath, "notebook");
|
||||
notebooksDir = String.join(File.separator, zpath, "notebook");
|
||||
File notebookDir = new File(notebooksDir);
|
||||
notebookDir.mkdirs();
|
||||
|
||||
|
|
@ -93,7 +91,7 @@ public class GitNotebookRepoTest {
|
|||
@Test
|
||||
public void initNonemptyNotebookDir() throws IOException, GitAPIException {
|
||||
//given - .git does not exit
|
||||
File dotGit = new File(Joiner.on(File.separator).join(notebooksDir, ".git"));
|
||||
File dotGit = new File(String.join(File.separator, notebooksDir, ".git"));
|
||||
assertThat(dotGit.exists()).isEqualTo(false);
|
||||
|
||||
//when
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
|
|
@ -30,6 +29,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
|
@ -41,10 +41,11 @@ public class VFSNotebookRepoTest {
|
|||
|
||||
private ZeppelinConfiguration zConf;
|
||||
private VFSNotebookRepo notebookRepo;
|
||||
private File notebookDir = Files.createTempDir();
|
||||
private File notebookDir;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
notebookDir = Files.createTempDirectory("notebookDir").toFile();
|
||||
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(),
|
||||
notebookDir.getAbsolutePath());
|
||||
notebookRepo = new VFSNotebookRepo();
|
||||
|
|
|
|||
Loading…
Reference in a new issue