diff --git a/pom.xml b/pom.xml index 80dd7f6..009b32b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 kangaroo-and-rabbit archidata - 0.1.3 + 0.1.4 2.1 2.32 diff --git a/src/org/kar/archidata/SqlWrapper.java b/src/org/kar/archidata/SqlWrapper.java index d16ae6a..93c759e 100644 --- a/src/org/kar/archidata/SqlWrapper.java +++ b/src/org/kar/archidata/SqlWrapper.java @@ -552,10 +552,16 @@ public class SqlWrapper { return getWhere(clazz, key, "=", value); } + public static T getWhere(Class clazz, String key, String operator, Object value, boolean full ) throws Exception { + return getWhere(clazz, key, operator, value, null, null, null, full); + } public static T getWhere(Class clazz, String key, String operator, Object value ) throws Exception { - return getWhere(clazz, key, operator, value, null, null, null); + return getWhere(clazz, key, operator, value, null, null, null, false); } public static T getWhere(Class clazz, String key, String operator, Object value, String key2, String operator2, Object value2 ) throws Exception { + return getWhere(clazz, key, operator, value, key2, operator2, value2, false); + } + public static T getWhere(Class clazz, String key, String operator, Object value, String key2, String operator2, Object value2, boolean full ) throws Exception { DBEntry entry = new DBEntry(GlobalConfiguration.dbConfig); T out = null; // real add in the BDD: @@ -575,12 +581,12 @@ public class SqlWrapper { continue; } boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0; - if (createTime) { + if (!full && createTime) { continue; } String name = elem.getName(); boolean updateTime = elem.getDeclaredAnnotationsByType(SQLUpdateTime.class).length != 0; - if (updateTime) { + if (!full && updateTime) { continue; } count++; @@ -639,12 +645,12 @@ public class SqlWrapper { continue; } boolean createTime = elem.getDeclaredAnnotationsByType(SQLCreateTime.class).length != 0; - if (createTime) { + if (!full && createTime) { continue; } String name = elem.getName(); boolean updateTime = elem.getDeclaredAnnotationsByType(SQLUpdateTime.class).length != 0; - if (updateTime) { + if (!full && updateTime) { continue; } //this.name = rs.getString(iii++); @@ -785,7 +791,7 @@ public class SqlWrapper { return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")); } - public static List gets(Class clazz, boolean fool) throws Exception { + public static List gets(Class clazz, boolean full) throws Exception { System.out.println("request get " + clazz.getCanonicalName() + " start @" + getCurrentTimeStamp()); DBEntry entry = new DBEntry(GlobalConfiguration.dbConfig); List out = new ArrayList<>(); @@ -805,7 +811,7 @@ public class SqlWrapper { for (Field elem : clazz.getFields()) { boolean notRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0; - if (!fool && notRead) { + if (!full && notRead) { autoClasify[indexAutoClasify++] = StateLoad.DISABLE; continue; } @@ -899,7 +905,7 @@ public class SqlWrapper { boolean notRead = elem.getDeclaredAnnotationsByType(SQLNotRead.class).length != 0; */ boolean notRead = autoClasify[indexAutoClasify] == StateLoad.DISABLE; - if (!fool && notRead) { + if (!full && notRead) { indexAutoClasify++; continue; } diff --git a/src/org/kar/archidata/api/DataResource.java b/src/org/kar/archidata/api/DataResource.java index 519c487..b104a69 100644 --- a/src/org/kar/archidata/api/DataResource.java +++ b/src/org/kar/archidata/api/DataResource.java @@ -277,19 +277,18 @@ public class DataResource { build(); } String filePathName = ConfigBaseVariable.getMediaDataFolder() + File.separator + id + File.separator + "data"; + File inputFile = new File(filePathName); + if (!inputFile.exists()) { + return Response.status(404). + entity("{\"error\":\"media Does not exist: " + id + "\"}"). + type("application/json"). + build(); + } if ( value.mimeType.contentEquals("image/jpeg") || value.mimeType.contentEquals("image/png") // || value.mimeType.contentEquals("image/webp") ) { // reads input image - //System.out.println("Read path: " + filePathName); - File inputFile = new File(filePathName); - if (!inputFile.exists()) { - return Response.status(500). - entity("Internal Error: Media is NOT FOUNDABLE: " + id). - type("text/plain"). - build(); - } BufferedImage inputImage = ImageIO.read(inputFile); int scaledWidth = 250; int scaledHeight = (int)((float)inputImage.getHeight() / (float)inputImage.getWidth() * (float) scaledWidth); @@ -305,7 +304,7 @@ public class DataResource { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // TODO: check how to remove buffer file !!! here, it is not needed at all... - ImageIO.write( outputImage, "JPG", baos); + ImageIO.write( outputImage, "JPG", baos); } catch (IOException e) { e.printStackTrace(); return Response.status(500). diff --git a/src/org/kar/archidata/model/State.java b/src/org/kar/archidata/model/State.java deleted file mode 100644 index bd3195e..0000000 --- a/src/org/kar/archidata/model/State.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.kar.archidata.model; - -public enum State { - // User has remove his account - REMOVED, - // User has been blocked his account - BLOCKED, - // generic user - USER, - // Administrator - ADMIN -} diff --git a/src/org/kar/archidata/model/UserExtern.java b/src/org/kar/archidata/model/UserExtern.java deleted file mode 100644 index 2a1b61c..0000000 --- a/src/org/kar/archidata/model/UserExtern.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.kar.archidata.model; - -/* -CREATE TABLE `user` ( - `id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY, - `login` varchar(128) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'login of the user', - `email` varchar(512) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'email of the user', - `lastConnection` datetime NOT NULL COMMENT 'last connection time', - `admin` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE', - `blocked` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE', - `removed` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE' -) AUTO_INCREMENT=10; - - */ - - -public class UserExtern { - public Long id; - public String login; - public boolean admin; - - public UserExtern(User other) { - this.id = other.id; - this.login = other.login; - this.admin = other.admin; - } - - @Override - public String toString() { - return "User{" + - "id=" + id + - ", login='" + login + '\'' + - ", admin=" + admin + - '}'; - } -} diff --git a/src/org/kar/archidata/model/UserPerso.java b/src/org/kar/archidata/model/UserPerso.java deleted file mode 100644 index 8c1be5b..0000000 --- a/src/org/kar/archidata/model/UserPerso.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.kar.archidata.model; - -/* -CREATE TABLE `user` ( - `id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY, - `login` varchar(128) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'login of the user', - `email` varchar(512) COLLATE 'utf8_general_ci' NOT NULL COMMENT 'email of the user', - `lastConnection` datetime NOT NULL COMMENT 'last connection time', - `admin` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE', - `blocked` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE', - `removed` enum("TRUE", "FALSE") NOT NULL DEFAULT 'FALSE' -) AUTO_INCREMENT=10; - - */ - - -public class UserPerso { - public Long id; - public String login; - public boolean admin; - public boolean blocked; - public boolean removed; - - public UserPerso(User other) { - this.id = other.id; - this.login = other.login; - this.admin = other.admin; - this.blocked = other.blocked; - this.removed = other.removed; - } - - @Override - public String toString() { - return "User{" + - "id=" + id + - ", login='" + login + '\'' + - ", admin=" + admin + - ", blocked=" + blocked + - ", removed=" + removed + - '}'; - } -} diff --git a/src/org/kar/archidata/util/ConfigBaseVariable.java b/src/org/kar/archidata/util/ConfigBaseVariable.java index 8891597..6501e17 100644 --- a/src/org/kar/archidata/util/ConfigBaseVariable.java +++ b/src/org/kar/archidata/util/ConfigBaseVariable.java @@ -70,7 +70,7 @@ public class ConfigBaseVariable { public static String getSSOAddress() { if (ssoAdress == null) { //return "http://sso_host/api/"; - return "http://192.168.1.156/karauth/api/"; + return "http://192.168.1.156/karso/api/"; } return ssoAdress; }