diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js
index a3ed7c2dff..c8474fd796 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js
@@ -4,6 +4,7 @@ var module = angular.module('keycloak.controllers', [ 'keycloak.services' ]);
var realmslist = {};
+
module.controller('GlobalCtrl', function($scope, $http, Auth, $location, Notifications) {
$scope.addMessage = function() {
Notifications.success("test");
@@ -152,20 +153,30 @@ module.controller('ApplicationDetailCtrl', function($scope, application, Applica
});
-module.controller('RealmListCtrl', function($scope, Realm) {
+module.controller('RealmListCtrl', function($scope, Realm, Current) {
$scope.realms = Realm.get();
- realmslist = $scope.realms;
+ Current.realms = $scope.realms;
});
-module.controller('RealmDropdownCtrl', function($scope, Realm) {
+module.controller('RealmDropdownCtrl', function($scope, Realm, Current, $location) {
console.log('test log writing');
- realmslist = Realm.get();
- $scope.realmslist = function() {
- return realmslist;
+ Current.realms = Realm.get();
+ $scope.current = Current;
+ $scope.changeRealm = function() {
+ console.log('select box changed');
+ for (var id in Current.realms) {
+ var val = Current.realms[id];
+ console.log('checking: ' + val);
+ if (val == Current.realm) {
+ console.log("redirect to: /realms/" + id);
+ $location.url("/realms/" + id);
+ break;
+ }
+ }
};
});
-module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, Dialog, Notifications) {
+module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $location, Dialog, Notifications) {
$scope.realm = angular.copy(realm);
$scope.createRealm = !realm.id;
@@ -260,13 +271,21 @@ module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, D
Realm.save(realmCopy, function(data, headers) {
var l = headers().location;
var id = l.substring(l.lastIndexOf("/") + 1);
- realmslist = Realm.get();
- $location.url("/realms/" + id);
+
+ var data = Realm.get(function() {
+ Current.realms = data;
+ Current.realm = Current.realms[id];
+ console.log('Current.realms[id]: ' + Current.realms[id]);
+ console.log('data[id]: ' + data[id]);
+ console.log('Current.realm.name: ' + Current.realm.name);
+
+ });
+ $location.url("/realms/" + id);
Notifications.success("Created realm");
});
} else {
Realm.update(realmCopy, function() {
- realmslist = Realm.get();
+ Current.realms = Realm.get();
$scope.changed = false;
realm = angular.copy($scope.realm);
Notifications.success("Saved changes to realm");
@@ -290,7 +309,7 @@ module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, D
$scope.remove = function() {
Dialog.confirmDelete($scope.realm.name, 'realm', function() {
Realm.remove($scope.realm, function() {
- realmslist = Realm.get();
+ Current.realms = Realm.get();
$location.url("/realms");
Notifications.success("Deleted realm");
});
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/services.js b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/services.js
index ba3a26a9d7..02995c8989 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/services.js
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/services.js
@@ -157,4 +157,11 @@ module.factory('Role', function($resource) {
method : 'PUT'
}
});
+});
+
+module.factory('Current', function($resource) {
+ return {
+ realm : null,
+ realms : {}
+ };
});
\ No newline at end of file
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/menu.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/menu.html
index effc324437..6d6423d49f 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/menu.html
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/menu.html
@@ -3,32 +3,36 @@
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html
index 7a841a1665..a10e742628 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html
@@ -7,7 +7,7 @@
New Realm
- {{realm.realm}}
+ Realm Settings
Please fill
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html
index d72e57a5ce..bfdbbe5bf0 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html
@@ -1,21 +1,11 @@
\ No newline at end of file
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html
index 6521861090..a2ea839fcd 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html
@@ -7,7 +7,7 @@
New Role
- Role {{role.name}}
+ Realm Role {{role.name}}
Please fill in
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html
index 1693cb1f61..107f6fdfad 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html
+++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html
@@ -7,7 +7,7 @@
Add Role
- {{realm.realm}} roles
+ Realm Roles
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmResourceResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmResourceResource.java
new file mode 100755
index 0000000000..5f91f64ed6
--- /dev/null
+++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmResourceResource.java
@@ -0,0 +1,69 @@
+package org.keycloak.services.resources.admin;
+
+import org.jboss.resteasy.annotations.cache.NoCache;
+import org.jboss.resteasy.logging.Logger;
+import org.keycloak.representations.idm.ResourceRepresentation;
+import org.keycloak.services.managers.RealmManager;
+import org.keycloak.services.managers.ResourceManager;
+import org.keycloak.services.models.RealmModel;
+import org.keycloak.services.models.ResourceModel;
+import org.keycloak.services.models.UserModel;
+import org.keycloak.services.resources.Transaction;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Bill Burke
+ * @version $Revision: 1 $
+ */
+public class RealmResourceResource {
+ protected static final Logger logger = Logger.getLogger(RealmAdminResource.class);
+ protected UserModel admin;
+ protected RealmModel realm;
+ protected ResourceModel resourceModel;
+
+ public RealmResourceResource(UserModel admin, RealmModel realm, ResourceModel resourceModel) {
+ this.admin = admin;
+ this.realm = realm;
+ this.resourceModel = resourceModel;
+ }
+
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ public void update(final ResourceRepresentation rep) {
+ new Transaction() {
+ @Override
+ protected void runImpl() {
+ ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
+ resourceManager.updateResource(rep, resourceModel);
+ }
+ }.run();
+ }
+
+
+ @GET
+ @NoCache
+ @Produces(MediaType.APPLICATION_JSON)
+ public ResourceRepresentation getResource(final @PathParam("id") String id) {
+ return new Transaction() {
+ @Override
+ protected ResourceRepresentation callImpl() {
+ ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
+ return resourceManager.toRepresentation(resourceModel);
+ }
+ }.call();
+ }
+}
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmResourcesResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmResourcesResource.java
index 2bb844dff5..99e69db13d 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/RealmResourcesResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmResourcesResource.java
@@ -71,38 +71,18 @@ public class RealmResourcesResource {
}
@Path("{id}")
- @PUT
- @Consumes(MediaType.APPLICATION_JSON)
- public void update(final @PathParam("id") String id, final ResourceRepresentation rep) {
- new Transaction() {
- @Override
- protected void runImpl() {
- ResourceModel resourceModel = realm.getResourceById(id);
- if (resourceModel == null) {
- throw new NotFoundException();
- }
- ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
- resourceManager.updateResource(rep, resourceModel);
- }
- }.run();
- }
-
-
- @Path("{id}")
- @GET
- @NoCache
- @Produces(MediaType.APPLICATION_JSON)
- public ResourceRepresentation getResource(final @PathParam("id") String id) {
+ public RealmResourceResource getResource(final @PathParam("id") String id) {
return new Transaction() {
@Override
- protected ResourceRepresentation callImpl() {
+ protected RealmResourceResource callImpl() {
ResourceModel resourceModel = realm.getResourceById(id);
if (resourceModel == null) {
throw new NotFoundException();
}
- ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
- return resourceManager.toRepresentation(resourceModel);
+ return new RealmResourceResource(admin, realm, resourceModel);
}
}.call();
+
}
+
}