[Trunk | Admin Tools Service]:

1. pom.xml: 
        a. Added timestamp in properties.
        b. In <build> added <resources> with filtering set to true.
2. GlobalVars.java: Added GlobalVars class for date of deploy & date of build.
3. UoaAdminToolsApplication.java: 
	a. Added  @PropertySource("classpath:authorization.properties") and @PropertySource("classpath:admintoolslibrary.properties").
	b. In @EnableConfigurationProperties added GlobalVars.class.
4. AdminToolsCheckDeployController.java: Added exposing date of deploy and date of build.
5. admintools.properties: Added property admintool.globalVars.buildDate=@timestamp@.
This commit is contained in:
Konstantina Galouni 2021-09-15 22:02:16 +00:00
parent 6f16710191
commit 7e5d71828e
6 changed files with 52 additions and 2 deletions

View File

@ -21,6 +21,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format>
</properties>
<dependencies>
@ -106,6 +108,12 @@
<!--</plugin>-->
</plugins>
<finalName>uoa-admin-tools</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

View File

@ -1,6 +1,7 @@
package eu.dnetlib.uoaadmintools;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.uoaadmintools.configuration.GlobalVars;
import eu.dnetlib.uoaadmintools.configuration.properties.ManagersApiConfig;
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
//import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
@ -18,10 +19,12 @@ import org.springframework.web.client.RestTemplate;
@SpringBootApplication(scanBasePackages = {"eu.dnetlib.uoaadmintools", "eu.dnetlib.uoaadmintoolslibrary"})
@PropertySources({
@PropertySource("classpath:authorization.properties"),
@PropertySource("classpath:admintoolslibrary.properties"),
@PropertySource("classpath:admintools.properties"),
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
})
@EnableConfigurationProperties({MongoConfig.class, ManagersApiConfig.class})
@EnableConfigurationProperties({MongoConfig.class, ManagersApiConfig.class, GlobalVars.class})
@Import(AuthorizationConfiguration.class)
public class UoaAdminToolsApplication {

View File

@ -0,0 +1,22 @@
package eu.dnetlib.uoaadmintools.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.Date;
@ConfigurationProperties("admintool.globalVars")
public class GlobalVars {
public static Date date = new Date();
private Date buildDate;
public String getBuildDate() {
if(buildDate == null) {
return null;
}
return buildDate.toString();
}
public void setBuildDate(Date buildDate) {
this.buildDate = buildDate;
}
}

View File

@ -3,6 +3,7 @@ package eu.dnetlib.uoaadmintools.controllers;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DBObject;
import eu.dnetlib.uoaadmintools.configuration.GlobalVars;
import eu.dnetlib.uoaadmintools.configuration.mongo.MongoConnection;
import eu.dnetlib.uoaadmintools.configuration.properties.ManagersApiConfig;
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -32,6 +34,9 @@ public class AdminToolsCheckDeployController {
@Autowired
private ManagersApiConfig managersApiConfig;
@Autowired
private GlobalVars globalVars;
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
public String hello() {
log.debug("Hello from uoa-admin-tools!");
@ -61,6 +66,14 @@ public class AdminToolsCheckDeployController {
response.put("admintool.managers.api.id", managersApiConfig.getId());
response.put("admintool.managers.api.email", managersApiConfig.getEmail());
if(globalVars.date != null) {
response.put("Date of deploy", globalVars.date.toString());
}
if(globalVars.getBuildDate() != null) {
response.put("Date of build", globalVars.getBuildDate());
}
return response;
}
}

View File

@ -14,6 +14,7 @@ admintool.mongodb.port=27017
admintool.mongodb.database=openaire_admin
admintool.managers.api.id = http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/community/{community}/managers/id
admintool.managers.api.email = http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/community/{community}/managers/email
admintool.globalVars.buildDate=@timestamp@
#beta
#admintool.security.userInfoUrl = https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=

View File

@ -1918,4 +1918,7 @@ addFooterDivIdForCommunities();
addFooterHelpTextForCommunities();
// 04-06-2021 debug helper function
// cleanPagesFromPortals();
// cleanPagesFromPortals();
// 07-06-2021 debug helper function
// cleanDivHelpTexts();