-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added initial user data * updating user requests * automatially bootstraps users * used more formal parsing * admins bootstrapped and updated * updated * added proper fields * updated * added proper private versus public list calls * added is public * added user * added shared user * monior cleanup
- Loading branch information
1 parent
745c94a
commit 106ad77
Showing
10 changed files
with
311 additions
and
11 deletions.
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
83 changes: 83 additions & 0 deletions
83
grails-app/controllers/org/xena/analysis/AuthenticatedUserController.groovy
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,83 @@ | ||
package org.xena.analysis | ||
|
||
import grails.validation.ValidationException | ||
import static org.springframework.http.HttpStatus.CREATED | ||
import static org.springframework.http.HttpStatus.NOT_FOUND | ||
import static org.springframework.http.HttpStatus.NO_CONTENT | ||
import static org.springframework.http.HttpStatus.OK | ||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY | ||
|
||
import grails.gorm.transactions.ReadOnly | ||
import grails.gorm.transactions.Transactional | ||
|
||
@ReadOnly | ||
class AuthenticatedUserController { | ||
|
||
AuthenticatedUserService authenticatedUserService | ||
|
||
static responseFormats = ['json', 'xml'] | ||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond authenticatedUserService.list(params), model:[authenticatedUserCount: authenticatedUserService.count()] | ||
} | ||
|
||
def show(Long id) { | ||
respond authenticatedUserService.get(id) | ||
} | ||
|
||
@Transactional | ||
def save(AuthenticatedUser authenticatedUser) { | ||
if (authenticatedUser == null) { | ||
render status: NOT_FOUND | ||
return | ||
} | ||
if (authenticatedUser.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond authenticatedUser.errors | ||
return | ||
} | ||
|
||
try { | ||
authenticatedUserService.save(authenticatedUser) | ||
} catch (ValidationException e) { | ||
respond authenticatedUser.errors | ||
return | ||
} | ||
|
||
respond authenticatedUser, [status: CREATED, view:"show"] | ||
} | ||
|
||
@Transactional | ||
def update(AuthenticatedUser authenticatedUser) { | ||
if (authenticatedUser == null) { | ||
render status: NOT_FOUND | ||
return | ||
} | ||
if (authenticatedUser.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond authenticatedUser.errors | ||
return | ||
} | ||
|
||
try { | ||
authenticatedUserService.save(authenticatedUser) | ||
} catch (ValidationException e) { | ||
respond authenticatedUser.errors | ||
return | ||
} | ||
|
||
respond authenticatedUser, [status: OK, view:"show"] | ||
} | ||
|
||
@Transactional | ||
def delete(Long id) { | ||
if (id == null || authenticatedUserService.delete(id) == null) { | ||
render status: NOT_FOUND | ||
return | ||
} | ||
|
||
render status: NO_CONTENT | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
grails-app/domain/org/xena/analysis/AuthenticatedUser.groovy
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,21 @@ | ||
package org.xena.analysis | ||
|
||
class AuthenticatedUser { | ||
|
||
static constraints = { | ||
email email: true,nullable: false,blank: false,unique: true | ||
firstName nullable: true | ||
lastName nullable: true | ||
role blank: false,nullable: false | ||
} | ||
|
||
String firstName | ||
String lastName | ||
String email | ||
RoleEnum role // | ||
|
||
static hasMany = [ | ||
gmts:Gmt | ||
] | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.xena.analysis | ||
|
||
enum RoleEnum { | ||
|
||
USER("user",10), | ||
BANNED("banned",1), | ||
INACTIVE("inactive",5), | ||
ADMIN("admin",100); | ||
|
||
private String display; // pertains to the 1.0 value | ||
private Integer rank; | ||
|
||
RoleEnum(String display , int rank) { | ||
this.display = display; | ||
this.rank = rank; | ||
} | ||
|
||
|
||
} |
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
18 changes: 18 additions & 0 deletions
18
grails-app/services/org/xena/analysis/AuthenticatedUserService.groovy
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,18 @@ | ||
package org.xena.analysis | ||
|
||
import grails.gorm.services.Service | ||
|
||
@Service(AuthenticatedUser) | ||
interface AuthenticatedUserService { | ||
|
||
AuthenticatedUser get(Serializable id) | ||
|
||
List<AuthenticatedUser> list(Map args) | ||
|
||
Long count() | ||
|
||
AuthenticatedUser delete(Serializable id) | ||
|
||
AuthenticatedUser save(AuthenticatedUser authenticatedUser) | ||
|
||
} |
Oops, something went wrong.