use of org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse in project dcache by dCache.
the class SRMExtendFileLifeTimeClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
ArrayOfAnyURI surlarray = new ArrayOfAnyURI();
URI[] uriarray = new URI[surls.length];
URI uri;
for (int i = 0; i < uriarray.length; i++) {
uri = new URI(surl_strings[i]);
uriarray[i] = uri;
}
surlarray.setUrlArray(uriarray);
SrmExtendFileLifeTimeRequest req = new SrmExtendFileLifeTimeRequest();
req.setArrayOfSURLs(surlarray);
req.setRequestToken(configuration.getExtendFileLifetimeRequestToken());
req.setNewFileLifeTime(configuration.getNewFileLifetime());
req.setNewPinLifeTime(configuration.getNewPinLifetime());
SrmExtendFileLifeTimeResponse resp = srm.srmExtendFileLifeTime(req);
if (resp == null) {
esay("Received null SrmExtendFileLifeTimeResponse");
System.exit(1);
}
try {
TReturnStatus rs = resp.getReturnStatus();
if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS || configuration.isDebug()) {
TStatusCode rc = rs.getStatusCode();
StringBuilder sb = new StringBuilder();
sb.append("Return code: ").append(rc.toString()).append("\n");
sb.append("Explanation: ").append(rs.getExplanation()).append("\n");
if (resp.getArrayOfFileStatuses() != null) {
if (resp.getArrayOfFileStatuses().getStatusArray() != null) {
for (int i = 0; i < resp.getArrayOfFileStatuses().getStatusArray().length; i++) {
TSURLLifetimeReturnStatus t = resp.getArrayOfFileStatuses().getStatusArray()[i];
sb.append("surl[").append(i).append("] ").append(t.getSurl()).append("\n");
sb.append("\tReturn code: ").append(t.getStatus().getStatusCode().toString()).append("\n");
sb.append("\tExplanation: ").append(t.getStatus().getExplanation()).append("\n");
sb.append("\t\tfilelifetime=").append(t.getFileLifetime()).append("\n");
sb.append("\t\tpinlifetime=").append(t.getPinLifetime()).append("\n");
}
} else {
sb.append("array of file statuse is null\n");
}
} else {
sb.append("array of file statuse is null\n");
}
if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
esay(sb.toString());
System.exit(1);
} else {
say(sb.toString());
}
} else {
System.exit(0);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
use of org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse in project dcache by dCache.
the class SrmExtendFileLifeTime method extendSurlLifeTime.
private SrmExtendFileLifeTimeResponse extendSurlLifeTime(org.apache.axis.types.URI[] surls, int newFileLifetime) throws SRMInternalErrorException {
long newLifetimeInMillis = toMillis(newFileLifetime, Long.MAX_VALUE);
int len = surls.length;
TSURLLifetimeReturnStatus[] surlStatus = new TSURLLifetimeReturnStatus[len];
for (int i = 0; i < len; ++i) {
surlStatus[i] = extendSurlLifeTime(surls[i], newLifetimeInMillis);
}
return new SrmExtendFileLifeTimeResponse(getSummaryReturnStatus(surlStatus), new ArrayOfTSURLLifetimeReturnStatus(surlStatus));
}
use of org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse in project dcache by dCache.
the class SrmExtendFileLifeTime method extendTurlOrPinLifeTime.
private SrmExtendFileLifeTimeResponse extendTurlOrPinLifeTime(String requestToken, org.apache.axis.types.URI[] surls, int newLifetime) throws SRMInvalidRequestException, SRMInternalErrorException {
ContainerRequest<?> containerRequest = Request.getRequest(requestToken, ContainerRequest.class);
try (JDC ignored = containerRequest.applyJdc()) {
long maxLifetime = getMaxLifetime(containerRequest);
long newLifetimeInMillis = toMillis(newLifetime, maxLifetime);
int len = surls.length;
TSURLLifetimeReturnStatus[] surlStatus = new TSURLLifetimeReturnStatus[len];
for (int i = 0; i < len; ++i) {
surlStatus[i] = extendTurlOrPinLifeTime(containerRequest, surls[i], newLifetimeInMillis);
}
return new SrmExtendFileLifeTimeResponse(getSummaryReturnStatus(surlStatus), new ArrayOfTSURLLifetimeReturnStatus(surlStatus));
}
}
use of org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse in project dcache by dCache.
the class SrmExtendFileLifeTime method getFailedResponse.
public static final SrmExtendFileLifeTimeResponse getFailedResponse(String error, TStatusCode statusCode) {
SrmExtendFileLifeTimeResponse response = new SrmExtendFileLifeTimeResponse();
response.setReturnStatus(new TReturnStatus(statusCode, error));
return response;
}
Aggregations