use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testDeleteVHNDeniedByACL.
@Test
public void testDeleteVHNDeniedByACL() throws Exception {
AccessControl mockAccessControl = mock(AccessControl.class);
DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
TestVirtualHostNode node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.setAccessControl(mockAccessControl);
node.open();
node.start();
when(mockAccessControl.authorise(null, Operation.DELETE, node, Collections.<String, Object>emptyMap())).thenReturn(Result.DENIED);
try {
node.delete();
fail("Exception not throws");
} catch (AccessControlException ace) {
// PASS
}
assertEquals("Virtual host node state changed unexpectedly", State.ACTIVE, node.getState());
node.close();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractSystemConfig method initiateStoreAndRecovery.
private Container<?> initiateStoreAndRecovery() throws IOException {
ConfiguredObjectRecord[] initialRecords = convertToConfigurationRecords(getInitialConfigurationLocation());
final DurableConfigurationStore store = getConfigurationStore();
store.init(AbstractSystemConfig.this);
store.upgradeStoreStructure();
final List<ConfiguredObjectRecord> records = new ArrayList<>();
boolean isNew = store.openConfigurationStore(new ConfiguredObjectRecordHandler() {
@Override
public void handle(final ConfiguredObjectRecord record) {
records.add(record);
}
}, initialRecords);
String containerTypeName = getDefaultContainerType();
for (ConfiguredObjectRecord record : records) {
if (record.getParents() != null && record.getParents().size() == 1 && getId().equals(record.getParents().get(SystemConfig.class.getSimpleName()))) {
containerTypeName = record.getType();
break;
}
}
QpidServiceLoader loader = new QpidServiceLoader();
final ContainerType<?> containerType = loader.getInstancesByType(ContainerType.class).get(containerTypeName);
if (containerType != null) {
if (containerType.getModel() != getModel()) {
updateModel(containerType.getModel());
}
containerType.getRecoverer(this).upgradeAndRecover(records);
} else {
throw new IllegalConfigurationException("Unknown container type '" + containerTypeName + "'");
}
final Class categoryClass = containerType.getCategoryClass();
return (Container<?>) getContainer(categoryClass);
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractVirtualHostNode method postResolve.
@Override
protected void postResolve() {
super.postResolve();
DurableConfigurationStore store = getConfigurationStore();
if (store == null) {
store = createConfigurationStore();
}
_configurationStoreLogSubject = new MessageStoreLogSubject(getName(), store.getClass().getSimpleName());
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class ProvidedStoreVirtualHostImpl method onValidate.
@Override
public void onValidate() {
super.onValidate();
VirtualHostNode<?> virtualHostNode = (VirtualHostNode) getParent();
DurableConfigurationStore configurationStore = virtualHostNode.getConfigurationStore();
if (!(configurationStore instanceof MessageStoreProvider)) {
throw new IllegalConfigurationException(VIRTUAL_HOST_TYPE + " virtual host can only be used where the node's store (" + configurationStore.getClass().getName() + ") is a message store provider. ");
}
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNode method validateOnCreate.
@Override
protected void validateOnCreate() {
super.validateOnCreate();
DurableConfigurationStore store = createConfigurationStore();
if (store != null) {
try {
store.init(this);
} catch (Exception e) {
throw new IllegalConfigurationException("Cannot open node configuration store:" + e.getMessage(), e);
} finally {
try {
store.closeConfigurationStore();
} catch (Exception e) {
LOGGER.warn("Failed to close database", e);
}
}
}
}
Aggregations