mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-9091 Fix findbugs warnings and issues
This commit is contained in:
parent
5893833ec2
commit
feeef7ae6e
@ -44,13 +44,13 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
*/
|
||||
public class ObjectsCache implements ObjectsCacheInstance, ObjectsCacheController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ObjectsCache.class);
|
||||
|
||||
protected String name;
|
||||
protected CacheSet cacheSet;
|
||||
protected CacheLoader loader;
|
||||
protected boolean logUpdateEvent = false;
|
||||
|
||||
protected static Logger log = LoggerFactory.getLogger(ObjectsCache.class);
|
||||
|
||||
protected ReentrantReadWriteLock cacheLock = new ReentrantReadWriteLock();
|
||||
protected ReentrantLock updateDataLock = new ReentrantLock();
|
||||
|
||||
|
@ -20,6 +20,7 @@ package com.haulmont.cuba.core.app.filestorage.amazon.auth;
|
||||
import com.haulmont.cuba.core.app.filestorage.amazon.util.BinaryUtils;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@ -102,7 +103,7 @@ public class AWS4SignerForAuthorizationHeader extends AWS4SignerBase {
|
||||
System.out.println("------------------------------------");
|
||||
|
||||
// compute the signing key
|
||||
byte[] kSecret = (SCHEME + awsSecretKey).getBytes();
|
||||
byte[] kSecret = (SCHEME + awsSecretKey).getBytes(StandardCharsets.UTF_8);
|
||||
byte[] kDate = sign(dateStamp, kSecret, "HmacSHA256");
|
||||
byte[] kRegion = sign(regionName, kDate, "HmacSHA256");
|
||||
byte[] kService = sign(serviceName, kRegion, "HmacSHA256");
|
||||
|
@ -20,6 +20,7 @@ package com.haulmont.cuba.core.app.filestorage.amazon.auth;
|
||||
import com.haulmont.cuba.core.app.filestorage.amazon.util.BinaryUtils;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@ -137,7 +138,7 @@ public class AWS4SignerForChunkedUpload extends AWS4SignerBase {
|
||||
System.out.println("------------------------------------");
|
||||
|
||||
// compute the signing key
|
||||
byte[] kSecret = (SCHEME + awsSecretKey).getBytes();
|
||||
byte[] kSecret = (SCHEME + awsSecretKey).getBytes(StandardCharsets.UTF_8);
|
||||
byte[] kDate = sign(dateStamp, kSecret, "HmacSHA256");
|
||||
byte[] kRegion = sign(regionName, kDate, "HmacSHA256");
|
||||
byte[] kService = sign(serviceName, kRegion, "HmacSHA256");
|
||||
|
@ -88,7 +88,7 @@ public class EntityImportExport implements EntityImportExportAPI {
|
||||
@Override
|
||||
public byte[] exportEntitiesToZIP(Collection<? extends Entity> entities) {
|
||||
String json = entitySerialization.toJson(entities, null, EntitySerializationOption.COMPACT_REPEATED_ENTITIES);
|
||||
byte[] jsonBytes = json.getBytes();
|
||||
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
|
||||
@ -156,13 +156,13 @@ public class EntityImportExport implements EntityImportExportAPI {
|
||||
@Override
|
||||
public Collection<Entity> importEntitiesFromZIP(byte[] zipBytes, EntityImportView view) {
|
||||
Collection<Entity> result = new ArrayList<>();
|
||||
Collection<? extends Entity> entities = null;
|
||||
Collection<? extends Entity> entities;
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(zipBytes);
|
||||
ZipArchiveInputStream archiveReader = new ZipArchiveInputStream(byteArrayInputStream);
|
||||
try {
|
||||
try {
|
||||
while (archiveReader.getNextZipEntry() != null) {
|
||||
String json = new String(readBytesFromEntry(archiveReader));
|
||||
String json = new String(readBytesFromEntry(archiveReader), StandardCharsets.UTF_8);
|
||||
entities = entitySerialization.entitiesCollectionFromJson(json,
|
||||
null,
|
||||
EntitySerializationOption.COMPACT_REPEATED_ENTITIES);
|
||||
|
@ -108,7 +108,7 @@ public class Scheduling implements SchedulingMBean {
|
||||
|
||||
Query query = em.createQuery(jpql);
|
||||
|
||||
Date startDate = DateUtils.addHours(timeSource.currentTimestamp(), -Integer.valueOf(age));
|
||||
Date startDate = DateUtils.addHours(timeSource.currentTimestamp(), -Integer.parseInt(age));
|
||||
query.setParameter(1, startDate);
|
||||
if (maxPeriod != null) {
|
||||
query.setParameter(2, Integer.parseInt(maxPeriod) * 3600);
|
||||
|
@ -23,7 +23,6 @@ import com.haulmont.cuba.core.Persistence;
|
||||
import com.haulmont.cuba.core.entity.BaseEntityInternalAccess;
|
||||
import com.haulmont.cuba.core.entity.BaseGenericIdEntity;
|
||||
import com.haulmont.cuba.core.global.GlobalPersistentAttributesLoadChecker;
|
||||
import com.haulmont.cuba.core.global.MetadataTools;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@ -33,9 +32,6 @@ public class CorePersistentAttributesLoadChecker extends GlobalPersistentAttribu
|
||||
@Inject
|
||||
protected Persistence persistence;
|
||||
|
||||
@Inject
|
||||
protected MetadataTools metadataTools;
|
||||
|
||||
@Override
|
||||
protected boolean isLoadedSpecificCheck(Object entity, String property, MetaClass metaClass, MetaProperty metaProperty) {
|
||||
if (metadataTools.isEmbeddable(metaClass)
|
||||
|
@ -327,7 +327,7 @@ public class EntityManagerImpl implements EntityManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (srcProperty.getRange().isClass() & !metadataTools.isEmbedded(srcProperty)) {
|
||||
if (srcProperty.getRange().isClass() && !metadataTools.isEmbedded(srcProperty)) {
|
||||
if (!metadataTools.isOwningSide(srcProperty))
|
||||
continue;
|
||||
|
||||
|
@ -102,7 +102,9 @@ public class SecurityTokenManager {
|
||||
protected Cipher getCipher(int mode) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
byte[] encryptionKey = rightPad(substring(config.getKeyForSecurityTokenEncryption(), 0, 16), 16).getBytes();
|
||||
byte[] encryptionKey = rightPad(substring(config.getKeyForSecurityTokenEncryption(), 0, 16), 16)
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
SecretKeySpec sKeySpec = new SecretKeySpec(encryptionKey, "AES");
|
||||
cipher.init(mode, sKeySpec);
|
||||
return cipher;
|
||||
|
@ -27,9 +27,8 @@ import java.util.regex.Pattern;
|
||||
@Scope("prototype")
|
||||
public class DateAfterMacroHandler extends AbstractQueryMacroHandler {
|
||||
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateAfter\\s*\\(([^\\)]+)\\)");
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateAfter\\s*\\(([^)]+)\\)");
|
||||
|
||||
protected int count;
|
||||
protected Map<String, Object> namedParameters;
|
||||
protected List<String> paramNames = new ArrayList<>();
|
||||
|
||||
|
@ -27,9 +27,8 @@ import java.util.regex.Pattern;
|
||||
@Scope("prototype")
|
||||
public class DateBeforeMacroHandler extends AbstractQueryMacroHandler {
|
||||
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateBefore\\s*\\(([^\\)]+)\\)");
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateBefore\\s*\\(([^)]+)\\)");
|
||||
|
||||
protected int count;
|
||||
protected Map<String, Object> namedParameters;
|
||||
protected List<String> paramNames = new ArrayList<>();
|
||||
|
||||
|
@ -28,9 +28,8 @@ import java.util.regex.Pattern;
|
||||
@Scope("prototype")
|
||||
public class DateEqualsMacroHandler extends AbstractQueryMacroHandler {
|
||||
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateEquals\\s*\\(([^\\)]+)\\)");
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@dateEquals\\s*\\(([^)]+)\\)");
|
||||
|
||||
protected int count;
|
||||
protected Map<String, Object> namedParameters;
|
||||
protected List<Pair<String, String>> paramNames = new ArrayList<>();
|
||||
|
||||
|
@ -36,7 +36,7 @@ import java.util.regex.Pattern;
|
||||
@Scope("prototype")
|
||||
public class TimeBetweenQueryMacroHandler extends AbstractQueryMacroHandler {
|
||||
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@between\\s*\\(([^\\)]+)\\)");
|
||||
protected static final Pattern MACRO_PATTERN = Pattern.compile("@between\\s*\\(([^)]+)\\)");
|
||||
protected static final Pattern PARAM_PATTERN = Pattern.compile("(now)\\s*([\\d\\s+-]*)");
|
||||
protected static final Pattern QUERY_PARAM_PATTERN = Pattern.compile(":(\\w+)");
|
||||
|
||||
@ -51,7 +51,6 @@ public class TimeBetweenQueryMacroHandler extends AbstractQueryMacroHandler {
|
||||
units.put("second", Calendar.SECOND);
|
||||
}
|
||||
|
||||
protected int count;
|
||||
protected Map<String, Object> params = new HashMap<>();
|
||||
|
||||
public TimeBetweenQueryMacroHandler() {
|
||||
|
@ -267,6 +267,7 @@ public class DbUpdaterUtil extends DbUpdaterEngine {
|
||||
private String url;
|
||||
private String user;
|
||||
private String password;
|
||||
private PrintWriter logWriter;
|
||||
|
||||
private SingleConnectionDataSource(String url, String user, String password) throws SQLException {
|
||||
this.url = url;
|
||||
@ -286,11 +287,12 @@ public class DbUpdaterUtil extends DbUpdaterEngine {
|
||||
|
||||
@Override
|
||||
public PrintWriter getLogWriter() throws SQLException {
|
||||
return new PrintWriter(System.out);
|
||||
return logWriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
||||
this.logWriter = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,8 +47,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Component(ServerTokenStore.NAME)
|
||||
public class ServerTokenStoreImpl implements ServerTokenStore {
|
||||
|
||||
@ -100,8 +98,8 @@ public class ServerTokenStoreImpl implements ServerTokenStore {
|
||||
|
||||
@Override
|
||||
public byte[] getState() {
|
||||
if (tokenValueToAccessTokenStore.isEmpty() && tokenValueToAccessTokenStore.isEmpty() & authenticationToAccessTokenStore.isEmpty()
|
||||
& tokenValueToSessionIdStore.isEmpty() & tokenValueToAuthenticationKeyStore.isEmpty()) {
|
||||
if (tokenValueToAccessTokenStore.isEmpty() && tokenValueToAuthenticationStore.isEmpty() && authenticationToAccessTokenStore.isEmpty()
|
||||
&& tokenValueToSessionIdStore.isEmpty() && tokenValueToAuthenticationKeyStore.isEmpty()) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
@ -409,6 +407,7 @@ public class ServerTokenStoreImpl implements ServerTokenStore {
|
||||
this.expiry = date.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Delayed other) {
|
||||
if (this == other) {
|
||||
return 0;
|
||||
@ -417,6 +416,7 @@ public class ServerTokenStoreImpl implements ServerTokenStore {
|
||||
return (diff == 0 ? 0 : ((diff < 0) ? -1 : 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDelay(TimeUnit unit) {
|
||||
return expiry - System.currentTimeMillis();
|
||||
}
|
||||
@ -425,4 +425,4 @@ public class ServerTokenStoreImpl implements ServerTokenStore {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,9 @@
|
||||
package com.haulmont.bali.db;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -198,7 +200,7 @@ public final class DbUtils {
|
||||
* @param e SQLException to print stack trace of
|
||||
*/
|
||||
public static void printStackTrace(SQLException e) {
|
||||
printStackTrace(e, new PrintWriter(System.err));
|
||||
printStackTrace(e, new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,7 +228,7 @@ public final class DbUtils {
|
||||
* @param conn Connection to print warnings from
|
||||
*/
|
||||
public static void printWarnings(Connection conn) {
|
||||
printWarnings(conn, new PrintWriter(System.err));
|
||||
printWarnings(conn, new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public class ByteArrayDatatype implements Datatype<byte[]> {
|
||||
if (value == null || value.length() == 0)
|
||||
return null;
|
||||
|
||||
return Base64.decodeBase64(value.getBytes());
|
||||
return Base64.decodeBase64(value.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +39,12 @@ public class GlobalPersistentAttributesLoadChecker implements PersistentAttribut
|
||||
@Inject
|
||||
protected Metadata metadata;
|
||||
|
||||
protected enum PropertyLoadedState {
|
||||
YES,
|
||||
NO,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(Object entity, String property) {
|
||||
MetaClass metaClass = metadata.getClassNN(entity.getClass());
|
||||
@ -57,15 +63,15 @@ public class GlobalPersistentAttributesLoadChecker implements PersistentAttribut
|
||||
}
|
||||
}
|
||||
|
||||
Boolean isLoaded = isLoadedCommonCheck(entity, property);
|
||||
if (isLoaded != null) {
|
||||
return isLoaded;
|
||||
PropertyLoadedState isLoaded = isLoadedCommonCheck(entity, property);
|
||||
if (isLoaded != PropertyLoadedState.UNKNOWN) {
|
||||
return isLoaded == PropertyLoadedState.YES;
|
||||
}
|
||||
|
||||
return isLoadedSpecificCheck(entity, property, metaClass, metaProperty);
|
||||
}
|
||||
|
||||
protected Boolean isLoadedCommonCheck(Object entity, String property) {
|
||||
protected PropertyLoadedState isLoadedCommonCheck(Object entity, String property) {
|
||||
if (entity instanceof BaseGenericIdEntity) {
|
||||
BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) entity;
|
||||
|
||||
@ -73,7 +79,7 @@ public class GlobalPersistentAttributesLoadChecker implements PersistentAttribut
|
||||
if (inaccessibleAttributes != null) {
|
||||
for (String inaccessibleAttr : inaccessibleAttributes) {
|
||||
if (inaccessibleAttr.equals(property))
|
||||
return false;
|
||||
return PropertyLoadedState.NO;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,16 +89,16 @@ public class GlobalPersistentAttributesLoadChecker implements PersistentAttribut
|
||||
boolean inFetchGroup = fetchGroup.getAttributeNames().contains(property);
|
||||
if (!inFetchGroup) {
|
||||
// definitely not loaded
|
||||
return false;
|
||||
return PropertyLoadedState.NO;
|
||||
} else {
|
||||
// requires additional check specific for the tier
|
||||
return null;
|
||||
return PropertyLoadedState.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return PropertyLoadedState.UNKNOWN;
|
||||
}
|
||||
|
||||
protected boolean isLoadedSpecificCheck(Object entity, String property, MetaClass metaClass, MetaProperty metaProperty) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package com.haulmont.cuba.core.global;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.haulmont.bali.util.Preconditions;
|
||||
import com.haulmont.chile.core.annotations.NamePattern;
|
||||
import com.haulmont.chile.core.datatypes.Datatype;
|
||||
@ -61,7 +62,7 @@ public class MetadataTools {
|
||||
public static final String SYSTEM_ANN_NAME = "cuba.system";
|
||||
public static final String STORE_ANN_NAME = "cuba.storeName";
|
||||
|
||||
public static final List<Class> SYSTEM_INTERFACES = Arrays.asList(
|
||||
public static final List<Class> SYSTEM_INTERFACES = ImmutableList.of(
|
||||
Instance.class,
|
||||
Entity.class,
|
||||
BaseGenericIdEntity.class,
|
||||
|
@ -42,6 +42,7 @@ import javax.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
@ -144,7 +145,7 @@ public class AbstractViewRepository implements ViewRepository {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document doc;
|
||||
try {
|
||||
doc = reader.read(new InputStreamReader(stream));
|
||||
doc = reader.read(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
} catch (DocumentException e) {
|
||||
throw new RuntimeException("Unable to parse view file " + fileName, e);
|
||||
}
|
||||
@ -363,7 +364,7 @@ public class AbstractViewRepository implements ViewRepository {
|
||||
}
|
||||
|
||||
public void deployViews(InputStream xml) {
|
||||
deployViews(new InputStreamReader(xml));
|
||||
deployViews(new InputStreamReader(xml, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public void deployViews(Reader xml) {
|
||||
@ -379,7 +380,7 @@ public class AbstractViewRepository implements ViewRepository {
|
||||
try {
|
||||
doc = reader.read(xml);
|
||||
} catch (DocumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException("Unable to read views xml", e);
|
||||
}
|
||||
Element rootElem = doc.getRootElement();
|
||||
|
||||
|
@ -90,13 +90,11 @@ public class LogControlImpl implements LogControl {
|
||||
randomAccessFile.seek(lengthFile - LOG_TAIL_AMOUNT_BYTES);
|
||||
skipFirstLine(randomAccessFile);
|
||||
}
|
||||
String str;
|
||||
while (randomAccessFile.read() != -1) {
|
||||
randomAccessFile.seek(randomAccessFile.getFilePointer() - 1);
|
||||
String line = readUtf8Line(randomAccessFile);
|
||||
if (line != null) {
|
||||
str = new String(line.getBytes(), StandardCharsets.UTF_8.name());
|
||||
sb.append(str).append("\n");
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -256,6 +254,6 @@ public class LogControlImpl implements LogControl {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new String(input.toByteArray(), StandardCharsets.UTF_8.name());
|
||||
return new String(input.toByteArray(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ package com.haulmont.cuba.core.sys;
|
||||
|
||||
import com.haulmont.cuba.core.global.LoadContext;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -45,4 +46,12 @@ public class QueryHolder implements Serializable {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (query != null) {
|
||||
return query.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ public class MBeanExporter extends org.springframework.jmx.export.MBeanExporter
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignore) {
|
||||
}
|
||||
if (beans != null) {
|
||||
log.info("Registering beans for JMX exposure: " + beans.keySet());
|
||||
log.info("Registering beans for JMX exposure: {}", beans.keySet());
|
||||
}
|
||||
|
||||
super.afterSingletonsInstantiated();
|
||||
|
@ -33,7 +33,7 @@ public class EclipseLinkLog extends AbstractSessionLog {
|
||||
|
||||
protected Map<String, Logger> logsCache = new ConcurrentHashMap<>();
|
||||
|
||||
protected static Map<Integer, Level> levels = new HashMap<>();
|
||||
protected static final Map<Integer, Level> levels = new HashMap<>();
|
||||
|
||||
static {
|
||||
levels.put(SessionLog.OFF, Level.OFF);
|
||||
|
@ -208,7 +208,7 @@ public abstract class ComponentsHelper {
|
||||
if (comp != null) {
|
||||
return comp;
|
||||
} else {
|
||||
findComponent((Frame) c, id);
|
||||
return findComponent((Frame) c, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@ -524,7 +525,9 @@ public class EntityInspectorBrowse extends AbstractLookup {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToZIP(selected)),
|
||||
selectedMeta.getJavaClass().getSimpleName() + ".zip", ZIP);
|
||||
} else if (exportFormat == JSON) {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToJSON(selected).getBytes()),
|
||||
byte[] data = entityImportExportService.exportEntitiesToJSON(selected)
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
exportDisplay.show(new ByteArrayDataProvider(data),
|
||||
selectedMeta.getJavaClass().getSimpleName() + ".json", JSON);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -52,6 +52,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class GroupBrowser extends AbstractWindow {
|
||||
@ -410,9 +411,12 @@ public class GroupBrowser extends AbstractWindow {
|
||||
if (!selected.isEmpty()) {
|
||||
try {
|
||||
if (exportFormat == ExportFormat.ZIP) {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToZIP(selected, view)), "Groups", ExportFormat.ZIP);
|
||||
byte[] data = entityImportExportService.exportEntitiesToZIP(selected, view);
|
||||
exportDisplay.show(new ByteArrayDataProvider(data), "Groups", ExportFormat.ZIP);
|
||||
} else if (exportFormat == ExportFormat.JSON) {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToJSON(selected, view).getBytes()), "Groups", ExportFormat.JSON);
|
||||
byte[] data = entityImportExportService.exportEntitiesToJSON(selected, view)
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
exportDisplay.show(new ByteArrayDataProvider(data), "Groups", ExportFormat.JSON);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
showNotification(getMessage("exportFailed"), e.getMessage(), NotificationType.ERROR);
|
||||
@ -420,5 +424,4 @@ public class GroupBrowser extends AbstractWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -42,13 +42,14 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class RoleBrowser extends AbstractLookup {
|
||||
|
||||
protected static final String DEFAULT_ROLE_PROPERTY = "defaultRole";
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(RoleBrowser.class);
|
||||
private final Logger log = LoggerFactory.getLogger(RoleBrowser.class);
|
||||
|
||||
@Inject
|
||||
protected Table<Role> rolesTable;
|
||||
@ -242,9 +243,12 @@ public class RoleBrowser extends AbstractLookup {
|
||||
if (!selected.isEmpty()) {
|
||||
try {
|
||||
if (exportFormat == ExportFormat.ZIP) {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToZIP(selected, view)), "Roles", ExportFormat.ZIP);
|
||||
byte[] data = entityImportExportService.exportEntitiesToZIP(selected, view);
|
||||
exportDisplay.show(new ByteArrayDataProvider(data), "Roles", ExportFormat.ZIP);
|
||||
} else if (exportFormat == ExportFormat.JSON) {
|
||||
exportDisplay.show(new ByteArrayDataProvider(entityImportExportService.exportEntitiesToJSON(selected, view).getBytes()), "Roles", ExportFormat.JSON);
|
||||
byte[] data = entityImportExportService.exportEntitiesToJSON(selected, view)
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
exportDisplay.show(new ByteArrayDataProvider(data), "Roles", ExportFormat.JSON);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
showNotification(getMessage("exportFailed"), e.getMessage(), NotificationType.ERROR);
|
||||
|
@ -23,7 +23,6 @@ import com.haulmont.cuba.client.ClientConfig;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.core.global.Security;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.components.DialogAction.Type;
|
||||
import com.haulmont.cuba.gui.data.CollectionDatasource;
|
||||
@ -61,8 +60,6 @@ public class RemoveAction extends ItemTrackingAction implements Action.HasBefore
|
||||
protected String confirmationMessage;
|
||||
protected String confirmationTitle;
|
||||
|
||||
protected Security security = AppBeans.get(Security.NAME);
|
||||
|
||||
protected AfterRemoveHandler afterRemoveHandler;
|
||||
|
||||
protected BeforeActionPerformedHandler beforeActionPerformedHandler;
|
||||
|
@ -34,7 +34,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
@Component(FilterParser.NAME)
|
||||
public class FilterParserImpl implements FilterParser {
|
||||
protected static Logger log = LoggerFactory.getLogger(FilterParser.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(FilterParser.class);
|
||||
|
||||
@Override
|
||||
public ConditionsTree getConditions(Filter filter, String xml) {
|
||||
|
@ -45,6 +45,8 @@ import java.util.*;
|
||||
*/
|
||||
public class FilterEditor extends AbstractWindow {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(FilterEditor.class);
|
||||
|
||||
protected static final String GLOBAL_FILTER_PERMISSION = "cuba.gui.filter.global";
|
||||
|
||||
protected FilterEntity filterEntity;
|
||||
@ -113,8 +115,6 @@ public class FilterEditor extends AbstractWindow {
|
||||
|
||||
protected boolean treeItemChangeListenerEnabled = true;
|
||||
|
||||
protected static Logger log = LoggerFactory.getLogger(FilterEditor.class);
|
||||
|
||||
@WindowParam(name = "useShortConditionForm")
|
||||
protected Boolean useShortConditionForm;
|
||||
|
||||
|
@ -417,7 +417,7 @@ public class ExcelExporter {
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return rowNumber++;
|
||||
return rowNumber;
|
||||
}
|
||||
|
||||
protected int createGroupRow(GroupTable table, List<Table.Column> columns, int rowNumber, GroupInfo groupInfo, int groupNumber) {
|
||||
|
@ -19,12 +19,10 @@ package com.haulmont.cuba.gui.xml.layout.loaders;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.client.ClientConfig;
|
||||
import com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributes;
|
||||
import com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesUtils;
|
||||
import com.haulmont.cuba.core.entity.CategoryAttribute;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.core.global.MetadataTools;
|
||||
import com.haulmont.cuba.gui.ComponentsHelper;
|
||||
import com.haulmont.cuba.gui.GuiDevelopmentException;
|
||||
@ -51,7 +49,6 @@ public abstract class AbstractTableLoader<T extends Table> extends ActionsHolder
|
||||
protected MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);
|
||||
protected DynamicAttributesGuiTools dynamicAttributesGuiTools = AppBeans.get(DynamicAttributesGuiTools.NAME);
|
||||
protected DynamicAttributes dynamicAttributes = AppBeans.get(DynamicAttributes.NAME);
|
||||
protected ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
|
||||
|
||||
protected ComponentLoader buttonsPanelLoader;
|
||||
protected Element panelElement;
|
||||
|
@ -55,7 +55,7 @@ public abstract class AbstractUploadFieldLoader<T extends UploadField> extends A
|
||||
|
||||
String fileSizeLimit = element.attributeValue("fileSizeLimit");
|
||||
if (StringUtils.isNotEmpty(fileSizeLimit)) {
|
||||
resultComponent.setFileSizeLimit(Long.valueOf(fileSizeLimit));
|
||||
resultComponent.setFileSizeLimit(Long.parseLong(fileSizeLimit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,10 @@ package com.haulmont.cuba.gui.xml.layout.loaders;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.client.ClientConfig;
|
||||
import com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributes;
|
||||
import com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesUtils;
|
||||
import com.haulmont.cuba.core.entity.CategoryAttribute;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.core.global.MetadataTools;
|
||||
import com.haulmont.cuba.gui.ComponentsHelper;
|
||||
import com.haulmont.cuba.gui.GuiDevelopmentException;
|
||||
@ -53,7 +51,6 @@ public class DataGridLoader extends ActionsHolderLoader<DataGrid> {
|
||||
protected MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);
|
||||
protected DynamicAttributesGuiTools dynamicAttributesGuiTools = AppBeans.get(DynamicAttributesGuiTools.NAME);
|
||||
protected DynamicAttributes dynamicAttributes = AppBeans.get(DynamicAttributes.NAME);
|
||||
protected ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
|
||||
|
||||
protected ComponentLoader buttonsPanelLoader;
|
||||
protected Element panelElement;
|
||||
@ -285,7 +282,7 @@ public class DataGridLoader extends ActionsHolderLoader<DataGrid> {
|
||||
|
||||
String expandRatio = element.attributeValue("expandRatio");
|
||||
if (StringUtils.isNotEmpty(expandRatio)) {
|
||||
column.setExpandRatio(Integer.valueOf(expandRatio));
|
||||
column.setExpandRatio(Integer.parseInt(expandRatio));
|
||||
}
|
||||
|
||||
String collapsed = element.attributeValue("collapsed");
|
||||
@ -441,7 +438,7 @@ public class DataGridLoader extends ActionsHolderLoader<DataGrid> {
|
||||
protected void loadFrozenColumnCount(DataGrid component, Element element) {
|
||||
String frozenColumnCount = element.attributeValue("frozenColumnCount");
|
||||
if (StringUtils.isNotEmpty(frozenColumnCount)) {
|
||||
component.setFrozenColumnCount(Integer.valueOf(frozenColumnCount));
|
||||
component.setFrozenColumnCount(Integer.parseInt(frozenColumnCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ public class FileUploadFieldLoader extends AbstractFieldLoader<FileUploadField>
|
||||
protected void loadFileSizeLimit() {
|
||||
String fileSizeLimit = element.attributeValue("fileSizeLimit");
|
||||
if (StringUtils.isNotEmpty(fileSizeLimit)) {
|
||||
resultComponent.setFileSizeLimit(Long.valueOf(fileSizeLimit));
|
||||
resultComponent.setFileSizeLimit(Long.parseLong(fileSizeLimit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,13 +712,7 @@ public class CubaFoldersPane extends VerticalLayout {
|
||||
|
||||
protected class SearchFolderActionsHandler extends AppFolderActionsHandler {
|
||||
|
||||
protected OpenAction openAction = new OpenAction();
|
||||
protected CopyAction copyAction = new CopyAction();
|
||||
protected CreateAction createAction = new CreateAction(false);
|
||||
protected EditAction editAction = new EditAction();
|
||||
protected RemoveAction removeAction = new RemoveAction();
|
||||
protected ExportAction exportAction = new ExportAction();
|
||||
protected ImportAction importAction = new ImportAction();
|
||||
protected CreateAction searchFolderCreateAction = new CreateAction(false);
|
||||
|
||||
@Override
|
||||
public Action[] getActions(Object target, Object sender) {
|
||||
@ -774,26 +768,25 @@ public class CubaFoldersPane extends VerticalLayout {
|
||||
}
|
||||
|
||||
protected Action[] createAllActions() {
|
||||
return new Action[] {openAction, copyAction, createAction,
|
||||
return new Action[] {openAction, copyAction, searchFolderCreateAction,
|
||||
editAction, removeAction, exportAction, importAction};
|
||||
}
|
||||
|
||||
protected Action[] createWithoutOpenActions() {
|
||||
return new Action[] {createAction, editAction, removeAction};
|
||||
return new Action[] {searchFolderCreateAction, editAction, removeAction};
|
||||
}
|
||||
|
||||
protected Action[] createOnlyCreateAction() {
|
||||
return new Action[] {createAction};
|
||||
return new Action[] {searchFolderCreateAction};
|
||||
}
|
||||
|
||||
protected Action[] createImportCreateAction() {
|
||||
return new Action[] {createAction, importAction};
|
||||
return new Action[] {searchFolderCreateAction, importAction};
|
||||
}
|
||||
|
||||
protected Action[] createOpenCreateAction() {
|
||||
return new Action[] {openAction, createAction, copyAction};
|
||||
return new Action[] {openAction, searchFolderCreateAction, copyAction};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected abstract class FolderAction extends Action {
|
||||
|
@ -54,7 +54,7 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class WebComponentsHelper {
|
||||
|
||||
protected static Map<String, Class<? extends FontIcon>> fontIcons = new ConcurrentHashMap<>();
|
||||
protected static final Map<String, Class<? extends FontIcon>> fontIcons = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
registerFontIcon("font-icon", FontAwesome.class);
|
||||
|
@ -138,7 +138,7 @@ public class WebDataGrid<E extends Entity> extends WebAbstractComponent<CubaGrid
|
||||
protected final List<HeaderRow> headerRows = new ArrayList<>();
|
||||
protected final List<FooterRow> footerRows = new ArrayList<>();
|
||||
|
||||
protected static Map<Class<? extends Renderer>, Class<? extends Renderer>> rendererClasses;
|
||||
protected static final Map<Class<? extends Renderer>, Class<? extends Renderer>> rendererClasses;
|
||||
|
||||
protected boolean showIconsForPopupMenuActions;
|
||||
|
||||
|
@ -87,8 +87,8 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
|
||||
component = new CubaHorizontalSplitPanel() {
|
||||
@Override
|
||||
public void setSplitPosition(float pos, Unit unit, boolean reverse) {
|
||||
currentPosition = getSplitPosition();
|
||||
inverse = isSplitPositionReversed();
|
||||
currentPosition = this.getSplitPosition();
|
||||
inverse = this.isSplitPositionReversed();
|
||||
|
||||
super.setSplitPosition(pos, unit, reverse);
|
||||
}
|
||||
@ -97,19 +97,16 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
|
||||
component = new VerticalSplitPanel() {
|
||||
@Override
|
||||
public void setSplitPosition(float pos, Unit unit, boolean reverse) {
|
||||
currentPosition = getSplitPosition();
|
||||
currentPosition = this.getSplitPosition();
|
||||
|
||||
super.setSplitPosition(pos, unit, reverse);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
component.addSplitPositionChangeListener(new AbstractSplitPanel.SplitPositionChangeListener() {
|
||||
@Override
|
||||
public void onSplitPositionChanged(AbstractSplitPanel.SplitPositionChangeEvent event) {
|
||||
firePositionUpdateListener(currentPosition, event.getSplitPosition());
|
||||
}
|
||||
});
|
||||
component.addSplitPositionChangeListener(event ->
|
||||
firePositionUpdateListener(currentPosition, event.getSplitPosition())
|
||||
);
|
||||
}
|
||||
|
||||
protected void firePositionUpdateListener(float previousPosition, float newPosition) {
|
||||
|
@ -281,9 +281,10 @@ public class WebTimeField extends WebAbstractField<CubaMaskedTextField> implemen
|
||||
|
||||
@Override
|
||||
public String getFormattedValue() {
|
||||
Object value = getValue();
|
||||
if (value instanceof Date)
|
||||
Object value = this.getValue();
|
||||
if (value instanceof Date) {
|
||||
return new SimpleDateFormat(timeFormat).format(value);
|
||||
}
|
||||
|
||||
return super.getFormattedValue();
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ public class CubaManagedTabSheet extends CssLayout
|
||||
}
|
||||
|
||||
protected void setComponent(Component component) {
|
||||
removeComponent(this.component);
|
||||
this.removeComponent(this.component);
|
||||
|
||||
this.component = component;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user