public abstract class ServiceAdapter extends Object implements ServiceInterface
Modifier and Type | Field and Description |
---|---|
protected ServiceRequest |
_oReq |
protected HashMap<String,String> |
httpParameters |
protected String |
id |
protected List<ServletListener> |
listeners |
protected STServiceContext |
serviceContext |
protected ServletUtilities |
servletUtilities |
protected ARTResource[] |
userGraphs |
Constructor and Description |
---|
ServiceAdapter(String id) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ServletListener l) |
void |
checkRequestParametersAllNotNull(String... pars)
checks that the http parameters identified by
pars have been properly initialized |
protected XMLResponseREPLY |
createBooleanResponse(boolean resp) |
protected XMLResponseREPLY |
createIntegerResponse(int value) |
protected ARTURIResource |
createNewURIResource(RDFModel model,
String qname,
ARTResource... graphs)
actually this method should be incorporated inside the OWLART, so that all the addXXX which take a
string as their element, should be able to check if the resource is at least existing on the checked
graph.
|
protected XMLResponseREPLY |
createReplyFAIL(String message) |
ResponseREPLY |
createReplyFAIL(String message,
ServiceVocabulary.SerializationType ser_type) |
protected XMLResponseREPLY |
createReplyResponse(ServiceVocabulary.RepliesStatus status) |
protected ResponseREPLY |
createReplyResponse(ServiceVocabulary.RepliesStatus status,
ServiceVocabulary.SerializationType ser_type) |
protected void |
fireServletEvent()
Funzione per chiamare avvertire tutti i listener che si erano registrati
|
protected ARTURIResource |
generateURI(String xRole,
Map<String,ARTNode> valueMapping)
Returns a new URI for a resource.
|
String |
getId() |
protected abstract org.slf4j.Logger |
getLogger() |
protected RDFModel |
getOntModel() |
protected OWLModel |
getOWLModel() |
protected abstract Response |
getPreCheckedResponse(String request)
this is a method invoked by this class' implementation of
ServiceInterface.getResponse() ,
throwing specific exceptions for wrongly specific http parameters. |
protected Project<? extends RDFModel> |
getProject() |
Response |
getResponse() |
protected ARTResource[] |
getUserNamedGraphs() |
protected ARTResource |
getWorkingGraph() |
protected ARTResourceIterator |
listNamedGraphs() |
protected Response |
logAndSendException(Exception e) |
protected Response |
logAndSendException(Exception e,
String msg) |
protected Response |
logAndSendException(String msg) |
protected Response |
logAndSendException(String request,
Exception e)
this convenience method prepares an exception response initialized with the given arguments, logs the
occurred exception with level "error" and prints the stack trace
|
protected Response |
logAndSendException(String request,
Exception e,
String msg)
this convenience method prepares an exception response initialized with the given arguments and logs
the occurred exception with level "error"
|
protected Response |
logAndSendException(String request,
String msg) |
protected Response |
logAndSendException(String request,
String msg,
ServiceVocabulary.SerializationType sertype) |
void |
removeListener(ServletListener l)
remove the listener associated to this server
|
protected ARTResource |
retrieveExistingResource(RDFModel model,
String qname,
ARTResource... graphs) |
protected ARTURIResource |
retrieveExistingURIResource(RDFModel model,
String qname,
ARTResource... graphs) |
boolean |
setHttpBooleanPar(String parameterName)
|
boolean |
setHttpBooleanPar(String parameterName,
boolean defaultValue)
ad for
setHttpBooleanPar(String) but allows for the specification of the default value in case
the parameter has not been specified |
File |
setHttpMultipartFilePar(String parameterName)
Retrieves the MultipartFile parameter from the http POST request, copies it to a temp file on server
and return it.
|
String |
setHttpPar(String parameterName)
this method performs the following operations:
given the argument
parameterName , retrieves the value for this parameter from the http
GET request
fills an internal map containing parameter name/value pairs, which can be lately accessed to get
parameter values
return the value obtained from the GET request
|
void |
setServiceRequest(ServiceRequest oReq) |
@Autowired protected STServiceContext serviceContext
protected String id
protected ServiceRequest _oReq
protected List<ServletListener> listeners
protected ServletUtilities servletUtilities
protected ARTResource[] userGraphs
public ServiceAdapter(String id)
public String setHttpPar(String parameterName)
parameterName
, retrieves the value for this parameter from the http
GET requestparameterName
- public File setHttpMultipartFilePar(String parameterName)
parameterName
- public boolean setHttpBooleanPar(String parameterName)
but invokes {@link Boolean#parseBoolean(String)} on
the string value of the parameter
. Defaults to false
.parameterName
- public boolean setHttpBooleanPar(String parameterName, boolean defaultValue)
setHttpBooleanPar(String)
but allows for the specification of the default value in case
the parameter has not been specifiedparameterName
- defaultValue
- public void checkRequestParametersAllNotNull(String... pars) throws HTTPParameterUnspecifiedException
pars
have been properly initializedpars
- HTTPParameterUnspecifiedException
public String getId()
getId
in interface STOSGIExtension
public void setServiceRequest(ServiceRequest oReq)
setServiceRequest
in interface ServiceInterface
oReq
- HttpServletRequestpublic void addListener(ServletListener l)
addListener
in interface ServiceInterface
public void removeListener(ServletListener l)
ServiceInterface
removeListener
in interface ServiceInterface
l
- listener da rimuovereprotected void fireServletEvent()
public Response getResponse()
getResponse
in interface ServiceInterface
protected XMLResponseREPLY createBooleanResponse(boolean resp)
protected XMLResponseREPLY createIntegerResponse(int value)
protected XMLResponseREPLY createReplyResponse(ServiceVocabulary.RepliesStatus status)
protected XMLResponseREPLY createReplyFAIL(String message)
protected ResponseREPLY createReplyResponse(ServiceVocabulary.RepliesStatus status, ServiceVocabulary.SerializationType ser_type)
public ResponseREPLY createReplyFAIL(String message, ServiceVocabulary.SerializationType ser_type)
protected abstract Response getPreCheckedResponse(String request) throws HTTPParameterUnspecifiedException, MalformedURIException
ServiceInterface.getResponse()
,
throwing specific exceptions for wrongly specific http parameters. Current implementation just throws
an HTTPParameterUnspecifiedException
whenever a mandatory parameter has not been specified in
the requestrequest
- HTTPParameterUnspecifiedException
MalformedURIException
protected abstract org.slf4j.Logger getLogger()
protected Response logAndSendException(String request, Exception e)
request
- e
- protected Response logAndSendException(String request, Exception e, String msg)
request
- e
- msg
- protected Response logAndSendException(String request, String msg, ServiceVocabulary.SerializationType sertype)
protected ARTResource getWorkingGraph() throws ModelAccessException, NonExistingRDFResourceException
protected ARTResource[] getUserNamedGraphs() throws ModelAccessException, NonExistingRDFResourceException
protected ARTResourceIterator listNamedGraphs() throws ModelAccessException, NonExistingRDFResourceException
protected RDFModel getOntModel()
protected OWLModel getOWLModel()
protected ARTResource retrieveExistingResource(RDFModel model, String qname, ARTResource... graphs) throws NonExistingRDFResourceException, ModelAccessException
protected ARTURIResource retrieveExistingURIResource(RDFModel model, String qname, ARTResource... graphs) throws NonExistingRDFResourceException, ModelAccessException
protected ARTURIResource createNewURIResource(RDFModel model, String qname, ARTResource... graphs) throws DuplicatedResourceException, ModelAccessException, MalformedURIException
model
- qname
- graphs
- these are the graphs to be checked for existence of the resourceNonExistingRDFResourceException
ModelAccessException
MalformedURIException
DuplicatedResourceException
protected ARTURIResource generateURI(String xRole, Map<String,ARTNode> valueMapping) throws URIGenerationException
xRole
holds the nature of the resource that
will be identified with the given URI. Depending on the value of the parameter xRole
, a
conforming converter may generate differently shaped URIs, possibly using specific arguments passed via
the map args
.xRole
- valueMapping
- URIGenerationException
Copyright © 2016 ART Group, University of Rome, Tor Vergata. All rights reserved.