private ProcedureException noSuchFunction( QualifiedName name ) { return new ProcedureException( Status.Procedure.ProcedureNotFound, "There is no function with the name `%s` registered for this database instance. " + "Please ensure you've spelled the function name correctly and that the " + "function is properly deployed.", name ); }
private ProcedureException noSuchProcedure( QualifiedName name ) { return new ProcedureException( Status.Procedure.ProcedureNotFound, "There is no procedure with the name `%s` registered for this database instance. " + "Please ensure you've spelled the procedure name correctly and that the " + "procedure is properly deployed.", name ); }
private ProcedureException noSuchFunction( int id ) { return new ProcedureException( Status.Procedure.ProcedureNotFound, "There is no function with the internal id `%d` registered for this database instance.", id ); }
private ProcedureException noSuchProcedure( int id ) { return new ProcedureException( Status.Procedure.ProcedureNotFound, "There is no procedure with the internal id `%d` registered for this database instance.", id ); }
public Object typeCheck( Object javaValue ) throws ProcedureException { if ( javaValue == null || javaClass.isInstance( javaValue ) ) { return javaValue; } throw new ProcedureException( Status.Procedure.ProcedureCallFailed, "Expected `%s` to be a `%s`, found `%s`.", javaValue, javaClass.getSimpleName(), javaValue.getClass() ); }
private ProcedureException javaToNeoMappingError( Type cls ) { List<String> types = Iterables.asList( javaToNeo.keySet() ) .stream() .map( Type::getTypeName ) .sorted( String::compareTo ) .collect( Collectors.toList() ); return new ProcedureException( Status.Statement.TypeError, "Don't know how to map `%s` to the Neo4j Type System.%n" + "Please refer to to the documentation for full details.%n" + "For your reference, known types are: %s", cls.getTypeName(), types ); }
private static void assertProviderNameNotNull( String providerName ) throws ProcedureException { if ( providerName == null ) { throw new ProcedureException( Status.Procedure.ProcedureCallFailed, indexProviderNullMessage() ); } }
private Object getValue( Object record ) throws ProcedureException { try { return getter.invoke( record ); } catch ( Throwable throwable ) { throw new ProcedureException( Status.Procedure.ProcedureCallFailed, throwable, "Unable to read value from record `%s`: %s", record, throwable.getMessage() ); } } }
@Override public <T> T get( Key<T> key ) throws ProcedureException { Object o = values.get( key.name() ); if ( o == null ) { throw new ProcedureException( Status.Procedure.ProcedureCallFailed, "There is no `%s` in the current procedure call context.", key.name() ); } return (T) o; }
private void validateSignature( String descriptiveName, List<FieldSignature> fields, String fieldType ) throws ProcedureException { Set<String> names = new HashSet<>(); for ( FieldSignature field : fields ) { if ( !names.add( field.name() ) ) { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, "Procedure `%s` cannot be registered, because it contains a duplicated " + fieldType + " field, '%s'. " + "You need to rename or remove one of the duplicate fields.", descriptiveName, field.name() ); } } }
private void waitUntilOnline( IndexReference index, IndexSpecifier indexDescription, long timeout, TimeUnit timeoutUnits ) throws ProcedureException { try { Predicates.awaitEx( () -> isOnline( indexDescription, index ), timeout, timeoutUnits ); } catch ( TimeoutException e ) { throw new ProcedureException( Status.Procedure.ProcedureTimedOut, "Index on %s did not come online within %s %s", indexDescription, timeout, timeoutUnits ); } }
private int getLabelId( String labelName ) throws ProcedureException { int labelId = ktx.tokenRead().nodeLabel( labelName ); if ( labelId == TokenRead.NO_TOKEN ) { throw new ProcedureException( Status.Schema.LabelAccessFailed, "No such label %s", labelName ); } return labelId; }
private String getFailure( IndexSpecifier indexDescription, IndexReference index ) throws ProcedureException { try { return ktx.schemaRead().indexGetFailure( index ); } catch ( IndexNotFoundKernelException e ) { throw new ProcedureException( Status.Schema.IndexNotFound, e, "No such index %s", indexDescription ); } }
private InternalIndexState getState( IndexSpecifier specifier, IndexReference index ) throws ProcedureException { try { return ktx.schemaRead().indexGetState( index ); } catch ( IndexNotFoundKernelException e ) { throw new ProcedureException( Status.Schema.IndexNotFound, e, "No such index %s", specifier ); } }
@Override public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, signature().description().orElse( "Failed to load " + signature().name() ) ); } }
private static void rejectEmptyNamespace( QualifiedName name ) throws ProcedureException { if ( name.namespace() == null || name.namespace().length == 0 ) { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, "It is not allowed to define functions in the root namespace please use a namespace, " + "e.g. `@UserFunction(\"org.example.com.%s\")", name.name() ); } }
@Override public UserAggregator create( Context ctx ) throws ProcedureException { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, signature().description().orElse( "Failed to load " + signature().name() ) ); } }
@Override public AnyValue apply( Context ctx, AnyValue[] input ) throws ProcedureException { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, signature().description().orElse( "Failed to load " + signature().name() ) ); } }
private int getOrCreateLabelId( String labelName ) throws ProcedureException { try { return ktx.tokenWrite().labelGetOrCreateForName( labelName ); } catch ( TooManyLabelsException | IllegalTokenNameException e ) { throw new ProcedureException( e.status(), e, e.getMessage() ); } }
public void resampleIndex( String indexSpecification ) throws ProcedureException { IndexSpecifier specifier = IndexSpecifier.byPattern( indexSpecification ); try { triggerSampling( getIndex( specifier ) ); } catch ( IndexNotFoundKernelException e ) { throw new ProcedureException( e.status(), e.getMessage(), e ); } }