[Trunk | Admin tools library Service]: Initial commit of project - Common files & methods copied from admin tools service.
1. Entities: common entities are Community, Entity, Page, DivId, PageHelpContent, DivHelpContent (+ fullEntities), email: Email, EmailRecaptcha, GoogleResponse. 2. DAOs: DAOs for common entities are CommunityDAO, EntityDAO, PageDAO, DivIdDAO, PageHelpContentDAO, DivHelpContentDAO (+MongoDBDAOs). 3. Controllers: controllers for common entities are CommunityController, EntityController, PageController, DivIdController, PageHelpContentController, DivHelpContentController (comment references to community specific entities e.g. Statistics, Subscribers, Layout). 4. Configuration: common configuration files are GoogleConfig, MailConfig. 5. For email: emailSender/EmailSender.java & handlers/InvalidReCaptchaException.java & recaptcha/VerifyRecaptcha.java. 6. Resources: log4j.properties.
This commit is contained in:
parent
d9b327a845
commit
caaa5921ca
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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-library</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>uoa-admin-tools-library</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.8.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<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>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>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- <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>-->
|
||||
</plugins>
|
||||
<finalName>uoa-admin-tools-library</finalName>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,10 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.GoogleConfig;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.MailConfig;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties({MailConfig.class, GoogleConfig.class})
|
||||
public class UoaAdminToolsLibraryApplication {}
|
|
@ -0,0 +1,14 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
public class UoaAdminToolsLibraryConfiguration extends WebMvcConfigurerAdapter {
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("admintoolslibrary.google")
|
||||
public class GoogleConfig {
|
||||
|
||||
private String secret;
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("admintoolslibrary.mail")
|
||||
public class MailConfig {
|
||||
private String host;
|
||||
private String port;
|
||||
private String auth;
|
||||
private String from;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,502 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.EntityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CommunityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentController pageHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
@RequestMapping(value = "/community", method = RequestMethod.GET)
|
||||
public List<Community> getAllCommunities() {
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
|
||||
return communities;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/communityFull", method = RequestMethod.GET)
|
||||
public List<CommunityResponse> getAllCommunitiesFull() {
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
List<CommunityResponse> communitiesResponse = new ArrayList<>();
|
||||
for(Community community : communities) {
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
log.debug("PAGES number="+pages.size());
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
log.debug("PAGES set");
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
log.debug("ENTITIES number="+entities.size());
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
// Layout layout = layoutDAO.findById(community.getLayout());
|
||||
// communityResponse.setLayout(layout);
|
||||
communitiesResponse.add(communityResponse);
|
||||
}
|
||||
return communitiesResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/communityFull/{pid}", method = RequestMethod.GET)
|
||||
public CommunityResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
// Layout layout = layoutDAO.findById(community.getLayout());
|
||||
// communityResponse.setLayout(layout);
|
||||
// communityResponse.setPages(this.getPagesForCommunityByType(community.getId(), null));
|
||||
// communityResponse.setEntities(this.getEntitiesForCommunity(community.getId()));
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/update", method = RequestMethod.POST)
|
||||
public CommunityResponse updateCommunity(@RequestBody Community community) {
|
||||
Community com = communityDAO.findById(community.getId());
|
||||
|
||||
// Statistics statistics = statisticsDAO.findByPid(com.getPid());
|
||||
// statistics.setPid(community.getPid());
|
||||
// statisticsDAO.save(statistics);
|
||||
//
|
||||
// CommunitySubscribers communitySubscribers = communitySubscribersDAO.findByPid(com.getPid());
|
||||
// communitySubscribers.setPid(community.getPid());
|
||||
// communitySubscribersDAO.save(communitySubscribers);
|
||||
|
||||
com.setName(community.getName());
|
||||
com.setPid(community.getPid());
|
||||
// = this.getCommunityByCommunityResponse(communityResponse);
|
||||
communityDAO.save(com);
|
||||
CommunityResponse communityResponse = this.getCommunityFull(community.getPid());
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/save", method = RequestMethod.POST)
|
||||
public CommunityResponse insertCommunity(@RequestBody Community community) {
|
||||
//Community community = this.getCommunityByCommunityResponse(communityResponse);
|
||||
|
||||
List<CommunityEntity> communityEntities = new ArrayList<>();
|
||||
List<CommunityPage> communityPages = new ArrayList<>();
|
||||
Map<String, Boolean> entities = new HashMap<>();
|
||||
Map<String, Boolean> pages = new HashMap<>();
|
||||
|
||||
for(Entity entity : entityDAO.findAll()) {
|
||||
entities.put(entity.getId(), true);
|
||||
|
||||
CommunityEntity communityEntity = new CommunityEntity(entity);
|
||||
communityEntity.setIsEnabled(true);
|
||||
communityEntities.add(communityEntity);
|
||||
}
|
||||
|
||||
for(Page page : pageDAO.findAll()) {
|
||||
pages.put(page.getId(), true);
|
||||
|
||||
CommunityPage communityPage = new CommunityPage(page);
|
||||
if(page.getRoute().equals("/curators") || page.getRoute().equals("/organizations")) {
|
||||
communityPage.setIsEnabled(false);
|
||||
} else {
|
||||
communityPage.setIsEnabled(true);
|
||||
}
|
||||
|
||||
communityPages.add(communityPage);
|
||||
}
|
||||
|
||||
community.setEntities(entities);
|
||||
community.setPages(pages);
|
||||
// Statistics statistics = new Statistics(community.getPid());
|
||||
// statisticsDAO.save(statistics);
|
||||
// CommunitySubscribers communitySubscribers = new CommunitySubscribers(community.getPid());
|
||||
// communitySubscribersDAO.save(communitySubscribers);
|
||||
Community savedCommunity = communityDAO.save(community);
|
||||
CommunityResponse communityResponse = this.getCommunityFull(savedCommunity.getPid());
|
||||
|
||||
log.debug("pid of saved community: "+savedCommunity.getPid());
|
||||
|
||||
String id = savedCommunity.getId();
|
||||
|
||||
divHelpContentController.addDivHelpContentsInCommunity(savedCommunity.getPid(), id, null);
|
||||
pageHelpContentController.addPageHelpContentsInCommunity(savedCommunity.getPid(), id);
|
||||
/*
|
||||
Page page = null;
|
||||
page = pageDAO.findByRoute("/about" );
|
||||
if(page != null) {
|
||||
String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> About the community </div> <p> This is an introductory text. To be updated... </p> </div>";
|
||||
HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
|
||||
htmlPageContentController.updateHtmlPageContent(htmlPageContent);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
page = pageDAO.findByRoute("/organizations");
|
||||
if(page != null) {
|
||||
String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> Organizations related to the community </div> <p> This is an introductory text. Here follows the list of organizations... </p> <div class=\"uk-child-width-1-3@m uk-text-center uk-grid-match \" uk-grid > <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://upload.wikimedia.org/wikipedia/el/2/2b/Logo_uoa_blue.png\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.uoa.gr/\">University of Athens</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://pbs.twimg.com/profile_images/631127495933165569/ElbqhHK0_400x400.jpg\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.athena-innovation.gr/en\">Athena Research & Innovation center</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 1\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 1</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 2\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 2</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 3\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 3</a> </h3> </div> </div> </div></div>";
|
||||
HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
|
||||
htmlPageContentController.updateHtmlPageContent(htmlPageContent);
|
||||
}
|
||||
*/
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
|
||||
private Community getCommunityByCommunityResponse(CommunityResponse communityResponse) {
|
||||
Community community = new Community();
|
||||
community.setId(communityResponse.getId());
|
||||
community.setName(communityResponse.getName());
|
||||
|
||||
List<CommunityEntity> fullEntities = communityResponse.getEntities();
|
||||
Map<String, Boolean> entities = new HashMap<String, Boolean>();
|
||||
for(CommunityEntity entity : fullEntities) {
|
||||
entities.put(entity.getId(), true);
|
||||
}
|
||||
for(Entity entity : entityDAO.findAll()) {
|
||||
if(!entities.containsKey(entity.getId())) {
|
||||
entities.put(entity.getId(), false);
|
||||
}
|
||||
}
|
||||
community.setEntities(entities);
|
||||
|
||||
List<CommunityPage> fullPages = communityResponse.getPages();
|
||||
Map<String, Boolean> pages = new HashMap<String, Boolean>();
|
||||
for(CommunityPage page : fullPages) {
|
||||
pages.put(page.getId(), true);
|
||||
}
|
||||
for(Page page : pageDAO.findAll()) {
|
||||
if(!pages.containsKey(page.getId())) {
|
||||
pages.put(page.getId(), false);
|
||||
}
|
||||
}
|
||||
community.setPages(pages);
|
||||
// Layout layout = communityResponse.getLayout();
|
||||
// community.setLayout(layout.getId());
|
||||
|
||||
return community;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteCommunities(@RequestBody List<String> communities) throws Exception {
|
||||
for (String id: communities) {
|
||||
Community community = communityDAO.findById(id);
|
||||
String pid = community.getPid();
|
||||
|
||||
// delete div contents related to this community
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(pid, null, null, null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
// delete page contents related to this community
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(pid, null, null, null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
// List<HtmlPageContent> htmlPageContents = htmlPageContentController.getHtmlPageContents(pid, null);
|
||||
// for(HtmlPageContent htmlPageContent : htmlPageContents) {
|
||||
// htmlPageContentController.deleteHtmlPageContent(htmlPageContent.getId());
|
||||
// }
|
||||
//
|
||||
// Statistics stats = statisticsDAO.findByPid(pid);
|
||||
// if(stats != null) {
|
||||
// statisticsDAO.delete(stats.getId());
|
||||
// }
|
||||
//
|
||||
// CommunitySubscribers communitySubscribers = communitySubscribersDAO.findByPid(pid);
|
||||
// if(communitySubscribers != null) {
|
||||
// communitySubscribersDAO.delete(communitySubscribers.getId());
|
||||
// }
|
||||
//
|
||||
// Layout layout = layoutDAO.findById(community.getLayout());
|
||||
// if(layout != null) {
|
||||
// layoutDAO.delete(layout.getId());
|
||||
// }
|
||||
|
||||
communityDAO.delete(id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/community", method = RequestMethod.DELETE)
|
||||
// public void deleteAllCommunities() {
|
||||
// communityDAO.deleteAll();
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/community", method = RequestMethod.POST)
|
||||
public Community insertOrUpdateCommunity(@RequestBody Community community) {
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}", method = RequestMethod.GET)
|
||||
public Community getCommunity(@PathVariable(value = "pid") String pid) {
|
||||
log.debug("PID: "+ pid);
|
||||
return communityDAO.findByPid(pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteCommunity(@PathVariable(value = "id") String id) {
|
||||
communityDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/pages", method = RequestMethod.GET)
|
||||
public List<CommunityPage> getPagesForCommunityByType(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(value="page_type", required=false) String page_type,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="div", required = false) String div) {
|
||||
List<CommunityPage> return_pages = new ArrayList<CommunityPage>();
|
||||
Map<String, Boolean> pages = communityDAO.findByPid(pid).getPages();
|
||||
|
||||
if(pages != null) {
|
||||
for (Map.Entry<String, Boolean> page : pages.entrySet()) {
|
||||
if(div != null && div.equals("true")) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
List<DivId> divIds = divIdDAO.findByPagesContaining(page.getKey());
|
||||
Iterator<DivId> divIdIterator = divIds.iterator();
|
||||
|
||||
while (divIdIterator.hasNext()) {
|
||||
DivId divId = divIdIterator.next();
|
||||
if((pid.equals("openaire") && !divId.getOpenaire()) ||
|
||||
(pid.equals("connect") && !divId.getConnect()) ||
|
||||
(!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities())) {
|
||||
divIdIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(divIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Page p = pageDAO.findById(page.getKey());
|
||||
|
||||
if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
|
||||
if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
|
||||
|| p.getRoute().equals(page_route)) {
|
||||
CommunityPage communityPage = new CommunityPage(p);
|
||||
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (String entity : p.getEntities()) {
|
||||
entities.add(entityDAO.findById(entity));
|
||||
}
|
||||
communityPage.setEntities(entities);
|
||||
communityPage.setIsEnabled(page.getValue());
|
||||
|
||||
return_pages.add(communityPage);
|
||||
|
||||
if (page_route != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return_pages.sort(Comparator.comparing(CommunityPage::getName));
|
||||
return return_pages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}/page", method = RequestMethod.POST)
|
||||
public Community insertOrUpdatePage(@PathVariable(value = "id") String id, @RequestBody CommunityPage page) {
|
||||
Community community = communityDAO.findById(id);
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
String name = page.getName();
|
||||
boolean isEnabled = page.getIsEnabled();
|
||||
|
||||
pages.put(name, isEnabled);
|
||||
community.setPages(pages);
|
||||
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "community/{pid}/page/toggle", method = RequestMethod.POST)
|
||||
public Community togglePage(@PathVariable(value = "pid") String pid, @RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
for (String pageId: pageIds) {
|
||||
log.debug("Toggle community page: " + pageId + " of community: " + pid + " to " + status);
|
||||
pages.put(pageId, Boolean.parseBoolean(status));
|
||||
}
|
||||
|
||||
community.setPages(pages);
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "community/{pid}/entity/toggle", method = RequestMethod.POST)
|
||||
public Community toggleEntity(@PathVariable(value = "pid") String pid, @RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
Map<String, Boolean> entities = community.getEntities();
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
for (String entityId: entityIds) {
|
||||
log.debug("Toggle community entity: " + entityId + " of community: " + pid + " to " + status);
|
||||
|
||||
entities.put(entityId, Boolean.parseBoolean(status));
|
||||
|
||||
if(pages != null) {
|
||||
for (Map.Entry<String, Boolean> pageEntry : pages.entrySet()) {
|
||||
Page page = pageDAO.findById(pageEntry.getKey());
|
||||
if (page.getEntities().contains(entityId) && page.getType().equals("search")) {
|
||||
pages.put(pageEntry.getKey(), Boolean.parseBoolean(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
community.setEntities(entities);
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/entities", method = RequestMethod.GET)
|
||||
public List<CommunityEntity> getEntitiesForCommunity(@PathVariable(value = "pid") String pid, @RequestParam(value="entity", required=false) String entity) {
|
||||
List<CommunityEntity> return_entities = new ArrayList<CommunityEntity>();
|
||||
Map<String, Boolean> entities = communityDAO.findByPid(pid).getEntities();
|
||||
|
||||
log.debug("/community/"+pid+"/entities -- entity: "+entity);
|
||||
if (entity != null) {
|
||||
String entityId = entityDAO.findByPid(entity).getId();
|
||||
CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(entityId));
|
||||
communityEntity.setIsEnabled(entities.get(entityId));
|
||||
return_entities.add(communityEntity);
|
||||
} else {
|
||||
if(entities != null) {
|
||||
for (Map.Entry<String, Boolean> _entity : entities.entrySet()) {
|
||||
CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(_entity.getKey()));
|
||||
communityEntity.setIsEnabled(_entity.getValue());
|
||||
return_entities.add(communityEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return return_entities;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.GET)
|
||||
// public Layout getLayoutForCommunity(@PathVariable(value = "pid") String pid) {
|
||||
// Community community = communityDAO.findByPid(pid);
|
||||
// if(community.getLayout() != null) {
|
||||
// return layoutDAO.findById(community.getLayout());
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.POST)
|
||||
// public Layout updateLayoutForCommunity(@PathVariable(value = "pid") String pid, @RequestBody Layout layout) {
|
||||
// Community community = communityDAO.findByPid(pid);
|
||||
// if(community.getLayout() != null) {
|
||||
// layout.setId(community.getLayout());
|
||||
// layout = layoutDAO.save(layout);
|
||||
// } else {
|
||||
// layout = layoutDAO.save(layout);
|
||||
// community.setLayout(layout.getId());
|
||||
// communityDAO.save(community);
|
||||
// }
|
||||
// return layout;
|
||||
// }
|
||||
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/pagehelpcontent", method = RequestMethod.GET)
|
||||
public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
|
||||
|
||||
List<PageHelpContentResponse> pageHelpContents = null;
|
||||
pageHelpContents = pageHelpContentController.getPageHelpContents(pid, page, null, active, null);
|
||||
|
||||
pageHelpContentResponses.put("top", new ArrayList<>());
|
||||
pageHelpContentResponses.put("bottom", new ArrayList<>());
|
||||
pageHelpContentResponses.put("left", new ArrayList<>());
|
||||
pageHelpContentResponses.put("right", new ArrayList<>());
|
||||
|
||||
for (PageHelpContentResponse pageHelpContentResponse : pageHelpContents) {
|
||||
pageHelpContentResponses.get(pageHelpContentResponse.getPlacement()).add(pageHelpContentResponse);
|
||||
}
|
||||
|
||||
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/divhelpcontent", method = RequestMethod.GET)
|
||||
public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
Map<String, List<DivHelpContentResponse>> divHelpContentResponses = new HashMap<>();
|
||||
|
||||
List<DivHelpContentResponse> divHelpContents = null;
|
||||
divHelpContents = divHelpContentController.getDivHelpContents(pid, page, null, active);
|
||||
|
||||
for (DivHelpContentResponse divHelpContentResponse : divHelpContents) {
|
||||
if(!divHelpContentResponses.containsKey(divHelpContentResponse.getDivId())) {
|
||||
divHelpContentResponses.put(divHelpContentResponse.getDivId().getName(), new ArrayList<>());
|
||||
}
|
||||
divHelpContentResponses.get(divHelpContentResponse.getDivId().getName()).add(divHelpContentResponse);
|
||||
}
|
||||
|
||||
|
||||
return divHelpContentResponses;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivHelpContent;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivHelpContentResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivIdResponse;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class DivHelpContentController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
DivIdController divIdController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentDAO divHelpContentDAO;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET)
|
||||
public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(required = false) String community,
|
||||
@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String div,
|
||||
@RequestParam(required = false) String active) {
|
||||
|
||||
Community _community = communityDAO.findByPid(community);
|
||||
String communityId = null;
|
||||
if(_community != null) {
|
||||
communityId = _community.getId();
|
||||
}
|
||||
|
||||
DivId divId = divIdDAO.findByName(div);
|
||||
String divIdId = null;
|
||||
if(divId != null) {
|
||||
divIdId = divId.getId();
|
||||
}
|
||||
|
||||
List<DivHelpContentResponse> divHelpContentResponses = new ArrayList<>();
|
||||
|
||||
List<DivHelpContent> divHelpContents = null;
|
||||
if(community != null && div != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndDivIdAndIsActive(communityId, divIdId, Boolean.parseBoolean(active));
|
||||
} else if(community != null && div != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndDivId(communityId, divIdId);
|
||||
} else if(community != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndIsActive(communityId, Boolean.parseBoolean(active));
|
||||
} else if(div != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByDivIdAndIsActive(divIdId, Boolean.parseBoolean(active));
|
||||
} else if(community != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunity(communityId);
|
||||
} else if(div != null) {
|
||||
divHelpContents = divHelpContentDAO.findByDivId(divIdId);
|
||||
} else if(active != null){
|
||||
divHelpContents = divHelpContentDAO.findByIsActive(Boolean.parseBoolean(active));
|
||||
} else {
|
||||
divHelpContents = divHelpContentDAO.findAll();
|
||||
}
|
||||
|
||||
for (DivHelpContent divHelpContent : divHelpContents) {
|
||||
DivIdResponse divIdResponse = null;
|
||||
if(div == null) {
|
||||
divId = divIdDAO.findById(divHelpContent.getDivId());
|
||||
}
|
||||
divIdResponse = divIdController.divIdResponseFromDivId(divId);
|
||||
|
||||
if(community == null) {
|
||||
_community = communityDAO.findById(divHelpContent.getCommunity());
|
||||
}
|
||||
|
||||
for(Page p : divIdResponse.getPages()) {
|
||||
if (page == null || p.getRoute().equals(page)) {
|
||||
DivHelpContentResponse divHelpContentResponse = new DivHelpContentResponse(divHelpContent);
|
||||
divHelpContentResponse.setDivId(divIdResponse);
|
||||
divHelpContentResponse.setCommunity(_community);
|
||||
divHelpContentResponses.add(divHelpContentResponse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return divHelpContentResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.GET)
|
||||
public DivHelpContent getDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
return divHelpContentDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.POST)
|
||||
public DivHelpContent insertOrUpdateDivHelpContent(@RequestBody DivHelpContent divHelpContent) {
|
||||
return divHelpContentDAO.save(divHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
divHelpContentDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivHelpContents(@RequestBody List<String> divHelpContents) throws Exception {
|
||||
for (String id: divHelpContents) {
|
||||
divHelpContentDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> toggleDivHelpContent(@RequestBody List<String> divHelpContents, @RequestParam String status) throws Exception {
|
||||
for (String id: divHelpContents) {
|
||||
log.debug("Id of divHelpContent: "+id);
|
||||
DivHelpContent divHelpContent = divHelpContentDAO.findById(id);
|
||||
divHelpContent.setIsActive(Boolean.parseBoolean(status));
|
||||
divHelpContentDAO.save(divHelpContent);
|
||||
}
|
||||
return divHelpContents;
|
||||
}
|
||||
|
||||
public void addDivHelpContentsInCommunity(String pid, String communityId, String divIdName) {
|
||||
//String organizations_class_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
|
||||
String link_context_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Select a research community and/or a category and search for a community concept, or browse to the community tree through the categories</div> </div>";
|
||||
String link_project_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Search for projects using project name or grant id. Limit results filtering by funder.</div> </div>";
|
||||
String link_result_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span></div> Search for research results in OpenAIRE information space, Datacite, CrossRef or ORCID. <div class=\"uk-text-small\">Use keywords, DOI (more than one - space separated), author's ORCID</div> </div>";
|
||||
String link_result_bulk_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef or Datacite and will be added to your selected research results.</div> <div class=\"uk-margin-top uk-text-small\"><span class=\"uk-text-bold\">CSV format:</span> <ul class=\"uk-list\"> <li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li> <li>The value "DOI" is required</li> <li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li> <li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li> <li>In case access mode is not available default value is "OPEN".</li> </ul> </div> </div>";
|
||||
String link_metadata_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Manage access mode & type of selected research results. For OpenAIRE this functionality isn't available.</div> </div>";
|
||||
|
||||
List<DivId> divIds = divIdController.getDivIds(null, divIdName, null);
|
||||
|
||||
for( DivId div : divIds ) {
|
||||
if (div != null && (
|
||||
(div.getOpenaire() && pid.equals("openaire")) ||
|
||||
(div.getConnect() && pid.equals("connect")) ||
|
||||
(div.getCommunities() && !pid.equals("openaire") && !pid.equals("connect"))
|
||||
)) {
|
||||
/*
|
||||
if (div.getName().equals("organizations")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, organizations_class_content, false));
|
||||
} else
|
||||
*/
|
||||
if (div.getName().equals("link-context-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_context_form_content, false));
|
||||
} else if (div.getName().equals("link-project-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_project_form_content, false));
|
||||
} else if (div.getName().equals("link-result-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_result_form_content, false));
|
||||
} else if (div.getName().equals("link-result-bulk")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_result_bulk_content, false));
|
||||
} else if (div.getName().equals("link-metadata")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_metadata_content, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,269 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivHelpContentResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivIdResponse;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class DivIdController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityController communityController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
DivIdController() {}
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.GET)
|
||||
public List<DivId> getDivIds(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value = "communityId", required = false) String pid) {
|
||||
List<DivId> divIds = null;
|
||||
|
||||
if(page != null && name != null) {
|
||||
DivId divId = divIdDAO.findByPagesContainingAndName(page, name);
|
||||
if(divId != null) {
|
||||
divIds = new ArrayList<>();
|
||||
divIds.add(divId);
|
||||
}
|
||||
} else if(page != null) {
|
||||
divIds = divIdDAO.findByPagesContaining(page);
|
||||
} else if(name != null) {
|
||||
DivId divId = divIdDAO.findByName(name);
|
||||
if(divId != null) {
|
||||
divIds = new ArrayList<>();
|
||||
divIds.add(divId);
|
||||
}
|
||||
} else {
|
||||
divIds = divIdDAO.findAll();
|
||||
}
|
||||
|
||||
if(pid != null) {
|
||||
Iterator<DivId> iteratorDivIds = divIds.iterator();
|
||||
while(iteratorDivIds.hasNext()) {
|
||||
DivId divId = iteratorDivIds.next();
|
||||
if (pid.equals("openaire") && !divId.getOpenaire()) {
|
||||
iteratorDivIds.remove();
|
||||
} else if (pid.equals("connect") && !divId.getConnect()) {
|
||||
iteratorDivIds.remove();
|
||||
} else if(!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities()){
|
||||
iteratorDivIds.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return divIds;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divFull", method = RequestMethod.GET)
|
||||
public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value="communityId", required = false) String pid) {
|
||||
|
||||
List<DivId> divIds = this.getDivIds(page, name, pid);
|
||||
|
||||
List<DivIdResponse> divIdResponses = new ArrayList<>();
|
||||
for(DivId divId : divIds) {
|
||||
DivIdResponse divIdResponse = new DivIdResponse(divId);
|
||||
List<Page> pages = new ArrayList<>();
|
||||
for(String pageId : divId.getPages()) {
|
||||
pages.add(pageDAO.findById(pageId));
|
||||
}
|
||||
divIdResponse.setPages(pages);
|
||||
|
||||
divIdResponses.add(divIdResponse);
|
||||
}
|
||||
|
||||
return divIdResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.GET)
|
||||
public DivId getDivId(@PathVariable(value = "id") String id) {
|
||||
return divIdDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divFull/{id}", method = RequestMethod.GET)
|
||||
public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) {
|
||||
DivId divId = divIdDAO.findById(id);
|
||||
return divIdResponseFromDivId(divId);
|
||||
}
|
||||
|
||||
public DivIdResponse divIdResponseFromDivId(DivId divId) {
|
||||
DivIdResponse divIdResponse = new DivIdResponse(divId);
|
||||
List<Page> pages = new ArrayList<>();
|
||||
for(String pageId : divId.getPages()) {
|
||||
pages.add(pageDAO.findById(pageId));
|
||||
}
|
||||
divIdResponse.setPages(pages);
|
||||
return divIdResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.DELETE)
|
||||
public void deleteAllDivIds() {
|
||||
divIdDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/save", method = RequestMethod.POST)
|
||||
public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
DivId divId = this.getDivIdByDivIdResponse(divIdResponse);
|
||||
|
||||
DivId savedDivId = divIdDAO.save(divId);
|
||||
divIdResponse.setId(savedDivId.getId());
|
||||
|
||||
return this.getDivIdFull(divId.getId());
|
||||
}
|
||||
|
||||
private DivId getDivIdByDivIdResponse(DivIdResponse divIdResponse) {
|
||||
DivId divId = new DivId();
|
||||
divId.setId(divIdResponse.getId());
|
||||
divId.setName(divIdResponse.getName());
|
||||
divId.setOpenaire(divIdResponse.getOpenaire());
|
||||
divId.setConnect(divIdResponse.getConnect());
|
||||
divId.setCommunities(divIdResponse.getCommunities());
|
||||
|
||||
List<Page> fullPages = divIdResponse.getPages();
|
||||
List<String> pages = new ArrayList<String>();
|
||||
for(Page page : fullPages) {
|
||||
pages.add(page.getId());
|
||||
}
|
||||
divId.setPages(pages);
|
||||
|
||||
return divId;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/update", method = RequestMethod.POST)
|
||||
public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
/*
|
||||
DivId divId = divIdDAO.findById(_divId.getId());
|
||||
divId.setName(_divId.getName());
|
||||
divId.setPages(_divId.getPages());
|
||||
divIdDAO.save(divId);
|
||||
return this.getDivIdFull(divId.getId());
|
||||
*/
|
||||
DivId divIdOld = divIdDAO.findById(divIdResponse.getId());
|
||||
DivId divId = this.getDivIdByDivIdResponse(divIdResponse);
|
||||
divIdDAO.save(divId);
|
||||
|
||||
boolean openaireEnabled = divId.getOpenaire();
|
||||
boolean connectEnabled = divId.getConnect();
|
||||
|
||||
if(divId.getCommunities() && !divIdOld.getCommunities()) {
|
||||
List<Community> communities = communityController.getAllCommunities();
|
||||
for( Community community : communities ) {
|
||||
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) {
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(openaireEnabled && !divIdOld.getOpenaire()) {
|
||||
Community community = communityController.getCommunity("openaire");
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
|
||||
if(connectEnabled && !divIdOld.getConnect()) {
|
||||
Community community = communityController.getCommunity("connect");
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
|
||||
if(!divId.getCommunities()) {
|
||||
List<Community> communities = communityController.getAllCommunities();
|
||||
for( Community community : communities ) {
|
||||
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) {
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(community.getPid(), null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!openaireEnabled) {
|
||||
Community community = communityController.getCommunity("openaire");
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("openaire", null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!connectEnabled) {
|
||||
Community community = communityController.getCommunity("connect");
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("connect", null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return divIdResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivIds(@RequestBody List<String> divIds) throws Exception {
|
||||
for (String id: divIds) {
|
||||
DivId divId = divIdDAO.findById(id);
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
divIdDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivId(@PathVariable(value = "id") String id) {
|
||||
divIdDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/pages", method = RequestMethod.GET)
|
||||
public Set<String> getDivIdsPages(@RequestParam(value="communityId", required = false) String pid) {
|
||||
List<DivId> divIds = null;
|
||||
Set<String> hasCommunityPageDivIds = new HashSet<>();
|
||||
|
||||
if(pid != null) {
|
||||
if(pid.equals("openaire")) {
|
||||
divIds = divIdDAO.findByOpenaire(true);
|
||||
} else if(pid.equals("connect")) {
|
||||
divIds = divIdDAO.findByConnect(true);
|
||||
} else {
|
||||
divIds = divIdDAO.findByCommunities(true);
|
||||
}
|
||||
} else {
|
||||
divIds = divIdDAO.findAll();
|
||||
}
|
||||
|
||||
for(DivId divId : divIds) {
|
||||
for(String pageId : divId.getPages()) {
|
||||
hasCommunityPageDivIds.add(pageId);
|
||||
}
|
||||
}
|
||||
return hasCommunityPageDivIds;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.EntityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.CommunityEntity;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class EntityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.GET)
|
||||
public List<Entity> getAllEntities() {
|
||||
return entityDAO.findAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.DELETE)
|
||||
public void deleteAllEntities() {
|
||||
entityDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.POST)
|
||||
public Entity insertOrUpdateEntity(@RequestBody Entity entity) {
|
||||
return entityDAO.save(entity);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.GET)
|
||||
public Entity getEntity(@PathVariable(value = "id") String id) {
|
||||
return entityDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteEntity(@PathVariable(value = "id") String id) {
|
||||
entityDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/update", method = RequestMethod.POST)
|
||||
public CommunityEntity updateEntity(@RequestBody CommunityEntity communityEntity) {
|
||||
Entity entity = this.getEntityByCommunityEntity(communityEntity);
|
||||
entityDAO.save(entity);
|
||||
|
||||
return communityEntity;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/save", method = RequestMethod.POST)
|
||||
public CommunityEntity insertEntity(@RequestBody Entity entity) {
|
||||
//Entity entity = this.getEntityByCommunityEntity(communityEntity);
|
||||
Entity savedEntity = entityDAO.save(entity);
|
||||
CommunityEntity communityEntity = new CommunityEntity(savedEntity);
|
||||
|
||||
// add entity in communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> entities = community.getEntities();
|
||||
entities.put(entity.getId(), true);
|
||||
community.setEntities(entities);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
return communityEntity;
|
||||
}
|
||||
|
||||
private Entity getEntityByCommunityEntity(CommunityEntity communityEntity) {
|
||||
Entity entity = new Entity();
|
||||
entity.setId(communityEntity.getId());
|
||||
entity.setPid(communityEntity.getPid());
|
||||
entity.setName(communityEntity.getName());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteEntities(@RequestBody List<String> entities) throws Exception {
|
||||
for (String id: entities) {
|
||||
entityDAO.delete(id);
|
||||
|
||||
// delete entity from communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> communityEntities = community.getEntities();
|
||||
communityEntities.remove(id);
|
||||
community.setEntities(communityEntities);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
// delete entity from pages
|
||||
List<Page> pages = pageDAO.findAll();
|
||||
for( Page page : pages ) {
|
||||
List<String> pageEntities = page.getEntities();
|
||||
int index = 0;
|
||||
for(String pageEntity : pageEntities) {
|
||||
if(pageEntity == id) {
|
||||
pageEntities.remove(index);
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
page.setEntities(pageEntities);
|
||||
pageDAO.save(page);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.CommunityPage;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.DivHelpContentResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PageHelpContentResponse;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PageController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentController pageHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivIdController divIdController;
|
||||
|
||||
@Autowired
|
||||
private EntityController entityController;
|
||||
|
||||
@RequestMapping(value = "/pageFull", method = RequestMethod.GET)
|
||||
public List<CommunityPage> getPagesFull(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route) {
|
||||
|
||||
List<Page> pages = this.getAllPages(pid, page_route, null);
|
||||
|
||||
List<CommunityPage> communityPages = new ArrayList<>();
|
||||
for(Page page : pages) {
|
||||
CommunityPage communityPage = new CommunityPage(page);
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for(String entityId : page.getEntities()) {
|
||||
entities.add(entityController.getEntity(entityId));
|
||||
}
|
||||
communityPage.setEntities(entities);
|
||||
|
||||
communityPages.add(communityPage);
|
||||
}
|
||||
|
||||
return communityPages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
public List<Page> getAllPages(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="with_positions", required=false) String with_positions) {
|
||||
List<Page> pages;
|
||||
if (pid != null) {
|
||||
if (pid.equals("openaire")) {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByOpenaireAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByOpenaire(true);
|
||||
}
|
||||
} else if (pid.equals("connect")) {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByConnectAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByConnect(true);
|
||||
}
|
||||
} else {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByCommunitiesAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByCommunities(true);
|
||||
}
|
||||
}
|
||||
} else if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByRoute(page_route));
|
||||
} else {
|
||||
pages = pageDAO.findAll();
|
||||
}
|
||||
|
||||
if (with_positions != null) {
|
||||
boolean at_least_one_position = Boolean.parseBoolean(with_positions);
|
||||
|
||||
Iterator<Page> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
Page page = iteratorPages.next();
|
||||
|
||||
if(at_least_one_position) {
|
||||
if(!page.getTop() && !page.getBottom() && !page.getLeft() && !page.getRight()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
} else {
|
||||
if(page.getTop() || page.getBottom() || page.getLeft() || page.getRight()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pages.sort(Comparator.comparing(Page::getName));
|
||||
return pages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.DELETE)
|
||||
public void deleteAllPages() {
|
||||
pageDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/update", method = RequestMethod.POST)
|
||||
public CommunityPage updatePage(@RequestBody CommunityPage communityPage) {
|
||||
this.deletePageHelpContentsForPositionsIfDisabled(communityPage);
|
||||
Page page = this.getPageByCommunityPage(communityPage);
|
||||
pageDAO.save(page);
|
||||
return communityPage;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/save", method = RequestMethod.POST)
|
||||
public CommunityPage insertPage(@RequestBody CommunityPage communityPage) {
|
||||
Page page = this.getPageByCommunityPage(communityPage);
|
||||
Page savedPage = pageDAO.save(page);
|
||||
communityPage.setId(savedPage.getId());
|
||||
|
||||
// add page in communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
pages.put(page.getId(), true);
|
||||
community.setPages(pages);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
return communityPage;
|
||||
}
|
||||
|
||||
private Page getPageByCommunityPage(CommunityPage communityPage) {
|
||||
Page page = new Page();
|
||||
page.setId(communityPage.getId());
|
||||
page.setRoute(communityPage.getRoute());
|
||||
page.setName(communityPage.getName());
|
||||
page.setType(communityPage.getType());
|
||||
page.setConnect(communityPage.getConnect());
|
||||
page.setCommunities(communityPage.getCommunities());
|
||||
page.setOpenaire(communityPage.getOpenaire());
|
||||
page.setTop(communityPage.getTop());
|
||||
page.setBottom(communityPage.getBottom());
|
||||
page.setLeft(communityPage.getLeft());
|
||||
page.setRight(communityPage.getRight());
|
||||
|
||||
List<Entity> fullEntities = communityPage.getEntities();
|
||||
List<String> entities = new ArrayList<String>();
|
||||
for(Entity entity : fullEntities) {
|
||||
entities.add(entity.getId());
|
||||
}
|
||||
page.setEntities(entities);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
private void deletePageHelpContentsForPositionsIfDisabled(CommunityPage communityPage) {
|
||||
|
||||
if(!communityPage.getTop()) {
|
||||
// delete page contents with position "top" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "top", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getBottom()) {
|
||||
// delete page contents with position "bottom" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "bottom", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getLeft()) {
|
||||
// delete page contents with position "left" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "left", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getRight()) {
|
||||
// delete page contents with position "right" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "right", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePages(@RequestBody List<String> pages) throws Exception {
|
||||
for (String id: pages) {
|
||||
pageDAO.delete(id);
|
||||
|
||||
// delete divIds related only to this page from all communities, otherwise remove this page from divIds
|
||||
List<DivId> divIds = divIdController.getDivIds(id, null, null);
|
||||
for(DivId divId : divIds) {
|
||||
if(divId.getPages().size() == 1) {
|
||||
divIdController.deleteDivId(divId.getId());
|
||||
|
||||
// delete div contents related to this page from all communities
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, divId.getId(), null);
|
||||
for (DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
} else {
|
||||
List<String> divIdPages = divId.getPages();
|
||||
divIdPages.remove(id);
|
||||
divId.setPages(divIdPages);
|
||||
divIdDAO.save(divId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete page contents related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, id, null, null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
// delete page from communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> communityPages = community.getPages();
|
||||
communityPages.remove(id);
|
||||
community.setPages(communityPages);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
|
||||
public Page getPage(@PathVariable(value = "id") String id) {
|
||||
return pageDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePage(@PathVariable(value = "id") String id) {
|
||||
pageDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}/entity", method = RequestMethod.GET)
|
||||
public List<String> getPageEntities(@PathVariable(value = "id") String id) {
|
||||
return pageDAO.findById(id).getEntities();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "page/{id}/entity/toggle", method = RequestMethod.POST)
|
||||
public Page togglePageEntity(@PathVariable(value = "id") String id, @RequestParam String entityId, @RequestParam String status) throws Exception {
|
||||
log.debug("Toggle entity : "+entityId +" of page: "+id+" to "+status);
|
||||
Page page = pageDAO.findById(id);
|
||||
List<String> entities = page.getEntities();
|
||||
if(Boolean.parseBoolean(status) && !entities.contains(entityId)) {
|
||||
entities.add(entityId);
|
||||
} else if (!Boolean.parseBoolean(status)) {
|
||||
entities.remove(entityId);
|
||||
}
|
||||
page.setEntities(entities);
|
||||
return pageDAO.save(page);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PageHelpContent;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PageHelpContentResponse;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PageHelpContentController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentDAO pageHelpContentDAO;
|
||||
|
||||
@Autowired
|
||||
private PageController pageController;
|
||||
|
||||
@Autowired
|
||||
private CommunityController communityController;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getPageHelpContents(@RequestParam(required=false) String community,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String position,
|
||||
@RequestParam(required=false) String active,
|
||||
@RequestParam(required=false) String before) {
|
||||
List<PageHelpContent> pageHelpContents = null;
|
||||
|
||||
Community _community = null;
|
||||
String communityId = null;
|
||||
if(community != null) {
|
||||
_community = communityController.getCommunity(community);
|
||||
if(_community != null) {
|
||||
communityId = _community.getId();
|
||||
}
|
||||
}
|
||||
//pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveAndisPriorToOrderByOrderAsc(community, position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
|
||||
if(community != null && position != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(communityId, position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null && position != null && active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(communityId, position, Boolean.parseBoolean(active));
|
||||
} else if(community != null && position != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(communityId, position, Boolean.parseBoolean(before));
|
||||
} else if(community != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(position != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null && position != null ) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementOrderByOrderAsc(communityId, position);
|
||||
} else if(community != null && active != null ) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(active));
|
||||
} else if(community != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(before));
|
||||
} else if(position != null && active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsActiveOrderByOrderAsc(position, Boolean.parseBoolean(active));
|
||||
} else if(position != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsPriorToOrderByOrderAsc(position, Boolean.parseBoolean(before));
|
||||
} else if(active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityOrderByPlacementAscOrderAsc(communityId);
|
||||
} else if(position != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementOrderByOrderAsc(position);
|
||||
} else if(active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsActiveOrderByPlacementAscOrderAsc(Boolean.parseBoolean(active));
|
||||
} else if(before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsPriorToOrderByPlacementAscOrderAsc(Boolean.parseBoolean(before));
|
||||
} else {
|
||||
pageHelpContents = pageHelpContentDAO.findAllByOrderByPlacementAscOrderAsc();
|
||||
}
|
||||
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = new ArrayList<>();
|
||||
for (PageHelpContent pageHelpContent : pageHelpContents) {
|
||||
Page _page = pageController.getPage(pageHelpContent.getPage());
|
||||
if(page == null || page.equals(_page.getRoute())) {
|
||||
PageHelpContentResponse pageHelpContentResponse = new PageHelpContentResponse(pageHelpContent);
|
||||
|
||||
pageHelpContentResponse.setPage(_page);
|
||||
pageHelpContentResponse.setCommunity(communityDAO.findById(pageHelpContent.getCommunity()));
|
||||
pageHelpContentResponses.add(pageHelpContentResponse);
|
||||
}
|
||||
}
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
/*
|
||||
@RequestMapping(value = "/pagehelpcontent/community/{id}", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getCommunityPageHelpContents(@PathVariable(value = "id") String communityId) {
|
||||
List<PageHelpContent> pageHelpContents = pageHelpContentDAO.findByCommunity(communityId);
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = new ArrayList<>();
|
||||
for (PageHelpContent pageHelpContent : pageHelpContents) {
|
||||
PageHelpContentResponse pageHelpContentResponse = new PageHelpContentResponse(pageHelpContent);
|
||||
pageHelpContentResponse.setPage(pageDAO.findById(pageHelpContent.getPage()));
|
||||
pageHelpContentResponse.setCommunity(communityDAO.findById(pageHelpContent.getCommunity()));
|
||||
pageHelpContentResponses.add(pageHelpContentResponse);
|
||||
}
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
*/
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.DELETE)
|
||||
public void deleteAllPageHelpContents() {
|
||||
pageHelpContentDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/save", method = RequestMethod.POST)
|
||||
public PageHelpContent insertPageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
String communityId = communityController.getCommunity(pageHelpContent.getCommunity()).getId();
|
||||
pageHelpContent.setCommunity(communityId);
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/update", method = RequestMethod.POST)
|
||||
public PageHelpContent updatePageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.GET)
|
||||
public PageHelpContent getPageHelpContent(@PathVariable(value = "id") String id) {
|
||||
return pageHelpContentDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> togglePageHelpContent(@RequestBody List<String> pageHelpContents, @RequestParam String status) throws Exception {
|
||||
for (String id: pageHelpContents) {
|
||||
log.debug("Id of pageHelpContent: "+id);
|
||||
PageHelpContent pageHelpContent = pageHelpContentDAO.findById(id);
|
||||
pageHelpContent.setIsActive(Boolean.parseBoolean(status));
|
||||
pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
return pageHelpContents;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePageHelpContent(@PathVariable(value = "id") String id) {
|
||||
pageHelpContentDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePageHelpContents(@RequestBody List<String> pageHelpContents) throws Exception {
|
||||
for (String id: pageHelpContents) {
|
||||
pageHelpContentDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPageHelpContentsInCommunity(String pid, String communityId) {
|
||||
if (pid != "connect" && pid != "openaire") {
|
||||
String organizations_page_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
|
||||
Page organizationsPage = (pageController.getAllPages(null, "/organizations", null)).get(0);
|
||||
|
||||
PageHelpContent organizations_pageHelpContent = new PageHelpContent(organizationsPage.getId(), pid, "top", 1, organizations_page_content, false, false);
|
||||
this.insertPageHelpContent(organizations_pageHelpContent);
|
||||
|
||||
String depositLearnHow_page_content = "" +
|
||||
"<div class=\"uk-width-3-5 uk-align-center\"> " +
|
||||
" <div class=\"uk-text-bold\">How to comply with funder Open Access policies</div> " +
|
||||
" <ul class=\"uk-list uk-list-bullet\"> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-publications\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on publications </a></li> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-data\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on research data </a></li> " +
|
||||
" <li>If you want to know about National Open Access policies, please check them out <a class=\"custom-external\" href=\"https://www.openaire.eu/frontpage/country-pages\" target=\"_blank\">here</a></li> " +
|
||||
" <li>All OpenAIRE guides can be found <a class=\"custom-external\" href=\"https://www.openaire.eu/guides\" target=\"_blank\">here</a></li> " +
|
||||
" </ul> " +
|
||||
"</div>";
|
||||
Page depositLearnHowPage = (pageController.getAllPages(null, "/participate/deposit/learn-how", null)).get(0);
|
||||
|
||||
PageHelpContent depositLearnHow_pageHelpContent = new PageHelpContent(depositLearnHowPage.getId(), pid, "bottom", 1, depositLearnHow_page_content, true, false);
|
||||
this.insertPageHelpContent(depositLearnHow_pageHelpContent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
|
||||
public interface CommunityDAO {
|
||||
List<Community> findAll();
|
||||
|
||||
Community findById(String Id);
|
||||
|
||||
Community findByPid(String Pid);
|
||||
|
||||
Community findByName(String Name);
|
||||
|
||||
Community save(Community community);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivHelpContent;
|
||||
|
||||
public interface DivHelpContentDAO {
|
||||
List<DivHelpContent> findAll();
|
||||
|
||||
List<DivHelpContent> findByCommunity(String community);
|
||||
List<DivHelpContent> findByDivId(String divId);
|
||||
List<DivHelpContent> findByIsActive(boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivId(String community, String divId);
|
||||
List<DivHelpContent> findByCommunityAndIsActive(String community, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivIdAndIsActive(String community, String divId, boolean isActive);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
DivHelpContent save(DivHelpContent divHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
|
||||
public interface DivIdDAO {
|
||||
List<DivId> findAll();
|
||||
|
||||
List<DivId> findByPagesContaining(String page);
|
||||
|
||||
DivId findByPagesContainingAndName(String page, String name);
|
||||
DivId findByName(String name);
|
||||
|
||||
DivId findById(String Id);
|
||||
|
||||
List<DivId> findByConnect(boolean connect);
|
||||
List<DivId> findByCommunities(boolean communities);
|
||||
List<DivId> findByOpenaire(boolean openaire);
|
||||
|
||||
DivId save(DivId divId);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
|
||||
public interface EntityDAO {
|
||||
List<Entity> findAll();
|
||||
|
||||
Entity findById(String Id);
|
||||
|
||||
Entity findByPid(String Pid);
|
||||
|
||||
Entity findByName(String name);
|
||||
|
||||
Entity save(Entity entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
|
||||
public interface MongoDBCommunityDAO extends CommunityDAO, MongoRepository<Community, String> {
|
||||
List<Community> findAll();
|
||||
|
||||
Community findById(String Id);
|
||||
|
||||
Community findByPid(String Pid);
|
||||
|
||||
Community findByName(String Name);
|
||||
|
||||
Community save(Community community);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivHelpContent;
|
||||
|
||||
public interface MongoDBDivHelpContentDAO extends DivHelpContentDAO, MongoRepository<DivHelpContent, String> {
|
||||
List<DivHelpContent> findAll();
|
||||
|
||||
List<DivHelpContent> findByCommunity(String community);
|
||||
List<DivHelpContent> findByDivId(String divId);
|
||||
List<DivHelpContent> findByIsActive(boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivId(String community, String divId);
|
||||
List<DivHelpContent> findByCommunityAndIsActive(String community, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivIdAndIsActive(String community, String divId, boolean isActive);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
DivHelpContent save(DivHelpContent divHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
|
||||
public interface MongoDBDivIdDAO extends DivIdDAO, MongoRepository<DivId, String> {
|
||||
List<DivId> findAll();
|
||||
|
||||
List<DivId> findByPagesContaining(String page);
|
||||
|
||||
DivId findByPagesContainingAndName(String page, String name);
|
||||
DivId findByName(String name);
|
||||
|
||||
DivId findById(String Id);
|
||||
|
||||
List<DivId> findByConnect(boolean connect);
|
||||
List<DivId> findByCommunities(boolean communities);
|
||||
List<DivId> findByOpenaire(boolean openaire);
|
||||
|
||||
DivId save(DivId divId);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.EntityDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBEntityDAO extends EntityDAO, MongoRepository<Entity, String> {
|
||||
List<Entity> findAll();
|
||||
|
||||
Entity findById(String Id);
|
||||
|
||||
Entity findByPid(String Pid);
|
||||
|
||||
Entity findByName(String name);
|
||||
|
||||
Entity save(Entity entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
|
||||
public interface MongoDBPageDAO extends PageDAO, MongoRepository<Page, String> {
|
||||
List<Page> findAll();
|
||||
List<Page> findByConnect(boolean connect);
|
||||
List<Page> findByCommunities(boolean communities);
|
||||
List<Page> findByOpenaire(boolean openaire);
|
||||
|
||||
Page findByConnectAndRoute(boolean connect, String route);
|
||||
Page findByCommunitiesAndRoute(boolean communities, String route);
|
||||
Page findByOpenaireAndRoute(boolean openaire, String route);
|
||||
|
||||
Page findById(String Id);
|
||||
Page findByRoute(String route);
|
||||
|
||||
Page save(Page page);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao.MongoDBDAOs;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PageHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PageHelpContent;
|
||||
|
||||
public interface MongoDBPageHelpContentDAO extends PageHelpContentDAO, MongoRepository<PageHelpContent, String> {
|
||||
List<PageHelpContent> findAll();
|
||||
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(String communityId, String position, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementOrderByOrderAsc(String communityId, String postion);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(String communityId, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveOrderByOrderAsc(String position, boolean isActive);
|
||||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityOrderByPlacementAscOrderAsc(String communityId);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
List<PageHelpContent> findByIsPriorToOrderByPlacementAscOrderAsc(boolean isPriorTo);
|
||||
List<PageHelpContent> findAllByOrderByPlacementAscOrderAsc();
|
||||
|
||||
|
||||
//List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndBeforeOrderByOrderAsc(String communityId, String postion, boolean isActive, boolean before);
|
||||
|
||||
PageHelpContent findById(String Id);
|
||||
|
||||
PageHelpContent findByIdOrderByOrder(String Id);
|
||||
|
||||
PageHelpContent save(PageHelpContent pageHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
|
||||
public interface PageDAO {
|
||||
List<Page> findAll();
|
||||
List<Page> findByConnect(boolean connect);
|
||||
List<Page> findByCommunities(boolean communities);
|
||||
List<Page> findByOpenaire(boolean openaire);
|
||||
|
||||
Page findByConnectAndRoute(boolean connect, String route);
|
||||
Page findByCommunitiesAndRoute(boolean communities, String route);
|
||||
Page findByOpenaireAndRoute(boolean openaire, String route);
|
||||
|
||||
Page findById(String Id);
|
||||
Page findByRoute(String route);
|
||||
|
||||
Page save(Page page);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PageHelpContent;
|
||||
|
||||
public interface PageHelpContentDAO {
|
||||
List<PageHelpContent> findAll();
|
||||
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(String communityId, String position, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementOrderByOrderAsc(String communityId, String postion);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(String communityId, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveOrderByOrderAsc(String position, boolean isActive);
|
||||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityOrderByPlacementAscOrderAsc(String communityId);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
List<PageHelpContent> findByIsPriorToOrderByPlacementAscOrderAsc(boolean isPriorTo);
|
||||
List<PageHelpContent> findAllByOrderByPlacementAscOrderAsc();
|
||||
|
||||
//List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String postion, boolean isActive, boolean isBefore);
|
||||
|
||||
|
||||
PageHelpContent findById(String Id);
|
||||
|
||||
PageHelpContent findByIdOrderByOrder(String Id);
|
||||
|
||||
PageHelpContent save(PageHelpContent pageHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.emailSender;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.MailConfig;
|
||||
|
||||
@Service
|
||||
@Configurable
|
||||
public class EmailSender {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EmailSender.class);
|
||||
|
||||
@Autowired
|
||||
private MailConfig mailConfig;
|
||||
|
||||
public boolean send(List<String> recipients, String subject, String body, Boolean bcc) {
|
||||
// Get system properties
|
||||
Properties properties = System.getProperties();
|
||||
properties.setProperty("mail.smtp.host", mailConfig.getHost());
|
||||
properties.put("mail.smtp.port", mailConfig.getPort());
|
||||
properties.put("mail.smtp.auth", mailConfig.getAuth()); //enable authentication
|
||||
properties.put("mail.smtp.starttls.enable", "true");
|
||||
logger.debug("Try to connect to mail sender with "+ mailConfig.getUsername());
|
||||
Session session = Session.getInstance(properties,
|
||||
new javax.mail.Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(mailConfig.getUsername(), mailConfig.getPassword());
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
logger.debug("Try to sent e-mail to "+recipients.toString()+
|
||||
"\nSubject: "+subject+
|
||||
"\nBody:"+body);
|
||||
|
||||
// Create a default MimeMessage object.
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
|
||||
// Set From: header field of the header.
|
||||
message.setFrom(new InternetAddress(mailConfig.getFrom()));
|
||||
|
||||
// Set To: header field of the header.
|
||||
if(!bcc) {
|
||||
for (String to : recipients) {
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
|
||||
}
|
||||
}else{
|
||||
for (String to : recipients) {
|
||||
message.addRecipient(Message.RecipientType.BCC, new InternetAddress(to));
|
||||
}
|
||||
}
|
||||
|
||||
message.addRecipient(Message.RecipientType.BCC, new InternetAddress("openaire.test@gmail.com"));
|
||||
|
||||
// Set Subject: header field
|
||||
message.setSubject(subject);
|
||||
|
||||
// For simple text setText() can be used instead of setContent()
|
||||
|
||||
// Send the actual HTML message, as big as you like
|
||||
message.setContent(body, "text/html");
|
||||
|
||||
// Send message
|
||||
Transport.send(message);
|
||||
logger.debug("Sent message successfully....\n");
|
||||
return true;
|
||||
} catch (AddressException ae) {
|
||||
logger.error("Email could not be send.", ae);
|
||||
return false;
|
||||
} catch (MessagingException me) {
|
||||
logger.error("Email could not be send.", me);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Community {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private Map<String, Boolean> pages;
|
||||
private Map<String, Boolean> entities;
|
||||
private String layout;
|
||||
|
||||
public Community() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getPages() { return pages; }
|
||||
|
||||
public void setPages(Map<String, Boolean> pages) { this.pages = pages; }
|
||||
|
||||
public Map<String, Boolean> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(Map<String, Boolean> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public String getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(String layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class DivHelpContent {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String divId;
|
||||
private String community;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
|
||||
public DivHelpContent() {}
|
||||
|
||||
public DivHelpContent(String divId, String community, String content, boolean isActive) {
|
||||
this.divId = divId;
|
||||
this.community = community;
|
||||
this.content = content;
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDivId() {
|
||||
return divId;
|
||||
}
|
||||
|
||||
public void setDivId(String divId) {
|
||||
this.divId = divId;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(String community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DivId {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private List<String> pages;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
public DivId() {}
|
||||
|
||||
public DivId(DivId divId) {
|
||||
setName(divId.getName());
|
||||
setPages(divId.getPages());
|
||||
setConnect(divId.getConnect());
|
||||
setCommunities(divId.getCommunities());
|
||||
setOpenaire(divId.getOpenaire());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<String> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() { return communities; }
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class Entity {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
|
||||
public Entity() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Page {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String route;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<String> entities;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
// Positions where help texts are allowed for this page
|
||||
private Boolean top;
|
||||
private Boolean bottom;
|
||||
private Boolean left;
|
||||
private Boolean right;
|
||||
|
||||
public Page() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
public void setRoute(String route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<String> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<String> entities) { this.entities = entities; }
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() {
|
||||
return communities;
|
||||
}
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(Boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public Boolean getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public void setBottom(Boolean bottom) {
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public Boolean getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(Boolean left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public Boolean getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(Boolean right) {
|
||||
this.right = right;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class PageHelpContent {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String page;
|
||||
private String community;
|
||||
private String placement;
|
||||
private int order;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
private boolean isPriorTo = false;
|
||||
|
||||
public PageHelpContent() {}
|
||||
|
||||
public PageHelpContent(String page, String community, String placement, int order, String content, boolean isActive, boolean isPriorTo) {
|
||||
this.page = page;
|
||||
this.community = community;
|
||||
this.placement = placement;
|
||||
this.order = order;
|
||||
this.content = content;
|
||||
this.isActive = isActive;
|
||||
this.isPriorTo = isPriorTo;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(String community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getPlacement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
public void setPlacement(String placement) {
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public boolean getIsPriorTo() { return isPriorTo; }
|
||||
|
||||
public void setIsPriorTo(boolean isPriorTo) { this.isPriorTo = isPriorTo; }
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.email;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Email {
|
||||
String subject;
|
||||
List<String> recipients;
|
||||
String body;
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public List<String> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public void setRecipients(List<String> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.email;
|
||||
|
||||
public class EmailRecaptcha {
|
||||
private Email email;
|
||||
private String recaptcha;
|
||||
|
||||
public Email getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(Email email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getRecaptcha() {
|
||||
return recaptcha;
|
||||
}
|
||||
|
||||
public void setRecaptcha(String recaptcha) {
|
||||
this.recaptcha = recaptcha;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.email;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonPropertyOrder({
|
||||
"success",
|
||||
"challenge_ts",
|
||||
"hostname",
|
||||
"error-codes"
|
||||
})
|
||||
public class GoogleResponse {
|
||||
|
||||
@JsonProperty("success")
|
||||
private boolean success;
|
||||
|
||||
@JsonProperty("challenge_ts")
|
||||
private String challengeTs;
|
||||
|
||||
@JsonProperty("hostname")
|
||||
private String hostname;
|
||||
|
||||
@JsonProperty("error-codes")
|
||||
private ErrorCode[] errorCodes;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasClientError() {
|
||||
ErrorCode[] errors = getErrorCodes();
|
||||
if(errors == null) {
|
||||
return false;
|
||||
}
|
||||
for(ErrorCode error : errors) {
|
||||
switch(error) {
|
||||
case InvalidResponse:
|
||||
case MissingResponse:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static enum ErrorCode {
|
||||
MissingSecret, InvalidSecret,
|
||||
MissingResponse, InvalidResponse;
|
||||
|
||||
private static Map<String, ErrorCode> errorsMap = new HashMap<>(4);
|
||||
|
||||
static {
|
||||
errorsMap.put("missing-input-secret", MissingSecret);
|
||||
errorsMap.put("invalid-input-secret", InvalidSecret);
|
||||
errorsMap.put("missing-input-response", MissingResponse);
|
||||
errorsMap.put("invalid-input-response", InvalidResponse);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ErrorCode forValue(String value) {
|
||||
return errorsMap.get(value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getChallengeTs() {
|
||||
return challengeTs;
|
||||
}
|
||||
|
||||
public void setChallengeTs(String challengeTs) {
|
||||
this.challengeTs = challengeTs;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public ErrorCode[] getErrorCodes() {
|
||||
return errorCodes;
|
||||
}
|
||||
|
||||
public void setErrorCodes(ErrorCode[] errorCodes) {
|
||||
this.errorCodes = errorCodes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
|
||||
public class CommunityEntity {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private Boolean isEnabled;
|
||||
|
||||
public CommunityEntity() {}
|
||||
|
||||
public CommunityEntity(Entity entity) {
|
||||
this.setId(entity.getId());
|
||||
this.setPid(entity.getPid());
|
||||
this.setName(entity.getName());
|
||||
this.setIsEnabled(true);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) { this.pid = pid; }
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; }
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Entity;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
|
||||
public class CommunityPage {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String route;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<Entity> entities;
|
||||
private Boolean isEnabled;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
// Posiitions where help texts are allowed for this page
|
||||
private Boolean top;
|
||||
private Boolean bottom;
|
||||
private Boolean left;
|
||||
private Boolean right;
|
||||
|
||||
public CommunityPage() {}
|
||||
|
||||
public CommunityPage(Page page) {
|
||||
this.setId(page.getId());
|
||||
this.setRoute(page.getRoute());
|
||||
this.setName(page.getName());
|
||||
this.setType(page.getType());
|
||||
this.setConnect(page.getConnect());
|
||||
this.setCommunities(page.getCommunities());
|
||||
this.setOpenaire(page.getOpenaire());
|
||||
this.setTop(page.getTop());
|
||||
this.setBottom(page.getBottom());
|
||||
this.setLeft(page.getLeft());
|
||||
this.setRight(page.getRight());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
public void setRoute(String route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<Entity> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<Entity> entities) { this.entities = entities; }
|
||||
|
||||
public Boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; }
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() {
|
||||
return communities;
|
||||
}
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(Boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public Boolean getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public void setBottom(Boolean bottom) {
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public Boolean getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(Boolean left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public Boolean getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(Boolean right) {
|
||||
this.right = right;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
|
||||
public class CommunityResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private List<CommunityPage> pages;
|
||||
private List<CommunityEntity> entities;
|
||||
//private Layout layout;
|
||||
|
||||
public CommunityResponse() {}
|
||||
|
||||
public CommunityResponse(Community community) {
|
||||
this.setId(community.getId());
|
||||
this.setPid(community.getPid());
|
||||
this.setName(community.getName());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<CommunityPage> getPages() { return pages; }
|
||||
|
||||
public void setPages(List<CommunityPage> pages) { this.pages = pages; }
|
||||
|
||||
public List<CommunityEntity> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<CommunityEntity> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
// public Layout getLayout() {
|
||||
// return layout;
|
||||
// }
|
||||
//
|
||||
// public void setLayout(Layout layout) {
|
||||
// this.layout = layout;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivHelpContent;
|
||||
|
||||
public class DivHelpContentResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private DivIdResponse divId;
|
||||
private Community community;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
|
||||
public DivHelpContentResponse(DivHelpContent divHelpContent) {
|
||||
this.id = divHelpContent.getId();
|
||||
this.content = divHelpContent.getContent();
|
||||
this.isActive = divHelpContent.getIsActive();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DivIdResponse getDivId() {
|
||||
return divId;
|
||||
}
|
||||
|
||||
public void setDivId(DivIdResponse divId) {
|
||||
this.divId = divId;
|
||||
}
|
||||
|
||||
public Community getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(Community community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
|
||||
|
||||
public class DivIdResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private List<Page> pages;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
public DivIdResponse() {}
|
||||
|
||||
public DivIdResponse(DivId divId) {
|
||||
this.id = divId.getId();
|
||||
this.name = divId.getName();
|
||||
setConnect(divId.getConnect());
|
||||
setCommunities(divId.getCommunities());
|
||||
setOpenaire(divId.getOpenaire());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Page> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<Page> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() { return communities; }
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Community;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.PageHelpContent;
|
||||
|
||||
public class PageHelpContentResponse {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private Page page;
|
||||
private Community community;
|
||||
private String placement;
|
||||
private int order;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
private boolean isPriorTo = false;
|
||||
|
||||
public PageHelpContentResponse() {}
|
||||
|
||||
public PageHelpContentResponse(PageHelpContent pageHelpContent) {
|
||||
this.id = pageHelpContent.getId();
|
||||
this.placement = pageHelpContent.getPlacement();
|
||||
this.order = pageHelpContent.getOrder();
|
||||
this.content = pageHelpContent.getContent();
|
||||
this.isActive = pageHelpContent.getIsActive();
|
||||
this.isPriorTo = pageHelpContent.getIsPriorTo();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Page getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Page page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public Community getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(Community community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getPlacement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
public void setPlacement(String placement) {
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public boolean getIsPriorTo() { return isPriorTo; }
|
||||
|
||||
public void setIsPriorTo(boolean isPriorTo) { this.isPriorTo = isPriorTo; }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.handlers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
|
||||
public class InvalidReCaptchaException extends RuntimeException{
|
||||
public InvalidReCaptchaException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.dnetlib.uoaadmintoolslibrary.recaptcha;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.GoogleConfig;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.email.GoogleResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
|
||||
|
||||
@Service
|
||||
@Configurable
|
||||
public class VerifyRecaptcha {
|
||||
|
||||
@Autowired
|
||||
private RestOperations restTemplate;
|
||||
|
||||
@Autowired
|
||||
private GoogleConfig googleConfig;
|
||||
|
||||
private static Pattern RESPONSE_PATTERN = Pattern.compile("[A-Za-z0-9_-]+");
|
||||
|
||||
@Bean
|
||||
public RestOperations restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void processResponse(String response) throws InvalidReCaptchaException {
|
||||
if(!responseSanityCheck(response)) {
|
||||
throw new InvalidReCaptchaException("Response contains invalid characters");
|
||||
}
|
||||
|
||||
URI verifyUri = URI.create(String.format(
|
||||
"https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s",
|
||||
googleConfig.getSecret(), response));
|
||||
|
||||
GoogleResponse googleResponse = restTemplate.getForObject(verifyUri, GoogleResponse.class);
|
||||
|
||||
if(!googleResponse.isSuccess()) {
|
||||
throw new InvalidReCaptchaException("reCaptcha was not successfully validated");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean responseSanityCheck(String response) {
|
||||
return StringUtils.hasLength(response) && RESPONSE_PATTERN.matcher(response).matches();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
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-library/uoa-admin-tools-library.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-library/uoa-admin-tools-library-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
|
Loading…
Reference in New Issue