use of org.apache.derby.io.StorageFactory in project derby by apache.
the class BasicDatabase method backupLucene.
/**
* <p>
* Backup Lucene indexes to the backup directory. This assumes
* that the rest of the database has been backup up and sanity
* checks have been run.
* </p>
*/
private void backupLucene(String backupDir) throws StandardException {
try {
File backupRoot = new File(backupDir);
StorageFactory storageFactory = getStorageFactory();
String canonicalDbName = storageFactory.getCanonicalName();
String dbname = StringUtil.shortDBName(canonicalDbName, storageFactory.getSeparator());
File backupDB = new File(backupRoot, dbname);
final File targetDir = new File(backupDB, Database.LUCENE_DIR);
final StorageFile sourceDir = getLuceneDir();
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Boolean run() throws StandardException {
if (!FileUtil.copyDirectory(getStorageFactory(), sourceDir, targetDir, null, null, true)) {
throw StandardException.newException(SQLState.UNABLE_TO_COPY_FILE_FROM_BACKUP, sourceDir.getPath(), targetDir.getAbsolutePath());
}
return null;
}
});
} catch (IOException ioe) {
throw StandardException.plainWrapException(ioe);
} catch (PrivilegedActionException pae) {
throw StandardException.plainWrapException(pae);
}
}
use of org.apache.derby.io.StorageFactory in project derby by apache.
the class BaseDataFileFactory method luceneLoaded.
/**
* Return true if the Lucene plugin is loaded
*/
public boolean luceneLoaded() throws StandardException {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
public Boolean run() {
StorageFactory storageFactory = getStorageFactory();
StorageFile luceneDir = storageFactory.newStorageFile(Database.LUCENE_DIR);
return luceneDir.exists();
}
}).booleanValue();
} catch (PrivilegedActionException pae) {
throw StandardException.plainWrapException(pae);
}
}
use of org.apache.derby.io.StorageFactory in project derby by apache.
the class LuceneSupport method getDerbyLuceneDir.
// ///////////////////////////////////////////////////////////////////
//
// DERBY STORE
//
// ///////////////////////////////////////////////////////////////////
/**
* <p>
* Get the handle on the Lucene directory inside the database.
* </p>
*/
static DerbyLuceneDir getDerbyLuceneDir(Connection conn, String schema, String table, String textcol) throws SQLException {
StorageFactory storageFactory = getStorageFactory(conn);
DerbyLuceneDir result = DerbyLuceneDir.getDirectory(storageFactory, schema, table, textcol);
return result;
}
use of org.apache.derby.io.StorageFactory in project derby by apache.
the class StorageFactoryService method getCanonicalServiceName.
// end of removeServiceRoot
public String getCanonicalServiceName(String name) throws StandardException {
int colon = name.indexOf(':');
// in the directory or database name.
if (colon < 2 && !getType().equals(PersistentService.DIRECTORY)) {
return null;
}
if (// Subsubprotocols must be at least 2 characters long
colon > 1) {
if (!name.startsWith(getType() + ":"))
// It is not our database
return null;
name = name.substring(colon + 1);
}
final String nm = name;
try {
return getProtocolLeadIn() + AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
public String run() throws StandardException, IOException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
StorageFactory storageFactory = privGetStorageFactoryInstance(true, nm, null, null);
try {
return storageFactory.getCanonicalName();
} finally {
storageFactory.shutdown();
}
}
});
} catch (PrivilegedActionException pae) {
throw Monitor.exceptionStartingModule(pae.getException());
}
}
Aggregations