summaryrefslogtreecommitdiffstats
path: root/install/ui/ipa.js
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2011-11-17 12:09:00 -0600
committerEndi S. Dewata <edewata@redhat.com>2011-11-18 15:57:00 +0000
commite84bd27af2db254fb1ed5ccc58202f0fb5c6f8cc (patch)
tree7f158d66b17e1639e685dc7673a995d31b3dfd32 /install/ui/ipa.js
parenta9e4316d5aa626e0831febd8b50678fd81f6a67d (diff)
downloadfreeipa-e84bd27af2db254fb1ed5ccc58202f0fb5c6f8cc.tar.gz
freeipa-e84bd27af2db254fb1ed5ccc58202f0fb5c6f8cc.tar.xz
freeipa-e84bd27af2db254fb1ed5ccc58202f0fb5c6f8cc.zip
Fixed entity definition in test cases.
The test cases have been updated to use the new extensible mechanism for defining and registering entities. Ticket #2043
Diffstat (limited to 'install/ui/ipa.js')
-rw-r--r--install/ui/ipa.js71
1 files changed, 39 insertions, 32 deletions
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index c6d39478a..1ebf1acc4 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -167,49 +167,56 @@ var IPA = function() {
};
that.register = function(name, factory) {
+ that.remove_entity(name);
that.entity_factories[name] = factory;
};
- that.get_entities = function() {
- return that.entities.values;
- };
+ that.create_entity = function(name) {
+ var factory = that.entity_factories[name];
+ if (!factory) return null;
- that.get_entity = function(name) {
- var entity = that.entities.get(name);
- if (!entity) {
- var factory = that.entity_factories[name];
- if (!factory) {
- return null;
- }
+ try {
+ var builder = that.entity_builder();
- try {
- var builder = that.entity_builder();
+ builder.entity({
+ factory: factory,
+ name: name
+ });
- builder.entity({
- factory: factory,
- name: name
- });
+ var entity = builder.build();
- entity = builder.build();
- entity.init({
- builder: builder
- });
+ entity.init({
+ builder: builder
+ });
- that.add_entity(entity);
+ return entity;
- } catch (e) {
- if (e.expected) {
- /*expected exceptions thrown by builder just mean that
- entities are not to be registered. */
- return null;
- }
- if (e.message) {
- alert(e.message);
- } else {
- alert(e);
- }
+ } catch (e) {
+ if (e.expected) {
+ /*expected exceptions thrown by builder just mean that
+ entities are not to be registered. */
return null;
}
+
+ if (e.message) {
+ alert(e.message);
+ } else {
+ alert(e);
+ }
+
+ return null;
+ }
+ };
+
+ that.get_entities = function() {
+ return that.entities.values;
+ };
+
+ that.get_entity = function(name) {
+ var entity = that.entities.get(name);
+ if (!entity) {
+ entity = that.create_entity(name);
+ if (entity) that.add_entity(entity);
}
return entity;
};