use of org.bimserver.database.BimserverLockConflictException in project BIMserver by opensourceBIM.
the class UpdatePluginBundle method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
MavenPluginLocation mavenPluginLocation = bimServer.getMavenPluginRepository().getPluginLocation(repository, groupId, artifactId);
try {
Path jarFile = mavenPluginLocation.getVersionJar(version);
Path pomFile = mavenPluginLocation.getVersionPom(version);
try {
List<SPluginInformation> plugins = null;
try {
plugins = bimServer.getPluginManager().getPluginInformationFromPluginFile(new ByteArrayInputStream(mavenPluginLocation.getVersionPluginXml(version)));
} catch (ArtifactResolutionException e) {
plugins = bimServer.getPluginManager().getPluginInformationFromJar(jarFile);
}
// IfcModelInterface allOfType = getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(), OldQuery.getDefault());
// for (SPluginInformation sPluginInformation : plugins) {
// update plugin information with data from potentially existing plugins
// }
bimServer.getPluginManager().update(mavenPluginLocation.getPluginVersionIdentifier(version), mavenPluginLocation.getPluginBundle(version), mavenPluginLocation.getPluginBundleVersion(version), jarFile, pomFile, plugins);
} catch (Exception e) {
throw new UserException(e);
}
} catch (Exception e) {
LOGGER.error("", e);
throw new UserException(e);
}
return null;
}
use of org.bimserver.database.BimserverLockConflictException in project BIMserver by opensourceBIM.
the class Schema method upgradeDatabase.
public void upgradeDatabase(Database database, int version, DatabaseSession databaseSession) {
LOGGER.info("Upgrading database to version " + version);
// initSubClasses();
for (Change change : changes) {
try {
change.change(database, databaseSession);
change.doSchemaChanges(this);
} catch (Exception e) {
LOGGER.error("", e);
}
}
try {
database.setDatabaseVersion(version, databaseSession);
} catch (BimserverLockConflictException e) {
LOGGER.error("", e);
}
}
use of org.bimserver.database.BimserverLockConflictException in project BIMserver by opensourceBIM.
the class AddIndexChange method change.
@Override
public void change(Database database, DatabaseSession databaseSession) throws NotImplementedException, BimserverDatabaseException {
EClass eClass = eStructuralFeature.getEContainingClass();
KeyValueStore keyValueStore = database.getKeyValueStore();
for (EClass subClass : schema.getSubClasses(eClass)) {
try {
if (subClass.getEAnnotation("nodatabase") == null) {
String indexTableName = subClass.getEPackage().getName() + "_" + subClass.getName() + "_" + eStructuralFeature.getName();
boolean transactional = !(subClass.getEPackage() == Ifc4Package.eINSTANCE || subClass.getEPackage() == Ifc2x3tc1Package.eINSTANCE);
keyValueStore.createIndexTable(indexTableName, databaseSession, transactional);
RecordIterator recordIterator = keyValueStore.getRecordIterator(subClass.getEPackage().getName() + "_" + subClass.getName(), databaseSession);
try {
Record record = recordIterator.next();
while (record != null) {
ByteBuffer buffer = ByteBuffer.wrap(record.getValue());
byte[] featureBytes = databaseSession.extractFeatureBytes(databaseSession, buffer, subClass, eStructuralFeature);
if (featureBytes != null) {
keyValueStore.store(indexTableName, featureBytes, record.getKey(), databaseSession);
}
record = recordIterator.next();
}
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
recordIterator.close();
}
}
} catch (BimserverLockConflictException e) {
LOGGER.error("", e);
}
}
}
use of org.bimserver.database.BimserverLockConflictException in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method store.
@Override
public void store(String tableName, byte[] key, byte[] value, int offset, int length, DatabaseSession databaseSession) throws BimserverDatabaseException, BimserverLockConflictException {
DatabaseEntry dbKey = new DatabaseEntry(key);
DatabaseEntry dbValue = new DatabaseEntry(value, offset, length);
try {
TableWrapper tableWrapper = getTableWrapper(tableName);
tableWrapper.getDatabase().put(getTransaction(databaseSession, tableWrapper), dbKey, dbValue);
} catch (LockConflictException e) {
throw new BimserverLockConflictException(e);
} catch (DatabaseException e) {
throw new BimserverDatabaseException("", e);
}
}
use of org.bimserver.database.BimserverLockConflictException in project BIMserver by opensourceBIM.
the class BerkeleySearchingRecordIterator method last.
@Override
public Record last() throws BimserverLockConflictException {
if (nextStartSearchingAt != null) {
return getFirstNext(nextStartSearchingAt);
}
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
if (onlyKeys) {
value.setPartial(0, 0, true);
}
try {
OperationStatus next = cursor.getLast(key, value, LockMode.DEFAULT);
if (next == OperationStatus.SUCCESS) {
byte[] firstBytes = new byte[mustStartWith.length];
System.arraycopy(key.getData(), 0, firstBytes, 0, mustStartWith.length);
if (Arrays.equals(firstBytes, mustStartWith)) {
return new BerkeleyRecord(key, value);
}
}
} catch (LockConflictException e) {
throw new BimserverLockConflictException(e);
} catch (DatabaseException e) {
LOGGER.error("", e);
}
return null;
}
Aggregations