Add JavaDoc, refactor staff for clean code convention and modify unit

tests

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-02-16 12:24:33 +01:00
parent be68ad32f5
commit b4421e7e44
15 changed files with 194 additions and 150 deletions

View File

@@ -15,7 +15,6 @@ import java.util.concurrent.Callable;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.TenantAware.TenantRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,8 +29,7 @@ import org.springframework.stereotype.Service;
import com.google.common.base.Throwables;
/**
* @author Michael Hirsch
*
*
*/
@Service
public class SystemSecurityContext {
@@ -45,15 +43,12 @@ public class SystemSecurityContext {
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
logger.debug("entering system code execution");
return tenantAware.runAsTenant(tenantAware.getCurrentTenant(), new TenantRunner<T>() {
@Override
public T run() {
try {
setSystemContext();
return callable.call();
} catch (final Exception e) {
throw Throwables.propagate(e);
}
return tenantAware.runAsTenant(tenantAware.getCurrentTenant(), () -> {
try {
setSystemContext();
return callable.call();
} catch (final Exception e) {
throw Throwables.propagate(e);
}
});
@@ -106,7 +101,8 @@ public class SystemSecurityContext {
}
@Override
public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException {
public void setAuthenticated(final boolean isAuthenticated) {
// not needed
}
}
}

View File

@@ -20,9 +20,6 @@ import com.google.common.net.HttpHeaders;
/**
* A utility which determines the correct IP of a connected {@link Target}. E.g
* from a {@link HttpServletRequest}.
*
*
*
*
*/
public final class IpUtil {
@@ -103,12 +100,14 @@ public final class IpUtil {
*
* @param host
* the host
* @param exchange
* the exchange will store in the path
* @return the {@link URI}
* @throws IllegalArgumentException
* If the given string not parsable
*/
public static URI createAmqpUri(final String virtualHost, final String exchange) {
return createUri(AMPQP_SCHEME, virtualHost).resolve("/" + exchange);
public static URI createAmqpUri(final String host, final String exchange) {
return createUri(AMPQP_SCHEME, host).resolve("/" + exchange);
}
/**