Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,26 @@ public final class MCRAccessKeyRestConstants {

/**
* Offset query parameter.
*
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#PARAM_OFFSET} instead.
*/
@Deprecated(forRemoval = true)
public static final String QUERY_PARAM_OFFSET = "offset";

/**
* Limit query parameter.
*
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#PARAM_LIMIT} instead.
*/
@Deprecated(forRemoval = true)
public static final String QUERY_PARAM_LIMIT = "limit";

/**
* Header name for total count info.
*
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#HEADER_X_TOTAL_COUNT} instead.
*/
@Deprecated(forRemoval = true)
public static final String HEADER_TOTAL_COUNT = "X-Total-Count";

private MCRAccessKeyRestConstants() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.mycore.mcr.acl.accesskey.dto.MCRAccessKeyDto;
import org.mycore.mcr.acl.accesskey.dto.MCRAccessKeyPartialUpdateDto;
import org.mycore.mcr.acl.accesskey.service.MCRAccessKeyService;
import org.mycore.restapi.MCRRestConstants;

import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.core.Response;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static List<MCRAccessKeyDto> findAccessKeys(String reference, String perm
} else {
accessKeyDtos.addAll(SERVICE.listAllAccessKeys());
}
response.setHeader(MCRAccessKeyRestConstants.HEADER_TOTAL_COUNT, Integer.toString(accessKeyDtos.size()));
response.setHeader(MCRRestConstants.HEADER_X_TOTAL_COUNT, Integer.toString(accessKeyDtos.size()));
return accessKeyDtos.stream().sorted((a1, a2) -> a1.getCreated().compareTo(a2.getCreated())).skip(offset)
.limit(limit).toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.mycore.mcr.acl.accesskey.dto.MCRAccessKeyPartialUpdateDto;
import org.mycore.mcr.acl.accesskey.restapi.v2.access.MCRAccessKeyRestAccessCheckStrategy;
import org.mycore.mcr.acl.accesskey.service.MCRAccessKeyService;
import org.mycore.restapi.MCRRestConstants;
import org.mycore.restapi.annotations.MCRApiDraft;
import org.mycore.restapi.annotations.MCRRequireTransaction;
import org.mycore.restapi.v2.MCRRestSchemaType;
Expand Down Expand Up @@ -125,7 +126,7 @@ public MCRAccessKeyRestResource(MCRAccessKeyService accessKeyService) {
array = @ArraySchema(schema = @Schema(implementation = MCRAccessKeyDto.class))),
},
headers = {
@Header(name = MCRAccessKeyRestConstants.HEADER_TOTAL_COUNT,
@Header(name = MCRRestConstants.HEADER_X_TOTAL_COUNT,
schema = @Schema(type = MCRRestSchemaType.INTEGER))
}),
@ApiResponse(responseCode = UNAUTHORIZED, description = DESCRIPTION_UNAUTHORIZED,
Expand All @@ -138,11 +139,11 @@ public MCRAccessKeyRestResource(MCRAccessKeyService accessKeyService) {
public List<MCRAccessKeyDto> findAccessKeys(
@Parameter(in = ParameterIn.QUERY, description = "The offset for pagination (default is 0)",
required = false, schema = @Schema(defaultValue = "0"))
@DefaultValue("0") @QueryParam(MCRAccessKeyRestConstants.QUERY_PARAM_OFFSET) int offset,
@DefaultValue("0") @QueryParam(MCRRestConstants.PARAM_OFFSET) int offset,
@Parameter(in = ParameterIn.QUERY,
description = "The number of results to return, defaults to 128 if not provided", required = false,
schema = @Schema(defaultValue = "128"))
@DefaultValue("128") @QueryParam(MCRAccessKeyRestConstants.QUERY_PARAM_LIMIT) int limit,
@DefaultValue("128") @QueryParam(MCRRestConstants.PARAM_LIMIT) int limit,
@Parameter(in = ParameterIn.QUERY, description = "The reference filter (default is all)", required = false,
schema = @Schema(defaultValue = ""))
@DefaultValue("") @QueryParam(MCRAccessKeyRestConstants.QUERY_PARAM_REFERENCE) String reference,
Expand All @@ -162,7 +163,7 @@ public List<MCRAccessKeyDto> findAccessKeys(
} else {
accessKeyDtos.addAll(accessKeyService.listAllAccessKeys());
}
response.setHeader(MCRAccessKeyRestConstants.HEADER_TOTAL_COUNT, Integer.toString(accessKeyDtos.size()));
response.setHeader(MCRRestConstants.HEADER_X_TOTAL_COUNT, Integer.toString(accessKeyDtos.size()));
return accessKeyDtos.stream().sorted((a1, a2) -> a1.getCreated().compareTo(a2.getCreated())).skip(offset)
.limit(limit).toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ protected List<URL> doSelect(List<URL> resourceUrls, MCRHints hints, MCRResource
for (MCRComponent component : componentsByComponentPriority(hints)) {
int priority = component.getPriority();
tracer.trace(() -> "Testing component " + component.getName() + " with priority " + priority);

if (component.getJarFile() == null) {
tracer.trace(() -> "Component " + component.getName()
+ " has no JAR file (directory-based), skipping");
continue;
}

if (highestPriority != -1 && highestPriority != priority) {
int highestPrioritySoFar = highestPriority;
tracer.trace(() -> "Found component with priority lower than "
Expand Down
5 changes: 5 additions & 0 deletions mycore-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@
<artifactId>mycore-tei</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mycore</groupId>
<artifactId>mycore-user-restapi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mycore</groupId>
<artifactId>mycore-user2</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions mycore-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
<groupId>org.mycore</groupId>
<artifactId>mycore-tei</artifactId>
</dependency>
<dependency>
<groupId>org.mycore</groupId>
<artifactId>mycore-user-restapi</artifactId>
</dependency>
<dependency>
<groupId>org.mycore</groupId>
<artifactId>mycore-user2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of *** M y C o R e ***
* See https://www.mycore.de/ for details.
*
* MyCoRe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MyCoRe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
*/

package org.mycore.restapi;

/**
* This class provides constants for rest.
*/
public final class MCRRestConstants {

/**
* Header name for total count info.
*/
public static final String HEADER_X_TOTAL_COUNT = "X-Total-Count";

public static final String PARAM_OFFSET = "offset";

public static final String PARAM_LIMIT = "limit";

private MCRRestConstants() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.mycore.frontend.jersey.MCRCacheControl;
import org.mycore.frontend.support.MCRObjectLock;
import org.mycore.media.services.MCRThumbnailGenerator;
import org.mycore.restapi.MCRRestConstants;
import org.mycore.restapi.annotations.MCRAccessControlExposeHeaders;
import org.mycore.restapi.annotations.MCRApiDraft;
import org.mycore.restapi.annotations.MCRParam;
Expand Down Expand Up @@ -145,8 +146,16 @@ public class MCRRestObjects {

public static final String PARAM_AFTER_ID = "after_id";

/**
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#PARAM_OFFSET} instead.
*/
@Deprecated(forRemoval = true)
public static final String PARAM_OFFSET = "offset";

/**
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#PARAM_LIMIT} instead.
*/
@Deprecated(forRemoval = true)
public static final String PARAM_LIMIT = "limit";

public static final String PARAM_TYPE = "type";
Expand Down Expand Up @@ -179,6 +188,10 @@ public class MCRRestObjects {

public static final String PARAM_SORT_BY = "sort_by";

/**
* @deprecated Use {@link org.mycore.restapi.MCRRestConstants#HEADER_X_TOTAL_COUNT} instead.
*/
@Deprecated(forRemoval = true)
public static final String HEADER_X_TOTAL_COUNT = "X-Total-Count";

public static final List<MCRThumbnailGenerator> THUMBNAIL_GENERATORS = MCRConfiguration2
Expand Down Expand Up @@ -220,11 +233,11 @@ public class MCRRestObjects {
description = "the id after which the results should be listed. Do not use after_id and offset " +
"together."),
@Parameter(
name = PARAM_OFFSET,
name = MCRRestConstants.PARAM_OFFSET,
description = "dictates the number of rows to skip from the beginning of the returned data before " +
"presenting the results. Do not use after_id and offset together."),
@Parameter(
name = PARAM_LIMIT,
name = MCRRestConstants.PARAM_LIMIT,
description = "limits the number of result returned"),
@Parameter(
name = PARAM_TYPE,
Expand Down Expand Up @@ -270,11 +283,11 @@ public class MCRRestObjects {
@SuppressWarnings("PMD.ExcessiveParameterList")
@XmlElementWrapper(name = "mycoreobjects")
@JacksonFeatures(serializationDisable = { SerializationFeature.WRITE_DATES_AS_TIMESTAMPS })
@MCRAccessControlExposeHeaders({ HEADER_X_TOTAL_COUNT, HttpHeaders.LINK })
@MCRAccessControlExposeHeaders({ MCRRestConstants.HEADER_X_TOTAL_COUNT, HttpHeaders.LINK })
public Response listObjects(
@QueryParam(PARAM_AFTER_ID) MCRObjectID afterID,
@QueryParam(PARAM_OFFSET) Integer offset,
@QueryParam(PARAM_LIMIT) Integer limit,
@QueryParam(MCRRestConstants.PARAM_OFFSET) Integer offset,
@QueryParam(MCRRestConstants.PARAM_LIMIT) Integer limit,
@QueryParam(PARAM_TYPE) String type,
@QueryParam(PARAM_PROJECT) String project,
@QueryParam(PARAM_NUMBER_GREATER) Integer numberGreater,
Expand Down Expand Up @@ -342,12 +355,12 @@ public Response listObjects(
nextBuilder.replaceQueryParam(PARAM_AFTER_ID, idDates.getLast().getId());
} else if (query.offset() + query.limit() < count) {
nextBuilder = uriInfo.getRequestUriBuilder();
nextBuilder.replaceQueryParam(PARAM_OFFSET, String.valueOf(query.offset() + limitInt));
nextBuilder.replaceQueryParam(MCRRestConstants.PARAM_OFFSET, String.valueOf(query.offset() + limitInt));
}

Response.ResponseBuilder responseBuilder = Response.ok(new GenericEntity<>(restIdDate) {
})
.header(HEADER_X_TOTAL_COUNT, count);
.header(MCRRestConstants.HEADER_X_TOTAL_COUNT, count);

if (nextBuilder != null) {
responseBuilder.link("next", nextBuilder.toString());
Expand Down
Loading
Loading