master #2
130
pom.xml
130
pom.xml
|
@ -2,27 +2,21 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-admin-tools</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>uoa-admin-tools</name>
|
||||
<scm>
|
||||
<connection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-admin-tools.git</connection>
|
||||
<developerConnection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-admin-tools.git</developerConnection>
|
||||
<url>https://code-repo.d4science.org/MaDgIK/uoa-admin-tools/</url>
|
||||
</scm>
|
||||
<!-- Use parent with artifact spring-boot-starter-parent and add plugin with artifact spring-boot-maven-plugin in order to run springboot run command-->
|
||||
<scm>
|
||||
<developerConnection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-admin-tools.git</developerConnection>
|
||||
</scm>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.8.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-spring-boot-parent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<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>
|
||||
|
@ -31,77 +25,51 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId> org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.5.0-b01</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>20030203.000550</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>commons-io</groupId>-->
|
||||
<!-- <artifactId>commons-io</artifactId>-->
|
||||
<!-- <version>20030203.000550</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-admin-tools-library</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<!--swagger-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger-version}</version>
|
||||
</dependency>
|
||||
<!--swagger official ui-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Use parent with artifact spring-boot-starter-parent and add plugin with artifact spring-boot-maven-plugin in order to run springboot run command-->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!--3d answer: https://stackoverflow.com/questions/23260057/the-forked-vm-terminated-without-saying-properly-goodbye-vm-crash-or-system-exi-->
|
||||
<!--If you use openjdk there might be a problem with surfire plugin - uncomment following lines-->
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!--<artifactId>maven-surefire-plugin</artifactId>-->
|
||||
<!--<version>2.19.1</version>-->
|
||||
<!--<configuration>-->
|
||||
<!--<!–<testFailureIgnore>true</testFailureIgnore>–>-->
|
||||
<!--<useSystemClassLoader>false</useSystemClassLoader>-->
|
||||
<!--</configuration>-->
|
||||
<!--</plugin>-->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>eu.dnetlib.uoaadmintools.UoaAdminToolsApplication</mainClass>
|
||||
<executable>true</executable>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
|
@ -112,27 +80,5 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
<finalName>uoa-admin-tools</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dnet45-releases</id>
|
||||
<name>D-Net 45 Releases</name>
|
||||
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-releases</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.uoaadmintools;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.uoaadmintools.configuration.GlobalVars;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.APIProperties;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.BrowserCacheConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.ManagersApiConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
|
||||
|
@ -24,7 +25,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
@PropertySource("classpath:admintools.properties"),
|
||||
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
|
||||
})
|
||||
@EnableConfigurationProperties({MongoConfig.class, ManagersApiConfig.class, BrowserCacheConfig.class, GlobalVars.class})
|
||||
@EnableConfigurationProperties({MongoConfig.class, ManagersApiConfig.class, BrowserCacheConfig.class, GlobalVars.class, APIProperties.class})
|
||||
@Import({AuthorizationConfiguration.class, UoaAdminToolsLibraryConfiguration.class})
|
||||
public class UoaAdminToolsApplication {
|
||||
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package eu.dnetlib.uoaadmintools.configuration;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.APIProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Parameter;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger configuration class
|
||||
*/
|
||||
@Configuration
|
||||
@Profile({"swagger"})
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
private final APIProperties apiProperties;
|
||||
|
||||
@Autowired
|
||||
public SwaggerConfig(APIProperties apiProperties) {
|
||||
this.apiProperties = apiProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .globalOperationParameters(globalParameterList())
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoaadmintools.controllers"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket createRestApiLibrary() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .globalOperationParameters(globalParameterList())
|
||||
.apiInfo(apiInfo())
|
||||
.groupName("Library")
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoaadmintoolslibrary.controllers"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket createRestApiAuthorizationLibrary() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.groupName("Authorization Library")
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoaauthorizationlibrary.controllers"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title(this.apiProperties.getTitle())
|
||||
.description(this.apiProperties.getDescription())
|
||||
.version(this.apiProperties.getVersion())
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<Parameter> globalParameterList() {
|
||||
Parameter authTokenHeader = new ParameterBuilder()
|
||||
.name("Session") // name of the header
|
||||
.modelRef(new ModelRef("string")) // data-type of the header
|
||||
.required(false)
|
||||
.parameterType("header")
|
||||
.description("Session ID")
|
||||
.build();
|
||||
return Collections.singletonList(authTokenHeader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addRedirectViewController("/v2/api-docs", "/v2/api-docs");
|
||||
registry.addRedirectViewController("/swagger-resources/configuration/ui", "/swagger-resources/configuration/ui");
|
||||
registry.addRedirectViewController("/swagger-resources/configuration/security", "/swagger-resources/configuration/security");
|
||||
registry.addRedirectViewController("/swagger-resources", "/swagger-resources");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package eu.dnetlib.uoaadmintools.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("api")
|
||||
public class APIProperties {
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String version;
|
||||
|
||||
public APIProperties() {
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
|
@ -5,9 +5,11 @@ 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.BrowserCacheConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.ManagersApiConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -23,7 +25,7 @@ import java.util.Map;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class AdminToolsCheckDeployController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private MongoConnection mongoConnection;
|
||||
|
@ -34,6 +36,9 @@ public class AdminToolsCheckDeployController {
|
|||
@Autowired
|
||||
private ManagersApiConfig managersApiConfig;
|
||||
|
||||
@Autowired
|
||||
private BrowserCacheConfig browserCacheConfig;
|
||||
|
||||
@Autowired
|
||||
private GlobalVars globalVars;
|
||||
|
||||
|
@ -67,6 +72,8 @@ public class AdminToolsCheckDeployController {
|
|||
response.put("admintool.managers.api.id", managersApiConfig.getId());
|
||||
response.put("admintool.managers.api.email", managersApiConfig.getEmail());
|
||||
|
||||
response.put("admintool.cache.url", browserCacheConfig.getUrl());
|
||||
|
||||
if(globalVars.date != null) {
|
||||
response.put("Date of deploy", globalVars.date.toString());
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.BrowserCacheConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.ResourceAccessException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cache")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class BrowserCacheController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
|
|
@ -8,7 +8,8 @@ import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -19,7 +20,7 @@ import java.util.List;
|
|||
@RequestMapping("/community")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CommunityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private RolesUtils rolesUtils;
|
||||
|
|
|
@ -7,7 +7,8 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -18,7 +19,7 @@ import java.util.List;
|
|||
@RequestMapping("/connect")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ConnectController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private LayoutService layoutService;
|
||||
|
|
|
@ -5,7 +5,8 @@ import eu.dnetlib.uoaadmintools.entities.curator.CuratorResponse;
|
|||
import eu.dnetlib.uoaadmintools.services.CuratorService;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CuratorController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CuratorService curatorService;
|
||||
|
|
|
@ -12,7 +12,8 @@ import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.recaptcha.VerifyRecaptcha;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -21,7 +22,7 @@ import java.util.*;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class EmailController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private EmailSender emailSender;
|
||||
|
|
|
@ -5,7 +5,8 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -17,7 +18,7 @@ import java.util.List;
|
|||
@CrossOrigin(origins = "*")
|
||||
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||
public class ExploreController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.Menu;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuFull;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuItem;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuItemFull;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.*;
|
||||
import eu.dnetlib.uoaadmintools.services.MenuService;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -20,7 +18,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class MenuController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
@ -208,4 +206,13 @@ public class MenuController {
|
|||
public Menu toggleMenu(@PathVariable(value = "pid") String pid, @RequestParam String status, @RequestParam(value="featured", required=false) String isFeatured) throws Exception {
|
||||
return menuService.toggleMenu(pid, status, isFeatured);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyAuthority(" +
|
||||
"@AuthorizationService.PORTAL_ADMIN, " +
|
||||
"@AuthorizationService.curator('community')," +
|
||||
"@AuthorizationService.manager('community', #pid))")
|
||||
@RequestMapping(value = {"/community/{pid}/menu/align"}, method = RequestMethod.POST)
|
||||
public Menu alignMenu(@PathVariable(value = "pid") String pid, @RequestParam String alignment) throws Exception {
|
||||
return menuService.alignMenu(pid, alignment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -20,7 +21,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class NotificationsController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
|
|
|
@ -5,7 +5,8 @@ import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
|||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.responses.SingleValueWrapperResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
@ -26,7 +27,7 @@ public class PortalSubscribersController {
|
|||
// @Autowired
|
||||
// private SecurityConfig securityConfig;
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscribers/count", method = RequestMethod.GET)
|
||||
public SingleValueWrapperResponse<Integer> getNumberOfSubscribersPerPortal(@PathVariable(value="pid", required = true) String pid) throws ContentNotFoundException {
|
||||
|
|
|
@ -3,7 +3,8 @@ package eu.dnetlib.uoaadmintools.controllers;
|
|||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class SubscriberController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private SubscriberDAO subscriberDAO;
|
||||
@RequestMapping(value = "/subscriber", method = RequestMethod.GET)
|
||||
|
|
|
@ -16,6 +16,7 @@ public class Curator {
|
|||
private List<Affiliation> affiliations;
|
||||
private String photo;
|
||||
private String bio;
|
||||
private boolean visible = true;
|
||||
|
||||
public Curator() {}
|
||||
|
||||
|
@ -66,4 +67,12 @@ public class Curator {
|
|||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class CuratorResponse {
|
|||
private List<Affiliation> affiliations;
|
||||
private String photo;
|
||||
private String bio;
|
||||
private boolean visible = true;
|
||||
|
||||
public CuratorResponse() {
|
||||
}
|
||||
|
@ -52,4 +53,12 @@ public class CuratorResponse {
|
|||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public class Menu {
|
|||
public boolean isMenuEnabled;
|
||||
public List<String> featuredMenuItems;
|
||||
public List<String> menuItems;
|
||||
public MenuAlignment featuredAlignment = MenuAlignment.CENTER;
|
||||
|
||||
public Menu(String portalPid) {
|
||||
this.setPortalPid(portalPid);
|
||||
|
@ -21,6 +22,7 @@ public class Menu {
|
|||
this.setFeaturedMenuEnabled(true);
|
||||
this.setMenuItems(new ArrayList<>());
|
||||
this.setFeaturedMenuItems(new ArrayList<>());
|
||||
this.setFeaturedAlignment(MenuAlignment.CENTER.name());
|
||||
}
|
||||
|
||||
public String getPortalPid() {
|
||||
|
@ -62,4 +64,20 @@ public class Menu {
|
|||
public void setMenuItems(List<String> menuItems) {
|
||||
this.menuItems = menuItems;
|
||||
}
|
||||
|
||||
public String getFeaturedAlignment() {
|
||||
if(featuredAlignment == null) {
|
||||
return null;
|
||||
}
|
||||
return featuredAlignment.name();
|
||||
}
|
||||
|
||||
public void setFeaturedAlignment(String featuredAlignment) {
|
||||
if(featuredAlignment == null) {
|
||||
this.featuredAlignment = null;
|
||||
} else {
|
||||
MenuAlignment alignment = MenuAlignment.valueOf(featuredAlignment);
|
||||
this.featuredAlignment = alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package eu.dnetlib.uoaadmintools.entities.menu;
|
||||
|
||||
public enum MenuAlignment {
|
||||
LEFT, CENTER, RIGHT
|
||||
}
|
|
@ -8,6 +8,7 @@ public class MenuFull {
|
|||
public boolean isMenuEnabled;
|
||||
public List<MenuItemFull> featuredMenuItems;
|
||||
public List<MenuItemFull> menuItems;
|
||||
public MenuAlignment featuredAlignment = MenuAlignment.CENTER;
|
||||
|
||||
public String getPortalPid() {
|
||||
return portalPid;
|
||||
|
@ -48,4 +49,20 @@ public class MenuFull {
|
|||
public void setMenuItems(List<MenuItemFull> menuItems) {
|
||||
this.menuItems = menuItems;
|
||||
}
|
||||
|
||||
public String getFeaturedAlignment() {
|
||||
if(featuredAlignment == null) {
|
||||
return null;
|
||||
}
|
||||
return featuredAlignment.name();
|
||||
}
|
||||
|
||||
public void setFeaturedAlignment(String featuredAlignment) {
|
||||
if(featuredAlignment == null) {
|
||||
this.featuredAlignment = null;
|
||||
} else {
|
||||
MenuAlignment alignment = MenuAlignment.valueOf(featuredAlignment);
|
||||
this.featuredAlignment = alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import eu.dnetlib.uoaadmintools.dao.CuratorDAO;
|
|||
import eu.dnetlib.uoaadmintools.entities.Manager;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.CuratorResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
@Service
|
||||
public class CuratorService {
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CuratorDAO curatorDAO;
|
||||
|
@ -28,7 +29,7 @@ public class CuratorService {
|
|||
List<CuratorResponse> curators = new ArrayList<>();
|
||||
for (Manager manager : managerService.getManagers(pid, ManagerService.Type.ID)) {
|
||||
Curator curator = curatorDAO.findById(parseId(manager.getId()));
|
||||
if (curator != null) {
|
||||
if (curator != null && curator.isVisible()) {
|
||||
curators.add(new CuratorResponse(curator));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,16 @@ package eu.dnetlib.uoaadmintools.services;
|
|||
import eu.dnetlib.uoaadmintools.dao.LayoutDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LayoutService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private LayoutDAO layoutDAO;
|
||||
|
|
|
@ -2,13 +2,11 @@ package eu.dnetlib.uoaadmintools.services;
|
|||
|
||||
import eu.dnetlib.uoaadmintools.dao.MenuDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.MenuItemDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.Menu;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuFull;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuItem;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.MenuItemFull;
|
||||
import eu.dnetlib.uoaadmintools.entities.menu.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.MismatchingContentException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -17,7 +15,7 @@ import java.util.List;
|
|||
|
||||
@Service
|
||||
public class MenuService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private MenuDAO menuDAO;
|
||||
|
@ -85,6 +83,7 @@ public class MenuService {
|
|||
if(menu == null) {
|
||||
menuFull.setFeaturedMenuEnabled(true);
|
||||
menuFull.setMenuEnabled(true);
|
||||
menuFull.setFeaturedAlignment(MenuAlignment.CENTER.name());
|
||||
} else {
|
||||
for (String menuItemId : menu.getFeaturedMenuItems()) {
|
||||
featuredMenuItems.add(getFullRootMenuItemById(menuItemId, portalPid, true));
|
||||
|
@ -96,6 +95,7 @@ public class MenuService {
|
|||
|
||||
menuFull.setFeaturedMenuEnabled(menu.getIsFeaturedMenuEnabled());
|
||||
menuFull.setMenuEnabled(menu.getIsMenuEnabled());
|
||||
menuFull.setFeaturedAlignment(menu.getFeaturedAlignment());
|
||||
}
|
||||
|
||||
menuFull.setPortalPid(portalPid);
|
||||
|
@ -365,4 +365,11 @@ public class MenuService {
|
|||
}
|
||||
return menuDAO.save(menu);
|
||||
}
|
||||
|
||||
public Menu alignMenu(String pid, String alignment) {
|
||||
Menu menu = menuDAO.findByPortalPid(pid);
|
||||
menu.setFeaturedAlignment(alignment);
|
||||
|
||||
return menuDAO.save(menu);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ package eu.dnetlib.uoaadmintools.services;
|
|||
|
||||
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -10,7 +11,7 @@ import java.util.List;
|
|||
|
||||
@Service
|
||||
public class NotificationsService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
|
|
|
@ -2,13 +2,14 @@ package eu.dnetlib.uoaadmintools.services;
|
|||
|
||||
import eu.dnetlib.uoaadmintools.dao.StatisticsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class StatisticsService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private StatisticsDAO statisticsDAO;
|
||||
|
|
|
@ -2,13 +2,14 @@ package eu.dnetlib.uoaadmintools.services;
|
|||
|
||||
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SubscriberService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PortalSubscribersDAO portalSubscribersDAO;
|
||||
|
|
|
@ -50,3 +50,8 @@ admintool.cache.url = https://beta.{community}.openaire.eu/purge/
|
|||
#admintool.mongodb.database=openaireconnect
|
||||
#admintool.mongodb.username=dnet8480
|
||||
#admintool.mongodb.password=
|
||||
|
||||
#static properties
|
||||
api.title = Uoa Admin Tools Documentation Swagger
|
||||
api.description = Uoa Admin Tools is a service which is saving and serving helptexts and dynamic content
|
||||
api.version = ${project.version}
|
|
@ -1,20 +0,0 @@
|
|||
log4j.rootLogger = DEBUG, R
|
||||
|
||||
log4j.logger.eu.dnetlib = DEBUG
|
||||
log4j.logger.org.springframework = DEBUG, S
|
||||
|
||||
log4j.additivity.org.springframework = false
|
||||
|
||||
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.R.File=/var/log/dnet/uoa-admin-tools/uoa-admin-tools.log
|
||||
log4j.appender.R.MaxFileSize=10MB
|
||||
log4j.appender.R.MaxBackupIndex=10
|
||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
||||
|
||||
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.S.File=/var/log/dnet/uoa-admin-tools/uoa-admin-tools-spring.log
|
||||
log4j.appender.S.MaxFileSize=10MB
|
||||
log4j.appender.S.MaxBackupIndex=10
|
||||
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN" monitorInterval="30">
|
||||
<Properties>
|
||||
<Property name="LOG_PATTERN">
|
||||
%d %p %t [%c] - %m%n
|
||||
</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<!-- Rolling File Appender -->
|
||||
<RollingFile name="R" fileName="/var/log/dnet/uoa-admin-tools/uoa-admin-tools.log"
|
||||
filePattern="/var/log/dnet/uoa-admin-tools/uoa-admin-tools-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout>
|
||||
<Pattern>${LOG_PATTERN}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="10MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="10"/>
|
||||
</RollingFile>
|
||||
<RollingFile name="S" fileName="/var/log/dnet/uoa-admin-tools/uoa-admin-tools-spring.log"
|
||||
filePattern="/var/log/dnet/uoa-admin-tools/uoa-admin-tools-spring-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout>
|
||||
<Pattern>${LOG_PATTERN}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="10MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="10"/>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="eu.dnetlib" level="debug" additivity="false">
|
||||
<AppenderRef ref="R"/>
|
||||
</Logger>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="S"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
Reference in New Issue