Skip to content

Commit 8645b40

Browse files
committed
remove useless property for logs
(cherry picked from commit edafe04)
1 parent 3d86411 commit 8645b40

4 files changed

Lines changed: 9 additions & 23 deletions

File tree

knowage-api/src/main/java/it/eng/knowage/logmanager/resource/LogsResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.util.List;
3131

3232
@Path("/2.0/resources/logs")
33-
@Component
33+
@Component("logsResourceLogManager")
3434
@Validated
3535

3636
/*

knowage-api/src/main/java/it/eng/knowage/logmanager/service/impl/LogManagerAPIImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package it.eng.knowage.logmanager.service.impl;
22

33
import it.eng.knowage.boot.error.KnowageRuntimeException;
4-
import it.eng.knowage.boot.utils.ContextPropertiesConfig;
54
import it.eng.knowage.boot.utils.HMACUtilities;
65
import it.eng.knowage.knowageapi.error.*;
76
import it.eng.knowage.logmanager.resource.dto.LogFileDTO;
@@ -75,12 +74,13 @@ public LogFolderDTO getFolders(SpagoBIUserProfile profile) throws ImpossibleToRe
7574
* - Creates directories when missing.
7675
*/
7776
public Path getWorkDirectory(SpagoBIUserProfile profile) throws IOException {
78-
String logPathBase = ContextPropertiesConfig.getLogPath();
77+
String catalinaBase = System.getProperty("catalina.base");
78+
String logPathBase = catalinaBase + File.separator + "logs";
7979
Path totalPath = Paths.get(logPathBase);
80-
if (!Files.isDirectory(totalPath)) {
81-
LOGGER.info("The log folder is missing at [" + totalPath + "]. It will be created now.");
80+
if (!Files.exists(totalPath)) {
8281
Files.createDirectories(totalPath);
8382
}
83+
8484
return totalPath;
8585
}
8686

@@ -151,7 +151,9 @@ private boolean canSee(Path path, SpagoBIUserProfile profile) throws IOException
151151

152152
if (hasAdminFunctionality(profile)){
153153
String tenant = resolveTenant(profile);
154-
Path baseLogPath = Paths.get(ContextPropertiesConfig.getLogPath()).normalize();
154+
Path workDir = getWorkDirectory(profile).normalize();
155+
//now that I have the work dir I can build the base log path
156+
Path baseLogPath = workDir.normalize();
155157
Path logsRoot = baseLogPath.resolve("logs").normalize();
156158
Path target = path.normalize();
157159

knowage-api/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ application.environment=${application.environment}
44

55
jndi.lookup.hmackey=java:comp/env/hmacKey
66
jndi.lookup.resourcepath=java:comp/env/resource_path
7-
jndi.lookup.logpath=java:comp/env/logs_path
87

98
logging.level.org.springframework.web=ERROR
109
logging.level.org.hibernate=ERROR

knowage-spring-boot-api-common/src/main/java/it/eng/knowage/boot/utils/ContextPropertiesConfig.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ public class ContextPropertiesConfig {
4747
private static String logPathKey;
4848

4949
@Autowired
50-
public ContextPropertiesConfig(@Value("${jndi.lookup.hmackey}") String hmacKey, @Value("${jndi.lookup.resourcepath}") String resourcePathKey, @Value("${jndi.lookup.logpath}") String logPathKey) {
50+
public ContextPropertiesConfig(@Value("${jndi.lookup.hmackey}") String hmacKey, @Value("${jndi.lookup.resourcepath}") String resourcePathKey) {
5151
// TODO : values for static attributes shouldn't not be injected in a non-static way
5252
this.hmacKey = hmacKey;
5353
this.resourcePathKey = resourcePathKey;
54-
this.logPathKey = logPathKey;
5554
}
5655

5756
public static String jwtToken2userId(String jwtToken) throws JWTVerificationException {
@@ -83,18 +82,4 @@ public static String getResourcePath() {
8382
}
8483
return resourcePath;
8584
}
86-
87-
public static String getLogPath() {
88-
String logPath = null;
89-
Context ctx;
90-
try {
91-
ctx = new InitialContext();
92-
logPath = (String) ctx.lookup(logPathKey);
93-
94-
} catch (Exception e) {
95-
throw new KnowageRuntimeException(e.getMessage(), e);
96-
}
97-
return logPath;
98-
}
99-
10085
}

0 commit comments

Comments
 (0)