resource-manager/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/ContextHolder.java

35 lines
803 B
Java

package org.gcube.resourcemanagement.manager.webapp.context;
import org.gcube.informationsystem.model.impl.utils.ISMapper;
import org.gcube.informationsystem.model.reference.entity.Context;
/**
* Hold a context before sending it to the Resource Registry.
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ContextHolder {
private final Context inputContext;
/**
* Create a new holder for the serialized context.
* @param serialization a serialization in the JSON formate
*/
public ContextHolder(String serialization) {
try {
this.inputContext = ISMapper.unmarshal(Context.class, serialization);
} catch (Exception e) {
throw new IllegalArgumentException("The context is syntactically not valid");
}
}
protected Context getContext() {
return inputContext;
}
}