use of org.neo4j.shell.ShellException in project neo4j by neo4j.
the class Dbinfo method getDescription.
@Override
public String getDescription() {
final Kernel kernel;
try {
kernel = getKernel();
} catch (ShellException e) {
return e.getMessage();
}
MBeanServer mbeans = getPlatformMBeanServer();
StringBuilder result = new StringBuilder("Get runtime information about the Graph Database.\n" + "This uses the Neo4j management beans to get" + " information about the Graph Database.\n\n");
availableBeans(mbeans, kernel, result);
result.append("\n");
getUsage(result);
return result.toString();
}
use of org.neo4j.shell.ShellException in project neo4j by neo4j.
the class Rollback method exec.
@Override
protected Continuation exec(AppCommandParser parser, Session session, Output out) throws ShellException, RemoteException {
if (parser.getLineWithoutApp().trim().length() > 0) {
out.println("Error: ROLLBACK should be run without trailing arguments");
return Continuation.INPUT_COMPLETE;
}
KernelTransaction tx = Begin.currentTransaction(getServer());
if (tx == null) {
throw Commit.fail(session, "Not in a transaction");
}
session.remove(Variables.TX_COUNT);
tx.failure();
try {
tx.close();
} catch (TransactionFailureException e) {
throw new ShellException(e.getMessage());
}
out.println("Transaction rolled back");
return Continuation.INPUT_COMPLETE;
}
use of org.neo4j.shell.ShellException in project neo4j by neo4j.
the class Schema method sampleIndexes.
private void sampleIndexes(Label[] labels, String property, boolean sampleAll, boolean forceSample) throws ShellException {
IndexingService indexingService = getServer().getDb().getDependencyResolver().resolveDependency(IndexingService.class);
if (indexingService == null) {
throw new ShellException("Internal error: failed to resolve IndexingService");
}
IndexSamplingMode samplingMode = getSamplingMode(forceSample);
// Trigger sampling for all indices
if (sampleAll) {
indexingService.triggerIndexSampling(samplingMode);
return;
}
validateLabelsAndProperty(labels, property);
Statement statement = getServer().getStatement();
int labelKey = statement.readOperations().labelGetForName(labels[0].name());
int propertyKey = statement.readOperations().propertyKeyGetForName(property);
if (labelKey == -1) {
throw new ShellException("No label associated with '" + labels[0].name() + "' was found");
}
if (propertyKey == -1) {
throw new ShellException("No property associated with '" + property + "' was found");
}
try {
indexingService.triggerIndexSampling(SchemaDescriptorFactory.forLabel(labelKey, propertyKey), samplingMode);
} catch (IndexNotFoundKernelException e) {
throw new ShellException(e.getMessage());
}
}
use of org.neo4j.shell.ShellException in project neo4j by neo4j.
the class Set method getValueType.
private static ValueType getValueType(AppCommandParser parser) throws ShellException {
String type = parser.options().containsKey("t") ? parser.options().get("t") : String.class.getSimpleName();
ValueType valueType = NAME_TO_VALUE_TYPE.get(type);
if (valueType == null) {
throw new ShellException("Invalid value type '" + type + "'");
}
return valueType;
}
use of org.neo4j.shell.ShellException in project neo4j by neo4j.
the class Set method exec.
@Override
protected Continuation exec(AppCommandParser parser, Session session, Output out) throws ShellException {
boolean forProperty = parser.options().containsKey("p");
boolean forLabel = parser.options().containsKey("l");
if (forProperty || !forLabel) {
// Property
if (parser.arguments().size() < 2) {
throw new ShellException("Must supply key and value, " + "like: set title \"This is a my title\"");
}
String key = parser.arguments().get(0);
ValueType valueType = getValueType(parser);
Object value = parseValue(parser.arguments().get(1), valueType);
NodeOrRelationship thing = getCurrent(session);
thing.setProperty(key, value);
} else {
// Label
Node node = getCurrent(session).asNode();
for (Label label : parseLabels(parser)) {
node.addLabel(label);
}
}
return Continuation.INPUT_COMPLETE;
}
Aggregations