-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #633 from zhenlineo/4.0-default-db-for-update-rt
Better error message for default database routing table update
- Loading branch information
Showing
61 changed files
with
556 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
driver/src/main/java/org/neo4j/driver/internal/DatabaseName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed 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.neo4j.driver.internal; | ||
|
||
import java.util.Optional; | ||
|
||
public interface DatabaseName | ||
{ | ||
Optional<String> databaseName(); | ||
|
||
String description(); | ||
} |
67 changes: 67 additions & 0 deletions
67
driver/src/main/java/org/neo4j/driver/internal/DatabaseNameUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed 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.neo4j.driver.internal; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public final class DatabaseNameUtil | ||
{ | ||
static final String DEFAULT_DATABASE_NAME = null; | ||
public static final String SYSTEM_DATABASE_NAME = "system"; | ||
|
||
private static final DatabaseName DEFAULT_DATABASE = new DatabaseName() | ||
{ | ||
@Override | ||
public Optional<String> databaseName() | ||
{ | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public String description() | ||
{ | ||
return "<default database>"; | ||
} | ||
}; | ||
private static final DatabaseName SYSTEM_DATABASE = new InternalDatabaseName( SYSTEM_DATABASE_NAME ); | ||
|
||
public static DatabaseName defaultDatabase() | ||
{ | ||
return DEFAULT_DATABASE; | ||
} | ||
|
||
public static DatabaseName systemDatabase() | ||
{ | ||
return SYSTEM_DATABASE; | ||
} | ||
|
||
public static DatabaseName database( String name ) | ||
{ | ||
if ( Objects.equals( name, DEFAULT_DATABASE_NAME ) ) | ||
{ | ||
return defaultDatabase(); | ||
} | ||
else if ( Objects.equals( name, SYSTEM_DATABASE_NAME ) ) | ||
{ | ||
return systemDatabase(); | ||
} | ||
return new InternalDatabaseName( name ); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
driver/src/main/java/org/neo4j/driver/internal/InternalDatabaseName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed 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.neo4j.driver.internal; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class InternalDatabaseName implements DatabaseName | ||
{ | ||
private final String databaseName; | ||
|
||
InternalDatabaseName( String databaseName ) | ||
{ | ||
this.databaseName = requireNonNull( databaseName ); | ||
} | ||
|
||
@Override | ||
public Optional<String> databaseName() | ||
{ | ||
return Optional.of( databaseName ); | ||
} | ||
|
||
@Override | ||
public String description() | ||
{ | ||
return databaseName; | ||
} | ||
|
||
@Override | ||
public boolean equals( Object o ) | ||
{ | ||
if ( this == o ) | ||
{ | ||
return true; | ||
} | ||
if ( o == null || getClass() != o.getClass() ) | ||
{ | ||
return false; | ||
} | ||
InternalDatabaseName that = (InternalDatabaseName) o; | ||
return databaseName.equals( that.databaseName ); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash( databaseName ); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "InternalDatabaseName{" + "databaseName='" + databaseName + '\'' + '}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.