diff options
| author | Robert Godfrey <rgodfrey@apache.org = rgodfrey = Robert Godfrey rgodfrey@apache.org@apache.org> | 2014-04-14 17:56:51 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org = rgodfrey = Robert Godfrey rgodfrey@apache.org@apache.org> | 2014-04-14 17:56:51 +0000 |
| commit | 25602a9f8431d99aaa9a726c0046941de24c520e (patch) | |
| tree | e2bb7aec9ec96262741bd936173a9a8c8c41bed4 /qpid/java | |
| parent | c66036bff1e7b5b0e800b9bfdfd8f88357bfd548 (diff) | |
| download | qpid-python-25602a9f8431d99aaa9a726c0046941de24c520e.tar.gz | |
QPID-5698 : [Java Broker] make the durable attribute automated, remove unused setters
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1587262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
27 files changed, 273 insertions, 739 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java index 1355770f53..e0fc64b6e2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java @@ -82,7 +82,7 @@ public class BindingImpl public BindingImpl(UUID id, Map<String, Object> attributes, AMQQueue queue, ExchangeImpl exchange) { - super(parentsMap(queue,exchange),combineIdWithAttributes(id,attributes),queue.getVirtualHost().getTaskExecutor()); + super(parentsMap(queue,exchange),enhanceWithDurable(combineIdWithAttributes(id, attributes), queue, exchange),queue.getVirtualHost().getTaskExecutor()); _id = id; _bindingKey = (String)attributes.get(org.apache.qpid.server.model.Binding.NAME); _queue = queue; @@ -101,6 +101,18 @@ public class BindingImpl } + private static Map<String, Object> enhanceWithDurable(Map<String, Object> attributes, + final AMQQueue queue, + final ExchangeImpl exchange) + { + if(!attributes.containsKey(DURABLE)) + { + attributes = new HashMap<String, Object>(attributes); + attributes.put(DURABLE, queue.isDurable() && exchange.isDurable()); + } + return attributes; + } + public String getBindingKey() { return _bindingKey; @@ -138,36 +150,12 @@ public class BindingImpl return _matches.get(); } - public boolean isDurable() - { - return _queue.isDurable() && _exchange.isDurable(); - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(durable != isDurable()) - { - throw new IllegalArgumentException("Cannot change the durability of a binding"); - } - } - - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - // TODO - return null; - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) { return Collections.emptySet(); @@ -232,14 +220,6 @@ public class BindingImpl } } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - // TODO - return null; - } - public State getState() { return _deleted.get() ? State.DELETED : State.ACTIVE; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index 933f2700bf..e8f8c20eb5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -77,8 +77,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> private ExchangeImpl _alternateExchange; - private boolean _durable; - private VirtualHostImpl _virtualHost; private final List<Action<ExchangeImpl>> _closeTaskList = new CopyOnWriteArrayList<Action<ExchangeImpl>>(); @@ -112,7 +110,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> super(parentsMap(vhost), attributes, vhost.getTaskExecutor()); _virtualHost = vhost; - _durable = MapValueConverter.getBooleanAttribute(org.apache.qpid.server.model.Exchange.DURABLE, attributes); _lifetimePolicy = MapValueConverter.getEnumAttribute(LifetimePolicy.class, org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, attributes, @@ -168,8 +165,14 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> } } }; + } + + @Override + protected void onOpen() + { + super.onOpen(); // Log Exchange creation - getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), _durable)); + getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), isDurable())); } @Override @@ -186,11 +189,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> return getExchangeType().getType(); } - public boolean isDurable() - { - return _durable; - } - public boolean isAutoDelete() { return _autoDelete; @@ -726,44 +724,18 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getState() { return _closed.get() ? State.DELETED : State.ACTIVE; } @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(durable == isDurable()) - { - return; - } - throw new IllegalArgumentException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return _lifetimePolicy; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - // TODO - return _lifetimePolicy; - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) { if(org.apache.qpid.server.model.Binding.class.isAssignableFrom(clazz)) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java index ac139a2c66..4dc9811934 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java @@ -20,6 +20,10 @@ */ package org.apache.qpid.server.exchange; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + import org.apache.log4j.Logger; import org.apache.qpid.exchange.ExchangeDefaults; @@ -29,10 +33,6 @@ import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.virtualhost.UnknownExchangeException; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - public class DefaultExchangeFactory implements ExchangeFactory { public static final String DEFAULT_DLE_NAME_SUFFIX = "_DLE"; @@ -99,6 +99,13 @@ public class DefaultExchangeFactory implements ExchangeFactory public ExchangeImpl createExchange(final Map<String, Object> attributes) throws AMQUnknownExchangeType, UnknownExchangeException { + ExchangeImpl exchange = createExchangeInstance(attributes); + ((AbstractExchange)exchange).create(); + return exchange; + } + + private ExchangeImpl createExchangeInstance(final Map<String, Object> attributes) + { String type = MapValueConverter.getStringAttribute(org.apache.qpid.server.model.Exchange.TYPE, attributes); ExchangeType<? extends ExchangeImpl> exchType = _exchangeClassMap.get(type); if (exchType == null) @@ -106,13 +113,16 @@ public class DefaultExchangeFactory implements ExchangeFactory throw new AMQUnknownExchangeType("Unknown exchange type: " + type,null); } return exchType.newInstance(_host, attributes); + } @Override public ExchangeImpl restoreExchange(Map<String,Object> attributes) throws AMQUnknownExchangeType, UnknownExchangeException { - return createExchange(attributes); + ExchangeImpl exchange = createExchangeInstance(attributes); + exchange.open(); + return exchange; } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index 9359429501..7b2790b56d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -132,6 +132,9 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @ManagedAttributeField private Map<String,String> _context; + @ManagedAttributeField + private boolean _durable; + private final Map<String, ConfiguredObjectAttribute<?,?>> _attributeTypes; private final Map<String, AutomatedField> _automatedFields; @@ -212,6 +215,8 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } _name = AttributeValueConverter.STRING_CONVERTER.convert(attributes.get(NAME),this); + Object durableObj = attributes.get(DURABLE); + _durable = AttributeValueConverter.BOOLEAN_CONVERTER.convert(durableObj == null ? _attributeTypes.get(DURABLE).getAnnotation().defaultValue() : durableObj, this); Collection<String> names = getAttributeNames(); if(names!=null) @@ -483,6 +488,12 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im return _name; } + public final boolean isDurable() + { + return _durable; + } + + public Class<? extends ConfiguredObject> getCategoryClass() { return _category; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java index d1e78def75..c3a2febfd3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java @@ -20,9 +20,6 @@ */ package org.apache.qpid.server.model; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; import java.util.Map; @ManagedObject @@ -30,7 +27,6 @@ public interface Binding<X extends Binding<X>> extends ConfiguredObject<X> { public String ARGUMENTS = "arguments"; - public String DURABLE = "durable"; public String LIFETIME_POLICY = "lifetimePolicy"; public String STATE = "state"; public String TIME_TO_LIVE = "timeToLive"; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java index ed7e9ac60e..6a7eabd5d6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java @@ -37,6 +37,7 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> public static final String NAME = "name"; public static final String TYPE = "type"; public static final String DESCRIPTION = "description"; + public static final String DURABLE = "durable"; public static final String CONTEXT = "context"; public static final String LAST_UPDATED_BY = "lastUpdatedBy"; public static final String LAST_UPDATED_TIME = "lastUpdatedTime"; @@ -83,23 +84,6 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> @ManagedAttribute long getCreatedTime(); - /** - * Attempt to change the name of the object - * - * Request a change to the name of the object. The caller must pass in the name it believes the object currently - * has. If the current name differs from this expected value, then no name change will occur - * - * @param currentName the name the caller believes the object to have - * @param desiredName the name the caller would like the object to have - * @return the new name for the object - * @throws IllegalStateException if the name of the object may not be changed in in the current state - * @throws AccessControlException if the current context does not have permission to change the name - * @throws IllegalArgumentException if the provided name is not legal - * @throws NullPointerException if the desired name is null - */ - String setName(String currentName, String desiredName) throws IllegalStateException, - AccessControlException; - /** * Get the desired state of the object. @@ -170,23 +154,10 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> * * @return the durability */ - @ManagedAttribute + @ManagedAttribute( automate = true, defaultValue = "true" ) boolean isDurable(); /** - * Sets the durability of the object - * - * @param durable true iff the caller wishes the object to store its configuration durably - * - * @throws IllegalStateException if the durability cannot be changed in the current state - * @throws AccessControlException if the current context does not have sufficient permission to change the durability - * @throws IllegalArgumentException if the object does not support the requested durability - */ - void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, - IllegalArgumentException; - - /** * Return the lifetime policy for the object * * @return the lifetime policy @@ -195,20 +166,6 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> LifetimePolicy getLifetimePolicy(); /** - * Set the lifetime policy of the object - * - * @param expected The lifetime policy the caller believes the object currently has - * @param desired The lifetime policy the caller desires the object to have - * @return the new lifetime policy - * @throws IllegalStateException if the lifetime policy cannot be changed in the current state - * @throws AccessControlException if the caller does not have permission to change the lifetime policy - * @throws IllegalArgumentException if the object does not support the requested lifetime policy - */ - LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, - IllegalArgumentException; - - /** * Get the names of attributes that are set on this object * * Note that the returned collection is correct at the time the method is called, but will not reflect future diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java index b4af364634..7575ad203a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.model; -import java.security.AccessControlException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -208,45 +207,18 @@ public class SystemContextImpl extends AbstractConfiguredObject<SystemContextImp } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getState() { return State.ACTIVE; } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalArgumentException("Cannot change the durability of the SystemContext object"); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalArgumentException("Cannot change the lifetime of the SystemContext object"); - } - - @Override public ConfiguredObjectFactory getObjectFactory() { return _objectFactory; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java index 1143ae0a4a..4c66ab26b5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java @@ -48,27 +48,29 @@ public abstract class AbstractPluginAdapter<X extends Plugin<X>> extends Abstrac @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + public void validate() { - throw new UnsupportedOperationException(); - } - - @Override - public State getState() - { - return null; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public boolean isDurable() + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - return true; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException + public State getState() { - throw new UnsupportedOperationException(); + return null; } @Override @@ -78,13 +80,6 @@ public abstract class AbstractPluginAdapter<X extends Plugin<X>> extends Abstrac } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) { return Collections.emptyList(); @@ -99,18 +94,10 @@ public abstract class AbstractPluginAdapter<X extends Plugin<X>> extends Abstrac @Override public Object getAttribute(String name) { - if (ID.equals(name)) - { - return getId(); - } - else if (STATE.equals(name)) + if (STATE.equals(name)) { return getState(); } - else if (DURABLE.equals(name)) - { - return isDurable(); - } else if (LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java index fb00ee7fb3..357d367f28 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java @@ -185,6 +185,20 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple + "' in configuration is incompatible with the broker model version '" + Model.MODEL_VERSION + "'"); } + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected void onOpen() @@ -436,41 +450,17 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple return true; } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; //TODO - } - public State getState() { return null; //TODO } - - public boolean isDurable() - { - return true; - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public long getTimeToLive() { return 0; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java index 25c0a97b14..00834c5866 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java @@ -77,6 +77,7 @@ public final class ConnectionAdapter extends AbstractConfiguredObject<Connection attributes.put(PORT, conn.getPort()); attributes.put(INCOMING, true); attributes.put(REMOTE_ADDRESS, conn.getRemoteAddressString()); + attributes.put(DURABLE, false); return attributes; } @@ -173,50 +174,16 @@ public final class ConnectionAdapter extends AbstractConfiguredObject<Connection _connection.close(AMQConstant.CONNECTION_FORCED, "Connection closed by external action"); } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; //TODO - } - public State getState() { return null; //TODO } - public boolean isDurable() - { - return false; //TODO - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - //TODO - } - public LifetimePolicy getLifetimePolicy() { return null; //TODO } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; //TODO - } - - public long getTimeToLive() - { - return 0; //TODO - } - - public long setTimeToLive(final long expected, final long desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return 0; //TODO - } - @Override public Object getAttribute(String name) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java index f80d043c02..0ec995810b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java @@ -82,8 +82,21 @@ public class FileBasedGroupProviderImpl } } } + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } protected void onOpen() { super.onOpen(); @@ -108,45 +121,18 @@ public class FileBasedGroupProviderImpl } @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getState() { return _state.get(); } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - return null; - } - - @Override public Collection<String> getAttributeNames() { return getAttributeNames(getClass()); @@ -353,29 +339,30 @@ public class FileBasedGroupProviderImpl @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException("Names cannot be updated"); - } - - @Override public State getState() { return State.ACTIVE; } + @Override - public boolean isDurable() + public void validate() { - return true; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, IllegalArgumentException + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - throw new IllegalStateException("Durability cannot be updated"); + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override @@ -385,14 +372,6 @@ public class FileBasedGroupProviderImpl } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new IllegalStateException("LifetimePolicy cannot be updated"); - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren( Class<C> clazz) { @@ -502,49 +481,42 @@ public class FileBasedGroupProviderImpl super(parentsMap(GroupAdapter.this),attrMap, taskExecutor); } - @Override - public Collection<String> getAttributeNames() - { - return getAttributeNames(GroupMember.class); - } - @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException + public void validate() { - return null; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public State getState() + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - return null; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public boolean isDurable() + public Collection<String> getAttributeNames() { - return false; + return getAttributeNames(GroupMember.class); } - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, - IllegalArgumentException - { - } @Override - public LifetimePolicy getLifetimePolicy() + public State getState() { return null; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException + public LifetimePolicy getLifetimePolicy() { return null; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java index c3a2cfde61..db01938af6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java @@ -91,21 +91,25 @@ public class FileSystemPreferencesProviderImpl } @Override - public Collection<String> getAttributeNames() + public void validate() { - return getAttributeNames(FileSystemPreferencesProviderImpl.class); + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public String getPath() + public Collection<String> getAttributeNames() { - return (String) getAttribute(PATH); + return getAttributeNames(FileSystemPreferencesProviderImpl.class); } @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + public String getPath() { - throw new UnsupportedOperationException(); + return (String) getAttribute(PATH); } @Override @@ -115,31 +119,12 @@ public class FileSystemPreferencesProviderImpl } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) { return Collections.emptySet(); @@ -338,6 +323,12 @@ public class FileSystemPreferencesProviderImpl { throw new IllegalConfigurationException("Path to preferences file is not specified"); } + + if(changedAttributes.contains(DURABLE) && !updated.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } public void createStoreIfNotExist() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java index 3194709743..47bf9293f9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java @@ -72,6 +72,7 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl attributes.put(ID, UUID.randomUUID()); attributes.put(NAME, String.valueOf(session.getChannelId())); attributes.put(CHANNEL_ID, session.getChannelId()); + attributes.put(DURABLE, false); return attributes; } @@ -97,39 +98,16 @@ final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> impl return Collections.emptySet(); //TODO } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; //TODO - } - public State getState() { return null; //TODO } - public boolean isDurable() - { - return false; //TODO - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - //TODO - } - public LifetimePolicy getLifetimePolicy() { return null; //TODO } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; //TODO - } - @Override public Collection<String> getAttributeNames() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java index d9d8877d01..7c654c566e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java @@ -21,7 +21,6 @@ package org.apache.qpid.server.model.adapter; -import java.security.AccessControlException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -78,44 +77,18 @@ public class VirtualHostAliasAdapter extends AbstractConfiguredObject<VirtualHos } @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); // TODO - Implement - } - - @Override public State getState() { return State.ACTIVE; // TODO - Implement } @Override - public boolean isDurable() - { - return true; // TODO - Implement - } - - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; // TODO - Implement } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); // TODO - Implement - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) { return Collections.emptySet(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java index 518abb692f..5464156a05 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java @@ -108,6 +108,21 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo { throw new IllegalConfigurationException("Can't create a port which uses a secure transport but has no KeyStore"); } + + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override @@ -199,44 +214,18 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo protected abstract Set<Protocol> getDefaultProtocols(); @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } - - @Override public State getState() { return _state.get(); } @Override - public boolean isDurable() - { - return false; - } - - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) { if(clazz == Connection.class) @@ -252,18 +241,10 @@ abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractCo @Override public Object getAttribute(String name) { - if(ID.equals(name)) - { - return getId(); - } - else if(STATE.equals(name)) + if(STATE.equals(name)) { return getState(); } - else if(DURABLE.equals(name)) - { - return isDurable(); - } else if(LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java index 78fea5a39c..0568e1eb3b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java @@ -120,8 +120,6 @@ public abstract class AbstractQueue private String _description; - private boolean _durable; - private ExchangeImpl _alternateExchange; @@ -301,9 +299,6 @@ public abstract class AbstractQueue Map<String,Object> attributes = getActualAttributes(); - boolean durable = MapValueConverter.getBooleanAttribute(Queue.DURABLE, attributes, false); - - _exclusive = MapValueConverter.getEnumAttribute(ExclusivityPolicy.class, Queue.EXCLUSIVE, attributes, @@ -313,7 +308,6 @@ public abstract class AbstractQueue attributes, LifetimePolicy.PERMANENT); - _durable = durable; final LinkedHashMap<String, Object> arguments = new LinkedHashMap<String, Object>(attributes); arguments.put(Queue.EXCLUSIVE, _exclusive); @@ -432,8 +426,8 @@ public abstract class AbstractQueue _entries.getPriorities(), ownerString != null, _lifetimePolicy != LifetimePolicy.PERMANENT, - durable, - !durable, + isDurable(), + !isDurable(), _entries.getPriorities() > 0)); if(attributes != null && attributes.containsKey(Queue.MESSAGE_GROUP_KEY)) @@ -511,11 +505,6 @@ public abstract class AbstractQueue _noLocal = nolocal; } - public boolean isDurable() - { - return _durable; - } - public boolean isExclusive() { return _exclusive != ExclusivityPolicy.NONE; @@ -596,10 +585,6 @@ public abstract class AbstractQueue } return "standard"; } - else if(DURABLE.equals(name)) - { - return isDurable(); - } else if(LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); @@ -2779,33 +2764,12 @@ public abstract class AbstractQueue @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getState() { return isDeleted() ? State.DELETED : State.ACTIVE; } @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) { if(clazz == Binding.class) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java index fd6528d4ad..4426ee36b7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.queue; import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT; -import java.security.AccessControlException; import java.text.MessageFormat; import java.util.Collection; import java.util.Collections; @@ -103,8 +102,6 @@ class QueueConsumerImpl } }; @ManagedAttributeField - private boolean _durable; - @ManagedAttributeField private boolean _exclusive; @ManagedAttributeField private boolean _noLocal; @@ -518,39 +515,12 @@ class QueueConsumerImpl } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override - public boolean isDurable() - { - return _durable; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.DELETE_ON_SESSION_END; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) { return Collections.<C>emptyList(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java index cfc3987677..8316e027d1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java @@ -105,11 +105,6 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject<FileKeyStoreImpl> { return getAttributeNames(getClass()); } - @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } @Override public State getState() @@ -118,41 +113,18 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject<FileKeyStoreImpl> } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, AccessControlException, - IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public Object getAttribute(String name) { if(KeyStore.STATE.equals(name)) { return getState(); } - else if(KeyStore.DURABLE.equals(name)) - { - return isDurable(); - } else if(KeyStore.LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); @@ -260,6 +232,11 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject<FileKeyStoreImpl> throw new IllegalConfigurationException("Unknown keyManagerFactoryAlgorithm: " + fileKeyStore.getKeyManagerFactoryAlgorithm()); } + + if(!fileKeyStore.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java index efaf565364..84b8b38ff1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java @@ -21,15 +21,12 @@ package org.apache.qpid.server.security; import java.io.IOException; -import java.lang.reflect.Type; import java.security.AccessControlException; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -51,7 +48,6 @@ import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory; -import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; import org.apache.qpid.transport.network.security.ssl.QpidPeersOnlyTrustManager; import org.apache.qpid.transport.network.security.ssl.SSLUtil; @@ -59,17 +55,6 @@ import org.apache.qpid.transport.network.security.ssl.SSLUtil; public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreImpl> implements FileTrustStore<FileTrustStoreImpl> { - - @SuppressWarnings("serial") - public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{ - put(NAME, String.class); - put(PATH, String.class); - put(PASSWORD, String.class); - put(TRUST_STORE_TYPE, String.class); - put(PEERS_ONLY, Boolean.class); - put(TRUST_MANAGER_FACTORY_ALGORITHM, String.class); - }}); - @ManagedAttributeField private String _trustStoreType; @ManagedAttributeField @@ -95,7 +80,11 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI public void validate() { super.validate(); - validateTrustStoreAttributes(_trustStoreType, _path, getPassword(), _trustManagerFactoryAlgorithm); + validateTrustStore(this); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override @@ -103,11 +92,6 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI { return getAttributeNames(getClass()); } - @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } @Override public State getState() @@ -116,31 +100,12 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, AccessControlException, - IllegalArgumentException - { - throw new IllegalStateException(); - } - - @Override protected boolean setState(State currentState, State desiredState) { if(desiredState == State.DELETED) @@ -206,56 +171,40 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI } @Override - protected void changeAttributes(Map<String, Object> attributes) + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - Map<String, Object> changedValues = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - if(changedValues.containsKey(TrustStore.NAME)) + super.validateChange(proxyForValidation, changedAttributes); + FileTrustStore updated = (FileTrustStore) proxyForValidation; + if(changedAttributes.contains(TrustStore.NAME) && !getName().equals(updated.getName())) { - String newName = (String) changedValues.get(TrustStore.NAME); - if(!getName().equals(newName)) - { - throw new IllegalConfigurationException("Changing the trust store name is not allowed"); - } + throw new IllegalConfigurationException("Changing the trust store name is not allowed"); } - - Map<String, Object> merged = generateEffectiveAttributes(changedValues); - - String trustStorePath = changedValues.containsKey(PATH) ? (String) changedValues.get(PATH) : getPath(); - String trustStorePassword = - changedValues.containsKey(PASSWORD) ? (String) changedValues.get(PASSWORD) : getPassword(); - String trustStoreType = changedValues.containsKey(TRUST_STORE_TYPE) - ? (String) changedValues.get(TRUST_STORE_TYPE) - : getTrustStoreType(); - String trustManagerFactoryAlgorithm = - changedValues.containsKey(TRUST_MANAGER_FACTORY_ALGORITHM) - ? (String) changedValues.get(TRUST_MANAGER_FACTORY_ALGORITHM) - : getTrustManagerFactoryAlgorithm(); - - validateTrustStoreAttributes(trustStoreType, trustStorePath, - trustStorePassword, trustManagerFactoryAlgorithm); - - super.changeAttributes(changedValues); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + validateTrustStore(updated); } - private void validateTrustStoreAttributes(String type, String trustStorePath, - String password, String trustManagerFactoryAlgorithm) + + private static void validateTrustStore(FileTrustStore trustStore) { try { - SSLUtil.getInitializedKeyStore(trustStorePath, password, type); + SSLUtil.getInitializedKeyStore(trustStore.getPath(), trustStore.getPassword(), trustStore.getTrustStoreType()); } catch (Exception e) { - throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStorePath, e); + throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStore.getPath(), e); } try { - TrustManagerFactory.getInstance(trustManagerFactoryAlgorithm); + TrustManagerFactory.getInstance(trustStore.getTrustManagerFactoryAlgorithm()); } catch (NoSuchAlgorithmException e) { - throw new IllegalConfigurationException("Unknown trustManagerFactoryAlgorithm: " + trustManagerFactoryAlgorithm); + throw new IllegalConfigurationException("Unknown trustManagerFactoryAlgorithm: " + trustStore.getTrustManagerFactoryAlgorithm()); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java index cacb08ab5c..a7a6ff42f1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java @@ -78,6 +78,21 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica { throw new IllegalConfigurationException("Only one preference provider can be configured for an authentication provider"); } + + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected final Broker getBroker() @@ -132,44 +147,17 @@ public abstract class AbstractAuthenticationManager<T extends AbstractAuthentica } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getState() { return _state.get(); } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - @SuppressWarnings("unchecked") @Override public <C extends ConfiguredObject> C addChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java index e454b1b50a..26421437a7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java @@ -357,6 +357,26 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal } @Override + public void validate() + { + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override public String getPassword() { return (String)getAttribute(PASSWORD); @@ -377,45 +397,18 @@ public abstract class PrincipalDatabaseAuthenticationManager<T extends Principal @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException("Names cannot be updated"); - } - - @Override public State getState() { return State.ACTIVE; } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException("Durability cannot be updated"); - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException("LifetimePolicy cannot be updated"); - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) { return null; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java index 82c045fe2d..c755015c33 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -449,6 +450,25 @@ public class ScramSHA1AuthenticationManager } @Override + public void validate() + { + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + @Override protected boolean setState(final State currentState, final State desiredState) { if(desiredState == State.DELETED) @@ -526,50 +546,18 @@ public class ScramSHA1AuthenticationManager } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException("Names cannot be updated"); - } - - @Override public State getState() { return State.ACTIVE; } @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(expected == desired && expected == LifetimePolicy.PERMANENT) - { - return LifetimePolicy.PERMANENT; - } - throw new IllegalArgumentException("Cannot change lifetime policy of a user"); - - } - - @Override public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz) { return Collections.emptySet(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index 007baf3422..3207e13e96 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -212,6 +212,20 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte { throw new IllegalConfigurationException("Virtual host type must be specified"); } + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected void onOpen() @@ -333,12 +347,6 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } - public String setType(final String currentType, final String desiredType) throws IllegalStateException, AccessControlException { @@ -373,28 +381,11 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } - public boolean isDurable() - { - return true; - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index 0182237a99..ea5e02e4d9 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -178,6 +178,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest Map<String,Object> map = new HashMap<String, Object>(); map.put(Binding.NAME, ROUTING_KEY); map.put(Binding.ARGUMENTS,_bindingArgs); + map.put(Binding.DURABLE,true); Map<String,UUID> parents = new HashMap<String, UUID>(); @@ -417,6 +418,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(queue.getId()).thenReturn(_queueId); when(queue.getAlternateExchange()).thenReturn(alternateExchange); when(queue.getCategoryClass()).thenReturn((Class)Queue.class); + when(queue.isDurable()).thenReturn(true); final VirtualHostImpl vh = mock(VirtualHostImpl.class); when(vh.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(queue.getVirtualHost()).thenReturn(vh); @@ -469,6 +471,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(exchange.isAutoDelete()).thenReturn(true); when(exchange.getId()).thenReturn(_exchangeId); when(exchange.getCategoryClass()).thenReturn(Exchange.class); + when(exchange.isDurable()).thenReturn(true); ConfiguredObjectRecord exchangeRecord = mock(ConfiguredObjectRecord.class); when(exchangeRecord.getId()).thenReturn(_exchangeId); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java index b4d3148dfa..37b464be40 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java @@ -149,13 +149,6 @@ public class MockVirtualHost implements VirtualHostImpl<MockVirtualHost, AMQQueu } @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override public State getDesiredState() { return null; @@ -493,26 +486,12 @@ public class MockVirtualHost implements VirtualHostImpl<MockVirtualHost, AMQQueu } @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override public LifetimePolicy getLifetimePolicy() { return null; } @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - - @Override public Collection<String> getAttributeNames() { return null; diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java index db2b44c5e6..ae23a308f5 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java @@ -72,40 +72,42 @@ public class ACLFileAccessControlProviderImpl } @Override - protected void onOpen() + public void validate() { - super.onOpen(); - _accessControl = new DefaultAccessControl(getPath(), _broker); - } - - @Override - public String getPath() - { - return _path; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) { - return null; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public State getState() + protected void onOpen() { - return _state.get(); + super.onOpen(); + _accessControl = new DefaultAccessControl(getPath(), _broker); } @Override - public boolean isDurable() + public String getPath() { - return true; + return _path; } @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException + public State getState() { + return _state.get(); } @Override @@ -115,13 +117,6 @@ public class ACLFileAccessControlProviderImpl } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - - @Override public Collection<String> getAttributeNames() { return getAttributeNames(getClass()); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java index 1584dc6e46..a2bb05dd00 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java @@ -258,7 +258,7 @@ public class Asserts public static void assertPortAttributes(Map<String, Object> port, State state) { assertNotNull("Unexpected value of attribute " + Port.ID, port.get(Port.ID)); - assertEquals("Unexpected value of attribute " + Port.DURABLE, Boolean.FALSE, port.get(Port.DURABLE)); + assertEquals("Unexpected value of attribute " + Port.DURABLE, Boolean.TRUE, port.get(Port.DURABLE)); assertEquals("Unexpected value of attribute " + Port.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(), port.get(Broker.LIFETIME_POLICY)); assertEquals("Unexpected value of attribute " + Port.STATE, state.name(), port.get(Port.STATE)); |
