Refactoring/Improving source: repository & fix log() (#1601)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,25 +9,23 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import com.cronutils.utils.StringUtils;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.parser.Parser;
|
||||
import org.jsoup.safety.Cleaner;
|
||||
import org.jsoup.safety.Safelist;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.cronutils.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Safe html constraint validator for strings submitted into the repository.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class ValidStringValidator implements ConstraintValidator<ValidString, String> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ValidStringValidator.class);
|
||||
|
||||
private final Cleaner cleaner = new Cleaner(Safelist.none());
|
||||
|
||||
@@ -40,7 +38,7 @@ public class ValidStringValidator implements ConstraintValidator<ValidString, St
|
||||
try {
|
||||
return cleaner.isValid(stringToDocument(value));
|
||||
} catch (final Exception ex) {
|
||||
LOG.error(String.format("There was an exception during bean field value (%s) validation", value), ex);
|
||||
log.error(String.format("There was an exception during bean field value (%s) validation", value), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -53,5 +51,4 @@ public class ValidStringValidator implements ConstraintValidator<ValidString, St
|
||||
|
||||
return resultingDocument;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,10 @@ package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
@@ -23,13 +22,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
* A base definition class for remote events which contain a tenant aware base
|
||||
* entity.
|
||||
*
|
||||
* @param <E>
|
||||
* the type of the entity
|
||||
* @param <E> the type of the entity
|
||||
*/
|
||||
@Slf4j
|
||||
public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteIdEvent {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RemoteEntityEvent.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient E entity;
|
||||
@@ -69,9 +66,8 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
|
||||
return EventEntityManagerHolder.getInstance().getEventEntityManager().findEntity(getTenant(), getEntityId(),
|
||||
clazz);
|
||||
} catch (final ClassNotFoundException e) {
|
||||
LOG.error("Cannot reload entity because class is not found", e);
|
||||
log.error("Cannot reload entity because class is not found", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public final class SpPermission {
|
||||
final String role = (String) field.get(null);
|
||||
allPermissions.add(role);
|
||||
} catch (final IllegalAccessException e) {
|
||||
log().error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user