Skip to content

Commit

Permalink
Add checks to avoid wrong db drop from console
Browse files Browse the repository at this point in the history
Resolves: #8690
  • Loading branch information
luigidellaquila committed Dec 6, 2018
1 parent 23e878d commit ec15707
Showing 1 changed file with 9 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,12 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.config.OStorageConfiguration;
import com.orientechnologies.orient.core.config.OStorageEntryConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.db.OrientDBConfigBuilder;
import com.orientechnologies.orient.core.db.OrientDBInternal;
import com.orientechnologies.orient.core.db.OrientDBRemote;
import com.orientechnologies.orient.core.db.*;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.SimpleRecordReader;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
import com.orientechnologies.orient.core.db.tool.OBonsaiTreeRepair;
import com.orientechnologies.orient.core.db.tool.OCheckIndexTool;
import com.orientechnologies.orient.core.db.tool.ODatabaseCompare;
import com.orientechnologies.orient.core.db.tool.ODatabaseExport;
import com.orientechnologies.orient.core.db.tool.ODatabaseExportException;
import com.orientechnologies.orient.core.db.tool.ODatabaseImport;
import com.orientechnologies.orient.core.db.tool.ODatabaseImportException;
import com.orientechnologies.orient.core.db.tool.OGraphRepair;
import com.orientechnologies.orient.core.db.tool.*;
import com.orientechnologies.orient.core.exception.OConfigurationException;
import com.orientechnologies.orient.core.exception.ODatabaseException;
import com.orientechnologies.orient.core.exception.ORetryQueryException;
Expand Down Expand Up @@ -101,33 +88,11 @@
import com.orientechnologies.orient.server.config.OServerConfigurationManager;
import com.orientechnologies.orient.server.config.OServerUserConfiguration;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.*;
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class OConsoleDatabaseApp extends OrientConsole implements OCommandOutputListener, OProgressListener {
Expand Down Expand Up @@ -1195,10 +1160,15 @@ public void dropDatabase(

final String dbName = currentDatabase.getName();
currentDatabase.close();
if (storageType != null && !"plocal".equalsIgnoreCase(storageType)&& !"local".equalsIgnoreCase(storageType)&& !"memory".equalsIgnoreCase(storageType)) {
message("\n\nInvalid storage type for db: '" + storageType + "'");
return;
}
orientDB.drop(dbName);
currentDatabase = null;
currentDatabaseName = null;
message("\n\nDatabase '" + dbName + "' deleted successfully");

}

@ConsoleCommand(description = "Delete the specified database", onlineHelp = "Console-Command-Drop-Database")
Expand Down

0 comments on commit ec15707

Please sign in to comment.