Skip to content

Commit 3f4bbf5

Browse files
committed
fix license problem
1 parent 94928e6 commit 3f4bbf5

File tree

14 files changed

+110
-34
lines changed

14 files changed

+110
-34
lines changed

common/src/main/java/com/robin/comm/util/config/YamlUtils.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import org.yaml.snakeyaml.Yaml;
44
import org.yaml.snakeyaml.constructor.Constructor;
55

6-
import java.io.InputStream;
7-
import java.io.OutputStream;
8-
import java.io.OutputStreamWriter;
6+
import java.io.*;
97
import java.util.Map;
108

119

@@ -16,7 +14,10 @@ public static Map<String,Object> parseYamlFileWithClasspath(String classPathFile
1614
Map<String,Object> map= yaml.load(clazz.getClassLoader().getResourceAsStream(classPathFile));
1715
return map;
1816
}
19-
public static Map<String,Object> parseYamlFileWithStream(InputStream in){
17+
public static Map<String,Object> parseYamlFromFile(String filePath) throws IOException {
18+
return parseYamlFromStream(new FileInputStream(filePath));
19+
}
20+
public static Map<String,Object> parseYamlFromStream(InputStream in){
2021
Map<String,Object> map= yaml.load(in);
2122
return map;
2223
}
@@ -31,5 +32,8 @@ public static <T> T loadFromStream(InputStream inputStream,Class<T> clazz){
3132
Yaml tyaml=new Yaml(new Constructor(clazz.getClass()));
3233
return tyaml.load(inputStream);
3334
}
35+
public static <T> T loadFromClassPath(String classPath,Class<T> clazz){
36+
return loadFromStream(clazz.getClassLoader().getResourceAsStream(classPath),clazz);
37+
}
3438

3539
}

common/src/main/java/com/robin/comm/util/xls/ExcelSheetProp.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.robin.comm.util.xls;
1717

18+
import com.robin.core.fileaccess.meta.DataCollectionMeta;
19+
import com.robin.core.fileaccess.meta.DataSetColumnMeta;
1820
import lombok.Data;
1921

