You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by mi...@apache.org on 2017/08/04 13:37:51 UTC
[7/7] incubator-rya git commit: RYA-325 Renamed rya.console to
rya.shell. Closes #194
RYA-325 Renamed rya.console to rya.shell. Closes #194
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/2564ac0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/2564ac0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/2564ac0a
Branch: refs/heads/master
Commit: 2564ac0ab7f1f0bbfad88d1bf671b9e7b0eea1f0
Parents: ec74291
Author: jdasch <jd...@localhost.localdomain>
Authored: Thu Aug 3 14:53:41 2017 -0400
Committer: Aaron Mihalik <aa...@gmail.com>
Committed: Thu Aug 3 22:16:26 2017 -0400
----------------------------------------------------------------------
extras/pom.xml | 2 +-
extras/rya.console/.gitignore | 8 -
extras/rya.console/pom.xml | 221 ---------
.../src/main/assembly/binary-release.xml | 33 --
.../src/main/assembly/component-release.xml | 90 ----
.../src/main/config/log4j.properties | 35 --
.../rya.console/src/main/examples/Query1.sparql | 24 -
.../src/main/examples/example.script | 26 -
extras/rya.console/src/main/examples/triples.nt | 25 -
.../org/apache/rya/shell/RyaAdminCommands.java | 388 ---------------
.../org/apache/rya/shell/RyaBannerProvider.java | 97 ----
.../java/org/apache/rya/shell/RyaCommands.java | 166 -------
.../apache/rya/shell/RyaConnectionCommands.java | 166 -------
.../org/apache/rya/shell/RyaPromptProvider.java | 62 ---
.../rya/shell/RyaShellHistoryProvider.java | 51 --
.../org/apache/rya/shell/SharedShellState.java | 339 -------------
.../apache/rya/shell/util/ConnectorFactory.java | 67 ---
.../apache/rya/shell/util/ConsolePrinter.java | 85 ----
.../apache/rya/shell/util/InstallPrompt.java | 139 ------
.../rya/shell/util/InstanceNamesFormatter.java | 78 ---
.../org/apache/rya/shell/util/JLinePrompt.java | 211 ---------
.../apache/rya/shell/util/PasswordPrompt.java | 72 ---
.../rya/shell/util/RyaDetailsFormatter.java | 120 -----
.../org/apache/rya/shell/util/SparqlPrompt.java | 82 ----
.../apache/rya/shell/util/UninstallPrompt.java | 58 ---
.../rya.console/src/main/resources/LICENSE.txt | 16 -
.../META-INF/spring/spring-shell-plugin.xml | 50 --
extras/rya.console/src/main/scripts/rya | 33 --
.../apache/rya/shell/RyaAdminCommandsTest.java | 474 -------------------
.../org/apache/rya/shell/RyaCommandsTest.java | 278 -----------
.../rya/shell/RyaConnectionCommandsIT.java | 250 ----------
.../apache/rya/shell/RyaPromptProviderTest.java | 80 ----
.../org/apache/rya/shell/RyaShellITBase.java | 102 ----
.../apache/rya/shell/SharedShellStateTest.java | 167 -------
.../rya/shell/util/ConnectorFactoryIT.java | 57 ---
.../shell/util/InstanceNamesFormatterTest.java | 81 ----
.../rya/shell/util/RyaDetailsFormatterTest.java | 111 -----
.../src/test/resources/Query1.sparql | 20 -
.../src/test/resources/RyaShellTest-context.xml | 63 ---
extras/shell/.gitignore | 8 +
extras/shell/pom.xml | 223 +++++++++
.../shell/src/main/assembly/binary-release.xml | 33 ++
.../src/main/assembly/component-release.xml | 90 ++++
extras/shell/src/main/config/log4j.properties | 35 ++
extras/shell/src/main/examples/Query1.sparql | 24 +
extras/shell/src/main/examples/example.script | 26 +
extras/shell/src/main/examples/triples.nt | 25 +
.../org/apache/rya/shell/RyaAdminCommands.java | 388 +++++++++++++++
.../org/apache/rya/shell/RyaBannerProvider.java | 97 ++++
.../java/org/apache/rya/shell/RyaCommands.java | 166 +++++++
.../apache/rya/shell/RyaConnectionCommands.java | 166 +++++++
.../org/apache/rya/shell/RyaPromptProvider.java | 62 +++
.../rya/shell/RyaShellHistoryProvider.java | 51 ++
.../org/apache/rya/shell/SharedShellState.java | 339 +++++++++++++
.../apache/rya/shell/util/ConnectorFactory.java | 67 +++
.../apache/rya/shell/util/ConsolePrinter.java | 85 ++++
.../apache/rya/shell/util/InstallPrompt.java | 139 ++++++
.../rya/shell/util/InstanceNamesFormatter.java | 78 +++
.../org/apache/rya/shell/util/JLinePrompt.java | 211 +++++++++
.../apache/rya/shell/util/PasswordPrompt.java | 72 +++
.../rya/shell/util/RyaDetailsFormatter.java | 120 +++++
.../org/apache/rya/shell/util/SparqlPrompt.java | 82 ++++
.../apache/rya/shell/util/UninstallPrompt.java | 58 +++
extras/shell/src/main/resources/LICENSE.txt | 16 +
.../META-INF/spring/spring-shell-plugin.xml | 50 ++
extras/shell/src/main/scripts/rya | 33 ++
.../apache/rya/shell/RyaAdminCommandsTest.java | 474 +++++++++++++++++++
.../org/apache/rya/shell/RyaCommandsTest.java | 278 +++++++++++
.../rya/shell/RyaConnectionCommandsIT.java | 250 ++++++++++
.../apache/rya/shell/RyaPromptProviderTest.java | 80 ++++
.../org/apache/rya/shell/RyaShellITBase.java | 102 ++++
.../apache/rya/shell/SharedShellStateTest.java | 167 +++++++
.../rya/shell/util/ConnectorFactoryIT.java | 57 +++
.../shell/util/InstanceNamesFormatterTest.java | 81 ++++
.../rya/shell/util/RyaDetailsFormatterTest.java | 111 +++++
extras/shell/src/test/resources/Query1.sparql | 20 +
.../src/test/resources/RyaShellTest-context.xml | 63 +++
77 files changed, 4428 insertions(+), 4426 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/pom.xml
----------------------------------------------------------------------
diff --git a/extras/pom.xml b/extras/pom.xml
index a2c8d58..8823031 100644
--- a/extras/pom.xml
+++ b/extras/pom.xml
@@ -34,7 +34,7 @@ under the License.
<module>rya.prospector</module>
<module>rya.manual</module>
<module>rya.periodic.service</module>
- <module>rya.console</module>
+ <module>shell</module>
<module>indexing</module>
<module>rya.indexing.pcj</module>
<module>indexingExample</module>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/.gitignore
----------------------------------------------------------------------
diff --git a/extras/rya.console/.gitignore b/extras/rya.console/.gitignore
deleted file mode 100644
index 5d1172a..0000000
--- a/extras/rya.console/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/.classpath
-/.project
-.settings/
-target/
-/log.roo
-*.log
-
-/bin/
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/pom.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/pom.xml b/extras/rya.console/pom.xml
deleted file mode 100644
index dec339b..0000000
--- a/extras/rya.console/pom.xml
+++ /dev/null
@@ -1,221 +0,0 @@
-<?xml version='1.0'?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.extras</artifactId>
- <version>3.2.11-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>rya.console</artifactId>
- <name>Apache Rya Console</name>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>accumulo.rya</artifactId>
- <exclusions>
- <exclusion>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.indexing</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.pcj.fluo.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.fluo</groupId>
- <artifactId>fluo-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.shell</groupId>
- <artifactId>spring-shell</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- <version>4.1.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.accumulo</groupId>
- <artifactId>accumulo-minicluster</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.fluo</groupId>
- <artifactId>fluo-mini</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>accumulo.rya</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>spring-shell.log</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <!-- Automatically place Apache 2 license headers at the top of all of the project's Java files.
- Rat runs during the 'validate' lifecycle step, so it will fail the build before this one
- executes if any of the headers are missing. Run the build with rat turned off to add
- missing headers to the Java files. -->
- <plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <!-- We use a custome Apache 2.0 license because we do not include a copywrite section. -->
- <header>src/main/resources/LICENSE.txt</header>
- </configuration>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <goals>
- <goal>format</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Create an executable jar file for the shell. -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>META-INF/spring.handlers</resource>
- </transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>META-INF/spring.schemas</resource>
- </transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.springframework.shell.Bootstrap</mainClass>
- </transformer>
- </transformers>
- <filters>
- <filter>
- <!--
- Shading signed JARs will fail without this.
- http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
- -->
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>create-binary-distribution</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/binary-release.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!-- Generate Code Coverage report. -->
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>default-prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/assembly/binary-release.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/assembly/binary-release.xml b/extras/rya.console/src/main/assembly/binary-release.xml
deleted file mode 100644
index 374213f..0000000
--- a/extras/rya.console/src/main/assembly/binary-release.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
- <id>bin</id>
- <formats>
- <format>tar.gz</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <componentDescriptors>
- <componentDescriptor>src/main/assembly/component-release.xml</componentDescriptor>
- </componentDescriptors>
-</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/assembly/component-release.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/assembly/component-release.xml b/extras/rya.console/src/main/assembly/component-release.xml
deleted file mode 100644
index 72c74d1..0000000
--- a/extras/rya.console/src/main/assembly/component-release.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<component
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3 http://maven.apache.org/xsd/component-1.1.3.xsd">
- <fileSets>
- <fileSet>
- <directory>src/main/config</directory>
- <outputDirectory>conf</outputDirectory>
- <directoryMode>0755</directoryMode>
- <fileMode>0644</fileMode>
- <lineEnding>unix</lineEnding>
- <filtered>false</filtered>
- <includes>
- <include>*.properties</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/scripts</directory>
- <outputDirectory>bin</outputDirectory>
- <directoryMode>0755</directoryMode>
- <fileMode>0755</fileMode>
- <includes>
- <include>rya</include>
- </includes>
- <lineEnding>unix</lineEnding>
- <filtered>true</filtered>
- </fileSet>
- <fileSet>
- <directory>src/main/scripts</directory>
- <outputDirectory>bin</outputDirectory>
- <directoryMode>0755</directoryMode>
- <fileMode>0644</fileMode>
- <includes>
- <include>*.bat</include>
- </includes>
- <lineEnding>dos</lineEnding>
- <filtered>true</filtered>
- </fileSet>
- <fileSet>
- <directory>src/main/examples</directory>
- <outputDirectory>examples</outputDirectory>
- <directoryMode>0755</directoryMode>
- <fileMode>0644</fileMode>
- <!-- <includes> <include>*.script</include> </includes> -->
- <lineEnding>unix</lineEnding>
- <filtered>false</filtered>
- </fileSet>
-
- <!-- create an empty directory for log files -->
- <fileSet>
- <directory>src/main/assembly</directory>
- <outputDirectory>logs</outputDirectory>
- <directoryMode>755</directoryMode>
- <excludes>
- <exclude>*</exclude>
- </excludes>
- </fileSet>
-
-
- <fileSet>
- <directory>${project.build.directory}</directory>
- <outputDirectory>lib</outputDirectory>
- <directoryMode>755</directoryMode>
- <fileMode>0644</fileMode>
- <includes>
- <include>${project.artifactId}-${project.version}-shaded.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/config/log4j.properties
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/config/log4j.properties b/extras/rya.console/src/main/config/log4j.properties
deleted file mode 100644
index 49d6822..0000000
--- a/extras/rya.console/src/main/config/log4j.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Valid levels:
-# TRACE, DEBUG, INFO, WARN, ERROR and FATAL
-log4j.rootCategory=INFO, LOGFILE
-
-# LOGFILE is set to be a File appender using a PatternLayout.
-log4j.appender.LOGFILE=org.apache.log4j.FileAppender
-log4j.appender.LOGFILE.File=${rya.shell.home}logs/rya-shell.log
-#log4j.appender.LOGFILE.Threshold=DEBUG
-log4j.appender.LOGFILE.Append=true
-
-log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-
-#log4j.appender.LOGFILE.layout=org.apache.log4j.EnhancedPatternLayout
-#log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c{1.} - %m%n
-
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/examples/Query1.sparql
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/Query1.sparql b/extras/rya.console/src/main/examples/Query1.sparql
deleted file mode 100644
index 33619fb..0000000
--- a/extras/rya.console/src/main/examples/Query1.sparql
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
-SELECT ?thing ?name WHERE {
- ?thing <http://predicates#name> ?name .
- ?thing rdf:type <http://types#Monkey> .
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/examples/example.script
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/example.script b/extras/rya.console/src/main/examples/example.script
deleted file mode 100644
index 529ea61..0000000
--- a/extras/rya.console/src/main/examples/example.script
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-connect-accumulo --username accumulo_user --instanceName accumulo_instance --zookeepers zoo1,zoo2,zoo3,zoo4,zoo5
-install-with-parameters --instanceName rya_example_
-connect-rya --instance rya_example_
-#load-data --file examples/ontology.owl
-load-data --file examples/triples.nt
-sparql-query --file examples/Query1.sparql
-# uninstall
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/examples/triples.nt
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/triples.nt b/extras/rya.console/src/main/examples/triples.nt
deleted file mode 100644
index 38b6c6f..0000000
--- a/extras/rya.console/src/main/examples/triples.nt
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-<http://Thing1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Monkey> .
-<http://Thing1> <http://predicates#name> "Thing 1".
-<http://Thing2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Gorilla> .
-<http://Thing2> <http://predicates#name> "Thing 2".
-<http://Thing3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Monkey> .
-<http://Thing3> <http://predicates#name> "Thing 3".
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
deleted file mode 100644
index 9239dc7..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.rya.api.client.GetInstanceDetails;
-import org.apache.rya.api.client.Install.DuplicateInstanceNameException;
-import org.apache.rya.api.client.Install.InstallConfiguration;
-import org.apache.rya.api.client.InstanceDoesNotExistException;
-import org.apache.rya.api.client.RyaClient;
-import org.apache.rya.api.client.RyaClientException;
-import org.apache.rya.api.instance.RyaDetails;
-import org.apache.rya.shell.SharedShellState.ConnectionState;
-import org.apache.rya.shell.SharedShellState.ShellState;
-import org.apache.rya.shell.util.InstallPrompt;
-import org.apache.rya.shell.util.InstanceNamesFormatter;
-import org.apache.rya.shell.util.RyaDetailsFormatter;
-import org.apache.rya.shell.util.SparqlPrompt;
-import org.apache.rya.shell.util.UninstallPrompt;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-import org.springframework.stereotype.Component;
-
-import com.google.common.base.Optional;
-
-/**
- * Rya Shell commands that have to do with administrative tasks.
- */
-@Component
-public class RyaAdminCommands implements CommandMarker {
-
- public static final String CREATE_PCJ_CMD = "create-pcj";
- public static final String DELETE_PCJ_CMD = "delete-pcj";
- public static final String PRINT_INSTANCE_DETAILS_CMD = "print-instance-details";
- public static final String INSTALL_CMD = "install";
- public static final String INSTALL_PARAMETERS_CMD = "install-with-parameters";
- public static final String LIST_INSTANCES_CMD = "list-instances";
- public static final String UNINSTALL_CMD = "uninstall";
- public static final String ADD_USER_CMD = "add-user";
- public static final String REMOVE_USER_CMD = "remove-user";
-
- private final SharedShellState state;
- private final InstallPrompt installPrompt;
- private final SparqlPrompt sparqlPrompt;
- private final UninstallPrompt uninstallPrompt;
-
- /**
- * Constructs an instance of {@link RyaAdminCommands}.
- *
- * @param state - Holds shared state between all of the command classes. (not null)
- * @param installPrompt - Prompts a user for installation details. (not null)
- * @param sparqlPrompt - Prompts a user for a SPARQL query. (not null)
- * @param uninstallPrompt - Prompts a user when uninstalling. (not null)
- */
- @Autowired
- public RyaAdminCommands(
- final SharedShellState state,
- final InstallPrompt installPrompt,
- final SparqlPrompt sparqlPrompt,
- final UninstallPrompt uninstallPrompt) {
- this.state = requireNonNull( state );
- this.installPrompt = requireNonNull(installPrompt);
- this.sparqlPrompt = requireNonNull(sparqlPrompt);
- this.uninstallPrompt = requireNonNull(uninstallPrompt);
- }
-
- /**
- * Enables commands that only become available once the Shell has been connected to a Rya Storage.
- */
- @CliAvailabilityIndicator({
- LIST_INSTANCES_CMD,
- INSTALL_CMD })
- public boolean areStorageCommandsAvailable() {
- switch(state.getShellState().getConnectionState()) {
- case CONNECTED_TO_STORAGE:
- case CONNECTED_TO_INSTANCE:
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Enables commands that are always available once the Shell is connected to a Rya Instance.
- */
- @CliAvailabilityIndicator({
- PRINT_INSTANCE_DETAILS_CMD,
- UNINSTALL_CMD,
- ADD_USER_CMD,
- REMOVE_USER_CMD})
- public boolean areInstanceCommandsAvailable() {
- switch(state.getShellState().getConnectionState()) {
- case CONNECTED_TO_INSTANCE:
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
- */
- @CliAvailabilityIndicator({
- CREATE_PCJ_CMD,
- DELETE_PCJ_CMD })
- public boolean arePCJCommandsAvailable() {
- // The PCJ commands are only available if the Shell is connected to an instance of Rya
- // that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
- final ShellState shellState = state.getShellState();
- if(shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE) {
- final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
- final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
- try {
- final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails( ryaInstanceName );
- if(instanceDetails.isPresent()) {
- return instanceDetails.get().getPCJIndexDetails().isEnabled();
- }
- } catch (final RyaClientException e) {
- return false;
- }
- }
- return false;
- }
-
- @CliCommand(value = LIST_INSTANCES_CMD, help = "List the names of the installed Rya instances.")
- public String listInstances() {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final Optional<String> ryaInstance = shellState.getRyaInstanceName();
-
- try {
- // Sort the names alphabetically.
- final List<String> instanceNames = commands.getListInstances().listInstances();
- Collections.sort( instanceNames );
-
- final String report;
- final InstanceNamesFormatter formatter = new InstanceNamesFormatter();
- if(ryaInstance.isPresent()) {
- report = formatter.format(instanceNames, ryaInstance.get());
- } else {
- report = formatter.format(instanceNames);
- }
- return report;
-
- } catch (final RyaClientException e) {
- throw new RuntimeException("Can not list the Rya instances. Reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.")
- public String install() {
- // Fetch the commands that are connected to the store.
- final RyaClient commands = state.getShellState().getConnectedCommands().get();
-
- String instanceName = null;
- InstallConfiguration installConfig = null;
- try {
- boolean verified = false;
- while(!verified) {
- // Use the install prompt to fetch the user's installation options.
- instanceName = installPrompt.promptInstanceName();
- installConfig = installPrompt.promptInstallConfiguration(instanceName);
-
- // Verify the configuration is what the user actually wants to do.
- verified = installPrompt.promptVerified(instanceName, installConfig);
- }
-
- // Execute the command.
- commands.getInstall().install(instanceName, installConfig);
- return String.format("The Rya instance named '%s' has been installed.", instanceName);
-
- } catch(final DuplicateInstanceNameException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
- } catch (final IOException | RyaClientException e) {
- throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = INSTALL_PARAMETERS_CMD, help = "Create a new instance of Rya with command line parameters.")
- public String installWithParameters(
- @CliOption(key = {"instanceName"}, mandatory = true, help = "The name of the Rya instance to create.")
- final String instanceName,
-
- @CliOption(key = {"enableTableHashPrefix"}, mandatory = false, help = "Use Shard Balancing (improves streamed input write speeds).", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enableTableHashPrefix,
-
- @CliOption(key = {"enableEntityCentricIndex"}, mandatory = false, help = "Use Entity Centric Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enableEntityCentricIndex,
-
- @CliOption(key = {"enableFreeTextIndex"}, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enableFreeTextIndex,
-
- @CliOption(key = {"enableGeospatialIndex"}, mandatory = false, help = "Use Geospatial Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enableGeospatialIndex,
-
- @CliOption(key = {"enableTemporalIndex"}, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enableTemporalIndex,
-
- @CliOption(key = {"enablePcjIndex"}, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
- final boolean enablePcjIndex,
-
- @CliOption(key = {"fluoPcjAppName"}, mandatory = false, help = "Fluo Application Name for PCJ Index Updater (fluo app must be initialized and enablePcjIndex=true).")
- final String fluoPcjAppName
- ) {
-
- // Fetch the commands that are connected to the store.
- final RyaClient commands = state.getShellState().getConnectedCommands().get();
-
- try {
- final InstallConfiguration installConfig = InstallConfiguration.builder()
- .setEnableTableHashPrefix(enableTableHashPrefix)
- .setEnableEntityCentricIndex(enableEntityCentricIndex)
- .setEnableFreeTextIndex(enableFreeTextIndex)
- .setEnableGeoIndex(enableGeospatialIndex)
- .setEnableTemporalIndex(enableTemporalIndex)
- .setEnablePcjIndex(enablePcjIndex)
- .setFluoPcjAppName(fluoPcjAppName)
- .build();
-
- // Verify the configuration is what the user actually wants to do.
- if (!installPrompt.promptVerified(instanceName, installConfig)) {
- return "Skipping Installation.";
- }
-
- // Execute the command.
- commands.getInstall().install(instanceName, installConfig);
- return String.format("The Rya instance named '%s' has been installed.", instanceName);
-
- } catch(final DuplicateInstanceNameException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
- } catch (final IOException | RyaClientException e) {
- throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = PRINT_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.")
- public String printInstanceDetails() {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final String ryaInstance = shellState.getRyaInstanceName().get();
-
- try {
- final Optional<RyaDetails> details = commands.getGetInstanceDetails().getDetails(ryaInstance);
- if(details.isPresent()) {
- return new RyaDetailsFormatter().format(details.get());
- } else {
- return "This instance of Rya does not have a Rya Details table. Consider migrating to a newer version of Rya.";
- }
- } catch(final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
- } catch (final RyaClientException e) {
- throw new RuntimeException("Could not get the instance details. Reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = CREATE_PCJ_CMD, help = "Creates and starts the maintenance of a new PCJ using a Fluo application.")
- public String createPcj() {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final String ryaInstance = shellState.getRyaInstanceName().get();
-
- try {
- // Prompt the user for the SPARQL.
- final Optional<String> sparql = sparqlPrompt.getSparql();
- if (sparql.isPresent()) {
- // Execute the command.
- final String pcjId = commands.getCreatePCJ().createPCJ(ryaInstance, sparql.get());
- // Return a message that indicates the ID of the newly created ID.
- return String.format("The PCJ has been created. Its ID is '%s'.", pcjId);
- } else {
- return ""; // user aborted the SPARQL prompt.
- }
- } catch (final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
- } catch (final IOException | RyaClientException e) {
- throw new RuntimeException("Could not create the PCJ. Provided reasons: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = DELETE_PCJ_CMD, help = "Deletes and halts maintenance of a PCJ.")
- public String deletePcj(
- @CliOption(key = {"pcjId"}, mandatory = true, help = "The ID of the PCJ that will be deleted.")
- final String pcjId) {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final String ryaInstance = shellState.getRyaInstanceName().get();
-
- try {
- // Execute the command.
- commands.getDeletePCJ().deletePCJ(ryaInstance, pcjId);
- return "The PCJ has been deleted.";
-
- } catch (final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
- } catch (final RyaClientException e) {
- throw new RuntimeException("The PCJ could not be deleted. Provided reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = ADD_USER_CMD, help = "Adds an authorized user to the Rya instance.")
- public void addUser(
- @CliOption(key = {"username"}, mandatory = true, help = "The username of the user that will be granted access.")
- final String username) {
- // Fetch the Rya client that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient ryaClient = shellState.getConnectedCommands().get();
- final String ryaInstance = shellState.getRyaInstanceName().get();
-
- try {
- ryaClient.getAddUser().addUser(ryaInstance, username);
- } catch (final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
- } catch (final RyaClientException e) {
- throw new RuntimeException("The user's access could not be granted. Provided reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = REMOVE_USER_CMD, help = "Removes an authorized user from the Rya instance.")
- public void removeUser(
- @CliOption(key = {"username"}, mandatory = true, help = "The username of the user whose access will be revoked.")
- final String username) {
- // Fetch the Rya client that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient ryaClient = shellState.getConnectedCommands().get();
- final String ryaInstance = shellState.getRyaInstanceName().get();
-
- try {
- ryaClient.getRemoveUser().removeUser(ryaInstance, username);
- } catch (final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
- } catch (final RyaClientException e) {
- throw new RuntimeException("The user's access could not be revoked. Provided reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = UNINSTALL_CMD, help = "Uninstall an instance of Rya.")
- public String uninstall() {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final String ryaInstanceName = shellState.getRyaInstanceName().get();
-
- try {
- // Make sure the user meant to uninstall the Rya instance.
- if(!uninstallPrompt.promptAreYouSure(ryaInstanceName)) {
- return "Cancelled.";
- }
-
- // Perform the uninstall.
- commands.getUninstall().uninstall(ryaInstanceName);
-
- } catch (final InstanceDoesNotExistException e) {
- throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstanceName), e);
- } catch (final IOException | RyaClientException e) {
- throw new RuntimeException("The Rya instance could not be uninstalled. Provided reason: " + e.getMessage(), e);
- }
-
- return "The Rya instance named '" + ryaInstanceName +"' has been uninstalled.";
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaBannerProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaBannerProvider.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaBannerProvider.java
deleted file mode 100644
index 42581ed..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaBannerProvider.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import java.io.IOException;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.Ordered;
-import org.springframework.core.annotation.Order;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.plugin.support.DefaultBannerProvider;
-import org.springframework.stereotype.Component;
-
-/**
- * Customizes the Rya Shell's banner.
- */
-@Component
-@Order(Ordered.HIGHEST_PRECEDENCE)
-public class RyaBannerProvider extends DefaultBannerProvider implements CommandMarker {
- private final Logger log = LoggerFactory.getLogger(RyaBannerProvider.class);
-
- private static final String BANNER =
- " _____ _____ _ _ _ \n" +
- "| __ \\ / ____| | | | |\n" +
- "| |__) | _ __ _ | (___ | |__ ___| | |\n" +
- "| _ / | | |/ _` | \\___ \\| '_ \\ / _ \\ | |\n" +
- "| | \\ \\ |_| | (_| | ____) | | | | __/ | |\n" +
- "|_| \\_\\__, |\\__,_| |_____/|_| |_|\\___|_|_|\n" +
- " __/ | \n" +
- " |___/ ";
-
- private String version = null;
-
- @Override
- public String getBanner() {
- return BANNER + "\n" + getVersion() + "\n";
- }
-
- @Override
- public String getWelcomeMessage() {
- return "Welcome to the Rya Shell.\n" +
- "\n" +
- "Execute one of the connect commands to start interacting with an instance of Rya.\n" +
- "You may press tab at any time to see which of the commands are available.";
- }
-
- @Override
- public String getVersion() {
- if(version == null) {
- version = loadVersion();
- }
- return version;
- }
-
- /**
- * Loads the version number from the Rya Shell's MANIFEST.MF file.
- *
- * @return The version number of the Rya Shell.
- */
- private String loadVersion() {
- final String className = getClass().getSimpleName() + ".class";
- final String classPath = getClass().getResource( className ).toString();
-
- try {
- final URL classUrl = new URL(classPath);
- final JarURLConnection jarConnection = (JarURLConnection) classUrl.openConnection();
- final Manifest manifest = jarConnection.getManifest();
- final Attributes attributes = manifest.getMainAttributes();
- return attributes.getValue("Implementation-Version");
- } catch (final IOException e) {
- log.error("Could not load the application's version from it's manifest.", e);
- }
-
- return "UNKNOWN";
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
deleted file mode 100644
index 09ee410..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.text.DecimalFormat;
-import java.util.Objects;
-
-import org.apache.rya.api.client.RyaClient;
-import org.apache.rya.api.client.RyaClientException;
-import org.apache.rya.shell.SharedShellState.ShellState;
-import org.apache.rya.shell.util.ConsolePrinter;
-import org.apache.rya.shell.util.SparqlPrompt;
-import org.openrdf.rio.RDFFormat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-import org.springframework.stereotype.Component;
-
-import com.google.common.base.Optional;
-
-/**
- * Rya Shell commands that have to do with common tasks (loading and querying data)
- */
-@Component
-public class RyaCommands implements CommandMarker {
-
- private static final Logger log = LoggerFactory.getLogger(RyaCommands.class);
-
- public static final String LOAD_DATA_CMD = "load-data";
- public static final String SPARQL_QUERY_CMD = "sparql-query";
-
- private final SharedShellState state;
- private final SparqlPrompt sparqlPrompt;
- private final ConsolePrinter consolePrinter;
-
- /**
- * Constructs an instance of {@link RyaCommands}.
- *
- * @param state - Holds shared state between all of the command classes. (not null)
- * @param sparqlPrompt - Prompts a user for a SPARQL query. (not null)
- * @param consolePrinter - Allows the command to print feedback to the user. (not null)
- */
- @Autowired
- public RyaCommands(final SharedShellState state, final SparqlPrompt sparqlPrompt,
- final ConsolePrinter consolePrinter) {
- this.state = Objects.requireNonNull(state);
- this.sparqlPrompt = requireNonNull(sparqlPrompt);
- this.consolePrinter = Objects.requireNonNull(consolePrinter);
- }
-
- /**
- * Enables commands that are always available once the Shell is connected to a Rya Instance.
- */
- @CliAvailabilityIndicator({ LOAD_DATA_CMD, SPARQL_QUERY_CMD })
- public boolean areInstanceCommandsAvailable() {
- switch (state.getShellState().getConnectionState()) {
- case CONNECTED_TO_INSTANCE:
- return true;
- default:
- return false;
- }
- }
-
- @CliCommand(value = LOAD_DATA_CMD, help = "Loads RDF Statement data from a local file to the connected Rya instance.")
- public String loadData(
- @CliOption(key = { "file" }, mandatory = true, help = "A local file containing RDF Statements that is to be loaded.")
- final String file,
- @CliOption(key = { "format" }, mandatory = false, help = "The format of the supplied RDF Statements file. [RDF/XML, N-Triples, Turtle, N3, TriX, TriG, BinaryRDF, N-Quads, JSON-LD, RDF/JSON, RDFa]")
- final String format
- ) {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final Optional<String> ryaInstanceName = shellState.getRyaInstanceName();
- try {
- final long start = System.currentTimeMillis();
- final File rdfInputFile = new File(file);
-
- RDFFormat rdfFormat = null;
- if (format != null) {
- rdfFormat = RDFFormat.valueOf(format);
- if (rdfFormat == null) {
- throw new RuntimeException("Unsupported RDF Statement data input format: " + format);
- }
- }
- if (rdfFormat == null) {
- rdfFormat = RDFFormat.forFileName(rdfInputFile.getName());
- if (rdfFormat == null) {
- throw new RuntimeException("Unable to detect RDF Statement data input format for file: " + rdfInputFile);
- } else {
- consolePrinter.println("Detected RDF Format: " + rdfFormat);
- consolePrinter.flush();
- }
- }
- commands.getLoadStatementsFile().loadStatements(ryaInstanceName.get(), rdfInputFile.toPath(), rdfFormat);
-
- final String seconds = new DecimalFormat("0.0##").format((System.currentTimeMillis() - start) / 1000.0);
- return "Loaded the file: '" + file + "' successfully in " + seconds + " seconds.";
-
- } catch (final RyaClientException | IOException e) {
- log.error("Error", e);
- throw new RuntimeException("Can not load the RDF Statement data. Reason: " + e.getMessage(), e);
- }
- }
-
- @CliCommand(value = SPARQL_QUERY_CMD, help = "Executes the provided SPARQL Query on the connected Rya instance.")
- public String sparqlQuery(
- @CliOption(key = { "file" }, mandatory = false, help = "A local file containing the SPARQL Query that is to be read and executed.")
- final String file) {
- // Fetch the command that is connected to the store.
- final ShellState shellState = state.getShellState();
- final RyaClient commands = shellState.getConnectedCommands().get();
- final Optional<String> ryaInstanceName = shellState.getRyaInstanceName();
-
- try {
- // file option specified
- String sparqlQuery;
- if (file != null) {
- sparqlQuery = new String(Files.readAllBytes(new File(file).toPath()), StandardCharsets.UTF_8);
- consolePrinter.println("Loaded Query:");
- consolePrinter.println(sparqlQuery);
- } else {
- // No Options specified. Show the user the SPARQL Prompt
- final Optional<String> sparqlQueryOpt = sparqlPrompt.getSparql();
- if (sparqlQueryOpt.isPresent()) {
- sparqlQuery = sparqlQueryOpt.get();
- } else {
- return ""; // user aborted the SPARQL prompt.
- }
- }
-
- consolePrinter.println("Executing Query...");
- consolePrinter.flush();
- return commands.getExecuteSparqlQuery().executeSparqlQuery(ryaInstanceName.get(), sparqlQuery);
- } catch (final RyaClientException | IOException e) {
- log.error("Error", e);
- throw new RuntimeException("Can not execute the SPARQL Query. Reason: " + e.getMessage(), e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
deleted file mode 100644
index f5ba451..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.IOException;
-import java.nio.CharBuffer;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.rya.api.client.InstanceExists;
-import org.apache.rya.api.client.RyaClient;
-import org.apache.rya.api.client.RyaClientException;
-import org.apache.rya.api.client.accumulo.AccumuloConnectionDetails;
-import org.apache.rya.api.client.accumulo.AccumuloRyaClientFactory;
-import org.apache.rya.shell.SharedShellState.ConnectionState;
-import org.apache.rya.shell.util.ConnectorFactory;
-import org.apache.rya.shell.util.PasswordPrompt;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-import org.springframework.stereotype.Component;
-
-import com.google.common.base.Optional;
-
-/**
- * Spring Shell commands that manage the connection that is used by the shell.
- */
-@Component
-public class RyaConnectionCommands implements CommandMarker {
-
- // Command line commands.
- public static final String PRINT_CONNECTION_DETAILS_CMD = "print-connection-details";
- public static final String CONNECT_ACCUMULO_CMD = "connect-accumulo";
- public static final String CONNECT_INSTANCE_CMD = "connect-rya";
- public static final String DISCONNECT_COMMAND_NAME_CMD = "disconnect";
-
- private final SharedShellState sharedState;
- private final PasswordPrompt passwordPrompt;
-
- /**
- * Constructs an instance of {@link RyaConnectionCommands}.
- *
- * @param state - Holds shared state between all of the command classes. (not null)
- * @param passwordPrompt - Prompts the user for their password when connecting to a Rya store. (not null)
- */
- @Autowired
- public RyaConnectionCommands(final SharedShellState state, final PasswordPrompt passwordPrompt) {
- this.sharedState = requireNonNull( state );
- this.passwordPrompt = requireNonNull(passwordPrompt);
- }
-
- @CliAvailabilityIndicator({PRINT_CONNECTION_DETAILS_CMD})
- public boolean isPrintConnectionDetailsAvailable() {
- return true;
- }
-
- @CliAvailabilityIndicator({CONNECT_ACCUMULO_CMD})
- public boolean areConnectCommandsAvailable() {
- return sharedState.getShellState().getConnectionState() == ConnectionState.DISCONNECTED;
- }
-
- @CliAvailabilityIndicator({CONNECT_INSTANCE_CMD})
- public boolean isConnectToInstanceAvailable() {
- switch(sharedState.getShellState().getConnectionState()) {
- case CONNECTED_TO_STORAGE:
- case CONNECTED_TO_INSTANCE:
- return true;
- default:
- return false;
- }
- }
-
- @CliAvailabilityIndicator({DISCONNECT_COMMAND_NAME_CMD})
- public boolean isDisconnectAvailable() {
- return sharedState.getShellState().getConnectionState() != ConnectionState.DISCONNECTED;
- }
-
- @CliCommand(value = PRINT_CONNECTION_DETAILS_CMD, help = "Print information about the Shell's Rya storage connection.")
- public String printConnectionDetails() {
- final Optional<AccumuloConnectionDetails> detailsHolder = sharedState.getShellState().getConnectionDetails();
-
- if(detailsHolder.isPresent()) {
- final AccumuloConnectionDetails details = detailsHolder.get();
- return "The shell is connected to an instance of Accumulo using the following parameters:\n" +
- " Username: " + details.getUsername() + "\n" +
- " Instance Name: " + details.getInstanceName() + "\n" +
- " Zookeepers: " + details.getZookeepers();
- } else {
- return "The shell is not connected to anything.";
- }
- }
-
- @CliCommand(value = CONNECT_ACCUMULO_CMD, help = "Connect the shell to an instance of Accumulo.")
- public String connectToAccumulo(
- @CliOption(key = {"username"}, mandatory = true, help = "The username that will be used to connect to Accummulo.")
- final String username,
- @CliOption(key = {"instanceName"}, mandatory = true, help = "The name of the Accumulo instance that will be connected to.")
- final String instanceName,
- @CliOption(key = {"zookeepers"}, mandatory = true, help = "A comma delimited list of zookeeper server hostnames.")
- final String zookeepers
- ) {
-
- try {
- // Prompt the user for their password.
- final char[] password = passwordPrompt.getPassword();
- final Connector connector= new ConnectorFactory().connect(username, CharBuffer.wrap(password), instanceName, zookeepers);
-
- // Initialize the connected to Accumulo shared state.
- final AccumuloConnectionDetails accumuloDetails = new AccumuloConnectionDetails(username, password, instanceName, zookeepers);
- final RyaClient commands = AccumuloRyaClientFactory.build(accumuloDetails, connector);
- sharedState.connectedToAccumulo(accumuloDetails, commands);
-
- } catch(IOException | AccumuloException | AccumuloSecurityException e) {
- throw new RuntimeException("Could not connect to Accumulo. Reason: " + e.getMessage(), e);
- }
-
- return "Connected. You must select a Rya instance to interact with next.";
- }
-
- @CliCommand(value = CONNECT_INSTANCE_CMD, help = "Connect to a specific Rya instance")
- public void connectToInstance(
- @CliOption(key = {"instance"}, mandatory = true, help = "The name of the Rya instance the shell will interact with.")
- final String instance) {
- try {
- final InstanceExists instanceExists = sharedState.getShellState().getConnectedCommands().get().getInstanceExists();
-
- // TODO gracefully fail if that version doen't support it. maybe the list command should go ahead
-
- // Make sure the requested instance exists.
- if(!instanceExists.exists(instance)) {
- throw new RuntimeException(String.format("'%s' does not match an existing Rya instance.", instance));
- }
- } catch(final RyaClientException e) {
- throw new RuntimeException("Could not connect to Rya instance. Reason: " + e.getMessage(), e);
- }
-
- // Store the instance name in the shared state.
- sharedState.connectedToInstance(instance);
- }
-
- @CliCommand(value = DISCONNECT_COMMAND_NAME_CMD, help = "Disconnect the shell's Rya storage connection (Accumulo).")
- public void disconnect() {
- sharedState.disconnected();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaPromptProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaPromptProvider.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaPromptProvider.java
deleted file mode 100644
index ed5f261..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaPromptProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import static java.util.Objects.requireNonNull;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.Ordered;
-import org.springframework.core.annotation.Order;
-import org.springframework.shell.plugin.support.DefaultPromptProvider;
-import org.springframework.stereotype.Component;
-
-import org.apache.rya.shell.SharedShellState.ShellState;
-
-/**
- * Customizes the Rya Shell's prompt.
- */
-@Component
-@Order(Ordered.HIGHEST_PRECEDENCE)
-public class RyaPromptProvider extends DefaultPromptProvider {
-
- private final SharedShellState sharedState;
-
- @Autowired
- public RyaPromptProvider(final SharedShellState sharedState) {
- this.sharedState = requireNonNull(sharedState);
- }
-
- @Override
- public String getPrompt() {
- final ShellState state = sharedState.getShellState();
-
- switch(state.getConnectionState()) {
- case DISCONNECTED:
- return "rya> ";
- case CONNECTED_TO_STORAGE:
- return String.format("rya/%s> ", state.getConnectionDetails().get().getInstanceName());
- case CONNECTED_TO_INSTANCE:
- return String.format("rya/%s:%s> ",
- state.getConnectionDetails().get().getInstanceName(),
- state.getRyaInstanceName().get());
- default:
- return "rya> ";
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
deleted file mode 100644
index b4ade8f..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import java.io.File;
-
-import org.springframework.core.Ordered;
-import org.springframework.core.annotation.Order;
-import org.springframework.shell.plugin.HistoryFileNameProvider;
-import org.springframework.stereotype.Component;
-
-/**
- * Customizes the Rya Shell's history file.
- */
-@Component
-@Order(Ordered.HIGHEST_PRECEDENCE)
-public class RyaShellHistoryProvider implements HistoryFileNameProvider {
-
- public static final String RYA_SHELL_HISTORY_FILENAME = ".rya_shell_history";
-
- @Override
- public String getHistoryFileName() {
- final String userHome = System.getProperty("user.home");
- if(userHome == null) {
- return RYA_SHELL_HISTORY_FILENAME;
- } else {
- return new File(userHome, RYA_SHELL_HISTORY_FILENAME).getAbsolutePath();
- }
- }
-
- @Override
- public String getProviderName() {
- return this.getClass().getSimpleName();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/2564ac0a/extras/rya.console/src/main/java/org/apache/rya/shell/SharedShellState.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/SharedShellState.java b/extras/rya.console/src/main/java/org/apache/rya/shell/SharedShellState.java
deleted file mode 100644
index 526b031..0000000
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/SharedShellState.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.shell;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Objects;
-import java.util.concurrent.locks.ReentrantLock;
-
-import edu.umd.cs.findbugs.annotations.Nullable;
-import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import net.jcip.annotations.Immutable;
-import net.jcip.annotations.ThreadSafe;
-
-import com.google.common.base.Optional;
-
-import org.apache.rya.api.client.RyaClient;
-import org.apache.rya.api.client.accumulo.AccumuloConnectionDetails;
-
-/**
- * Holds values that are shared between the various Rya command classes.
- */
-@ThreadSafe
-@DefaultAnnotation(NonNull.class)
-public class SharedShellState {
- // The shared nature of this object means we shouldn't assume only a single thread is accessing it.
- private final ReentrantLock lock = new ReentrantLock();
-
- // The current state.
- private ShellState shellState = ShellState.builder()
- .setConnectionState( ConnectionState.DISCONNECTED )
- .build();
-
- /**
- * @return The values that define the state of the Rya Shell.
- */
- public ShellState getShellState() {
- lock.lock();
- try {
- return shellState;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * This method indicates a shift into the {@link ConnectionState#CONNECTED_TO_STORAGE} state.
- * <p/>
- * Store the values used by an Accumulo Rya Storage connection. This may
- * only be called when the shell is disconnected.
- *
- * @param connectionDetails - Metadata about the Accumulo connection. (not null)
- * @param connectedCommands - Rya Commands that will execute against the Accumulo instance. (not null)
- * @throws IllegalStateException Thrown if the shell is already connected to a Rya storage.
- */
- public void connectedToAccumulo(
- final AccumuloConnectionDetails connectionDetails,
- final RyaClient connectedCommands) throws IllegalStateException {
- requireNonNull(connectionDetails);
- requireNonNull(connectedCommands);
-
- lock.lock();
- try {
- // Ensure the Rya Shell is disconnected.
- if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) {
- throw new IllegalStateException("You must clear the old connection state before you may set a new connection state.");
- }
-
- // Store the connection details.
- shellState = ShellState.builder()
- .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE )
- .setAccumuloConnectionDetails( connectionDetails )
- .setConnectedCommands( connectedCommands )
- .build();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * This method indicates a shift into the {@link ConnectionState#CONNECTED_TO_INSTANCE} state.
- * <p/>
- * Store the name of the Rya instance all commands will be executed against.
- *
- * @param instanceName - The name of the Rya instance. (not null)
- * @throws IllegalStateException Thrown if the shell is disconnected.
- */
- public void connectedToInstance(final String instanceName) throws IllegalStateException {
- requireNonNull(instanceName);
-
- lock.lock();
- try {
- // Verify the Rya Shell is connected to a storage.
- if(shellState.getConnectionState() == ConnectionState.DISCONNECTED) {
- throw new IllegalStateException("You can not set a Rya Instance Name before connecting to a Rya Storage.");
- }
-
- // Set the instance name.
- shellState = ShellState.builder( shellState )
- .setConnectionState(ConnectionState.CONNECTED_TO_INSTANCE)
- .setRyaInstanceName( instanceName )
- .build();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * This method indicates a shift into the {@link DISCONNECTED} state.
- * <p/>
- * Clears all of the values associated with a Rya Storage/Instance connection.
- * If the shell is already disconnected, then this method does not do anything.
- */
- public void disconnected() {
- lock.lock();
- try {
- shellState = ShellState.builder()
- .setConnectionState(ConnectionState.DISCONNECTED)
- .build();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Enumerates the various states a Rya Shell may be in.
- */
- public static enum ConnectionState {
- /**
- * The shell is not connected to a Rya Storage.
- */
- DISCONNECTED,
-
- /**
- * The shell is connected to a Rya Storage, but a specific instance hasn't been set.
- */
- CONNECTED_TO_STORAGE,
-
- /**
- * The shell is connected to Rya Storage and a specific Rya Instance.
- */
- CONNECTED_TO_INSTANCE;
- }
-
- /**
- * Values that define the state of a Rya Shell.
- */
- @Immutable
- @DefaultAnnotation(NonNull.class)
- public static final class ShellState {
- // Indicates the state of the shell.
- private final ConnectionState connectionState;
-
- // Connection specific values.
- private final Optional<AccumuloConnectionDetails> connectionDetails;
- private final Optional<RyaClient> connectedCommands;
-
- // Instance specific values.
- private final Optional<String> instanceName;
-
- private ShellState(
- final ConnectionState connectionState,
- final Optional<AccumuloConnectionDetails> connectionDetails,
- final Optional<RyaClient> connectedCommands,
- final Optional<String> instanceName) {
- this.connectionState = requireNonNull(connectionState);
- this.connectionDetails = requireNonNull(connectionDetails);
- this.connectedCommands = requireNonNull(connectedCommands);
- this.instanceName = requireNonNull(instanceName);
- }
-
- /**
- * @return The {@link ConnectionState} of the Rya Shell.
- */
- public ConnectionState getConnectionState() {
- return connectionState;
- }
-
- /**
- * @return Metadata about the Accumulo connection. The value will not be present
- * if the Rya Shell is not connected to a storage.
- */
- public Optional<AccumuloConnectionDetails> getConnectionDetails() {
- return connectionDetails;
- }
-
- /**
- * @return The {@link RyaClient} to use when a command on the shell is issued.
- * The value will not be present if the Rya Shell is not connected to a storage.
- */
- public Optional<RyaClient> getConnectedCommands() {
- return connectedCommands;
- }
-
- /**
- * @return The name of the Rya Instance the Rya Shell is issuing commands to.
- * The value will not be present if the Rya Shell is not connected to a
- * storage or if a target instance has not been set yet.
- */
- public Optional<String> getRyaInstanceName() {
- return instanceName;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectionState, connectionDetails, connectedCommands, instanceName);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) {
- return true;
- }
- if(obj instanceof ShellState) {
- final ShellState state = (ShellState)obj;
- return Objects.equals(connectionState, state.connectionState) &&
- Objects.equals(connectionDetails, state.connectionDetails) &&
- Objects.equals(connectedCommands, state.connectedCommands) &&
- Objects.equals(instanceName, state.instanceName);
- }
- return false;
- }
-
- /**
- * @return An empty instance of {@link Builder}.
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Create an instance of {@link Builder} populated with the values of {code shellState}.
- *
- * @param shellState - The initial state of the Builder.
- * @return An instance of {@link Builder} populated with the values
- * of {code shellState}.
- */
- public static Builder builder(final ShellState shellState) {
- return new Builder(shellState);
- }
-
- /**
- * Builds instances of {@link ShellState}.
- */
- @DefaultAnnotation(NonNull.class)
- public static class Builder {
- private ConnectionState connectionState;
-
- // Connection specific values.
- private AccumuloConnectionDetails connectionDetails;
- private RyaClient connectedCommands;
-
- // Instance specific values.
- private String instanceName;
-
- /**
- * Constructs an empty instance of {@link Builder}.
- */
- public Builder() { }
-
- /**
- * Constructs an instance of {@builder} initialized with the values
- * of a {@link ShellState}.
- *
- * @param shellState - The initial state of the builder. (not null)
- */
- public Builder(final ShellState shellState) {
- this.connectionState = shellState.getConnectionState();
- this.connectionDetails = shellState.getConnectionDetails().orNull();
- this.connectedCommands = shellState.getConnectedCommands().orNull();
- this.instanceName = shellState.getRyaInstanceName().orNull();
- }
-
- /**
- * @param connectionState - The {@link ConnectionState} of the Rya Shell.
- * @return This {@link Builder} so that method invocations may be chained.
- */
- public Builder setConnectionState(@Nullable final ConnectionState connectionState) {
- this.connectionState = connectionState;
- return this;
- }
-
- /**
- * @param connectionDetails - Metadata about the Accumulo connection.
- * @return This {@link Builder} so that method invocations may be chained.
- */
- public Builder setAccumuloConnectionDetails(@Nullable final AccumuloConnectionDetails connectionDetails) {
- this.connectionDetails = connectionDetails;
- return this;
- }
-
- /**
- * @param connectedCommands - The {@link RyaClient} to use when a command on the shell is issued.
- * @return This {@link Builder} so that method invocations may be chained.
- */
- public Builder setConnectedCommands(@Nullable final RyaClient connectedCommands) {
- this.connectedCommands = connectedCommands;
- return this;
- }
-
- /**
- * @param instanceName - The name of the Rya Instance the Rya Shell is issuing commands to.
- * @return This {@link Builder} so that method invocations may be chained.
- */
- public Builder setRyaInstanceName(@Nullable final String instanceName) {
- this.instanceName = instanceName;
- return this;
- }
-
- /**
- * @return An instance of {@link ShellState} built using this builder's values.
- */
- public ShellState build() {
- return new ShellState(
- connectionState,
- Optional.fromNullable(connectionDetails),
- Optional.fromNullable(connectedCommands),
- Optional.fromNullable(instanceName));
- }
- }
- }
-}
\ No newline at end of file