Some clean code refactorings
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -114,7 +114,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
@Description("Tests authentication manager without principal")
|
||||
public void testAuthenticationeBadCredantialsWithoutPricipal() {
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
try {
|
||||
authenticationManager.doAuthenticate(securityToken);
|
||||
fail("BadCredentialsException was excepeted since principal was missing");
|
||||
@@ -128,7 +128,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
@Description("Tests authentication manager without wrong credential")
|
||||
public void testAuthenticationBadCredantialsWithWrongCredential() {
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
when(tenantConfigurationManagement.getConfigurationValue(
|
||||
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
|
||||
.thenReturn(CONFIG_VALUE_TRUE);
|
||||
@@ -146,7 +146,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
@Description("Tests authentication successfull")
|
||||
public void testSuccessfullAuthentication() {
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
when(tenantConfigurationManagement.getConfigurationValue(
|
||||
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
|
||||
.thenReturn(CONFIG_VALUE_TRUE);
|
||||
@@ -161,7 +161,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
|
||||
messageProperties);
|
||||
|
||||
@@ -180,7 +180,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
public void testAuthenticationMessageBadCredantialsWithWrongCredential() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
when(tenantConfigurationManagement.getConfigurationValue(
|
||||
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
|
||||
.thenReturn(CONFIG_VALUE_TRUE);
|
||||
@@ -203,7 +203,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
public void testSuccessfullMessageAuthentication() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, CONTROLLLER_ID,
|
||||
FileResource.sha1("12345"));
|
||||
FileResource.createFileResourceBySha1("12345"));
|
||||
when(tenantConfigurationManagement.getConfigurationValue(
|
||||
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
|
||||
.thenReturn(CONFIG_VALUE_TRUE);
|
||||
|
||||
@@ -264,7 +264,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
@Description("Tests that an download request is denied for an artifact which does not exists")
|
||||
public void authenticationRequestDeniedForArtifactWhichDoesNotExists() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.sha1("12345"));
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.createFileResourceBySha1("12345"));
|
||||
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
|
||||
messageProperties);
|
||||
|
||||
@@ -283,7 +283,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
@Description("Tests that an download request is denied for an artifact which is not assigned to the requested target")
|
||||
public void authenticationRequestDeniedForArtifactWhichIsNotAssignedToTarget() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.sha1("12345"));
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.createFileResourceBySha1("12345"));
|
||||
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
|
||||
messageProperties);
|
||||
|
||||
@@ -307,7 +307,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
@Description("Tests that an download request is allowed for an artifact which exists and assigned to the requested target")
|
||||
public void authenticationRequestAllowedForArtifactWhichExistsAndAssignedToTarget() throws MalformedURLException {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.sha1("12345"));
|
||||
final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, "123", FileResource.createFileResourceBySha1("12345"));
|
||||
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
|
||||
messageProperties);
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TenantSecurityToken {
|
||||
* the SHA1 key of the file to obtain
|
||||
* @return the {@link FileResource} with SHA1 key set
|
||||
*/
|
||||
public static FileResource sha1(final String sha1) {
|
||||
public static FileResource createFileResourceBySha1(final String sha1) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.sha1 = sha1;
|
||||
return resource;
|
||||
@@ -148,7 +148,7 @@ public class TenantSecurityToken {
|
||||
* the filename of the file to obtain
|
||||
* @return the {@link FileResource} with filename set
|
||||
*/
|
||||
public static FileResource filename(final String filename) {
|
||||
public static FileResource createFileResourceByFilename(final String filename) {
|
||||
final FileResource resource = new FileResource();
|
||||
resource.filename = filename;
|
||||
return resource;
|
||||
|
||||
@@ -47,7 +47,7 @@ import com.google.common.collect.UnmodifiableIterator;
|
||||
*/
|
||||
public abstract class AbstractHttpControllerAuthenticationFilter extends AbstractPreAuthenticatedProcessingFilter {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpControllerAuthenticationFilter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpControllerAuthenticationFilter.class);
|
||||
|
||||
private static final String TENANT_PLACE_HOLDER = "tenant";
|
||||
private static final String CONTROLLER_ID_PLACE_HOLDER = "controllerId";
|
||||
@@ -73,10 +73,12 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac
|
||||
/**
|
||||
* Constructor for sub-classes.
|
||||
*
|
||||
* @param systemManagement
|
||||
* the system management service
|
||||
* @param tenantConfigurationManagement
|
||||
* the tenant configuration service
|
||||
* @param tenantAware
|
||||
* the tenant aware service
|
||||
* @param systemSecurityContext
|
||||
* the system secruity context
|
||||
*/
|
||||
public AbstractHttpControllerAuthenticationFilter(final TenantConfigurationManagement tenantConfigurationManagement,
|
||||
final TenantAware tenantAware, final SystemSecurityContext systemSecurityContext) {
|
||||
@@ -136,28 +138,28 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac
|
||||
final String requestURI = request.getRequestURI();
|
||||
|
||||
if (pathExtractor.match(request.getContextPath() + CONTROLLER_REQUEST_ANT_PATTERN, requestURI)) {
|
||||
LOGGER.debug("retrieving principal from URI request {}", requestURI);
|
||||
LOG.debug("retrieving principal from URI request {}", requestURI);
|
||||
final Map<String, String> extractUriTemplateVariables = pathExtractor
|
||||
.extractUriTemplateVariables(request.getContextPath() + CONTROLLER_REQUEST_ANT_PATTERN, requestURI);
|
||||
final String controllerId = extractUriTemplateVariables.get(CONTROLLER_ID_PLACE_HOLDER);
|
||||
final String tenant = extractUriTemplateVariables.get(TENANT_PLACE_HOLDER);
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Parsed tenant {} and controllerId {} from path request {}", tenant, controllerId,
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("Parsed tenant {} and controllerId {} from path request {}", tenant, controllerId,
|
||||
requestURI);
|
||||
}
|
||||
return createTenantSecruityTokenVariables(request, tenant, controllerId);
|
||||
} else if (pathExtractor.match(request.getContextPath() + CONTROLLER_DL_REQUEST_ANT_PATTERN, requestURI)) {
|
||||
LOGGER.debug("retrieving path variables from URI request {}", requestURI);
|
||||
LOG.debug("retrieving path variables from URI request {}", requestURI);
|
||||
final Map<String, String> extractUriTemplateVariables = pathExtractor.extractUriTemplateVariables(
|
||||
request.getContextPath() + CONTROLLER_DL_REQUEST_ANT_PATTERN, requestURI);
|
||||
final String tenant = extractUriTemplateVariables.get(TENANT_PLACE_HOLDER);
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Parsed tenant {} from path request {}", tenant, requestURI);
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("Parsed tenant {} from path request {}", tenant, requestURI);
|
||||
}
|
||||
return createTenantSecruityTokenVariables(request, tenant, "anonymous");
|
||||
} else {
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("request {} does not match the path pattern {}, request gets ignored", requestURI,
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("request {} does not match the path pattern {}, request gets ignored", requestURI,
|
||||
CONTROLLER_REQUEST_ANT_PATTERN);
|
||||
}
|
||||
return null;
|
||||
@@ -166,7 +168,8 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac
|
||||
|
||||
private TenantSecurityToken createTenantSecruityTokenVariables(final HttpServletRequest request,
|
||||
final String tenant, final String controllerId) {
|
||||
final TenantSecurityToken secruityToken = new TenantSecurityToken(tenant, controllerId, FileResource.sha1(""));
|
||||
final TenantSecurityToken secruityToken = new TenantSecurityToken(tenant, controllerId,
|
||||
FileResource.createFileResourceBySha1(""));
|
||||
final UnmodifiableIterator<String> forEnumeration = Iterators.forEnumeration(request.getHeaderNames());
|
||||
forEnumeration.forEachRemaining(header -> secruityToken.getHeaders().put(header, request.getHeader(header)));
|
||||
return secruityToken;
|
||||
|
||||
@@ -22,15 +22,11 @@ import org.springframework.util.AntPathMatcher;
|
||||
* An {@link AuthenticationDetailsSource} implementation which retrieves the
|
||||
* tenant from a request pattern {@link #TENANT_AWARE_CONTROLLER_PATTERN} and
|
||||
* stores the retrieved tenant in the {@link TenantAwareAuthenticationDetails}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ControllerTenantAwareAuthenticationDetailsSource
|
||||
implements AuthenticationDetailsSource<HttpServletRequest, TenantAwareAuthenticationDetails> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String TENANT_AWARE_CONTROLLER_PATTERN = "/{tenant}/controller/**";
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(ControllerTenantAwareAuthenticationDetailsSource.class);
|
||||
@@ -38,19 +34,12 @@ public class ControllerTenantAwareAuthenticationDetailsSource
|
||||
private final AntPathMatcher pathExtractor;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
* Constructor.
|
||||
*/
|
||||
public ControllerTenantAwareAuthenticationDetailsSource() {
|
||||
pathExtractor = new AntPathMatcher();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.security.authentication.AuthenticationDetailsSource#
|
||||
* buildDetails(java. lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public TenantAwareAuthenticationDetails buildDetails(final HttpServletRequest request) {
|
||||
return new TenantAwareWebAuthenticationDetails(getTenantFromRequestUri(request), request.getRemoteAddr(), true);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.security.web.authentication.preauth.AbstractPreAuthen
|
||||
public class HttpDownloadAuthenticationFilter extends AbstractPreAuthenticatedProcessingFilter {
|
||||
|
||||
public static final String REQUEST_ID_REGEX_PATTERN = ".*\\/downloadId\\/.*";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HttpDownloadAuthenticationFilter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HttpDownloadAuthenticationFilter.class);
|
||||
|
||||
private final Pattern pattern;
|
||||
private final Cache cache;
|
||||
@@ -50,7 +50,7 @@ public class HttpDownloadAuthenticationFilter extends AbstractPreAuthenticatedPr
|
||||
if (!matcher.matches()) {
|
||||
return null;
|
||||
}
|
||||
LOGGER.debug("retrieving id from URI request {}", requestURI);
|
||||
LOG.debug("retrieving id from URI request {}", requestURI);
|
||||
final String[] groups = requestURI.split("\\/");
|
||||
final String id = groups[groups.length - 1];
|
||||
if (id == null) {
|
||||
|
||||
@@ -32,9 +32,6 @@ import org.springframework.hateoas.Identifiable;
|
||||
* by this entity listener cause the cache keys are calculated with the ID of
|
||||
* the entity.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CacheFieldEntityListener {
|
||||
|
||||
@@ -48,24 +45,21 @@ public class CacheFieldEntityListener {
|
||||
*/
|
||||
@PostLoad
|
||||
public void postLoad(final Object target) {
|
||||
if (target instanceof Identifiable) {
|
||||
final CacheManager cacheManager = CacheManagerHolder.getInstance().getCacheManager();
|
||||
@SuppressWarnings("rawtypes")
|
||||
final String id = ((Identifiable) target).getId().toString();
|
||||
final Class<? extends Object> type = target.getClass();
|
||||
findCacheFields(type, id, new CacheFieldCallback() {
|
||||
@Override
|
||||
public void fromCache(final Field field, final String cacheKey, final Serializable id)
|
||||
throws IllegalAccessException {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
final ValueWrapper valueWrapper = cache
|
||||
.get(CacheKeys.entitySpecificCacheKey(id.toString(), cacheKey));
|
||||
if (valueWrapper != null && valueWrapper.get() != null) {
|
||||
FieldUtils.writeField(field, target, valueWrapper.get(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!isIdentifiable(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CacheFieldCallback cacheFieldCallback = (type, field, cacheKey, entityId) -> {
|
||||
final CacheManager cacheManager = CacheManagerHolder.getInstance().getCacheManager();
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
final ValueWrapper valueWrapper = cache
|
||||
.get(CacheKeys.entitySpecificCacheKey(entityId.toString(), cacheKey));
|
||||
if (valueWrapper != null && valueWrapper.get() != null) {
|
||||
FieldUtils.writeField(field, target, valueWrapper.get(), true);
|
||||
}
|
||||
};
|
||||
|
||||
findCacheFields((Identifiable<?>) target, cacheFieldCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,30 +71,32 @@ public class CacheFieldEntityListener {
|
||||
*/
|
||||
@PostRemove
|
||||
public void postDelete(final Object target) {
|
||||
if (target instanceof Identifiable) {
|
||||
final CacheManager cacheManager = CacheManagerHolder.getInstance().getCacheManager();
|
||||
@SuppressWarnings("rawtypes")
|
||||
final String id = ((Identifiable) target).getId().toString();
|
||||
final Class<? extends Object> type = target.getClass();
|
||||
findCacheFields(type, id, new CacheFieldCallback() {
|
||||
@Override
|
||||
public void fromCache(final Field field, final String cacheKey, final Serializable id)
|
||||
throws IllegalAccessException {
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
cache.evict(CacheKeys.entitySpecificCacheKey(id.toString(), cacheKey));
|
||||
}
|
||||
});
|
||||
if (!isIdentifiable(target)) {
|
||||
return;
|
||||
}
|
||||
final CacheFieldCallback cacheFieldCallback = (type, field, cacheKey, entityId) -> {
|
||||
final CacheManager cacheManager = CacheManagerHolder.getInstance().getCacheManager();
|
||||
final Cache cache = cacheManager.getCache(type.getName());
|
||||
cache.evict(CacheKeys.entitySpecificCacheKey(entityId.toString(), cacheKey));
|
||||
};
|
||||
|
||||
findCacheFields((Identifiable<?>) target, cacheFieldCallback);
|
||||
}
|
||||
|
||||
private void findCacheFields(final Class<? extends Object> type, final Serializable id,
|
||||
final CacheFieldCallback callback) {
|
||||
private boolean isIdentifiable(final Object target) {
|
||||
return target instanceof Identifiable;
|
||||
}
|
||||
|
||||
private void findCacheFields(final Identifiable<?> target, final CacheFieldCallback callback) {
|
||||
final String id = target.getId().toString();
|
||||
final Class<?> type = target.getClass();
|
||||
|
||||
final Field[] declaredFields = type.getDeclaredFields();
|
||||
for (final Field field : declaredFields) {
|
||||
if (field.getAnnotation(CacheField.class) != null) {
|
||||
try {
|
||||
final CacheField annotation = field.getAnnotation(CacheField.class);
|
||||
callback.fromCache(field, annotation.key(), id);
|
||||
callback.fromCache(type, field, annotation.key(), id);
|
||||
} catch (final IllegalAccessException e) {
|
||||
LOGGER.error("cannot access the field {} for the entity {}, ignoring the cacheable field", field,
|
||||
type, e);
|
||||
@@ -109,23 +105,26 @@ public class CacheFieldEntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface CacheFieldCallback {
|
||||
/**
|
||||
* callback methods which is called by the
|
||||
* {@link CacheFieldEntityListener#findCacheFields(Class, Serializable, CacheFieldCallback)}
|
||||
* in case a field is annotated with {@link CacheField}.
|
||||
* callback methods which is called when a field is annotated with
|
||||
* {@link CacheField}.
|
||||
*
|
||||
* @param type
|
||||
* the type of the target.
|
||||
* @param field
|
||||
* the field which is annotaed with {@link CacheField}
|
||||
* @param cacheKey
|
||||
* the configured cache key in the annotation
|
||||
* {@link CacheField#key()}
|
||||
* @param id
|
||||
* @param entityId
|
||||
* the ID of the entity
|
||||
* @throws IllegalAccessException
|
||||
* in case the field cannot be accessed
|
||||
*/
|
||||
void fromCache(final Field field, final String cacheKey, Serializable id) throws IllegalAccessException;
|
||||
void fromCache(Class<?> type, final Field field, final String cacheKey, Serializable entityId)
|
||||
throws IllegalAccessException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,11 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
/**
|
||||
* Vaadin management UI.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Title("hawkBit Update Server")
|
||||
public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HawkbitUI.class);
|
||||
|
||||
private static final String EMPTY_VIEW = "";
|
||||
@@ -139,7 +137,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
contentVerticalLayout.addComponent(content);
|
||||
content.setStyleName("view-content");
|
||||
content.setSizeFull();
|
||||
rootLayout.setExpandRatio(contentVerticalLayout, 1.0f);
|
||||
rootLayout.setExpandRatio(contentVerticalLayout, 1.0F);
|
||||
contentVerticalLayout.setStyleName("main-content");
|
||||
contentVerticalLayout.setExpandRatio(content, 1.0F);
|
||||
setContent(rootLayout);
|
||||
@@ -154,6 +152,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
}
|
||||
final Navigator navigator = new Navigator(this, content);
|
||||
navigator.addViewChangeListener(new ViewChangeListener() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean beforeViewChange(final ViewChangeEvent event) {
|
||||
return true;
|
||||
@@ -197,7 +197,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
* as set
|
||||
* @return String as preferred locale
|
||||
*/
|
||||
private String getLocaleId(final Set<String> availableLocalesInApp) {
|
||||
private static String getLocaleId(final Set<String> availableLocalesInApp) {
|
||||
final String[] localeChain = getLocaleChain();
|
||||
String spLocale = SPUIDefinitions.DEFAULT_LOCALE;
|
||||
if (null != localeChain) {
|
||||
@@ -217,16 +217,18 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
*
|
||||
* @return String as locales
|
||||
*/
|
||||
private String[] getLocaleChain() {
|
||||
private static String[] getLocaleChain() {
|
||||
String[] localeChain = null;
|
||||
// Fetch all cookies from the request
|
||||
final Cookie[] cookies = VaadinService.getCurrentRequest().getCookies();
|
||||
if (cookies != null) {
|
||||
for (final Cookie c : cookies) {
|
||||
if (c.getName().equals(SPUIDefinitions.COOKIE_NAME) && !c.getValue().isEmpty()) {
|
||||
localeChain = c.getValue().split("#");
|
||||
break;
|
||||
}
|
||||
if (cookies == null) {
|
||||
return localeChain;
|
||||
}
|
||||
|
||||
for (final Cookie c : cookies) {
|
||||
if (c.getName().equals(SPUIDefinitions.COOKIE_NAME) && !c.getValue().isEmpty()) {
|
||||
localeChain = c.getValue().split("#");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return localeChain;
|
||||
@@ -234,6 +236,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
|
||||
private class ManagementViewProvider implements ViewProvider {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getViewName(final String viewAndParameters) {
|
||||
return viewProvider.getViewName(getStartView(viewAndParameters));
|
||||
|
||||
@@ -158,7 +158,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
detailAndUploadLayout.setComponentAlignment(dadw, Alignment.MIDDLE_CENTER);
|
||||
}
|
||||
|
||||
detailAndUploadLayout.setExpandRatio(artifactDetailsLayout, 1.0f);
|
||||
detailAndUploadLayout.setExpandRatio(artifactDetailsLayout, 1.0F);
|
||||
detailAndUploadLayout.setSizeFull();
|
||||
detailAndUploadLayout.addStyleName("group");
|
||||
detailAndUploadLayout.setSpacing(true);
|
||||
@@ -177,9 +177,9 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
mainLayout.addComponent(detailAndUploadLayout, 2, 0);
|
||||
mainLayout.addComponent(deleteActionsLayout, 1, 1);
|
||||
mainLayout.addComponent(uplaodButtonsLayout, 2, 1);
|
||||
mainLayout.setRowExpandRatio(0, 1.0f);
|
||||
mainLayout.setColumnExpandRatio(1, 0.5f);
|
||||
mainLayout.setColumnExpandRatio(2, 0.5f);
|
||||
mainLayout.setRowExpandRatio(0, 1.0F);
|
||||
mainLayout.setColumnExpandRatio(1, 0.5F);
|
||||
mainLayout.setColumnExpandRatio(2, 0.5F);
|
||||
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
|
||||
mainLayout.setComponentAlignment(uplaodButtonsLayout, Alignment.BOTTOM_CENTER);
|
||||
return mainLayout;
|
||||
@@ -201,8 +201,8 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
private void maximizeSwTable() {
|
||||
mainLayout.removeComponent(detailAndUploadLayout);
|
||||
removeOtherComponents();
|
||||
mainLayout.setColumnExpandRatio(1, 1f);
|
||||
mainLayout.setColumnExpandRatio(2, 0f);
|
||||
mainLayout.setColumnExpandRatio(1, 1F);
|
||||
mainLayout.setColumnExpandRatio(2, 0F);
|
||||
}
|
||||
|
||||
private void minimizeArtifactoryDetails() {
|
||||
@@ -219,15 +219,15 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
mainLayout.removeComponent(smTableLayout);
|
||||
detailAndUploadLayout.removeComponent(dadw);
|
||||
removeOtherComponents();
|
||||
mainLayout.setColumnExpandRatio(1, 0f);
|
||||
mainLayout.setColumnExpandRatio(2, 1f);
|
||||
mainLayout.setColumnExpandRatio(1, 0F);
|
||||
mainLayout.setColumnExpandRatio(2, 1F);
|
||||
}
|
||||
|
||||
private void addOtherComponents() {
|
||||
mainLayout.addComponent(deleteActionsLayout, 1, 1);
|
||||
mainLayout.addComponent(uplaodButtonsLayout, 2, 1);
|
||||
mainLayout.setColumnExpandRatio(1, 0.5f);
|
||||
mainLayout.setColumnExpandRatio(2, 0.5f);
|
||||
mainLayout.setColumnExpandRatio(1, 0.5F);
|
||||
mainLayout.setColumnExpandRatio(2, 0.5F);
|
||||
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
|
||||
mainLayout.setComponentAlignment(uplaodButtonsLayout, Alignment.BOTTOM_CENTER);
|
||||
}
|
||||
@@ -240,6 +240,8 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
|
||||
|
||||
private void hideDropHints() {
|
||||
UI.getCurrent().addClickListener(new ClickListener() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void click(final com.vaadin.event.MouseEvents.ClickEvent event) {
|
||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||
|
||||
@@ -36,9 +36,9 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
private static final long serialVersionUID = -333786310371208962L;
|
||||
private Sort sort = new Sort(Direction.DESC, "filename");
|
||||
private transient ArtifactManagement artifactManagement = null;
|
||||
private transient Page<LocalArtifact> firstPagetArtifacts = null;
|
||||
private Long baseSwModuleId = null;
|
||||
private transient ArtifactManagement artifactManagement;
|
||||
private transient Page<LocalArtifact> firstPagetArtifacts;
|
||||
private Long baseSwModuleId;
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
|
||||
Reference in New Issue
Block a user