2022
import java.util.*;
@@ -39,6 +41,8 @@ public class ExcelSheetProp {
3941
private String templateFile;
4042
private boolean useOffHeap=false;
4143
private String fontName;
44+
private int maxRows;
45+
private int maxSheetSize;
4246
private ExcelSheetProp(){
4347

4448
}
@@ -61,6 +65,15 @@ public void addColumnProp(ExcelColumnProp prop){
6165
public List<ExcelColumnProp> getColumnPropList() {
6266
return columnPropList;
6367
}
68+
69+
public static ExcelSheetProp fromDataCollectionMeta(DataCollectionMeta colmeta){
70+
ExcelSheetProp.Builder builder=ExcelSheetProp.Builder.newBuilder();
71+
for(DataSetColumnMeta setColumnMeta:colmeta.getColumnList()){
72+
builder.addColumnProp(setColumnMeta.getColumnName(), setColumnMeta.getColumnName(), setColumnMeta.getColumnType());
73+
}
74+
builder.setStartRow(2);
75+
return builder.build();
76+
}
6477
public static class Builder{
6578
private ExcelSheetProp prop=new ExcelSheetProp();
6679
private Builder(){
@@ -130,6 +143,14 @@ public Builder dumpUseTempFile(){
130143
prop.setUseOffHeap(false);
131144
return this;
132145
}
146+
public Builder maxRows(int maxRows){
147+
prop.setMaxRows(maxRows);
148+
return this;
149+
}
150+
public Builder maxSheetSize(int maxSheetSize){
151+
prop.setMaxSheetSize(maxSheetSize);
152+
return this;
153+
}
133154
public ExcelSheetProp build(){
134155
return prop;
135156
}

common/src/main/java/com/robin/core/fileaccess/util/ByteBufferInputStream.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public ByteBufferInputStream(ByteBuffer buffer,byte[] bytes){
2222
buffer.put(bytes);
2323
this.count=bytes.length;
2424
}
25+
public ByteBufferInputStream(ByteBuffer buffer,InputStream inputStream) throws IOException{
26+
this.byteBuffer=buffer;
27+
byteBuffer.position(0);
28+
byte[] readBytes=new byte[8192];
29+
int count;
30+
while ((count=inputStream.read(readBytes))>0){
31+
byteBuffer.put(readBytes,0,count);
32+
}
33+
this.count=byteBuffer.position();
34+
}
2535
@Override
2636
public int read() throws IOException {
2737
if (byteBuffer.position()>count || byteBuffer.remaining() == 0) {

common/src/main/java/com/robin/core/fileaccess/util/ByteBufferOutputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void writeLong(long value) throws IOException{
4444
}
4545
public void writeGap() throws IOException{
4646
write(0);
47+
count++;
4748
}
4849
public void writeNullTag() throws IOException{
4950
//overwrite 0x00 with 0xff

core/src/main/java/com/robin/core/base/dao/IjdbcDao.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,5 @@ public interface IjdbcDao {
240240
<T extends BaseObject,P extends Serializable> int deleteByLogic(Class<T> clazz,List<P> pkObjs,String statusColumn,String statusValue) throws DAOException;
241241
<T extends BaseObject> List<T> queryByVO(Class<T> type, BaseObject vo, String orderByStr);
242242
List<Map<String, Object>> queryByNamedParam(String executeSql, Map<String, List<Object>> parmaMap) throws DAOException;
243+
long executeSqlWithReturn(final String sql, Object[] object);
243244
}

core/src/main/java/com/robin/core/base/dao/JdbcDao.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,12 @@ public <T extends BaseObject,P extends Serializable> T getEntity(Class<T> clazz,
811811
throw wrapException(ex);
812812
}
813813
}
814+
public long executeSqlWithReturn(final String sql, Object[] object)
815+
throws DAOException {
816+
KeyHolder keyHolder = new GeneratedKeyHolder();
817+
getJdbcTemplate().update(new SimplePrepareStatement(sql, object, lobHandler), keyHolder);
818+
return keyHolder.getKey().longValue();
819+
}
814820

815821

816822
public void setSqlGen(BaseSqlGen sqlGen) {

core/src/main/java/com/robin/core/base/dao/util/SimplePrepareStatement.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.robin.core.base.dao.util;
22

3-
import com.robin.core.base.model.BaseObject;
43
import org.springframework.jdbc.core.PreparedStatementCreator;
54
import org.springframework.jdbc.support.lob.LobHandler;
5+
import org.springframework.util.ObjectUtils;
66

7-
import java.sql.Connection;
8-
import java.sql.PreparedStatement;
9-
import java.sql.SQLException;
10-
import java.sql.Statement;
7+
import java.io.ByteArrayInputStream;
8+
import java.sql.*;
119

1210

1311
public class SimplePrepareStatement implements PreparedStatementCreator {
@@ -24,7 +22,23 @@ public SimplePrepareStatement(String sql,Object[] objects,LobHandler lobHandler)
2422
public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {
2523
try(PreparedStatement ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
2624
for (int i = 0; i < objects.length; i++) {
27-
ps.setObject(i + 1, objects[i]);
25+
if(!ObjectUtils.isEmpty(objects[i])) {
26+
if (byte[].class.isAssignableFrom(objects[i].getClass())) {
27+
byte[] bytes = (byte[]) objects[i];
28+
lobHandler.getLobCreator().setBlobAsBinaryStream(ps, i + 1, new ByteArrayInputStream(bytes), bytes.length);
29+
}
30+
if (String.class.isAssignableFrom(objects[i].getClass())) {
31+
if(objects[i].toString().length()>512){
32+
lobHandler.getLobCreator().setClobAsString(ps,i+1,objects[i].toString());
33+
}else{
34+
ps.setString(i+1,objects[i].toString());
35+
}
36+
} else {
37+
ps.setObject(i + 1, objects[i]);
38+
}
39+
}else{
40+
ps.setNull(i+1, Types.VARCHAR);
41+
}
2842
}
2943
return ps;
3044
}

core/src/main/java/com/robin/core/base/util/FileUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import lombok.extern.slf4j.Slf4j;
88
import org.apache.commons.io.FileExistsException;
99
import org.springframework.util.Assert;
10-
import org.springframework.util.MimeTypeUtils;
1110
import org.springframework.util.ObjectUtils;
1211

1312
import java.io.File;
@@ -20,7 +19,6 @@
2019
import java.nio.file.attribute.PosixFilePermission;
2120
import java.nio.file.attribute.UserPrincipalLookupService;
2221
import java.util.*;
23-
import java.util.stream.Collectors;
2422

2523
@Slf4j
2624
public class FileUtils {
@@ -200,7 +198,7 @@ public static class FileContent{
200198
private Const.CompressType compressType= Const.CompressType.COMPRESS_TYPE_NONE;
201199
}
202200
public static void main(String[] args){
203-
String path="file:///e:/tmp/test/test1.avro.cs.lz4";
201+
String path="tmp/1234.xlsx";
204202
System.out.println(parseFile(path));
205203
}
206204
}

core/src/main/java/com/robin/core/base/util/LicenseUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class LicenseUtils {
3939
private static final LicenseUtils utils = new LicenseUtils();
4040
private static RunThread thread = null;
4141
private static LocalDateTime lastCheckTs;
42+
private static final Long startTs=System.currentTimeMillis();
4243

4344
private static final Logger logger= LoggerFactory.getLogger(CharUtils.class);
4445
private static LocalDateTime lastCredentianlTs=null;
@@ -48,8 +49,9 @@ public class LicenseUtils {
4849
private LicenseUtils() {
4950
if (thread == null) {
5051
thread = new RunThread();
52+
thread.setDaemon(true);
5153
thread.start();
52-
Runtime.getRuntime().addShutdownHook(new Thread(() ->thread.stopRun()));
54+
//Runtime.getRuntime().addShutdownHook(new Thread(() ->thread.stopRun()));
5355
}
5456
}
5557

@@ -101,6 +103,7 @@ private static PublicKey getPublicKey(String userPath) {
101103
File rsaPath = new File(userPath + File.separator + ".ssh" + File.separator + "id_rsa.pub");
102104
if (rsaPath.exists()) {
103105
publicKey = CipherUtil.readPublicKeyByPem(new FileInputStream(userPath + File.separator + ".ssh" + File.separator + "id_rsa.pub"));
106+
valid=true;
104107
}
105108
}
106109
} catch (Exception ex1) {
@@ -160,6 +163,10 @@ private static boolean validate(PublicKey publicKey,String machineId) {
160163
logger.error("license locked");
161164
System.exit(1);
162165
}
166+
if(CharUtils.getInstance().retKeyword(121).equals(CharUtils.getInstance().retKeyword(119)) && System.currentTimeMillis()-startTs>24*3600*1000L) {
167+
logger.error("server run more than one day,Stopped!");
168+
System.exit(1);
169+
}
163170
length=inputStream.readInt();
164171
byte[] signbytes=new byte[length];
165172
inputStream.read(signbytes);

core/src/main/java/com/robin/core/convert/util/ConvertUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static void mapToObject(Object target, Map<String, Object> src, String...
179179
}
180180

181181

182-
private static String wordCase(String value) {
182+
private static String camelCase(String value) {
183183
return value.substring(0, 1).toUpperCase() + value.substring(1);
184184
}
185185

0 commit comments

Comments
 (0)