use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.
the class OInternalGraphImporter method runImport.
public void runImport(String inputFile, String dbURL) throws IOException, FileNotFoundException {
if (inputFile == null)
throw new OSystemException("needed an input file as first argument");
if (dbURL == null)
throw new OSystemException("needed an database location as second argument");
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbURL);
ODatabaseHelper.deleteDatabase(db, db.getStorage().getType());
OrientBaseGraph g = OrientGraphFactory.getNoTxGraphImplFactory().getGraph(dbURL);
System.out.println("Importing graph from file '" + inputFile + "' into database: " + g + "...");
final long startTime = System.currentTimeMillis();
OConsoleDatabaseApp console = new OGremlinConsole(new String[] { "import database " + inputFile }).setCurrentDatabase(g.getRawGraph());
console.run();
System.out.println("Imported in " + (System.currentTimeMillis() - startTime) + "ms. Vertexes: " + g.countVertices());
g.command(new OCommandSQL("alter database TIMEZONE 'GMT'")).execute();
g.command(new OCommandSQL("alter database LOCALECOUNTRY 'UK'")).execute();
g.command(new OCommandSQL("alter database LOCALELANGUAGE 'EN'")).execute();
g.shutdown();
}
use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method displayRecord.
@ConsoleCommand(aliases = { "display" }, description = "Display current record attributes", onlineHelp = "Console-Command-Display-Record")
public void displayRecord(@ConsoleParameter(name = "number", description = "The number of the record in the most recent result set") final String iRecordNumber) {
checkForDatabase();
if (iRecordNumber == null || currentResultSet == null)
checkCurrentObject();
else {
int recNumber = Integer.parseInt(iRecordNumber);
if (currentResultSet.size() == 0)
throw new OSystemException("No result set where to find the requested record. Execute a query first.");
if (currentResultSet.size() <= recNumber)
throw new OSystemException("The record requested is not part of current result set (0" + (currentResultSet.size() > 0 ? "-" + (currentResultSet.size() - 1) : "") + ")");
setCurrentRecord(recNumber);
}
dumpRecordDetails();
}
use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.
the class OChannelBinaryClientAbstract method createException.
@SuppressWarnings("unchecked")
private static RuntimeException createException(final String iClassName, final String iMessage, final Exception iPrevious) {
RuntimeException rootException = null;
Constructor<?> c = null;
try {
final Class<RuntimeException> excClass = (Class<RuntimeException>) Class.forName(iClassName);
if (iPrevious != null) {
try {
c = excClass.getConstructor(String.class, Throwable.class);
} catch (NoSuchMethodException e) {
c = excClass.getConstructor(String.class, Exception.class);
}
}
if (c == null)
c = excClass.getConstructor(String.class);
} catch (Exception e) {
// UNABLE TO REPRODUCE THE SAME SERVER-SIZE EXCEPTION: THROW AN IO EXCEPTION
rootException = OException.wrapException(new OSystemException(iMessage), iPrevious);
}
if (c != null)
try {
final Exception cause;
if (c.getParameterTypes().length > 1)
cause = (Exception) c.newInstance(iMessage, iPrevious);
else
cause = (Exception) c.newInstance(iMessage);
rootException = OException.wrapException(new OSystemException("Data processing exception"), cause);
} catch (InstantiationException ignored) {
} catch (IllegalAccessException ignored) {
} catch (InvocationTargetException ignored) {
}
return rootException;
}
use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.
the class OClientConnection method validateSession.
public void validateSession(byte[] tokenFromNetwork, OTokenHandler handler, ONetworkProtocolBinary protocol) {
if (tokenFromNetwork == null || tokenFromNetwork.length == 0) {
if (!protocols.contains(protocol))
throw new OTokenSecurityException("No valid session found, provide a token");
} else {
//IF the byte from the network are the same of the one i have a don't check them
if (tokenBytes != null && tokenBytes.length > 0) {
if (// SAME SESSION AND TOKEN DO
tokenBytes.equals(tokenFromNetwork))
return;
}
OToken token = null;
try {
if (tokenFromNetwork != null)
token = handler.parseBinaryToken(tokenFromNetwork);
} catch (Exception e) {
throw OException.wrapException(new OSystemException("Error on token parse"), e);
}
if (token == null || !token.getIsVerified()) {
cleanSession();
protocol.getServer().getClientConnectionManager().disconnect(this);
throw new OTokenSecurityException("The token provided is not a valid token, signature does not match");
}
if (!handler.validateBinaryToken(token)) {
cleanSession();
protocol.getServer().getClientConnectionManager().disconnect(this);
throw new OTokenSecurityException("The token provided is expired");
}
if (tokenBased == null) {
tokenBased = Boolean.TRUE;
}
if (!Arrays.equals(this.tokenBytes, tokenFromNetwork))
cleanSession();
this.tokenBytes = tokenFromNetwork;
this.token = token;
protocols.add(protocol);
}
}
use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.
the class OHttpUtils method getParameters.
protected static Map<String, String> getParameters(final String iURL) {
int begin = iURL.indexOf("?");
if (begin > -1) {
Map<String, String> params = new HashMap<String, String>();
String parameters = iURL.substring(begin + 1);
final String[] paramPairs = parameters.split("&");
for (String p : paramPairs) {
final String[] parts = p.split("=");
if (parts.length == 2)
try {
params.put(parts[0], URLDecoder.decode(parts[1], "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw OException.wrapException(new OSystemException("Can not parse HTTP parameters"), e);
}
}
return params;
}
return Collections.emptyMap();
}
Aggregations