Skip to content

Commit

Permalink
fixed issue on copy database in case of database open without authent…
Browse files Browse the repository at this point in the history
…ication,issue #7761
  • Loading branch information
tglman committed Oct 3, 2017
1 parent 7154e82 commit a6c108c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,26 @@ public ODatabaseDocumentEmbedded openNoAuthenticate(String name, String user) {
embedded.init(config);
}
embedded.rebuildIndexes();
embedded.internalOpen(user, "nopwd", false);
embedded.callOnOpenListeners();
return embedded;
} catch (Exception e) {
throw OException.wrapException(new ODatabaseException("Cannot open database '" + name + "'"), e);
}
}

//** THIS IS COMMENTED OUT BECAUSE WE NEED BOTH (NO PASSWORD AND NO USER AUTHORIZATION CHECK).
// embedded.internalOpen(user, "nopwd", false);
////////////////////////////////////////////////////////////////////////////////////////////

public ODatabaseDocumentEmbedded openNoAuthorization(String name, String user) {
try {
final ODatabaseDocumentEmbedded embedded;
OrientDBConfig config = solveConfig(null);
synchronized (this) {
OAbstractPaginatedStorage storage = getOrInitStorage(name);
// THIS OPEN THE STORAGE ONLY THE FIRST TIME
storage.open(config.getConfigurations());
embedded = factory.newInstance(storage);
embedded.init(config);
}
embedded.rebuildIndexes();
embedded.callOnOpenListeners();
return embedded;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ public void drop() {
public ODatabaseDocumentInternal copy() {
ODatabaseDocumentEmbedded database = new ODatabaseDocumentEmbedded(storage);
database.init(config);
database.internalOpen(getUser().getName(), null, false);
String user;
if (getUser() != null) {
user = getUser().getName();
} else {
user = null;
}
database.internalOpen(user, null, false);
database.callOnOpenListeners();
this.activateOnCurrentThread();
return database;
Expand Down Expand Up @@ -352,7 +358,7 @@ public OResultSet query(String query, Object[] args) {
}
OResultSet original = statement.execute(this, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -365,7 +371,7 @@ public OResultSet query(String query, Map args) {
}
OResultSet original = statement.execute(this, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -375,7 +381,7 @@ public OResultSet command(String query, Object[] args) {
OStatement statement = OSQLEngine.parse(query, this);
OResultSet original = statement.execute(this, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -385,7 +391,7 @@ public OResultSet command(String query, Map args) {
OStatement statement = OSQLEngine.parse(query, this);
OResultSet original = statement.execute(this, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -395,7 +401,7 @@ public OResultSet execute(String language, String script, Object... args) {
OScriptExecutor executor = OCommandManager.instance().getScriptExecutor(language);
OResultSet original = executor.execute(this, script, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -405,7 +411,7 @@ public OResultSet execute(String language, String script, Map<String, ?> args) {
OScriptExecutor executor = OCommandManager.instance().getScriptExecutor(language);
OResultSet original = executor.execute(this, script, args);
OLocalResultSetLifecycleDecorator result = new OLocalResultSetLifecycleDecorator(original);
this.queryStarted(result.getQueryId(),result);
this.queryStarted(result.getQueryId(), result);
result.addLifecycleListener(this);
return result;
}
Expand All @@ -417,7 +423,7 @@ public OLocalResultSetLifecycleDecorator query(OExecutionPlan plan, Map<Object,

OLocalResultSet result = new OLocalResultSet((OInternalExecutionPlan) plan);
OLocalResultSetLifecycleDecorator decorator = new OLocalResultSetLifecycleDecorator(result);
this.queryStarted(decorator.getQueryId(),decorator);
this.queryStarted(decorator.getQueryId(), decorator);
decorator.addLifecycleListener(this);

return decorator;
Expand Down

0 comments on commit a6c108c

Please sign in to comment.