Implement new edge node endpoints, test flow, add applicationId handling and sanitize http error of SAL
Change-Id: I2ce2828053762d4ae46a0ca330693471da066b88
This commit is contained in:
parent
3b1077c958
commit
ef7de76229
@ -61,7 +61,7 @@ public class AMQPSalMessageHandler extends Handler {
|
||||
String tempKey = message.replyTo() + message.correlationId()
|
||||
Publisher tempPublisher = new Publisher(tempKey, message.replyTo(), true, true)
|
||||
|
||||
tempPublisher.send(response, null, amqpProperties)
|
||||
tempPublisher.send(response, message.subject(), amqpProperties)
|
||||
context.unregisterPublisher(tempKey)
|
||||
|
||||
return
|
||||
@ -74,7 +74,7 @@ public class AMQPSalMessageHandler extends Handler {
|
||||
// Publisher publisher = context.getPublisher(StringUtils.substringAfter(destination,context.base+'.')) as StringPublisher
|
||||
Publisher publisher = context.getPublisher(StringUtils.substringAfter(destination, context.base + '.'))
|
||||
|
||||
publisher.send(response, null, amqpProperties)
|
||||
publisher.send(response, message.subject(), amqpProperties)
|
||||
} catch (Exception e) {
|
||||
log.error('Pre Sent caught exception', e)
|
||||
}
|
||||
|
@ -69,19 +69,22 @@ abstract class AbstractProcessor implements Processor {
|
||||
} catch (HttpClientErrorException e) {
|
||||
logger.error("[{} -> {}] Client Exception during gateway request for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW HTTP CLIENT ERROR:\n {}', e.getMessage())
|
||||
String sanitizedError = StringUtils.substringBetween(e.getMessage(),'Message</b>','</p><p><b>Exception') ?: 'Unparsable Http Client Error'
|
||||
ret.status = e.getStatusCode().value()
|
||||
ret.body = ["key": "gateway-client-exception-error", "message": StringUtils.substring(e.getMessage(), 0, 50)]
|
||||
ret.body = ["key": "gateway-client-exception-error", "message": StringUtils.substring(sanitizedError, 0, 300)]
|
||||
}
|
||||
catch (HttpServerErrorException e) {
|
||||
logger.error("[{} -> {}] Server Exception during gateway request for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW HTTP SERVER ERROR:\n {}',e.getMessage())
|
||||
String sanitizedError = StringUtils.substringBetween(e.getMessage(),'Message</b>','</p><p><b>Exception') ?: 'Unparsable Http Server Error'
|
||||
ret.status = e.getStatusCode().value()
|
||||
ret.body = ["key": "gateway-server-exception-error", "message": StringUtils.substring(e.getMessage(),0,50)]
|
||||
ret.body = ["key": "gateway-server-exception-error", "message": StringUtils.substring(sanitizedError,0,300)]
|
||||
} catch (Exception e) {
|
||||
logger.error("[{} -> {}] Exception for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW EXCEPTION ERROR:\n {}',e.getMessage())
|
||||
String sanitizedError = StringUtils.substringBetween(e.getMessage(),'Message</b>','</p><p><b>Exception') ?: 'Unparsable Generic Internal Error'
|
||||
ret.status = HttpStatus.INTERNAL_SERVER_ERROR.value()
|
||||
ret.body = ["key": "generic-exception-error", "message": 'Generic exception while handling request for user ' + StringUtils.substring(e.getMessage(),0,50)]
|
||||
ret.body = ["key": "generic-exception-error", "message": 'Generic exception while handling request for user ' + StringUtils.substring(sanitizedError,0,300)]
|
||||
}
|
||||
|
||||
metaData.status = ret.status
|
||||
|
@ -123,7 +123,7 @@ class NodeProcessor extends AbstractProcessor{
|
||||
HttpHeaders headers = new HttpHeaders()
|
||||
headers.add('sessionid',sessionId)
|
||||
|
||||
Object response = nodeRegistrarRepository.deleteById(metaData.jobId as String, headers)
|
||||
Object response = nodeRegistrarRepository.deleteById(metaData.nodeId as String, headers)
|
||||
|
||||
return [
|
||||
"status": HttpStatus.OK.value(),
|
||||
|
@ -83,6 +83,10 @@ abstract class AbstractSalRepository{
|
||||
//PUT
|
||||
protected Object put(String url, String body, HttpHeaders headers) throws HttpStatusCodeException{
|
||||
|
||||
if(!headers.containsKey('Content-Type')) {
|
||||
headers.add('Content-Type', 'application/json')
|
||||
}
|
||||
|
||||
RequestEntity<String> entity = new RequestEntity<String>(body, headers, HttpMethod.PUT, new URI(baseUrl+'/'+resource+(url? '/'+url:'')))
|
||||
|
||||
return restTemplate.exchange(entity, Object.class).getBody()
|
||||
@ -104,7 +108,7 @@ abstract class AbstractSalRepository{
|
||||
}
|
||||
|
||||
def getById(String id, HttpHeaders headers){
|
||||
return get(id, headers, Map.class)
|
||||
return get(id, headers, Object.class)
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,12 +24,8 @@ abstract class AbstractNodeRepository extends AbstractSalRepository implements N
|
||||
}
|
||||
|
||||
@Override
|
||||
def deleteById(String jobId, HttpHeaders headers){
|
||||
//Payload not clear enough if this work for other type of nodes, if not override this in the derived class
|
||||
if(jobId) {
|
||||
return delete('remove/job/' + jobId, headers)
|
||||
}
|
||||
def deleteById(String edgeId, HttpHeaders headers){
|
||||
|
||||
return delete('remove',headers)
|
||||
return delete(edgeId,headers)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.nebulouscloud.exn.modules.sal.repository.node
|
||||
|
||||
import org.springframework.http.HttpHeaders
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
@ -8,4 +9,9 @@ class EdgeNodeRepository extends AbstractNodeRepository{
|
||||
EdgeNodeRepository() {
|
||||
super('edge')
|
||||
}
|
||||
|
||||
@Override
|
||||
def register(String jobId, String body, HttpHeaders headers){
|
||||
post('register', body, headers)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user