Fixed Sonar issues

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-09-27 09:43:46 +02:00
parent 760484921b
commit 97b3313642
12 changed files with 78 additions and 17 deletions

View File

@@ -38,6 +38,8 @@ public interface DdiRootControllerRestApi {
/** /**
* Returns all artifacts of a given software module and target. * Returns all artifacts of a given software module and target.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* of the target that matches to controller id * of the target that matches to controller id
* @param softwareModuleId * @param softwareModuleId
@@ -53,6 +55,8 @@ public interface DdiRootControllerRestApi {
/** /**
* Root resource for an individual {@link Target}. * Root resource for an individual {@link Target}.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* of the target that matches to controller id * of the target that matches to controller id
* @param request * @param request
@@ -68,6 +72,8 @@ public interface DdiRootControllerRestApi {
* Handles GET {@link DdiArtifact} download request. This could be full or * Handles GET {@link DdiArtifact} download request. This could be full or
* partial (as specified by RFC7233 (Range Requests)) download request. * partial (as specified by RFC7233 (Range Requests)) download request.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* of the related target * of the related target
* @param softwareModuleId * @param softwareModuleId
@@ -92,6 +98,8 @@ public interface DdiRootControllerRestApi {
/** /**
* Handles GET {@link DdiArtifact} MD5 checksum file download request. * Handles GET {@link DdiArtifact} MD5 checksum file download request.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* of the related target * of the related target
* @param softwareModuleId * @param softwareModuleId
@@ -116,6 +124,8 @@ public interface DdiRootControllerRestApi {
/** /**
* Resource for software module. * Resource for software module.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* of the target that matches to controller id * of the target that matches to controller id
* @param actionId * @param actionId
@@ -139,6 +149,8 @@ public interface DdiRootControllerRestApi {
/** /**
* This is the feedback channel for the {@link DdiDeploymentBase} action. * This is the feedback channel for the {@link DdiDeploymentBase} action.
* *
* @param tenant
* of the request
* @param feedback * @param feedback
* to provide * to provide
* @param targetid * @param targetid
@@ -159,6 +171,8 @@ public interface DdiRootControllerRestApi {
/** /**
* This is the feedback channel for the config data action. * This is the feedback channel for the config data action.
* *
* @param tenant
* of the request
* @param configData * @param configData
* as body * as body
* @param targetid * @param targetid
@@ -176,6 +190,8 @@ public interface DdiRootControllerRestApi {
/** /**
* RequestMethod.GET method for the {@link DdiCancel} action. * RequestMethod.GET method for the {@link DdiCancel} action.
* *
* @param tenant
* of the request
* @param targetid * @param targetid
* ID of the calling target * ID of the calling target
* @param actionId * @param actionId
@@ -195,6 +211,8 @@ public interface DdiRootControllerRestApi {
* RequestMethod.POST method receiving the {@link DdiActionFeedback} from * RequestMethod.POST method receiving the {@link DdiActionFeedback} from
* the target. * the target.
* *
* @param tenant
* of the request
* @param feedback * @param feedback
* the {@link DdiActionFeedback} from the target. * the {@link DdiActionFeedback} from the target.
* @param targetid * @param targetid

View File

@@ -35,7 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;

View File

@@ -151,7 +151,12 @@ public class DdiRootController implements DdiRootControllerRestApi {
LOG.warn("Softare module with id {} could not be found.", softwareModuleId); LOG.warn("Softare module with id {} could not be found.", softwareModuleId);
result = new ResponseEntity<>(HttpStatus.NOT_FOUND); result = new ResponseEntity<>(HttpStatus.NOT_FOUND);
} else { } else {
// Exception squid:S3655 - Optional access is checked in checkModule
// subroutine
@SuppressWarnings("squid:S3655")
final LocalArtifact artifact = module.getLocalArtifactByFilename(fileName).get(); final LocalArtifact artifact = module.getLocalArtifactByFilename(fileName).get();
final DbArtifact file = artifactManagement.loadLocalArtifactBinary(artifact); final DbArtifact file = artifactManagement.loadLocalArtifactBinary(artifact);
final String ifMatch = requestResponseContextHolder.getHttpServletRequest().getHeader("If-Match"); final String ifMatch = requestResponseContextHolder.getHttpServletRequest().getHeader("If-Match");
@@ -196,6 +201,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
} }
@Override @Override
// Exception squid:S3655 - Optional access is checked in checkModule
// subroutine
@SuppressWarnings("squid:S3655")
public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant, public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid, @PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("softwareModuleId") final Long softwareModuleId,

View File

@@ -22,12 +22,13 @@ import com.google.common.collect.Maps;
*/ */
@ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter") @ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter")
public class AmqpDeadletterProperties { public class AmqpDeadletterProperties {
private static final int THREE_WEEKS = 21;
/** /**
* Message time to live (ttl) for the deadletter queue. Default ttl is 3 * Message time to live (ttl) for the deadletter queue. Default ttl is 3
* weeks. * weeks.
*/ */
private long ttl = Duration.ofDays(21).toMillis(); private long ttl = Duration.ofDays(THREE_WEEKS).toMillis();
/** /**
* Return the deadletter arguments. * Return the deadletter arguments.

View File

@@ -20,6 +20,16 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("hawkbit.dmf.rabbitmq") @ConfigurationProperties("hawkbit.dmf.rabbitmq")
public class AmqpProperties { public class AmqpProperties {
private static final int ONE_MINUTE = 60;
private static final int DEFAULT_QUEUE_DECLARATION_RETRIES = 50;
private static final int DEFAULT_INITIAL_CONSUMERS = 3;
private static final int DEFAULT_PREFETCH_COUNT = 10;
private static final int DEFAULT_MAX_CONSUMERS = 10;
/** /**
* Enable DMF API based on AMQP 0.9 * Enable DMF API based on AMQP 0.9
*/ */
@@ -54,24 +64,24 @@ public class AmqpProperties {
/** /**
* Requested heartbeat interval from broker in {@link TimeUnit#SECONDS}. * Requested heartbeat interval from broker in {@link TimeUnit#SECONDS}.
*/ */
private int requestedHeartBeat = (int) TimeUnit.SECONDS.toSeconds(60); private int requestedHeartBeat = (int) TimeUnit.SECONDS.toSeconds(ONE_MINUTE);
/** /**
* Sets an upper limit to the number of consumers. * Sets an upper limit to the number of consumers.
*/ */
private int maxConcurrentConsumers = 10; private int maxConcurrentConsumers = DEFAULT_MAX_CONSUMERS;
/** /**
* Tells the broker how many messages to send to each consumer in a single * Tells the broker how many messages to send to each consumer in a single
* request. Often this can be set quite high to improve throughput. * request. Often this can be set quite high to improve throughput.
*/ */
private int prefetchCount = 10; private int prefetchCount = DEFAULT_PREFETCH_COUNT;
/** /**
* Initial number of consumers. Is scaled up if necessary up to * Initial number of consumers. Is scaled up if necessary up to
* {@link #maxConcurrentConsumers}. * {@link #maxConcurrentConsumers}.
*/ */
private int initialConcurrentConsumers = 3; private int initialConcurrentConsumers = DEFAULT_INITIAL_CONSUMERS;
/** /**
* The number of retry attempts when passive queue declaration fails. * The number of retry attempts when passive queue declaration fails.
@@ -79,7 +89,7 @@ public class AmqpProperties {
* consuming from multiple queues, when not all queues were available during * consuming from multiple queues, when not all queues were available during
* initialization. * initialization.
*/ */
private int declarationRetries = 50; private int declarationRetries = DEFAULT_QUEUE_DECLARATION_RETRIES;
public int getDeclarationRetries() { public int getDeclarationRetries() {
return declarationRetries; return declarationRetries;

View File

@@ -107,10 +107,15 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@Override @Override
@ResponseBody @ResponseBody
// Exception squid:S3655 - Optional access is checked in
// findSoftwareModuleWithExceptionIfNotFound
// subroutine
@SuppressWarnings("squid:S3655")
public ResponseEntity<MgmtArtifact> getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, public ResponseEntity<MgmtArtifact> getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId) { @PathVariable("artifactId") final Long artifactId) {
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
return ResponseEntity.ok(toResponse(module.getLocalArtifact(artifactId).get())); return ResponseEntity.ok(toResponse(module.getLocalArtifact(artifactId).get()));
} }

View File

@@ -23,7 +23,7 @@
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" /> <Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
<!-- <Logger name="org.eclipse.hawkbit.rest.util.MockMvcResultPrinter" level="DEBUG" /> --> <Logger name="org.eclipse.hawkbit.rest.util.MockMvcResultPrinter" level="DEBUG" />
<!-- Security Log with hints on potential attacks --> <!-- Security Log with hints on potential attacks -->
<logger name="server-security" level="INFO" /> <logger name="server-security" level="INFO" />

View File

@@ -32,11 +32,11 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -572,6 +572,9 @@ public class UploadConfirmationWindow implements Button.ClickListener {
} }
// Exception squid:S3655 - Optional access is checked in
// checkIfArtifactDetailsDispalyed subroutine
@SuppressWarnings("squid:S3655")
private void processArtifactUpload() { private void processArtifactUpload() {
final List<String> itemIds = (List<String>) uploadDetailsTable.getItemIds(); final List<String> itemIds = (List<String>) uploadDetailsTable.getItemIds();
if (preUploadValidation(itemIds)) { if (preUploadValidation(itemIds)) {
@@ -593,6 +596,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
} }
refreshArtifactDetailsLayout = checkIfArtifactDetailsDispalyed(bSoftwareModule.getId()); refreshArtifactDetailsLayout = checkIfArtifactDetailsDispalyed(bSoftwareModule.getId());
} }
if (refreshArtifactDetailsLayout) { if (refreshArtifactDetailsLayout) {
uploadLayout.refreshArtifactDetailsLayout(artifactUploadState.getSelectedBaseSoftwareModule().get()); uploadLayout.refreshArtifactDetailsLayout(artifactUploadState.getSelectedBaseSoftwareModule().get());
} }

View File

@@ -34,10 +34,10 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.util.SPInfo; import org.eclipse.hawkbit.util.SPInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -254,6 +254,11 @@ public class UploadLayout extends VerticalLayout {
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
// selected software module at the time of file drop is // selected software module at the time of file drop is
// considered for upload // considered for upload
if (!artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
return;
}
final SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get(); final SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get();
// reset the flag // reset the flag
hasDirectory = Boolean.FALSE; hasDirectory = Boolean.FALSE;

View File

@@ -173,9 +173,11 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
} }
private Button assignSoftModuleButton(final String softwareModuleName) { private Button assignSoftModuleButton(final String softwareModuleName) {
if (getPermissionChecker().hasUpdateDistributionPermission() && distributionSetManagement if (getPermissionChecker().hasUpdateDistributionPermission()
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) && manageDistUIState.getLastSelectedDistribution().isPresent()
.getAssignedTargets().isEmpty()) { && distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true, final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule.setEnabled(false); reassignSoftModule.setEnabled(false);

View File

@@ -26,9 +26,9 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@@ -136,7 +136,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private LayoutClickListener nameLayoutClickListner; private LayoutClickListener nameLayoutClickListner;
private boolean validationFailed = false; private boolean validationFailed;
/** /**
* Initialize the Campaign Status History Header. * Initialize the Campaign Status History Header.
@@ -509,6 +509,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private void updateCustomFilter() { private void updateCustomFilter() {
if (!filterManagementUIState.getTfQuery().isPresent()) {
return;
}
final TargetFilterQuery targetFilterQuery = filterManagementUIState.getTfQuery().get(); final TargetFilterQuery targetFilterQuery = filterManagementUIState.getTfQuery().get();
targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue());

View File

@@ -42,11 +42,11 @@ import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -525,6 +525,10 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
} }
private void styleDistributionTableOnPinning() { private void styleDistributionTableOnPinning() {
if (!managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) {
return;
}
final Target targetObj = targetService.findTargetByControllerIDWithDetails( final Target targetObj = targetService.findTargetByControllerIDWithDetails(
managementUIState.getDistributionTableFilters().getPinnedTargetId().get()); managementUIState.getDistributionTableFilters().getPinnedTargetId().get());