-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HAWKULAR-59 - Listing users in organization
- Loading branch information
1 parent
03d94b6
commit b74366d
Showing
7 changed files
with
211 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../src/main/java/org/hawkular/accounts/backend/boundary/OrganizationMembershipEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.accounts.backend.boundary; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.security.PermitAll; | ||
import javax.ejb.Stateless; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.hawkular.accounts.api.OrganizationMembershipService; | ||
import org.hawkular.accounts.api.OrganizationService; | ||
import org.hawkular.accounts.api.model.Organization; | ||
import org.hawkular.accounts.api.model.OrganizationMembership; | ||
|
||
/** | ||
* REST service responsible for managing {@link org.hawkular.accounts.api.model.OrganizationMembership}. | ||
* | ||
* @author Juraci Paixão Kröhling | ||
*/ | ||
@Path("/organizationMemberships/{organizationId}") | ||
@PermitAll | ||
@Stateless | ||
public class OrganizationMembershipEndpoint { | ||
|
||
@Inject | ||
OrganizationMembershipService membershipService; | ||
|
||
@Inject | ||
OrganizationService organizationService; | ||
|
||
@GET | ||
public Response getOrganizationMembershipsForOrganization(@PathParam("organizationId") String organizationId) { | ||
Organization organization = organizationService.get(organizationId); | ||
List<OrganizationMembership> memberships = membershipService.getMembershipsForOrganization(organization); | ||
return Response.ok().entity(memberships).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
api/src/main/java/org/hawkular/accounts/api/internal/impl/NameChangeObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.accounts.api.internal.impl; | ||
|
||
import javax.annotation.security.PermitAll; | ||
import javax.ejb.Asynchronous; | ||
import javax.ejb.Singleton; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.hawkular.accounts.api.UserService; | ||
import org.hawkular.accounts.api.internal.adapter.HawkularAccounts; | ||
import org.hawkular.accounts.api.model.HawkularUser; | ||
import org.hawkular.accounts.api.model.NameChangedEvent; | ||
|
||
/** | ||
* @author Juraci Paixão Kröhling | ||
*/ | ||
@Singleton | ||
@PermitAll | ||
public class NameChangeObserver { | ||
|
||
@Inject | ||
@HawkularAccounts | ||
EntityManager em; | ||
|
||
@Inject | ||
UserService userService; | ||
|
||
@Asynchronous | ||
public void persistNameChange(@Observes NameChangedEvent event) { | ||
HawkularUser user = userService.getById(event.getUser().getId()); | ||
user.setName(event.getUser().getName()); | ||
em.persist(user); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
api/src/main/java/org/hawkular/accounts/api/model/NameChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.accounts.api.model; | ||
|
||
/** | ||
* CDI event for propagating the change of an user's full name. | ||
* | ||
* @author Juraci Paixão Kröhling | ||
*/ | ||
public class NameChangedEvent { | ||
|
||
private HawkularUser user; | ||
|
||
public NameChangedEvent(HawkularUser user) { | ||
this.user = user; | ||
} | ||
|
||
public HawkularUser getUser() { | ||
return user; | ||
} | ||
} |