Skip to content

Commit

Permalink
Revert "dcache-frontend,common: check parsing of Duration in STAGE"
Browse files Browse the repository at this point in the history
This reverts commit 6ffe2cd.
  • Loading branch information
alrossi committed Nov 9, 2023
1 parent 6ffe2cd commit 82922f2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import java.util.ArrayList;
import java.util.List;
import org.dcache.util.TimeUtils;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -100,7 +99,7 @@ private static QoSPolicy deserializePolicy(JSONObject object) {
private static QoSState deserializeState(JSONObject jsonState) {
QoSState state = new QoSState();
if (jsonState.has(DURATION)) {
state.setDuration(TimeUtils.validateDuration(jsonState.getString(DURATION)));
state.setDuration(jsonState.getString(DURATION));
}
List<QoSStorageMediumSpecification> media = new ArrayList<>();
JSONArray mediaArray = jsonState.getJSONArray(MEDIA);
Expand Down
14 changes: 0 additions & 14 deletions modules/common/src/main/java/org/dcache/util/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Comparator;
Expand All @@ -37,10 +36,6 @@ public class TimeUtils {

public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd' 'HH:mm:ss.SSS";

private static final String BAD_DURATION_FORMAT_ERROR = "Duration '%s' cannot be parsed. "
+ "Accepted duration is a text string such as 'PnDTnHnMn.nS' based on the ISO-8601 "
+ "duration format. E.g. 'P30DT2H30M15.5S' for 30 days, 2 hours, 30 minutes, 15.5 seconds.";

/**
* <p>Compares time units such that the larger unit is
* ordered before the smaller.</p>
Expand Down Expand Up @@ -584,13 +579,4 @@ public static long getMillis(Properties properties, String key) {
public static Duration durationOf(long value, TimeUnit unit) {
return Duration.of(value, unit.toChronoUnit());
}

public static String validateDuration(String duration) throws IllegalArgumentException {
try {
Duration.parse(duration);
return duration;
} catch (DateTimeParseException e) {
throw new IllegalArgumentException(String.format(BAD_DURATION_FORMAT_ERROR, duration));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import org.dcache.services.bulk.BulkRequestMessage;
import org.dcache.services.bulk.BulkRequestStatusMessage;
import org.dcache.services.bulk.BulkRequestTargetInfo;
import org.dcache.util.TimeUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -382,8 +381,7 @@ private BulkRequest toBulkRequest(String requestPayload) {
String path = file.getString("path");
paths.add(path);
if (file.has("diskLifetime")) {
jsonLifetimes.put(path,
TimeUtils.validateDuration(file.getString("diskLifetime")));
jsonLifetimes.put(path, file.getString("diskLifetime"));
}
if (file.has("targetedMetadata")) {
getTargetedMetadataForPath(file).ifPresent(mdata ->
Expand All @@ -396,7 +394,7 @@ private BulkRequest toBulkRequest(String requestPayload) {
arguments.put("diskLifetime", jsonLifetimes.toString());
arguments.put("targetedMetadata", jsonMetadata.toString());
request.setArguments(arguments);
} catch (JSONException | IllegalArgumentException e) {
} catch (JSONException e) {
throw newBadRequestException(requestPayload, e);
}

Expand Down

0 comments on commit 82922f2

Please sign in to comment.