Skip to content

Commit

Permalink
Add convenience method for Neo4jVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Sep 28, 2016
1 parent 2d2a1b4 commit 2551dc9
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private static void printOverview( File storeDir, Collection<Option<File[]>> nod
Collection<Option<File[]>> relationshipsFiles,
org.neo4j.unsafe.impl.batchimport.Configuration configuration )
{
System.out.println( "Neo4j version: " + Version.getKernel().getReleaseVersion() );
System.out.println( "Neo4j version: " + Version.getNeo4jVersion() );
System.out.println( "Importing the contents of these files into " + storeDir + ":" );
printInputFiles( "Nodes", nodesFiles );
printInputFiles( "Relationships", relationshipsFiles );
Expand Down Expand Up @@ -547,7 +547,7 @@ public int pageSize()
private static String manualReference( ManualPage page, Anchor anchor )
{
// Docs are versioned major.minor-suffix, so drop the patch version.
String[] versionParts = Version.getKernel().getReleaseVersion().split("-");
String[] versionParts = Version.getNeo4jVersion().split("-");
versionParts[0] = versionParts[0].substring(0, 3);
String docsVersion = String.join("-", versionParts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ public void shouldDisallowMultilineFieldsByDefault() throws Exception
@Test
public void shouldPrintReferenceLinkOnDataImportErrors() throws Exception
{
String[] versionParts = Version.getKernel().getReleaseVersion().split("-");
String[] versionParts = Version.getNeo4jVersion().split("-");
versionParts[0] = versionParts[0].substring(0, 3);
String docsVersion = String.join("-", versionParts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private Procedures setupProcedures( PlatformModule platform, CoreAPIAvailability
Log internalLog = platform.logging.getInternalLog( Procedures.class );

Procedures procedures = new Procedures(
new BuiltInProcedures( Version.getKernel().getReleaseVersion(), platform.databaseInfo.edition.toString()),
new BuiltInProcedures( Version.getNeo4jVersion(), platform.databaseInfo.edition.toString()),
pluginDir, internalLog );
platform.life.add( procedures );
platform.dependencies.satisfyDependency( procedures );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public DependencyResolver get()

private void publishPlatformInfo( UsageData sysInfo )
{
sysInfo.set( UsageDataKeys.version, Version.getKernel().getReleaseVersion() );
sysInfo.set( UsageDataKeys.revision, Version.getKernel().getVersion() );
sysInfo.set( UsageDataKeys.version, Version.getNeo4jVersion() );
sysInfo.set( UsageDataKeys.revision, Version.getKernelVersion() );
}

public LifeSupport createLife()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static String getKernelVersion()
return getKernel().getVersion();
}

public static String getNeo4jVersion()
{
return getKernel().getReleaseVersion();
}

private final String artifactId;
private final String title;
private final String vendor;
Expand Down Expand Up @@ -73,7 +78,7 @@ else if ( artifactId != null )

/**
* @return a detailed version string, including source control revision information if that is available, suitable
* for internal use, logging and debugging.
* for internal use, logging and debugging.
*/
public final String getVersion()
{
Expand All @@ -88,37 +93,6 @@ public String getReleaseVersion()
return releaseVersion;
}

/**
* @return the source control revision information, if that is available
*/
public final String getRevision()
{
StringBuilder result = new StringBuilder( getReleaseVersion() );
result.append( ':' ).append( getBranchName() ).append( ':' );
String build = getBuildNumber();
if ( !(build.startsWith( "${" ) || build.startsWith( "{" )) )
{
result.append( build ).append( '/' );
}
result.append( getCommitId() );
return result.toString();
}

protected String getBuildNumber()
{
return "{BuildNumber}";
}

protected String getCommitId()
{
return "{CommitId}";
}

protected String getBranchName()
{
return "{BranchName}";
}

protected Version( String artifactId, String version )
{
super( artifactId );
Expand Down Expand Up @@ -146,7 +120,7 @@ private String parseReleaseVersion( String fullVersion )
);

Matcher matcher = pattern.matcher( fullVersion );
if(matcher.matches())
if ( matcher.matches() )
{
return matcher.group( 1 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.security.AccessMode;
import org.neo4j.kernel.builtinprocs.ListIndexesProcedure;
import org.neo4j.kernel.internal.Version;
import org.neo4j.server.security.auth.AuthSubject;

import static java.util.Collections.singletonList;
Expand Down Expand Up @@ -284,6 +285,7 @@ public void listAllComponents() throws Throwable
readOperationsInNewTransaction().procedureCallRead( procedureName( "dbms", "components" ), new Object[0] );

// Then
assertThat( asList( stream ), contains( equalTo( new Object[]{"Neo4j Kernel", singletonList("dev"), "community"} ) ) );
assertThat( asList( stream ), contains(
equalTo( new Object[]{"Neo4j Kernel", singletonList( Version.getNeo4jVersion() ), "community"} ) ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ protected void serialize( MappingSerializer serializer )
serializer.putUri( "constraints", PATH_SCHEMA_CONSTRAINT );
serializer.putUri( "transaction", PATH_TRANSACTION );
serializer.putUri( "node_labels", PATH_LABELS );
serializer.putString( "neo4j_version", Version.getKernel().getReleaseVersion() );
serializer.putString( "neo4j_version", Version.getNeo4jVersion() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void start( String[] arguments, CtrlCHandler signalHandler )
if ( version )
{
String edition = StringUtils.capitalize( factory.getEdition().toLowerCase() );
out.printf( "Neo4j %s, version %s", edition, Version.getKernelVersion() );
out.printf( "Neo4j %s, version %s", edition, Version.getNeo4jVersion() );
}
else if ( (path != null && (port != null || name != null || host != null || pid != null))
|| (pid != null && host != null) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.neo4j.shell.ShellException;
import org.neo4j.shell.ShellServer;

import static org.neo4j.kernel.internal.Version.getKernel;

/**
* Can replace the prompt string (PS1) with common Bash variable interpretation,
* f.ex. "\h [\t] \W $ " would result in "shell [10:05:30] 1243 $"
Expand All @@ -51,8 +49,8 @@ public class BashVariableInterpreter
STATIC_REPLACERS.put( "@", new DateReplacer( "KK:mm aa" ) );
STATIC_REPLACERS.put( "A", new DateReplacer( "HH:mm" ) );
STATIC_REPLACERS.put( "u", new StaticReplacer( "user" ) );
STATIC_REPLACERS.put( "v", new StaticReplacer( getKernel().getReleaseVersion() ) );
STATIC_REPLACERS.put( "V", new StaticReplacer( getKernel().getVersion() ) );
STATIC_REPLACERS.put( "v", new StaticReplacer( Version.getNeo4jVersion() ) );
STATIC_REPLACERS.put( "V", new StaticReplacer( Version.getKernelVersion() ) );
}

private final Map<String, Replacer> localReplacers = new HashMap<String, Replacer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

import org.neo4j.kernel.internal.Version;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;

public class VersionIT
{
@Test
public void canGetKernelRevision() throws Exception
{
assertFalse( "Kernel revision not specified", "".equals( Version.getKernelVersion() ) );
assertNotEquals( "Kernel revision not specified", "", Version.getKernelVersion() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Config getConfig()

public String getNeo4jVersion()
{
return format( "%s", Version.getKernel().getReleaseVersion() );
return format( "%s", Version.getNeo4jVersion() );
}

public HostnamePort getServerAddress()
Expand Down

0 comments on commit 2551dc9

Please sign in to comment.