Remove swagger and minor feature extensions and bug fixes

- Various Bug fixes and improvements
- Management API extended
- Swagger removed
- Guava Upgraded to 19
This commit is contained in:
Kai Zimmermann
2016-01-21 13:42:38 +01:00
parent fb9dfd204c
commit 64deaeea3c
813 changed files with 9787 additions and 4929 deletions

View File

@@ -47,7 +47,7 @@ public class AmqpConfiguration {
/**
* Method to set the Jackson2JsonMessageConverter.
*
*
* @return the Jackson2JsonMessageConverter
*/
@Bean
@@ -59,7 +59,7 @@ public class AmqpConfiguration {
/**
* Create the sp receiver queue.
*
*
* @return the receiver queue
*/
@Bean
@@ -69,7 +69,7 @@ public class AmqpConfiguration {
/**
* Create the dead letter fanout exchange.
*
*
* @return the fanout exchange
*/
@Bean
@@ -79,7 +79,7 @@ public class AmqpConfiguration {
/**
* Create dead letter queue.
*
*
* @return the queue
*/
@Bean
@@ -89,7 +89,7 @@ public class AmqpConfiguration {
/**
* Create the dead letter fanout exchange.
*
*
* @return the fanout exchange
*/
@Bean
@@ -99,7 +99,7 @@ public class AmqpConfiguration {
/**
* Create the Binding deadLetterQueue to exchangeDeadLetter.
*
*
* @return the binding
*/
@Bean
@@ -110,7 +110,7 @@ public class AmqpConfiguration {
/**
* Create the Binding {@link AmqpConfiguration#receiverQueueFromSp()} to
* {@link AmqpConfiguration#senderConnectorToSpExchange()}.
*
*
* @return the binding and create the queue and exchange
*/
@Bean
@@ -120,7 +120,7 @@ public class AmqpConfiguration {
/**
* Create amqp handler service bean.
*
*
* @return
*/
@Bean
@@ -130,7 +130,7 @@ public class AmqpConfiguration {
/**
* Returns the Listener factory.
*
*
* @return the {@link SimpleMessageListenerContainer} that gets used receive
* AMQP messages
*/
@@ -143,7 +143,7 @@ public class AmqpConfiguration {
}
private Map<String, Object> getDeadLetterExchangeArgs() {
final Map<String, Object> args = new HashMap<String, Object>();
final Map<String, Object> args = new HashMap<>();
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
return args;
}

View File

@@ -91,7 +91,7 @@ public class AmqpControllerAuthentfication {
/**
* Performs authentication with the secruity token.
*
*
* @param secruityToken
* the authentication request object
* @return the authentfication object
@@ -110,7 +110,7 @@ public class AmqpControllerAuthentfication {
}
private PreAuthenticatedAuthenticationToken createAuthentication(final PreAuthenficationFilter filter,
private static PreAuthenticatedAuthenticationToken createAuthentication(final PreAuthenficationFilter filter,
final TenantSecruityToken secruityToken) {
if (!filter.isEnable(secruityToken)) {

View File

@@ -31,13 +31,14 @@ import org.eclipse.hawkbit.util.IpUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.eventbus.Subscribe;
/**
* {@link AmqpMessageDispatcherService} handles all outgoing AMQP messages.
*
*
*
*
*/
@@ -56,7 +57,7 @@ public class AmqpMessageDispatcherService {
/**
* Method to send a message to a RabbitMQ Exchange after the Distribution
* set has been assign to a Target.
*
*
* @param targetAssignDistributionSetEvent
* the object to be send.
*/
@@ -86,7 +87,7 @@ public class AmqpMessageDispatcherService {
/**
* Method to send a message to a RabbitMQ Exchange after the assignment of
* the Distribution set to a Target has been canceled.
*
*
* @param cancelTargetAssignmentDistributionSetEvent
* the object to be send.
*/
@@ -104,13 +105,14 @@ public class AmqpMessageDispatcherService {
/**
* Send message to exchange.
*
*
* @param exchange
* the exchange
* @param message
* the message
*/
public void sendMessage(final String exchange, final Message message) {
message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME);
rabbitTemplate.setExchange(exchange);
rabbitTemplate.send(message);
}
@@ -124,7 +126,7 @@ public class AmqpMessageDispatcherService {
return messageProperties;
}
private MessageProperties createMessageProperties() {
private static MessageProperties createMessageProperties() {
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
messageProperties.setHeader(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON);

View File

@@ -71,9 +71,9 @@ import org.springframework.web.util.UriComponentsBuilder;
import com.google.common.eventbus.EventBus;
/**
*
*
* {@link AmqpMessageHandlerService} handles all incoming AMQP messages.
*
*
*
*
*
@@ -106,7 +106,7 @@ public class AmqpMessageHandlerService {
/**
* /** Method to handle all incoming amqp messages.
*
*
* @param message
* incoming message
* @param type
@@ -199,7 +199,7 @@ public class AmqpMessageHandlerService {
return rabbitTemplate.getMessageConverter().toMessage(authentificationResponse, messageProperties);
}
private Artifact convertDbArtifact(final DbArtifact dbArtifact) {
private static Artifact convertDbArtifact(final DbArtifact dbArtifact) {
final Artifact artifact = new Artifact();
artifact.setSize(dbArtifact.getSize());
final DbArtifactHash dbArtifactHash = dbArtifact.getHashes();
@@ -212,13 +212,13 @@ public class AmqpMessageHandlerService {
throw new IllegalArgumentException(error);
}
private void setSecurityContext(final Authentication authentication) {
private static void setSecurityContext(final Authentication authentication) {
final SecurityContextImpl securityContextImpl = new SecurityContextImpl();
securityContextImpl.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContextImpl);
}
private void setTenantSecurityContext(final String tenantId) {
private static void setTenantSecurityContext(final String tenantId) {
final AnonymousAuthenticationToken authenticationToken = new AnonymousAuthenticationToken(
UUID.randomUUID().toString(), "AMQP-Controller",
Collections.singletonList(new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS)));
@@ -237,7 +237,7 @@ public class AmqpMessageHandlerService {
/**
* Method to create a new target or to find the target if it already exists.
*
*
* @param targetID
* the ID of the target/thing
* @param ip
@@ -274,7 +274,7 @@ public class AmqpMessageHandlerService {
/**
* Method to handle the different topics to an event.
*
*
* @param message
* the incoming event message.
* @param topic
@@ -292,7 +292,7 @@ public class AmqpMessageHandlerService {
/**
* Method to update the action status of an action through the event.
*
*
* @param actionUpdateStatus
* the object form the ampq message
*/
@@ -330,6 +330,9 @@ public class AmqpMessageHandlerService {
case RUNNING:
actionStatus.setStatus(Status.RUNNING);
break;
case CANCELED:
actionStatus.setStatus(Status.CANCELED);
break;
case FINISHED:
actionStatus.setStatus(Status.FINISHED);
break;
@@ -339,19 +342,43 @@ public class AmqpMessageHandlerService {
case WARNING:
actionStatus.setStatus(Status.WARNING);
break;
case CANCEL_REJECTED:
handleCancelRejected(message, action, actionStatus);
break;
default:
logAndThrowMessageError(message, "Status for action does not exisit.");
}
final Action savedAction = controllerManagement.addUpdateActionStatus(actionStatus, action);
if (Status.FINISHED == savedAction.getStatus()) {
Action addUpdateActionStatus;
if (!actionStatus.getStatus().equals(Status.CANCELED)) {
addUpdateActionStatus = controllerManagement.addUpdateActionStatus(actionStatus, action);
} else {
addUpdateActionStatus = controllerManagement.addCancelActionStatus(actionStatus, action);
}
if (!addUpdateActionStatus.isActive()) {
lookIfUpdateAvailable(action.getTarget());
}
}
private void handleCancelRejected(final Message message, final Action action, final ActionStatus actionStatus) {
if (action.isCancelingOrCanceled()) {
actionStatus.setStatus(Status.WARNING);
// cancel action rejected, write warning status message and fall
// back to running action status
} else {
logAndThrowMessageError(message,
"Cancel Recjected message is not allowed, if action is on state: " + action.getStatus());
}
}
/**
* Is needed to convert a incoming message to is originally object type.
*
*
* @param message
* the message to convert.
* @param clazz
@@ -367,14 +394,15 @@ public class AmqpMessageHandlerService {
/**
* Is needed to verify if an incoming message has the content type json.
*
*
* @param message
* the to verify
* @param contentType
* the content type
* @return true if the content type has json, false it not.
*/
private void checkContentTypeJson(final Message message) {
private static void checkContentTypeJson(final Message message) {
final MessageProperties messageProperties = message.getMessageProperties();
if (messageProperties.getContentType() != null && messageProperties.getContentType().contains("json")) {
return;

View File

@@ -14,15 +14,14 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact;
/**
* Interface declaration of the {@link ArtifactUrlHandler} which generates the
* URLs to specific artifacts.
*
*
*
*/
@FunctionalInterface
public interface ArtifactUrlHandler {
/**
* Returns a generated URL for a given artifact for a specific protocol.
*
*
* @param controllerId
* the authentifacted controller id
* @param localArtifact

View File

@@ -43,6 +43,7 @@ import org.mockito.Mockito;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.test.context.ActiveProfiles;
@@ -154,15 +155,15 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit
CONTROLLER_ID, 1l, IpUtil.createAmqpUri("mytest"));
amqpMessageDispatcherService
.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
final Message sendMessage = createArgumentCapture(
cancelTargetAssignmentDistributionSetEvent.getTargetAdress().getHost());
final Message sendMessage = createArgumentCapture(cancelTargetAssignmentDistributionSetEvent.getTargetAdress()
.getHost());
assertCancelMessage(sendMessage);
}
private void assertCancelMessage(final Message sendMessage) {
assertEventMessage(sendMessage);
final Long actionId = (Long) messageConverter.fromMessage(sendMessage);
final Long actionId = convertMessage(sendMessage, Long.class);
assertEquals(actionId, Long.valueOf(1));
assertEquals(EventTopic.CANCEL_DOWNLOAD,
sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC));
@@ -171,8 +172,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit
private DownloadAndUpdateRequest assertDownloadAndInstallMessage(final Message sendMessage) {
assertEventMessage(sendMessage);
final DownloadAndUpdateRequest downloadAndUpdateRequest = (DownloadAndUpdateRequest) messageConverter
.fromMessage(sendMessage);
final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(sendMessage,
DownloadAndUpdateRequest.class);
assertEquals(downloadAndUpdateRequest.getActionId(), Long.valueOf(1));
assertEquals(EventTopic.DOWNLOAD_AND_INSTALL,
sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC));
@@ -197,4 +198,11 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit
return argumentCaptor.getValue();
}
@SuppressWarnings("unchecked")
private <T> T convertMessage(final Message message, final Class<T> clazz) {
message.getMessageProperties().getHeaders()
.put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, clazz.getTypeName());
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
}
}