You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/08/25 17:35:12 UTC
svn commit: r1620350 [2/4] - in /qpid/branches/0.30/qpid/java: ./
bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/
bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/
bdbstore/src/test/java/org/apache/qpid/server/vi...
Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java Mon Aug 25 15:35:10 2014
@@ -20,36 +20,61 @@
*/
package org.apache.qpid.server.virtualhostnode;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.apache.log4j.Logger;
+
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.ManagedAttributeField;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.StateTransition;
import org.apache.qpid.server.model.SystemConfig;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ConfiguredObjectRecordConverter;
+import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
import org.apache.qpid.server.store.DurableConfigurationStore;
-
-import java.security.AccessControlException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode<X>> extends AbstractConfiguredObject<X> implements VirtualHostNode<X>
{
- public static final String VIRTUALHOST_BLUEPRINT_CONTEXT_VAR = "virtualhostBlueprint";
- public static final String VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR = "virtualhostBlueprintUtilised";
private static final Logger LOGGER = Logger.getLogger(AbstractVirtualHostNode.class);
+
+ static
+ {
+ Handler.register();
+ }
+
private final Broker<?> _broker;
private final AtomicReference<State> _state = new AtomicReference<State>(State.UNINITIALIZED);
private final EventLogger _eventLogger;
@@ -58,6 +83,9 @@ public abstract class AbstractVirtualHos
private MessageStoreLogSubject _configurationStoreLogSubject;
+ @ManagedAttributeField
+ private String _virtualHostInitialConfiguration;
+
public AbstractVirtualHostNode(Broker<?> parent, Map<String, Object> attributes)
{
super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, parent),
@@ -241,8 +269,152 @@ public abstract class AbstractVirtualHos
}
}
+ @Override
+ public String getVirtualHostInitialConfiguration()
+ {
+ return _virtualHostInitialConfiguration;
+ }
+
protected abstract DurableConfigurationStore createConfigurationStore();
protected abstract void activate();
+
+
+ protected abstract ConfiguredObjectRecord enrichInitialVirtualHostRootRecord(final ConfiguredObjectRecord vhostRecord);
+
+ protected final ConfiguredObjectRecord[] getInitialRecords() throws IOException
+ {
+ ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(getModel());
+
+ Collection<ConfiguredObjectRecord> records =
+ new ArrayList<>(converter.readFromJson(VirtualHost.class,this,getInitialConfigReader()));
+
+ if(!records.isEmpty())
+ {
+ ConfiguredObjectRecord vhostRecord = null;
+ for(ConfiguredObjectRecord record : records)
+ {
+ if(record.getType().equals(VirtualHost.class.getSimpleName()))
+ {
+ vhostRecord = record;
+ break;
+ }
+ }
+ if(vhostRecord != null)
+ {
+ records.remove(vhostRecord);
+ vhostRecord = enrichInitialVirtualHostRootRecord(vhostRecord);
+ records.add(vhostRecord);
+ }
+ else
+ {
+ // this should be impossible as the converter should always generate a parent record
+ throw new IllegalConfigurationException("Somehow the initial configuration has records but "
+ + "not a VirtualHost. This must be a coding error in Qpid");
+ }
+ addStandardExchangesIfNecessary(records, vhostRecord);
+ enrichWithAuditInformation(records);
+ }
+
+
+ return records.toArray(new ConfiguredObjectRecord[records.size()]);
+ }
+
+ private void enrichWithAuditInformation(final Collection<ConfiguredObjectRecord> records)
+ {
+ List<ConfiguredObjectRecord> replacements = new ArrayList<>(records.size());
+
+ for(ConfiguredObjectRecord record : records)
+ {
+ replacements.add(new ConfiguredObjectRecordImpl(record.getId(), record.getType(),
+ enrichAttributesWithAuditInformation(record.getAttributes()),
+ record.getParents()));
+ }
+ records.clear();
+ records.addAll(replacements);
+ }
+
+ private Map<String, Object> enrichAttributesWithAuditInformation(final Map<String, Object> attributes)
+ {
+ LinkedHashMap<String,Object> enriched = new LinkedHashMap<>(attributes);
+ final AuthenticatedPrincipal currentUser = org.apache.qpid.server.security.SecurityManager.getCurrentUser();
+
+ if(currentUser != null)
+ {
+ enriched.put(ConfiguredObject.LAST_UPDATED_BY, currentUser.getName());
+ enriched.put(ConfiguredObject.CREATED_BY, currentUser.getName());
+ }
+ long currentTime = System.currentTimeMillis();
+ enriched.put(ConfiguredObject.LAST_UPDATED_TIME, currentTime);
+ enriched.put(ConfiguredObject.CREATED_TIME, currentTime);
+
+ return enriched;
+ }
+
+ private void addStandardExchangesIfNecessary(final Collection<ConfiguredObjectRecord> records,
+ final ConfiguredObjectRecord vhostRecord)
+ {
+ addExchangeIfNecessary(ExchangeDefaults.FANOUT_EXCHANGE_CLASS, ExchangeDefaults.FANOUT_EXCHANGE_NAME, records, vhostRecord);
+ addExchangeIfNecessary(ExchangeDefaults.HEADERS_EXCHANGE_CLASS, ExchangeDefaults.HEADERS_EXCHANGE_NAME, records, vhostRecord);
+ addExchangeIfNecessary(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, ExchangeDefaults.TOPIC_EXCHANGE_NAME, records, vhostRecord);
+ addExchangeIfNecessary(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, ExchangeDefaults.DIRECT_EXCHANGE_NAME, records, vhostRecord);
+ }
+
+ private void addExchangeIfNecessary(final String exchangeClass,
+ final String exchangeName,
+ final Collection<ConfiguredObjectRecord> records,
+ final ConfiguredObjectRecord vhostRecord)
+ {
+ boolean found = false;
+
+ for(ConfiguredObjectRecord record : records)
+ {
+ if(Exchange.class.getSimpleName().equals(record.getType())
+ && exchangeName.equals(record.getAttributes().get(ConfiguredObject.NAME)))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if(!found)
+ {
+ final Map<String, Object> exchangeAttributes = new HashMap<>();
+ exchangeAttributes.put(ConfiguredObject.NAME, exchangeName);
+ exchangeAttributes.put(ConfiguredObject.TYPE, exchangeClass);
+
+ records.add(new ConfiguredObjectRecordImpl(UUID.randomUUID(), Exchange.class.getSimpleName(),
+ exchangeAttributes, Collections.singletonMap(VirtualHost.class.getSimpleName(), vhostRecord.getId())));
+ }
+ }
+
+ protected final Reader getInitialConfigReader() throws IOException
+ {
+ Reader initialConfigReader;
+ if(getVirtualHostInitialConfiguration() != null)
+ {
+ String initialContextString = getVirtualHostInitialConfiguration();
+
+
+ try
+ {
+ URL url = new URL(initialContextString);
+
+ initialConfigReader =new InputStreamReader(url.openStream());
+ }
+ catch (MalformedURLException e)
+ {
+ initialConfigReader = new StringReader(initialContextString);
+ }
+
+ }
+ else
+ {
+ LOGGER.warn("No initial configuration found for the virtual host");
+ initialConfigReader = new StringReader("{}");
+ }
+ return initialConfigReader;
+ }
+
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/resources/initial-config.json
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/resources/initial-config.json?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/resources/initial-config.json (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/resources/initial-config.json Mon Aug 25 15:35:10 2014
@@ -20,7 +20,6 @@
*/
{
"name": "${broker.name}",
- "storeVersion": 1,
"modelVersion": "2.0",
"defaultVirtualHost" : "default",
"authenticationproviders" : [ {
@@ -55,9 +54,7 @@
"virtualhostnodes" : [ {
"name" : "default",
"type" : "JSON",
- "context" : {
- "virtualhostBlueprint" : "{ \"type\" : \"DERBY\" }"
- }
+ "virtualHostInitialConfiguration" : "{ \"type\" : \"DERBY\" }"
} ],
"plugins" : [ {
"type" : "MANAGEMENT-HTTP",
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java Mon Aug 25 15:35:10 2014
@@ -26,6 +26,7 @@ import java.util.Map;
import junit.framework.TestCase;
+import org.apache.qpid.server.model.testmodel.TestChildCategory;
import org.apache.qpid.server.model.testmodel.TestModel;
import org.apache.qpid.server.model.testmodel.TestRootCategory;
import org.apache.qpid.server.store.ConfiguredObjectRecord;
@@ -187,4 +188,73 @@ public class AbstractConfiguredObjectTes
assertEquals("myValue", object1.getStringValue());
}
-}
\ No newline at end of file
+ public void testCreationOfObjectWithInvalidInterpolatedValues()
+ {
+ final String parentName = "parent";
+ TestRootCategory parent =
+ _model.getObjectFactory().create(TestRootCategory.class,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+ parentName)
+ );
+
+ parent.setAttributes(Collections.singletonMap(ConfiguredObject.CONTEXT,
+ Collections.singletonMap("contextVal", "foo")));
+
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put("intValue", "${contextVal}");
+ attributes.put("name", "child");
+ attributes.put("integerSet", "[ ]");
+ attributes.put(ConfiguredObject.TYPE, "test");
+
+ try
+ {
+ _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
+ fail("creation of child object should have failed due to invalid value");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // PASS
+ String message = e.getMessage();
+ assertTrue("Message does not contain the attribute name", message.contains("intValue"));
+ assertTrue("Message does not contain the non-interpolated value", message.contains("contextVal"));
+ assertTrue("Message does not contain the interpolated value", message.contains("foo"));
+
+ }
+
+ assertTrue("Child should not have been registered with parent",
+ parent.getChildren(TestChildCategory.class).isEmpty());
+ }
+
+ public void testCreationOfObjectWithInvalidDefaultValues()
+ {
+ final String parentName = "parent";
+ TestRootCategory parent =
+ _model.getObjectFactory().create(TestRootCategory.class,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+ parentName)
+ );
+
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put("intValue", "1");
+ attributes.put("name", "child");
+ attributes.put(ConfiguredObject.TYPE, "test");
+
+ try
+ {
+ _model.getObjectFactory().create(TestChildCategory.class, attributes, parent);
+ fail("creation of child object should have failed due to invalid value");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // PASS
+ String message = e.getMessage();
+ assertTrue("Message does not contain the attribute name", message.contains("integerSet"));
+ assertTrue("Message does not contain the error value", message.contains("foo"));
+
+ }
+
+ assertTrue("Child should not have been registered with parent",
+ parent.getChildren(TestChildCategory.class).isEmpty());
+ }
+
+}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java Mon Aug 25 15:35:10 2014
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.model.testmodel;
+import java.util.Set;
+
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ManagedAttribute;
import org.apache.qpid.server.model.ManagedObject;
@@ -30,6 +32,12 @@ public interface TestChildCategory<X ext
String NON_INTERPOLATED_VALID_VALUE = "${file.separator}";
- @ManagedAttribute(validValues = { NON_INTERPOLATED_VALID_VALUE })
+ @ManagedAttribute(validValues = { NON_INTERPOLATED_VALID_VALUE }, defaultValue = "")
String getValidValueNotInterpolated();
+
+ @ManagedAttribute( defaultValue = "3" )
+ int getIntValue();
+
+ @ManagedAttribute( defaultValue = "[ \"1\", \"2\", \"foo\" ]" )
+ Set<Integer> getIntegerSet();
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java Mon Aug 25 15:35:10 2014
@@ -21,6 +21,7 @@
package org.apache.qpid.server.model.testmodel;
import java.util.Map;
+import java.util.Set;
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.ManagedAttributeField;
@@ -37,6 +38,12 @@ public class TestChildCategoryImpl
@ManagedAttributeField
private String _validValueNotInterpolated;
+ @ManagedAttributeField
+ private int _intValue;
+
+ @ManagedAttributeField
+ private Set<Integer> _integerSet;
+
@ManagedObjectFactoryConstructor
public TestChildCategoryImpl(final Map<String, Object> attributes, TestRootCategory<?> parent)
@@ -57,4 +64,16 @@ public class TestChildCategoryImpl
{
return _validValueNotInterpolated;
}
+
+ @Override
+ public int getIntValue()
+ {
+ return _intValue;
+ }
+
+ @Override
+ public Set<Integer> getIntegerSet()
+ {
+ return _integerSet;
+ }
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java Mon Aug 25 15:35:10 2014
@@ -36,7 +36,6 @@ import org.apache.qpid.server.model.Brok
import org.apache.qpid.server.model.BrokerModel;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.TrustStore;
-import org.apache.qpid.server.model.UnknownConfiguredObjectException;
import org.apache.qpid.server.util.BrokerTestHelper;
public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase
@@ -108,10 +107,12 @@ public class SimpleLDAPAuthenticationMan
_factory.create(AuthenticationProvider.class, _configuration, _broker);
fail("Exception not thrown");
}
- catch(UnknownConfiguredObjectException e)
+ catch(IllegalArgumentException e)
{
- assertEquals(e.getCategory(), TrustStore.class);
- assertEquals(e.getName(), "notfound");
+ // PASS
+ assertTrue("Message does not include underlying issue", e.getMessage().contains("name 'notfound'"));
+ assertTrue("Message does not include the attribute name", e.getMessage().contains("trustStore"));
+ assertTrue("Message does not include the expected type", e.getMessage().contains("TrustStore"));
}
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Mon Aug 25 15:35:10 2014
@@ -115,7 +115,7 @@ public abstract class AbstractDurableCon
_configStore = createConfigStore();
_configStore.openConfigurationStore(_parent, false);
- _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(), Collections.<String, Object>emptyMap());
+ _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(), Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "vhost"));
_configStore.create(_rootRecord);
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java Mon Aug 25 15:35:10 2014
@@ -38,6 +38,7 @@ import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
import org.apache.qpid.server.model.Queue;
@@ -248,10 +249,14 @@ public class JsonFileConfigStoreTest ext
createRootRecord();
final UUID id = UUID.randomUUID();
- _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Queue",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue"),
+ getRootAsParentMap()));
try
{
- _store.create(new ConfiguredObjectRecordImpl(id, "Exchange", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange"),
+ getRootAsParentMap()));
fail("Should not be able to create two objects with same id");
}
catch (StoreException e)
@@ -261,19 +266,61 @@ public class JsonFileConfigStoreTest ext
}
+ public void testObjectWithoutName() throws Exception
+ {
+ _store.openConfigurationStore(_parent, false);
+ createRootRecord();
+
+ final UUID id = UUID.randomUUID();
+ try
+ {
+ _store.create(new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>emptyMap(),
+ getRootAsParentMap()));
+ fail("Should not be able to create an object without a name");
+ }
+ catch (StoreException e)
+ {
+ // pass
+ }
+ }
+
+ public void testObjectWithNonStringName() throws Exception
+ {
+ _store.openConfigurationStore(_parent, false);
+ createRootRecord();
+
+ final UUID id = UUID.randomUUID();
+ try
+ {
+ _store.update(true, new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, 3),
+ getRootAsParentMap()));
+ fail("Should not be able to create an object without a name");
+ }
+ catch (StoreException e)
+ {
+ // pass
+ }
+ }
+
public void testChangeTypeOfObject() throws Exception
{
_store.openConfigurationStore(_parent, false);
createRootRecord();
final UUID id = UUID.randomUUID();
- _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.create(new ConfiguredObjectRecordImpl(id, "Queue",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue"),
+ getRootAsParentMap()));
_store.closeConfigurationStore();
_store.openConfigurationStore(_parent, false);
try
{
- _store.update(false, new ConfiguredObjectRecordImpl(id, "Exchange", Collections.<String, Object>emptyMap(), getRootAsParentMap()));
+ _store.update(false, new ConfiguredObjectRecordImpl(id, "Exchange",
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange"),
+ getRootAsParentMap()));
fail("Should not be able to update object to different type");
}
catch (StoreException e)
@@ -329,40 +376,57 @@ public class JsonFileConfigStoreTest ext
final UUID queueId = new UUID(0, 1);
final UUID queue2Id = new UUID(1, 1);
- final Map<String, Object> EMPTY_ATTR = Collections.emptyMap();
final UUID exchangeId = new UUID(0, 2);
final UUID bindingId = new UUID(0, 3);
final UUID binding2Id = new UUID(1, 3);
Map<String, UUID> parents = getRootAsParentMap();
- final ConfiguredObjectRecordImpl queueRecord = new ConfiguredObjectRecordImpl(queueId, "Queue", EMPTY_ATTR, parents);
+ Map<String, Object> queueAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue");
+ final ConfiguredObjectRecordImpl queueRecord =
+ new ConfiguredObjectRecordImpl(queueId, "Queue",
+ queueAttr,
+ parents);
_store.create(queueRecord);
- final ConfiguredObjectRecordImpl queue2Record = new ConfiguredObjectRecordImpl(queue2Id, "Queue", EMPTY_ATTR, parents);
+ Map<String, Object> queue2Attr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "queue2");
+ final ConfiguredObjectRecordImpl queue2Record =
+ new ConfiguredObjectRecordImpl(queue2Id, "Queue",
+ queue2Attr,
+ parents);
_store.create(queue2Record);
- final ConfiguredObjectRecordImpl exchangeRecord = new ConfiguredObjectRecordImpl(exchangeId, "Exchange", EMPTY_ATTR, parents);
+ Map<String, Object> exchangeAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "exchange");
+ final ConfiguredObjectRecordImpl exchangeRecord =
+ new ConfiguredObjectRecordImpl(exchangeId, "Exchange",
+ exchangeAttr,
+ parents);
_store.create(exchangeRecord);
Map<String,UUID> bindingParents = new HashMap();
bindingParents.put("Exchange", exchangeRecord.getId());
bindingParents.put("Queue", queueRecord.getId());
+ Map<String, Object> bindingAttr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "binding");
final ConfiguredObjectRecordImpl bindingRecord =
- new ConfiguredObjectRecordImpl(bindingId, "Binding", EMPTY_ATTR, bindingParents);
+ new ConfiguredObjectRecordImpl(bindingId, "Binding",
+ bindingAttr,
+ bindingParents);
Map<String,UUID> binding2Parents = new HashMap();
binding2Parents.put("Exchange", exchangeRecord.getId());
binding2Parents.put("Queue", queue2Record.getId());
+ Map<String, Object> binding2Attr = Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "binding2");
final ConfiguredObjectRecordImpl binding2Record =
- new ConfiguredObjectRecordImpl(binding2Id, "Binding", EMPTY_ATTR, binding2Parents);
+ new ConfiguredObjectRecordImpl(binding2Id, "Binding",
+ binding2Attr,
+ binding2Parents);
_store.update(true, bindingRecord, binding2Record);
_store.closeConfigurationStore();
_store.openConfigurationStore(_parent, false);
_store.visitConfiguredObjectRecords(_handler);
- verify(_handler).handle(matchesRecord(queueId, "Queue", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(queue2Id, "Queue", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(exchangeId, "Exchange", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(bindingId, "Binding", EMPTY_ATTR));
- verify(_handler).handle(matchesRecord(binding2Id, "Binding", EMPTY_ATTR));
+ verify(_handler).handle(matchesRecord(queueId, "Queue", queueAttr));
+ verify(_handler).handle(matchesRecord(queue2Id, "Queue", queue2Attr));
+ verify(_handler).handle(matchesRecord(exchangeId, "Exchange", exchangeAttr));
+ verify(_handler).handle(matchesRecord(bindingId, "Binding", bindingAttr));
+ verify(_handler).handle(matchesRecord(binding2Id, "Binding", binding2Attr));
_store.closeConfigurationStore();
}
@@ -371,7 +435,10 @@ public class JsonFileConfigStoreTest ext
private void createRootRecord()
{
UUID rootRecordId = UUID.randomUUID();
- _rootRecord = new ConfiguredObjectRecordImpl(rootRecordId, VIRTUAL_HOST_TYPE, Collections.<String, Object>emptyMap());
+ _rootRecord =
+ new ConfiguredObjectRecordImpl(rootRecordId,
+ VIRTUAL_HOST_TYPE,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME, "root"));
_store.create(_rootRecord);
}
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java Mon Aug 25 15:35:10 2014
@@ -22,6 +22,7 @@ package org.apache.qpid.server.util;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -90,6 +91,7 @@ public class BrokerTestHelper
when(broker.getSecurityManager()).thenReturn(new SecurityManager(broker, false));
when(broker.getObjectFactory()).thenReturn(objectFactory);
when(broker.getModel()).thenReturn(objectFactory.getModel());
+ when(broker.getModelVersion()).thenReturn(BrokerModel.MODEL_VERSION);
when(broker.getEventLogger()).thenReturn(eventLogger);
when(broker.getCategoryClass()).thenReturn(Broker.class);
when(broker.getParent(SystemConfig.class)).thenReturn(systemConfig);
@@ -117,9 +119,11 @@ public class BrokerTestHelper
VirtualHostNode virtualHostNode = mock(VirtualHostNode.class);
when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
+ when(virtualHostNode.getParent(eq(Broker.class))).thenReturn(broker);
+
DurableConfigurationStore dcs = mock(DurableConfigurationStore.class);
when(virtualHostNode.getConfigurationStore()).thenReturn(dcs);
- when(virtualHostNode.getParent(Broker.class)).thenReturn(broker);
+ when(virtualHostNode.getParent(eq(VirtualHostNode.class))).thenReturn(virtualHostNode);
when(virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
when(virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
when(virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
Modified: qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java Mon Aug 25 15:35:10 2014
@@ -139,7 +139,7 @@ public class AbstractStandardVirtualHost
*/
public void testActivateVHNWithVHBlueprint_StoreHasNoVH() throws Exception
{
- DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
+ DurableConfigurationStore configStore = new NullMessageStore() {};
String vhBlueprint = String.format("{ \"type\" : \"%s\", \"name\" : \"%s\"}",
TestMemoryVirtualHost.VIRTUAL_HOST_TYPE,
@@ -162,18 +162,12 @@ public class AbstractStandardVirtualHost
assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState());
assertNotNull("Unexpected virtual host id", virtualHost.getId());
- Map<String, String> updatedContext = node.getContext();
-
- assertTrue("Context should now have utilised flag", updatedContext.containsKey(
- AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR));
- assertEquals("Utilised flag should be true",
- Boolean.TRUE.toString(),
- updatedContext.get(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR));
+ assertEquals("Initial configuration should be empty", "{}", node.getVirtualHostInitialConfiguration());
}
/**
* Tests activating a virtualhostnode with blueprint context variable and the
- * marked utilised flag. Config store does not specify a virtualhost.
+ * but the virtualhostInitialConfiguration set to empty. Config store does not specify a virtualhost.
* Checks virtualhost is not recreated from the blueprint.
*/
public void testActivateVHNWithVHBlueprintUsed_StoreHasNoVH() throws Exception
@@ -185,12 +179,12 @@ public class AbstractStandardVirtualHost
TEST_VIRTUAL_HOST_NAME);
Map<String, String> context = new HashMap<>();
context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, vhBlueprint);
- context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR, Boolean.TRUE.toString());
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
nodeAttributes.put(VirtualHostNode.CONTEXT, context);
+ nodeAttributes.put(VirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, "{}");
VirtualHostNode<?> node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.open();
Modified: qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/CreditCreditManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/CreditCreditManager.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/CreditCreditManager.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/CreditCreditManager.java Mon Aug 25 15:35:10 2014
@@ -21,7 +21,9 @@
package org.apache.qpid.server.protocol.v0_10;
-import org.apache.qpid.server.flow.AbstractFlowCreditManager;public class CreditCreditManager extends AbstractFlowCreditManager implements FlowCreditManager_0_10
+import org.apache.qpid.server.flow.AbstractFlowCreditManager;
+
+public class CreditCreditManager extends AbstractFlowCreditManager implements FlowCreditManager_0_10
{
private volatile long _bytesCredit;
private volatile long _messageCredit;
Modified: qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java Mon Aug 25 15:35:10 2014
@@ -32,6 +32,7 @@ import org.apache.qpid.exchange.Exchange
import org.apache.qpid.framing.AMQMethodBody;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.ExchangeDeclareBody;
+import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.MethodRegistry;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.exchange.ExchangeImpl;
@@ -115,15 +116,22 @@ public class ExchangeDeclareHandler impl
{
String name = exchangeName == null ? null : exchangeName.intern().toString();
String type = body.getType() == null ? null : body.getType().intern().toString();
- Map<String,Object> attributes = new HashMap<String, Object>();
+ Map<String,Object> attributes = new HashMap<String, Object>();
+ if(body.getArguments() != null)
+ {
+ attributes.putAll(FieldTable.convertToMap(body.getArguments()));
+ }
attributes.put(org.apache.qpid.server.model.Exchange.ID, null);
attributes.put(org.apache.qpid.server.model.Exchange.NAME,name);
attributes.put(org.apache.qpid.server.model.Exchange.TYPE,type);
attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, body.getDurable());
attributes.put(org.apache.qpid.server.model.Exchange.LIFETIME_POLICY,
body.getAutoDelete() ? LifetimePolicy.DELETE_ON_NO_LINKS : LifetimePolicy.PERMANENT);
- attributes.put(org.apache.qpid.server.model.Exchange.ALTERNATE_EXCHANGE, null);
+ if(!attributes.containsKey(org.apache.qpid.server.model.Exchange.ALTERNATE_EXCHANGE))
+ {
+ attributes.put(org.apache.qpid.server.model.Exchange.ALTERNATE_EXCHANGE, null);
+ }
exchange = virtualHost.createExchange(attributes);
}
@@ -160,6 +168,10 @@ public class ExchangeDeclareHandler impl
// note - since 0-8/9/9-1 can't set the alt. exchange this exception should never occur
throw body.getConnectionException(AMQConstant.NOT_FOUND, "Unknown alternate exchange",e);
}
+ catch (IllegalArgumentException e)
+ {
+ throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Error creating exchange",e);
+ }
}
}
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Mon Aug 25 15:35:10 2014
@@ -210,7 +210,7 @@ public class HttpManagement extends Abst
+ transports);
}
lastPort = port.getPort();
- String bindingAddress = port.getBindingAddress();
+ String bindingAddress = ((HttpPort)port).getBindingAddress();
if (bindingAddress != null && !bindingAddress.trim().equals("") && !bindingAddress.trim().equals("*"))
{
connector.setHost(bindingAddress.trim());
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java Mon Aug 25 15:35:10 2014
@@ -119,7 +119,7 @@ public class FileServlet extends HttpSer
}
else
{
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "unknown file: "+ filename);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "unknown file");
}
}
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java Mon Aug 25 15:35:10 2014
@@ -20,33 +20,53 @@
package org.apache.qpid.server.management.plugin.servlet.rest;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectAttribute;
public class ConfiguredObjectToMapConverter
{
/** Name of the key used for the statistics map */
public static final String STATISTICS_MAP_KEY = "statistics";
+ private static Set<String> CONFIG_EXCLUDED_ATTRIBUTES =
+ new HashSet<>(Arrays.asList(ConfiguredObject.ID,
+ ConfiguredObject.DURABLE,
+ ConfiguredObject.CREATED_BY,
+ ConfiguredObject.CREATED_TIME,
+ ConfiguredObject.LAST_UPDATED_BY,
+ ConfiguredObject.LAST_UPDATED_TIME));
+
public Map<String, Object> convertObjectToMap(final ConfiguredObject<?> confObject,
Class<? extends ConfiguredObject> clazz,
int depth,
final boolean useActualValues,
- final boolean includeSystemContext)
+ final boolean includeSystemContext,
+ final boolean extractAsConfig)
{
- Map<String, Object> object = new LinkedHashMap<String, Object>();
+ Map<String, Object> object = new LinkedHashMap<>();
- incorporateAttributesIntoMap(confObject, object, useActualValues, includeSystemContext);
- incorporateStatisticsIntoMap(confObject, object);
+ incorporateAttributesIntoMap(confObject, object, useActualValues, includeSystemContext, extractAsConfig);
+ if(!extractAsConfig)
+ {
+ incorporateStatisticsIntoMap(confObject, object);
+ }
if(depth > 0)
{
- incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, includeSystemContext);
+ incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, includeSystemContext, extractAsConfig);
}
return object;
}
@@ -56,60 +76,100 @@ public class ConfiguredObjectToMapConver
final ConfiguredObject<?> confObject,
Map<String, Object> object,
final boolean useActualValues,
- final boolean includeSystemContext)
+ final boolean includeSystemContext,
+ final boolean extractAsConfig)
{
-
- for(String name : confObject.getAttributeNames())
+ // if extracting as config add a fake attribute for each secondary parent
+ if(extractAsConfig && confObject.getModel().getParentTypes(confObject.getCategoryClass()).size()>1)
{
- Object value = useActualValues ? confObject.getActualAttributes().get(name) : confObject.getAttribute(name);
- if(value instanceof ConfiguredObject)
+ Iterator<Class<? extends ConfiguredObject>> parentClasses =
+ confObject.getModel().getParentTypes(confObject.getCategoryClass()).iterator();
+
+ // ignore the first parent which is supplied by structure
+ parentClasses.next();
+
+ while(parentClasses.hasNext())
{
- object.put(name, ((ConfiguredObject) value).getName());
+ Class<? extends ConfiguredObject> parentClass = parentClasses.next();
+ ConfiguredObject parent = confObject.getParent(parentClass);
+ if(parent != null)
+ {
+ String categoryName = parentClass.getSimpleName();
+ object.put(categoryName.substring(0,1).toLowerCase()+categoryName.substring(1), parent.getName());
+ }
}
- else if(ConfiguredObject.CONTEXT.equals(name))
+ }
+
+ for(String name : confObject.getAttributeNames())
+ {
+ if (!(extractAsConfig && CONFIG_EXCLUDED_ATTRIBUTES.contains(name)))
{
- Map<String,Object> contextValues = new HashMap<>();
- if(useActualValues)
+ Object value =
+ useActualValues ? confObject.getActualAttributes().get(name) : confObject.getAttribute(name);
+ if (value instanceof ConfiguredObject)
{
- contextValues.putAll(confObject.getContext());
+ object.put(name, ((ConfiguredObject) value).getName());
}
- else
+ else if (ConfiguredObject.CONTEXT.equals(name))
{
- for(String contextName : confObject.getContextKeys(!includeSystemContext))
+ Map<String, Object> contextValues = new HashMap<>();
+ if (useActualValues)
+ {
+ contextValues.putAll(confObject.getContext());
+ }
+ else
{
- contextValues.put(contextName, confObject.getContextValue(String.class, contextName));
+ for (String contextName : confObject.getContextKeys(!includeSystemContext))
+ {
+ contextValues.put(contextName, confObject.getContextValue(String.class, contextName));
+ }
+ }
+ if (!contextValues.isEmpty())
+ {
+ object.put(ConfiguredObject.CONTEXT, contextValues);
}
}
- object.put(ConfiguredObject.CONTEXT, contextValues);
- }
- else if(value instanceof Collection)
- {
- List<Object> converted = new ArrayList();
- for(Object member : (Collection)value)
+ else if (value instanceof Collection)
{
- if(member instanceof ConfiguredObject)
+ List<Object> converted = new ArrayList<>();
+ for (Object member : (Collection) value)
{
- converted.add(((ConfiguredObject)member).getName());
+ if (member instanceof ConfiguredObject)
+ {
+ converted.add(((ConfiguredObject) member).getName());
+ }
+ else
+ {
+ converted.add(member);
+ }
}
- else
+ object.put(name, converted);
+ }
+ else if (value != null)
+ {
+ object.put(name, value);
+ }
+ else if (extractAsConfig)
+ {
+ ConfiguredObjectAttribute<?, ?> attribute = confObject.getModel()
+ .getTypeRegistry()
+ .getAttributeTypes(confObject.getClass())
+ .get(name);
+
+ if(attribute.isPersisted() && attribute.isDerived())
{
- converted.add(member);
+ object.put(name, confObject.getAttribute(name));
}
}
- object.put(name, converted);
- }
- else if(value != null)
- {
- object.put(name, value);
}
}
}
private void incorporateStatisticsIntoMap(
- final ConfiguredObject confObject, Map<String, Object> object)
+ final ConfiguredObject<?> confObject, Map<String, Object> object)
{
- Map<String, Object> statMap = confObject.getStatistics();
+ Map<String, Object> statMap = new TreeMap<String,Object>(confObject.getStatistics());
if(!statMap.isEmpty())
{
@@ -120,24 +180,60 @@ public class ConfiguredObjectToMapConver
private void incorporateChildrenIntoMap(
final ConfiguredObject confObject,
- Class<? extends ConfiguredObject> clazz, int depth,
- Map<String, Object> object, final boolean useActualValues, final boolean includeSystemContext)
+ Class<? extends ConfiguredObject> clazz,
+ int depth,
+ Map<String, Object> object,
+ final boolean useActualValues,
+ final boolean includeSystemContext,
+ final boolean extractAsConfig)
{
- for(Class<? extends ConfiguredObject> childClass : confObject.getModel().getChildTypes(clazz))
+ List<Class<? extends ConfiguredObject>> childTypes = new ArrayList<>(confObject.getModel().getChildTypes(clazz));
+
+ Collections.sort(childTypes, new Comparator<Class<? extends ConfiguredObject>>()
{
- Collection<? extends ConfiguredObject> children = confObject.getChildren(childClass);
- if(children != null)
+ @Override
+ public int compare(final Class<? extends ConfiguredObject> o1, final Class<? extends ConfiguredObject> o2)
+ {
+ return o1.getSimpleName().compareTo(o2.getSimpleName());
+ }
+ });
+ for(Class<? extends ConfiguredObject> childClass : childTypes)
+ {
+ if(!(extractAsConfig && confObject.getModel().getParentTypes(childClass).iterator().next() != confObject.getCategoryClass()))
{
- List<Map<String, Object>> childObjects = new ArrayList<Map<String, Object>>();
- for(ConfiguredObject child : children)
+ Collection children = confObject.getChildren(childClass);
+ if(children != null)
{
- childObjects.add(convertObjectToMap(child, childClass, depth-1, useActualValues, includeSystemContext));
- }
+ List<? extends ConfiguredObject> sortedChildren = new ArrayList<ConfiguredObject>(children);
+ Collections.sort(sortedChildren, new Comparator<ConfiguredObject>()
+ {
+ @Override
+ public int compare(final ConfiguredObject o1, final ConfiguredObject o2)
+ {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
- if(!childObjects.isEmpty())
- {
- object.put(childClass.getSimpleName().toLowerCase()+"s",childObjects);
+ List<Map<String, Object>> childObjects = new ArrayList<>();
+
+ for (ConfiguredObject child : sortedChildren)
+ {
+ if (!(extractAsConfig && !child.isDurable()))
+ {
+ childObjects.add(convertObjectToMap(child,
+ childClass,
+ depth - 1,
+ useActualValues,
+ includeSystemContext,
+ extractAsConfig));
+ }
+ }
+
+ if (!childObjects.isEmpty())
+ {
+ object.put(childClass.getSimpleName().toLowerCase() + "s", childObjects);
+ }
}
}
}
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java Mon Aug 25 15:35:10 2014
@@ -59,8 +59,14 @@ public class RestServlet extends Abstrac
public static final String ACTUALS_PARAM = "actuals";
public static final String SORT_PARAM = "sort";
public static final String INCLUDE_SYS_CONTEXT_PARAM = "includeSysContext";
+ public static final String EXTRACT_INITIAL_CONFIG_PARAM = "extractInitialConfig";
- public static final Set<String> RESERVED_PARAMS = new HashSet<String>(Arrays.asList(DEPTH_PARAM, SORT_PARAM, ACTUALS_PARAM, INCLUDE_SYS_CONTEXT_PARAM));
+ public static final Set<String> RESERVED_PARAMS =
+ new HashSet<>(Arrays.asList(DEPTH_PARAM,
+ SORT_PARAM,
+ ACTUALS_PARAM,
+ INCLUDE_SYS_CONTEXT_PARAM,
+ EXTRACT_INITIAL_CONFIG_PARAM));
private Class<? extends ConfiguredObject>[] _hierarchy;
@@ -316,21 +322,35 @@ public class RestServlet extends Abstrac
Collection<ConfiguredObject<?>> allObjects = getObjects(request);
// TODO - sort special params, everything else should act as a filter
- int depth = getDepthParameterFromRequest(request);
- boolean actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM);
- boolean includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM);
+ boolean extractInitialConfig = getBooleanParameterFromRequest(request, EXTRACT_INITIAL_CONFIG_PARAM);
+ int depth;
+ boolean actuals;
+ boolean includeSystemContext;
+
+ if(extractInitialConfig)
+ {
+ depth = Integer.MAX_VALUE;
+ actuals = true;
+ includeSystemContext = false;
+ }
+ else
+ {
+ depth = getDepthParameterFromRequest(request);
+ actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM);
+ includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM);
+ }
List<Map<String, Object>> output = new ArrayList<Map<String, Object>>();
for(ConfiguredObject configuredObject : allObjects)
{
output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(),
- depth, actuals, includeSystemContext));
+ depth, actuals, includeSystemContext, extractInitialConfig));
}
Writer writer = getOutputWriter(request, response);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
- mapper.writeValue(writer, output);
+ mapper.writeValue(writer, extractInitialConfig && output.size() == 1 ? output.get(0) : output);
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html Mon Aug 25 15:35:10 2014
@@ -39,6 +39,25 @@
title: 'Enter name of port'"/>
</div>
</div>
+
+ <div class="clear">
+ <div class="formLabel-labelCell">
+ <label for="formAddPort.type">Port Type*:</label>
+ </div>
+ <div class="formLabel-controlCell">
+ <select id="formAddPort.type"
+ data-dojo-type="dijit.form.FilteringSelect"
+ data-dojo-props="
+ name: 'type',
+ label: 'Port Type*:',
+ value: '',
+ placeHolder: 'port type',
+ promptMessage: 'Port type',
+ title: 'Enter port type'">
+ </select>
+ </div>
+ </div>
+
<div class="clear">
<div class="formLabel-labelCell">
<label for="formAddPort.port">Port Number*:</label>
@@ -54,27 +73,27 @@
title: 'Enter port number'"/>
</div>
</div>
+ </div>
+
+ <div id="formAddPort:fieldsProtocols">
<div class="clear">
<div class="formLabel-labelCell">
- <label for="formAddPort.type">Port Type*:</label>
+ <label for="formAddPort.protocols">Protocols*:</label>
</div>
<div class="formLabel-controlCell">
- <select id="formAddPort.type"
- data-dojo-type="dijit.form.FilteringSelect"
+ <select id="formAddPort.protocols"
+ data-dojo-type="dijit.form.MultiSelect"
data-dojo-props="
- name: 'type',
- label: 'Port Type*:',
+ name: 'protocols',
value: '',
- placeHolder: 'port type',
- promptMessage: 'Port type',
- title: 'Enter port type'">
- <option value="AMQP" selected="selected">AMQP</option>
- <option value="JMX">JMX</option>
- <option value="HTTP">HTTP</option>
+ label: 'protocol*:',
+ promptMessage: 'Protocol to be associated with this port',
+ title: 'Enter protocol to be associated with this port'">
</select>
</div>
</div>
</div>
+
<div id="formAddPort:fieldsAuthenticationProvider">
<div class="clear">
<div class="formLabel-labelCell">
@@ -94,6 +113,7 @@
</div>
</div>
</div>
+
<div id="formAddPort:fieldsBindingAddress">
<div class="clear">
<div class="formLabel-labelCell">
@@ -110,79 +130,6 @@
</div>
</div>
</div>
- <div id="formAddPort:fieldsAMQP">
- <div class="clear">
- <div class="formLabel-labelCell">
- <label for="formAddPort.protocolsDefault">Support default protocols:</label>
- </div>
- <div class="formLabel-controlCell">
- <input id="formAddPort.protocolsDefault" type="checkbox"
- dojoType="dijit.form.CheckBox"
- data-dojo-props="checked: true"/>
- </div>
- </div>
- <div class="clear">
- <div class="formLabel-labelCell">
- <label for="formAddPort.protocolsAMQP">AMQP protocols:</label>
- </div>
- <div class="formLabel-controlCell">
- <select id="formAddPort.protocolsAMQP"
- data-dojo-type="dijit.form.MultiSelect"
- data-dojo-props="
- name: 'protocols',
- value: '',
- placeHolder: 'AMQP protocols',
- promptMessage: 'AMQP protocols to be associated with this port',
- title: 'Select AMQP protocols to be associated with this port',
- multiple: true">
- <option value="AMQP_0_8">AMQP 0.8</option>
- <option value="AMQP_0_9">AMQP 0.9</option>
- <option value="AMQP_0_9_1">AMQP 0.9.1</option>
- <option value="AMQP_0_10">AMQP 0.10</option>
- <option value="AMQP_1_0">AMQP 1.0</option>
- </select>
- </div>
- </div>
- </div>
- <div id="formAddPort:fieldsJMX">
- <div class="clear">
- <div class="formLabel-labelCell">
- <label for="formAddPort.protocolsJMX">JMX protocol*:</label>
- </div>
- <div class="formLabel-controlCell">
- <select id="formAddPort.protocolsJMX"
- data-dojo-type="dijit.form.FilteringSelect"
- data-dojo-props="
- name: 'protocols',
- value: '',
- promptMessage: 'JMX protocol to be associated with this port',
- title: 'Enter JMX protocol to be associated with this port'">
- <option value="RMI">RMI</option>
- <option value="JMX_RMI">JMX RMI</option>
- </select>
- </div>
- </div>
- </div>
-
- <div id="formAddPort:fieldsHTTP">
- <div class="clear">
- <div class="formLabel-labelCell">
- <label for="formAddPort.protocolsHTTP">HTTP protocols*:</label>
- </div>
- <div class="formLabel-controlCell">
- <select id="formAddPort.protocolsHTTP"
- data-dojo-type="dijit.form.FilteringSelect"
- data-dojo-props="
- name: 'protocols',
- value: 'HTTP',
- label: 'HTTP protocol*:',
- promptMessage: 'HTTP protocol to be associated with this port',
- title: 'Enter HTTP protocol to be associated with this port'">
- <option value="HTTP">HTTP</option>
- </select>
- </div>
- </div>
- </div>
<div id="formAddPort:transport" >
<div class="clear">
@@ -199,13 +146,11 @@
multiple: true,
promptMessage: 'Transport(s)',
title: 'Select transports'">
- <option value="TCP">TCP</option>
- <option value="SSL">SSL</option>
</select>
</div>
</div>
- <div class="clear"/>
</div>
+
<div id="formAddPort:fieldsTransportSSL">
<div class="clear">
<div class="formLabel-labelCell">
@@ -227,6 +172,7 @@
</div>
</div>
</div>
+
<div id="formAddPort:fieldsClientAuth">
<div id="formAddPort:fieldsClientAuthCheckboxes">
<div class="clear">
@@ -252,6 +198,7 @@
</div>
</div>
</div>
+
<div class="clear">
<div class="formLabel-labelCell">
Trust Stores:
@@ -265,7 +212,7 @@
data-dojo-props="
plugins: {indirectSelection: true},
rowSelector:'0px'"
- style="height: 100px; width:400px">
+ style="height: 100px; width:400px"> <!--todo remove -->
<thead>
<tr>
<th field="name">Name</th>
@@ -276,8 +223,9 @@
</div>
</div>
</div>
+
<input type="hidden" id="formAddPort.id" name="id"/>
- <div class="clear"/>
+ <div class="clear"></div>
<div class="dijitDialogPaneActionBar">
<!-- submit buttons -->
<input type="submit" value="Save Port" label="Save Port" dojoType="dijit.form.Button" />
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css Mon Aug 25 15:35:10 2014
@@ -279,3 +279,7 @@ div .messages {
border: none;
background-color: transparent;
}
+
+.dijitMultiSelect {
+ width : 14.75em;
+}
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js Mon Aug 25 15:35:10 2014
@@ -17,11 +17,12 @@
* under the License.
*/
define(["dojo/_base/xhr",
+ "dojo/_base/array",
"dojox/lang/functional/object",
"qpid/common/properties",
"dojo/domReady!"
],
- function (xhr, fobject, properties)
+ function (xhr, array, fobject, properties)
{
var metadata =
{
@@ -48,6 +49,22 @@ define(["dojo/_base/xhr",
getTypesForCategory: function (category)
{
return fobject.keys(this.metadata[category]);
+ },
+ extractUniqueListOfValues : function(data)
+ {
+ var values = [];
+ for (i = 0; i < data.length; i++)
+ {
+ for (j = 0; j < data[i].length; j++)
+ {
+ var current = data[i][j];
+ if (array.indexOf(values, current) == -1)
+ {
+ values.push(current);
+ }
+ }
+ }
+ return values;
}
};
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js Mon Aug 25 15:35:10 2014
@@ -26,7 +26,7 @@ define(["dojo/_base/xhr",
"dojo/dom-construct",
"dojo/dom-geometry",
"dojo/dom-style",
- "dojo/window",
+ "dojo/_base/window",
"dojo/query",
"dojo/parser",
"dojo/store/Memory",
@@ -683,7 +683,37 @@ define(["dojo/_base/xhr",
return new Memory({ data: typeData });
}
- var singleContextVarRegexp = "(\\${[\\w\\.\\-]+})";
+ util.setMultiSelectOptions = function(multiSelectWidget, options)
+ {
+ util.addMultiSelectOptions(multiSelectWidget, options, true);
+ }
+
+ util.addMultiSelectOptions = function(multiSelectWidget, options, clearExistingOptions)
+ {
+ if (clearExistingOptions)
+ {
+ var children = multiSelectWidget.children;
+ var initialLength = children.length;
+ for (var i = initialLength - 1; i >= 0 ; i--)
+ {
+ var child = children.item(i);
+ multiSelectWidget.removeChild(child);
+ }
+ }
+ for (var i = 0; i < options.length; i++)
+ {
+ // construct new option for list
+ var newOption = win.doc.createElement('option');
+ var value = options[i];
+ newOption.innerHTML = value;
+ newOption.value = value;
+
+ // add new option to list
+ multiSelectWidget.appendChild(newOption);
+ }
+ }
+
+ var singleContextVarRegexp = "(\\${[\\w+\\.\\-:]+})";
util.numericOrContextVarRegexp = function(constraints)
{
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js Mon Aug 25 15:35:10 2014
@@ -210,7 +210,7 @@ define(["dojo/_base/xhr",
var addPortButton = query(".addPort", contentPane.containerNode)[0];
connect.connect(registry.byNode(addPortButton), "onClick", function(evt){
- addPort.show(null, that.brokerUpdater.brokerData.authenticationproviders,
+ addPort.show(null, "AMQP", that.brokerUpdater.brokerData.authenticationproviders,
that.brokerUpdater.brokerData.keystores, that.brokerUpdater.brokerData.truststores);
});
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js Mon Aug 25 15:35:10 2014
@@ -140,6 +140,7 @@ define(["dojo/_base/xhr",
}
storeNodes(["name",
+ "type",
"state",
"durable",
"lifetimePolicy",
@@ -197,6 +198,8 @@ define(["dojo/_base/xhr",
ExchangeUpdater.prototype.updateHeader = function()
{
this.name.innerHTML = entities.encode(String(this.exchangeData[ "name" ]));
+ this["type"].innerHTML = entities.encode(String(this.exchangeData[ "type" ]));
+
this.state.innerHTML = entities.encode(String(this.exchangeData[ "state" ]));
this.durable.innerHTML = entities.encode(String(this.exchangeData[ "durable" ]));
this.lifetimePolicy.innerHTML = entities.encode(String(this.exchangeData[ "lifetimePolicy" ]));
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js Mon Aug 25 15:35:10 2014
@@ -30,8 +30,9 @@ define(["dojo/dom",
"qpid/common/util",
"qpid/common/formatter",
"qpid/management/addPort",
+ "qpid/common/metadata",
"dojo/domReady!"],
- function (dom, xhr, parser, query, connect, registry, entities, properties, updater, util, formatter, addPort) {
+ function (dom, xhr, parser, query, connect, registry, entities, properties, updater, util, formatter, addPort, metadata) {
function Port(name, parent, controller) {
this.name = name;
@@ -104,7 +105,7 @@ define(["dojo/dom",
.then(function(data)
{
var brokerData= data[0];
- addPort.show(that.name, brokerData.authenticationproviders, brokerData.keystores, brokerData.truststores);
+ addPort.show(that.name, that.portUpdater.portData.type, brokerData.authenticationproviders, brokerData.keystores, brokerData.truststores);
}
);
}
@@ -126,6 +127,7 @@ define(["dojo/dom",
storeNodes(["nameValue",
"stateValue",
+ "typeValue",
"portValue",
"authenticationProviderValue",
"protocolsValue",
@@ -146,7 +148,7 @@ define(["dojo/dom",
xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
{
- that.keyStoreData = data[0];
+ that.portData = data[0];
that.updateHeader();
});
@@ -166,26 +168,26 @@ define(["dojo/dom",
return data + "</div>";
}
- this.nameValue.innerHTML = entities.encode(String(this.keyStoreData[ "name" ]));
- this.stateValue.innerHTML = entities.encode(String(this.keyStoreData[ "state" ]));
- this.portValue.innerHTML = entities.encode(String(this.keyStoreData[ "port" ]));
- this.authenticationProviderValue.innerHTML = this.keyStoreData[ "authenticationProvider" ] ? entities.encode(String(this.keyStoreData[ "authenticationProvider" ])) : "";
- this.protocolsValue.innerHTML = printArray( "protocols", this.keyStoreData);
- this.transportsValue.innerHTML = printArray( "transports", this.keyStoreData);
- this.bindingAddressValue.innerHTML = this.keyStoreData[ "bindingAddress" ] ? entities.encode(String(this.keyStoreData[ "bindingAddress" ])) : "" ;
- this.keyStoreValue.innerHTML = this.keyStoreData[ "keyStore" ] ? entities.encode(String(this.keyStoreData[ "keyStore" ])) : "";
- this.needClientAuthValue.innerHTML = "<input type='checkbox' disabled='disabled' "+(this.keyStoreData[ "needClientAuth" ] ? "checked='checked'": "")+" />" ;
- this.wantClientAuthValue.innerHTML = "<input type='checkbox' disabled='disabled' "+(this.keyStoreData[ "wantClientAuth" ] ? "checked='checked'": "")+" />" ;
- this.trustStoresValue.innerHTML = printArray( "trustStores", this.keyStoreData);
- var amqpProtocol = this.keyStoreData["protocols"][0] && this.keyStoreData["protocols"][0].indexOf("AMQP") == 0;
- this.bindingAddress.style.display= amqpProtocol? "block" : "none";
- var sslTransport = this.keyStoreData["transports"][0] && this.keyStoreData["transports"][0] == "SSL";
- var displayStyle = sslTransport ? "block" : "none";
- this.trustStoresValue.style.display = displayStyle;
- this.keyStore.style.display = displayStyle;
- this.needClientAuth.style.display = displayStyle;
- this.wantClientAuth.style.display = displayStyle;
- this.trustStores.style.display = displayStyle;
+ this.nameValue.innerHTML = entities.encode(String(this.portData[ "name" ]));
+ this.stateValue.innerHTML = entities.encode(String(this.portData[ "state" ]));
+ this.typeValue.innerHTML = entities.encode(String(this.portData[ "type" ]));
+ this.portValue.innerHTML = entities.encode(String(this.portData[ "port" ]));
+ this.authenticationProviderValue.innerHTML = this.portData[ "authenticationProvider" ] ? entities.encode(String(this.portData[ "authenticationProvider" ])) : "";
+ this.protocolsValue.innerHTML = printArray( "protocols", this.portData);
+ this.transportsValue.innerHTML = printArray( "transports", this.portData);
+ this.bindingAddressValue.innerHTML = this.portData[ "bindingAddress" ] ? entities.encode(String(this.portData[ "bindingAddress" ])) : "" ;
+ this.keyStoreValue.innerHTML = this.portData[ "keyStore" ] ? entities.encode(String(this.portData[ "keyStore" ])) : "";
+ this.needClientAuthValue.innerHTML = "<input type='checkbox' disabled='disabled' "+(this.portData[ "needClientAuth" ] ? "checked='checked'": "")+" />" ;
+ this.wantClientAuthValue.innerHTML = "<input type='checkbox' disabled='disabled' "+(this.portData[ "wantClientAuth" ] ? "checked='checked'": "")+" />" ;
+ this.trustStoresValue.innerHTML = printArray( "trustStores", this.portData);
+
+ var typeMetaData = metadata.getMetaData("Port", this.portData["type"]);
+
+ this.bindingAddress.style.display = "bindingAddress" in typeMetaData.attributes ? "block" : "none";
+ this.keyStore.style.display = "keyStore" in typeMetaData.attributes ? "block" : "none";
+ this.needClientAuth.style.display = "needClientAuth" in typeMetaData.attributes ? "block" : "none";
+ this.wantClientAuth.style.display = "wantClientAuth" in typeMetaData.attributes ? "block" : "none";
+ this.trustStores.style.display = "trustStores" in typeMetaData.attributes ? "block" : "none";
};
PortUpdater.prototype.update = function()
@@ -195,7 +197,7 @@ define(["dojo/dom",
xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
{
- thisObj.keyStoreData = data[0];
+ thisObj.portData = data[0];
thisObj.updateHeader();
});
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org