Skip to content

Commit

Permalink
refactor: simplify endpoint paths in ResourceTypesRest (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeriBoss authored Jan 13, 2025
1 parent 5011acd commit f8d3059
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions AMW_angular/io/src/app/resource/resource-types.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ export class ResourceTypesService extends BaseService {

getResourceType(id: number): Observable<ResourceType> {
return this.http
.get<ResourceType>(`${this.getBaseUrl()}/resources/resourceTypes/${id}`, {
.get<ResourceType>(`${this.getBaseUrl()}/resourceTypes/${id}`, {
headers: this.getHeaders(),
})
.pipe(catchError(this.handleError));
}

getAllResourceTypes(): Observable<ResourceType[]> {
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resources/resourceTypes`);
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resourceTypes`);
}

getPredefinedResourceTypes(): Observable<ResourceType[]> {
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resources/predefinedResourceTypes`);
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resourceTypes/predefinedResourceTypes`);
}

getRootResourceTypes(): Observable<ResourceType[]> {
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resources/rootResourceTypes`);
return this.http.get<ResourceType[]>(`${this.getBaseUrl()}/resourceTypes/rootResourceTypes`);
}

addNewResourceType(resourceTypeRequest: ResourceTypeRequest): Observable<void> {
return this.http.post<void>(`${this.getBaseUrl()}/resources/resourceTypes`, resourceTypeRequest);
return this.http.post<void>(`${this.getBaseUrl()}/resourceTypes`, resourceTypeRequest);
}

refreshData() {
Expand All @@ -66,7 +66,7 @@ export class ResourceTypesService extends BaseService {

delete(id: number): Observable<number> {
return this.http
.delete<number>(`${this.getBaseUrl()}/resources/resourceTypes/${id}`, {
.delete<number>(`${this.getBaseUrl()}/resourceTypes/${id}`, {
headers: this.getHeaders(),
})
.pipe(catchError(this.handleError));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import static javax.ws.rs.core.Response.Status.NO_CONTENT;

@RequestScoped
@Path("/resources")
@Api(value = "/resources")
@Path("/resourceTypes")
@Api(value = "/resourceTypes")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public class ResourceTypesRest {
Expand All @@ -67,7 +67,7 @@ public class ResourceTypesRest {
@Inject
private ResourceTypeDomainService resourceTypeDomainService;

@Path("/resourceTypes")
@Path("/")
@GET
@ApiOperation(value = "Get all resource types")
public List<ResourceTypeDTO> getAllResourceTypes() {
Expand All @@ -77,7 +77,7 @@ public List<ResourceTypeDTO> getAllResourceTypes() {
}

@GET
@Path("/resourceTypes/{id : \\d+}")
@Path("/{id : \\d+}")
@ApiOperation(value = "Get a resourceType by id")
@Produces(MediaType.APPLICATION_JSON)
public Response getById(@ApiParam("ResourceType ID") @PathParam("id") Integer id) throws NotFoundException {
Expand All @@ -102,7 +102,7 @@ public List<ResourceTypeDTO> getRootResourceTypes() {
.collect(Collectors.toList());
}

@Path("/resourceTypes")
@Path("/")
@POST
@ApiOperation(value = "Add a new resource type")
@Consumes("application/json")
Expand All @@ -127,7 +127,7 @@ public Response addNewResourceType(ResourceTypeRequestDTO request)


@DELETE
@Path("/resourceTypes/{id : \\d+}")
@Path("/{id : \\d+}")
@ApiOperation(value = "Delete a resource type")
public Response deleteResourceType(@PathParam("id") Integer id) throws NotAuthorizedException, NotFoundException {
try {
Expand Down

0 comments on commit f8d3059

Please sign in to comment.