1
0

adding and importing accessrights.jdl with spotless

This commit is contained in:
Michael Hoennig
2019-04-30 17:24:24 +02:00
parent 2c94d6a985
commit 084c12d2c4
55 changed files with 2604 additions and 35 deletions

View File

@ -1,3 +1,4 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.config;
import org.hostsharing.hsadminng.security.*;
@ -41,7 +42,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private final SecurityProblemSupport problemSupport;
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter, SecurityProblemSupport problemSupport) {
public SecurityConfiguration(
AuthenticationManagerBuilder authenticationManagerBuilder,
UserDetailsService userDetailsService,
TokenProvider tokenProvider,
CorsFilter corsFilter,
SecurityProblemSupport problemSupport) {
this.authenticationManagerBuilder = authenticationManagerBuilder;
this.userDetailsService = userDetailsService;
this.tokenProvider = tokenProvider;
@ -53,8 +59,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public void init() {
try {
authenticationManagerBuilder
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
} catch (Exception e) {
throw new BeanInitializationException("Security configuration failed", e);
}
@ -74,13 +80,13 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**")
.antMatchers("/app/**/*.{js,html}")
.antMatchers("/i18n/**")
.antMatchers("/content/**")
.antMatchers("/h2-console/**")
.antMatchers("/swagger-ui/index.html")
.antMatchers("/test/**");
.antMatchers(HttpMethod.OPTIONS, "/**")
.antMatchers("/app/**/*.{js,html}")
.antMatchers("/i18n/**")
.antMatchers("/content/**")
.antMatchers("/h2-console/**")
.antMatchers("/swagger-ui/index.html")
.antMatchers("/test/**");
}
@Override

View File

@ -0,0 +1,152 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.domain;
import org.hostsharing.hsadminng.domain.enumeration.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.*;
import javax.validation.constraints.*;
/**
* A UserRoleAssignment.
*/
@Entity
@Table(name = "user_role_assignment")
public class UserRoleAssignment implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Column(name = "entity_type_id")
private String entityTypeId;
@Column(name = "entity_object_id")
private Long entityObjectId;
@NotNull
@Column(name = "user_id", nullable = false)
private Long userId;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "assigned_role", nullable = false)
private UserRole assignedRole;
@ManyToOne
@JsonIgnoreProperties("requireds")
private User user;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEntityTypeId() {
return entityTypeId;
}
public UserRoleAssignment entityTypeId(String entityTypeId) {
this.entityTypeId = entityTypeId;
return this;
}
public void setEntityTypeId(String entityTypeId) {
this.entityTypeId = entityTypeId;
}
public Long getEntityObjectId() {
return entityObjectId;
}
public UserRoleAssignment entityObjectId(Long entityObjectId) {
this.entityObjectId = entityObjectId;
return this;
}
public void setEntityObjectId(Long entityObjectId) {
this.entityObjectId = entityObjectId;
}
public Long getUserId() {
return userId;
}
public UserRoleAssignment userId(Long userId) {
this.userId = userId;
return this;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public UserRole getAssignedRole() {
return assignedRole;
}
public UserRoleAssignment assignedRole(UserRole assignedRole) {
this.assignedRole = assignedRole;
return this;
}
public void setAssignedRole(UserRole assignedRole) {
this.assignedRole = assignedRole;
}
public User getUser() {
return user;
}
public UserRoleAssignment user(User user) {
this.user = user;
return this;
}
public void setUser(User user) {
this.user = user;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserRoleAssignment userRoleAssignment = (UserRoleAssignment) o;
if (userRoleAssignment.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), userRoleAssignment.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "UserRoleAssignment{" +
"id=" + getId() +
", entityTypeId='" + getEntityTypeId() + "'" +
", entityObjectId=" + getEntityObjectId() +
", userId=" + getUserId() +
", assignedRole='" + getAssignedRole() + "'" +
"}";
}
}

View File

@ -0,0 +1,15 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.domain.enumeration;
/**
* The UserRole enumeration.
*/
public enum UserRole {
HOSTMASTER,
ADMIN,
SUPPORTER,
CONTRACTUAL_CONTACT,
FINANCIAL_CONTACT,
TECHNICAL_CONTACT,
CUSTOMER_USER
}

View File

@ -0,0 +1,22 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.UserRoleAssignment;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the UserRoleAssignment entity.
*/
@SuppressWarnings("unused")
@Repository
public interface UserRoleAssignmentRepository
extends JpaRepository<UserRoleAssignment, Long>, JpaSpecificationExecutor<UserRoleAssignment> {
@Query("select user_role_assignment from UserRoleAssignment user_role_assignment where user_role_assignment.user.login = ?#{principal.username}")
List<UserRoleAssignment> findByUserIsCurrentUser();
}

View File

@ -0,0 +1,115 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.domain.UserRoleAssignment;
import org.hostsharing.hsadminng.repository.UserRoleAssignmentRepository;
import org.hostsharing.hsadminng.service.dto.UserRoleAssignmentCriteria;
import io.github.jhipster.service.QueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import javax.persistence.criteria.JoinType;
/**
* Service for executing complex queries for UserRoleAssignment entities in the database.
* The main input is a {@link UserRoleAssignmentCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link UserRoleAssignment} or a {@link Page} of {@link UserRoleAssignment} which fulfills the
* criteria.
*/
@Service
@Transactional(readOnly = true)
public class UserRoleAssignmentQueryService extends QueryService<UserRoleAssignment> {
private final Logger log = LoggerFactory.getLogger(UserRoleAssignmentQueryService.class);
private final UserRoleAssignmentRepository userRoleAssignmentRepository;
public UserRoleAssignmentQueryService(UserRoleAssignmentRepository userRoleAssignmentRepository) {
this.userRoleAssignmentRepository = userRoleAssignmentRepository;
}
/**
* Return a {@link List} of {@link UserRoleAssignment} which matches the criteria from the database
*
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<UserRoleAssignment> findByCriteria(UserRoleAssignmentCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<UserRoleAssignment> specification = createSpecification(criteria);
return userRoleAssignmentRepository.findAll(specification);
}
/**
* Return a {@link Page} of {@link UserRoleAssignment} which matches the criteria from the database
*
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<UserRoleAssignment> findByCriteria(UserRoleAssignmentCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<UserRoleAssignment> specification = createSpecification(criteria);
return userRoleAssignmentRepository.findAll(specification, page);
}
/**
* Return the number of matching entities in the database
*
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(UserRoleAssignmentCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<UserRoleAssignment> specification = createSpecification(criteria);
return userRoleAssignmentRepository.count(specification);
}
/**
* Function to convert UserRoleAssignmentCriteria to a {@link Specification}
*/
private Specification<UserRoleAssignment> createSpecification(UserRoleAssignmentCriteria criteria) {
Specification<UserRoleAssignment> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), UserRoleAssignment_.id));
}
if (criteria.getEntityTypeId() != null) {
specification = specification
.and(buildStringSpecification(criteria.getEntityTypeId(), UserRoleAssignment_.entityTypeId));
}
if (criteria.getEntityObjectId() != null) {
specification = specification
.and(buildRangeSpecification(criteria.getEntityObjectId(), UserRoleAssignment_.entityObjectId));
}
if (criteria.getUserId() != null) {
specification = specification.and(buildRangeSpecification(criteria.getUserId(), UserRoleAssignment_.userId));
}
if (criteria.getAssignedRole() != null) {
specification = specification
.and(buildSpecification(criteria.getAssignedRole(), UserRoleAssignment_.assignedRole));
}
if (criteria.getUserId() != null) {
specification = specification.and(
buildSpecification(
criteria.getUserId(),
root -> root.join(UserRoleAssignment_.user, JoinType.LEFT).get(User_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,75 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.UserRoleAssignment;
import org.hostsharing.hsadminng.repository.UserRoleAssignmentRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing UserRoleAssignment.
*/
@Service
@Transactional
public class UserRoleAssignmentService {
private final Logger log = LoggerFactory.getLogger(UserRoleAssignmentService.class);
private final UserRoleAssignmentRepository userRoleAssignmentRepository;
public UserRoleAssignmentService(UserRoleAssignmentRepository userRoleAssignmentRepository) {
this.userRoleAssignmentRepository = userRoleAssignmentRepository;
}
/**
* Save a userRoleAssignment.
*
* @param userRoleAssignment the entity to save
* @return the persisted entity
*/
public UserRoleAssignment save(UserRoleAssignment userRoleAssignment) {
log.debug("Request to save UserRoleAssignment : {}", userRoleAssignment);
return userRoleAssignmentRepository.save(userRoleAssignment);
}
/**
* Get all the userRoleAssignments.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<UserRoleAssignment> findAll(Pageable pageable) {
log.debug("Request to get all UserRoleAssignments");
return userRoleAssignmentRepository.findAll(pageable);
}
/**
* Get one userRoleAssignment by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<UserRoleAssignment> findOne(Long id) {
log.debug("Request to get UserRoleAssignment : {}", id);
return userRoleAssignmentRepository.findById(id);
}
/**
* Delete the userRoleAssignment by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete UserRoleAssignment : {}", id);
userRoleAssignmentRepository.deleteById(id);
}
}

View File

@ -0,0 +1,131 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.service.dto;
import org.hostsharing.hsadminng.domain.enumeration.UserRole;
import io.github.jhipster.service.filter.Filter;
import io.github.jhipster.service.filter.LongFilter;
import io.github.jhipster.service.filter.StringFilter;
import java.io.Serializable;
import java.util.Objects;
/**
* Criteria class for the UserRoleAssignment entity. This class is used in UserRoleAssignmentResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /user-role-assignments?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class UserRoleAssignmentCriteria implements Serializable {
/**
* Class for filtering UserRole
*/
public static class UserRoleFilter extends Filter<UserRole> {
}
private static final long serialVersionUID = 1L;
private LongFilter id;
private StringFilter entityTypeId;
private LongFilter entityObjectId;
private LongFilter userId;
private UserRoleFilter assignedRole;
private LongFilter userId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public StringFilter getEntityTypeId() {
return entityTypeId;
}
public void setEntityTypeId(StringFilter entityTypeId) {
this.entityTypeId = entityTypeId;
}
public LongFilter getEntityObjectId() {
return entityObjectId;
}
public void setEntityObjectId(LongFilter entityObjectId) {
this.entityObjectId = entityObjectId;
}
public LongFilter getUserId() {
return userId;
}
public void setUserId(LongFilter userId) {
this.userId = userId;
}
public UserRoleFilter getAssignedRole() {
return assignedRole;
}
public void setAssignedRole(UserRoleFilter assignedRole) {
this.assignedRole = assignedRole;
}
public LongFilter getUserId() {
return userId;
}
public void setUserId(LongFilter userId) {
this.userId = userId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final UserRoleAssignmentCriteria that = (UserRoleAssignmentCriteria) o;
return Objects.equals(id, that.id) &&
Objects.equals(entityTypeId, that.entityTypeId) &&
Objects.equals(entityObjectId, that.entityObjectId) &&
Objects.equals(userId, that.userId) &&
Objects.equals(assignedRole, that.assignedRole) &&
Objects.equals(userId, that.userId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
entityTypeId,
entityObjectId,
userId,
assignedRole,
userId);
}
@Override
public String toString() {
return "UserRoleAssignmentCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(entityTypeId != null ? "entityTypeId=" + entityTypeId + ", " : "") +
(entityObjectId != null ? "entityObjectId=" + entityObjectId + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") +
(assignedRole != null ? "assignedRole=" + assignedRole + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,148 @@
// Licensed under Apache-2.0
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.domain.UserRoleAssignment;
import org.hostsharing.hsadminng.service.UserRoleAssignmentQueryService;
import org.hostsharing.hsadminng.service.UserRoleAssignmentService;
import org.hostsharing.hsadminng.service.dto.UserRoleAssignmentCriteria;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
/**
* REST controller for managing UserRoleAssignment.
*/
@RestController
@RequestMapping("/api")
public class UserRoleAssignmentResource {
private final Logger log = LoggerFactory.getLogger(UserRoleAssignmentResource.class);
private static final String ENTITY_NAME = "userRoleAssignment";
private final UserRoleAssignmentService userRoleAssignmentService;
private final UserRoleAssignmentQueryService userRoleAssignmentQueryService;
public UserRoleAssignmentResource(
UserRoleAssignmentService userRoleAssignmentService,
UserRoleAssignmentQueryService userRoleAssignmentQueryService) {
this.userRoleAssignmentService = userRoleAssignmentService;
this.userRoleAssignmentQueryService = userRoleAssignmentQueryService;
}
/**
* POST /user-role-assignments : Create a new userRoleAssignment.
*
* @param userRoleAssignment the userRoleAssignment to create
* @return the ResponseEntity with status 201 (Created) and with body the new userRoleAssignment, or with status 400 (Bad
* Request) if the userRoleAssignment has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/user-role-assignments")
public ResponseEntity<UserRoleAssignment> createUserRoleAssignment(
@Valid @RequestBody UserRoleAssignment userRoleAssignment) throws URISyntaxException {
log.debug("REST request to save UserRoleAssignment : {}", userRoleAssignment);
if (userRoleAssignment.getId() != null) {
throw new BadRequestAlertException("A new userRoleAssignment cannot already have an ID", ENTITY_NAME, "idexists");
}
UserRoleAssignment result = userRoleAssignmentService.save(userRoleAssignment);
return ResponseEntity.created(new URI("/api/user-role-assignments/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /user-role-assignments : Updates an existing userRoleAssignment.
*
* @param userRoleAssignment the userRoleAssignment to update
* @return the ResponseEntity with status 200 (OK) and with body the updated userRoleAssignment,
* or with status 400 (Bad Request) if the userRoleAssignment is not valid,
* or with status 500 (Internal Server Error) if the userRoleAssignment couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/user-role-assignments")
public ResponseEntity<UserRoleAssignment> updateUserRoleAssignment(
@Valid @RequestBody UserRoleAssignment userRoleAssignment) throws URISyntaxException {
log.debug("REST request to update UserRoleAssignment : {}", userRoleAssignment);
if (userRoleAssignment.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
UserRoleAssignment result = userRoleAssignmentService.save(userRoleAssignment);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, userRoleAssignment.getId().toString()))
.body(result);
}
/**
* GET /user-role-assignments : get all the userRoleAssignments.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of userRoleAssignments in body
*/
@GetMapping("/user-role-assignments")
public ResponseEntity<List<UserRoleAssignment>> getAllUserRoleAssignments(
UserRoleAssignmentCriteria criteria,
Pageable pageable) {
log.debug("REST request to get UserRoleAssignments by criteria: {}", criteria);
Page<UserRoleAssignment> page = userRoleAssignmentQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/user-role-assignments");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /user-role-assignments/count : count all the userRoleAssignments.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/user-role-assignments/count")
public ResponseEntity<Long> countUserRoleAssignments(UserRoleAssignmentCriteria criteria) {
log.debug("REST request to count UserRoleAssignments by criteria: {}", criteria);
return ResponseEntity.ok().body(userRoleAssignmentQueryService.countByCriteria(criteria));
}
/**
* GET /user-role-assignments/:id : get the "id" userRoleAssignment.
*
* @param id the id of the userRoleAssignment to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the userRoleAssignment, or with status 404 (Not Found)
*/
@GetMapping("/user-role-assignments/{id}")
public ResponseEntity<UserRoleAssignment> getUserRoleAssignment(@PathVariable Long id) {
log.debug("REST request to get UserRoleAssignment : {}", id);
Optional<UserRoleAssignment> userRoleAssignment = userRoleAssignmentService.findOne(id);
return ResponseUtil.wrapOrNotFound(userRoleAssignment);
}
/**
* DELETE /user-role-assignments/:id : delete the "id" userRoleAssignment.
*
* @param id the id of the userRoleAssignment to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/user-role-assignments/{id}")
public ResponseEntity<Void> deleteUserRoleAssignment(@PathVariable Long id) {
log.debug("REST request to delete UserRoleAssignment : {}", id);
userRoleAssignmentService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}