Integrated `ingnore_errors` in the deleteFileSet
This commit is contained in:
parent
ac5d2a5c63
commit
bdd92cd2ac
|
@ -2,6 +2,7 @@
|
|||
|
||||
## [v1.2.0-SNAPSHOT] - 2023-04-26
|
||||
- Added PATCH method [#24985]
|
||||
- Integrated `ingnore_errors` in the deleteFileSet
|
||||
|
||||
## [v1.1.2] - 2023-01-10
|
||||
- Pom updates
|
||||
|
|
|
@ -31,6 +31,15 @@ import lombok.NonNull;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Instantiates a new default documents client.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 2, 2023
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instantiates a new default documents client.
|
||||
*
|
||||
|
@ -49,7 +58,6 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@NonNull
|
||||
protected final Class<T> managedClass;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the managed class.
|
||||
*
|
||||
|
@ -69,11 +77,11 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T createNew(Document toCreate) throws RemoteException {
|
||||
try {
|
||||
log.debug("Creating Profiled Document (class {}, useCaseDescriptor {}) with content {} ",
|
||||
getManagedClass(),profileID, toCreate);
|
||||
log.debug("Creating Profiled Document (class {}, useCaseDescriptor {}) with content {} ", getManagedClass(),
|
||||
profileID, toCreate);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(toCreate, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).request(MediaType.APPLICATION_JSON)
|
||||
.post(Entity.entity(toCreate, MediaType.APPLICATION_JSON)), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Registered {} profiled {} ", toReturn.getId(), profileID);
|
||||
|
@ -110,9 +118,9 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
try {
|
||||
log.debug("Deleting ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(id).
|
||||
queryParam(InterfaceConstants.Parameters.FORCE,force).
|
||||
request(MediaType.APPLICATION_JSON).delete(),null);
|
||||
return ResponseCommons
|
||||
.check(endpoint.path(profileID).path(id).queryParam(InterfaceConstants.Parameters.FORCE, force)
|
||||
.request(MediaType.APPLICATION_JSON).delete(), null);
|
||||
};
|
||||
delegate.make(call);
|
||||
log.info("Deleted ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
|
@ -135,11 +143,10 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T getById(String id) throws RemoteException {
|
||||
try {
|
||||
log.info("Loading Document ID {} (class {}, useCaseDescriptor {})",
|
||||
id, getManagedClass(),profileID);
|
||||
log.info("Loading Document ID {} (class {}, useCaseDescriptor {})", id, getManagedClass(), profileID);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(id).
|
||||
request(MediaType.APPLICATION_JSON).get(), getManagedClass());
|
||||
return ResponseCommons.check(
|
||||
endpoint.path(profileID).path(id).request(MediaType.APPLICATION_JSON).get(), getManagedClass());
|
||||
};
|
||||
return delegate.make(call);
|
||||
} catch (RemoteException e) {
|
||||
|
@ -162,8 +169,9 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
try {
|
||||
log.info("Loading Configuration for useCaseDescriptor {}", profileID);
|
||||
Call<WebTarget, Configuration> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.CONFIGURATION_PATH).
|
||||
request(MediaType.APPLICATION_JSON).get(), Configuration.class);
|
||||
return ResponseCommons.check(endpoint.path(profileID)
|
||||
.path(InterfaceConstants.Methods.CONFIGURATION_PATH).request(MediaType.APPLICATION_JSON).get(),
|
||||
Configuration.class);
|
||||
};
|
||||
return delegate.make(call);
|
||||
} catch (RemoteException e) {
|
||||
|
@ -222,8 +230,9 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
try {
|
||||
log.debug("Querying useCaseDescriptor {} for {}", profileID, request);
|
||||
Call<WebTarget, String> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.QUERY_PATH).
|
||||
request(MediaType.APPLICATION_JSON).post(Entity.entity(request,MediaType.APPLICATION_JSON)), String.class);
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.QUERY_PATH)
|
||||
.request(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON)),
|
||||
String.class);
|
||||
};
|
||||
return delegate.make(call);
|
||||
} catch (RemoteException e) {
|
||||
|
@ -246,16 +255,16 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T performStep(String id, StepExecutionRequest request) throws RemoteException {
|
||||
try {
|
||||
log.debug("Executing step on {} (class {}, useCaseDescriptor {}) with request {} ",
|
||||
id, getManagedClass(),profileID, request);
|
||||
log.debug("Executing step on {} (class {}, useCaseDescriptor {}) with request {} ", id, getManagedClass(),
|
||||
profileID, request);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.STEP)
|
||||
.path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(request, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.STEP).path(id)
|
||||
.request(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON)),
|
||||
getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Executed STEP {} on {} [useCaseDescriptor {}, class {}] ",request.getStepID(),
|
||||
id,profileID,getManagedClass());
|
||||
log.info("Executed STEP {} on {} [useCaseDescriptor {}, class {}] ", request.getStepID(), id, profileID,
|
||||
getManagedClass());
|
||||
return toReturn;
|
||||
} catch (RemoteException e) {
|
||||
log.error("Unexpected error ", e);
|
||||
|
@ -278,17 +287,18 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException {
|
||||
try {
|
||||
log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ",
|
||||
id, getManagedClass(), profileID, req);
|
||||
log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ", id,
|
||||
getManagedClass(), profileID, req);
|
||||
req.validate();
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.REGISTER_FILES_PATH)
|
||||
.path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(req, MediaType.APPLICATION_JSON)), getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID)
|
||||
.path(InterfaceConstants.Methods.REGISTER_FILES_PATH).path(id)
|
||||
.request(MediaType.APPLICATION_JSON).post(Entity.entity(req, MediaType.APPLICATION_JSON)),
|
||||
getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}",
|
||||
id, profileID, getManagedClass(), req);
|
||||
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}", id, profileID,
|
||||
getManagedClass(), req);
|
||||
return toReturn;
|
||||
} catch (InvalidRequestException e) {
|
||||
log.error("Invalid Request ", e);
|
||||
|
@ -315,13 +325,15 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T deleteFileSet(String id, String path, Boolean force, Boolean ignoreErrors) throws RemoteException {
|
||||
try {
|
||||
log.debug("Deleting Fileset for ID {} [useCaseDescriptor {} , class {}] at {} (force {} )",
|
||||
id, profileID,getManagedClass(),path, force);
|
||||
log.debug(
|
||||
"Deleting Fileset for ID {} [useCaseDescriptor {} , class {}] at {} (force {} ) (ignoreErrors {} )",
|
||||
id, profileID, getManagedClass(), path, force, ignoreErrors);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.DELETE_FILES_PATH).
|
||||
path(id).queryParam(InterfaceConstants.Parameters.FORCE,force).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(path, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.DELETE_FILES_PATH)
|
||||
.path(id).queryParam(InterfaceConstants.Parameters.FORCE, force)
|
||||
.queryParam(InterfaceConstants.Parameters.IGNORE_ERRORS, ignoreErrors)
|
||||
.request(MediaType.APPLICATION_JSON).post(Entity.entity(path, MediaType.APPLICATION_JSON)),
|
||||
getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Deleted ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
|
@ -345,12 +357,10 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T forceUnlock(String id) throws RemoteException {
|
||||
try {
|
||||
log.warn("Force Unlock of {} [useCaseDescriptor {} , class {}]",
|
||||
id, profileID,getManagedClass());
|
||||
log.warn("Force Unlock of {} [useCaseDescriptor {} , class {}]", id, profileID, getManagedClass());
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.FORCE_UNLOCK).path(id).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.json("")),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.FORCE_UNLOCK)
|
||||
.path(id).request(MediaType.APPLICATION_JSON).put(Entity.json("")), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Unlocked ID {} useCaseDescriptor {}", id, profileID);
|
||||
|
@ -375,12 +385,13 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T setAccessPolicy(String id, Access toSet) throws RemoteException {
|
||||
try {
|
||||
log.info("Setting Access of {} [useCaseDescriptor {} , class {}] as {}",
|
||||
id, profileID,getManagedClass(),toSet);
|
||||
log.info("Setting Access of {} [useCaseDescriptor {} , class {}] as {}", id, profileID, getManagedClass(),
|
||||
toSet);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.SET_PROJECT_ACCESS_POLICY).path(id).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.json(toSet)),getManagedClass());
|
||||
return ResponseCommons.check(
|
||||
endpoint.path(profileID).path(InterfaceConstants.Methods.SET_PROJECT_ACCESS_POLICY).path(id)
|
||||
.request(MediaType.APPLICATION_JSON).put(Entity.json(toSet)),
|
||||
getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.debug("Updated Access of ID {} useCaseDescriptor {}", id, profileID);
|
||||
|
@ -405,12 +416,11 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public T updateDocument(String id, Document updatedDocument) throws RemoteException {
|
||||
try {
|
||||
log.debug("Updating {} [useCaseDescriptor {} , class {}] with ",
|
||||
id, profileID,getManagedClass(),updatedDocument);
|
||||
log.debug("Updating {} [useCaseDescriptor {} , class {}] with ", id, profileID, getManagedClass(),
|
||||
updatedDocument);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(id).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(updatedDocument, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(id).request(MediaType.APPLICATION_JSON)
|
||||
.put(Entity.entity(updatedDocument, MediaType.APPLICATION_JSON)), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Updated ID {} useCaseDescriptor {}", id, profileID);
|
||||
|
@ -425,8 +435,7 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Patch document.
|
||||
* Added by Francesco Mangiacrapa
|
||||
* Patch document. Added by Francesco Mangiacrapa
|
||||
*
|
||||
* @param id the id
|
||||
* @param path the path
|
||||
|
@ -444,7 +453,8 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
WebTarget webTarget = endpoint.path(profileID).path(id);
|
||||
webTarget.queryParam(InterfaceConstants.Parameters.PATH, path);
|
||||
webTarget.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||
Response response = webTarget.request(MediaType.APPLICATION_JSON).method("PATCH", Entity.entity(updatedDocument, MediaType.APPLICATION_JSON));
|
||||
Response response = webTarget.request(MediaType.APPLICATION_JSON).method("PATCH",
|
||||
Entity.entity(updatedDocument, MediaType.APPLICATION_JSON));
|
||||
return ResponseCommons.check(response, getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
|
@ -469,23 +479,18 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public Project setRelation(CreateRelationshipRequest request) throws RemoteException {
|
||||
try {
|
||||
log.debug("Setting relationship {}:{} --{}--> {}:{}",
|
||||
profileID, request.getProjectId(), request.getRelationshipId(),
|
||||
request.getTargetUCD(),request.getTargetId());
|
||||
log.debug("Setting relationship {}:{} --{}--> {}:{}", profileID, request.getProjectId(),
|
||||
request.getRelationshipId(), request.getTargetUCD(), request.getTargetId());
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).
|
||||
path(InterfaceConstants.Methods.RELATIONSHIP).
|
||||
path(request.getProjectId()).
|
||||
path(request.getRelationshipId()).
|
||||
queryParam(InterfaceConstants.Parameters.TARGET_ID,request.getTargetId()).
|
||||
queryParam(InterfaceConstants.Parameters.TARGET_UCD,request.getTargetUCD()).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.json("")),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.RELATIONSHIP)
|
||||
.path(request.getProjectId()).path(request.getRelationshipId())
|
||||
.queryParam(InterfaceConstants.Parameters.TARGET_ID, request.getTargetId())
|
||||
.queryParam(InterfaceConstants.Parameters.TARGET_UCD, request.getTargetUCD())
|
||||
.request(MediaType.APPLICATION_JSON).put(Entity.json("")), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Set relationship {}:{} --{}--> {}:{}",
|
||||
profileID, request.getProjectId(), request.getRelationshipId(),
|
||||
request.getTargetUCD(),request.getTargetId());
|
||||
log.info("Set relationship {}:{} --{}--> {}:{}", profileID, request.getProjectId(),
|
||||
request.getRelationshipId(), request.getTargetUCD(), request.getTargetId());
|
||||
return toReturn;
|
||||
} catch (RemoteException e) {
|
||||
log.error("Unexpected error ", e);
|
||||
|
@ -506,23 +511,18 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
@Override
|
||||
public Project deleteRelation(DeleteRelationshipRequest request) throws RemoteException {
|
||||
try {
|
||||
log.debug("Deleting relationship {}:{} --{}--> {}:{}",
|
||||
profileID, request.getProjectId(), request.getRelationshipId(),
|
||||
request.getTargetUCD(),request.getTargetId());
|
||||
log.debug("Deleting relationship {}:{} --{}--> {}:{}", profileID, request.getProjectId(),
|
||||
request.getRelationshipId(), request.getTargetUCD(), request.getTargetId());
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).
|
||||
path(InterfaceConstants.Methods.RELATIONSHIP).
|
||||
path(request.getProjectId()).
|
||||
path(request.getRelationshipId()).
|
||||
queryParam(InterfaceConstants.Parameters.TARGET_ID,request.getTargetId()).
|
||||
queryParam(InterfaceConstants.Parameters.TARGET_UCD,request.getTargetUCD()).
|
||||
request(MediaType.APPLICATION_JSON).
|
||||
delete(),getManagedClass());
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.RELATIONSHIP)
|
||||
.path(request.getProjectId()).path(request.getRelationshipId())
|
||||
.queryParam(InterfaceConstants.Parameters.TARGET_ID, request.getTargetId())
|
||||
.queryParam(InterfaceConstants.Parameters.TARGET_UCD, request.getTargetUCD())
|
||||
.request(MediaType.APPLICATION_JSON).delete(), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Deleted relationship {}:{} --{}--> {}:{}",
|
||||
profileID, request.getProjectId(), request.getRelationshipId(),
|
||||
request.getTargetUCD(),request.getTargetId());
|
||||
log.info("Deleted relationship {}:{} --{}--> {}:{}", profileID, request.getProjectId(),
|
||||
request.getRelationshipId(), request.getTargetUCD(), request.getTargetId());
|
||||
return toReturn;
|
||||
} catch (RemoteException e) {
|
||||
log.error("Unexpected error ", e);
|
||||
|
@ -542,7 +542,8 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
@Override
|
||||
public Iterator<RelationshipNavigationObject> getRelationshipChain(String id, String relationId) throws RemoteException {
|
||||
public Iterator<RelationshipNavigationObject> getRelationshipChain(String id, String relationId)
|
||||
throws RemoteException {
|
||||
return getRelationshipChain(id, relationId, null);
|
||||
}
|
||||
|
||||
|
@ -556,21 +557,21 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
@Override
|
||||
public Iterator<RelationshipNavigationObject> getRelationshipChain(String id, String relationId, Boolean deep) throws RemoteException {
|
||||
public Iterator<RelationshipNavigationObject> getRelationshipChain(String id, String relationId, Boolean deep)
|
||||
throws RemoteException {
|
||||
try {
|
||||
log.debug("Get relationship chain ID {} for {} [useCaseDescriptor {} , class {}]",
|
||||
relationId, id, profileID,getManagedClass());
|
||||
log.debug("Get relationship chain ID {} for {} [useCaseDescriptor {} , class {}]", relationId, id,
|
||||
profileID, getManagedClass());
|
||||
Call<WebTarget, Iterator<RelationshipNavigationObject>> call = endpoint -> {
|
||||
|
||||
WebTarget target = endpoint.path(profileID).
|
||||
path(InterfaceConstants.Methods.RELATIONSHIP).
|
||||
path(id).
|
||||
path(relationId);
|
||||
WebTarget target = endpoint.path(profileID).path(InterfaceConstants.Methods.RELATIONSHIP).path(id)
|
||||
.path(relationId);
|
||||
|
||||
if(deep!=null) target = target.queryParam(InterfaceConstants.Parameters.DEEP,deep);
|
||||
if (deep != null)
|
||||
target = target.queryParam(InterfaceConstants.Parameters.DEEP, deep);
|
||||
|
||||
String jsonChain = ResponseCommons.check(target.request(MediaType.APPLICATION_JSON).
|
||||
get(),String.class);
|
||||
String jsonChain = ResponseCommons.check(target.request(MediaType.APPLICATION_JSON).get(),
|
||||
String.class);
|
||||
|
||||
return Serialization.readCollection(jsonChain, RelationshipNavigationObject.class);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue