Skip to content

Commit

Permalink
Merge pull request #326 from diging/develop
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
jdamerow authored Mar 6, 2023
2 parents 8251890 + 3a14c10 commit f924cbb
Show file tree
Hide file tree
Showing 87 changed files with 4,963 additions and 672 deletions.
16 changes: 8 additions & 8 deletions vspace/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@

<properties>
<org.slf4j-version>1.7.5</org.slf4j-version>
<spring.version>5.0.19.RELEASE</spring.version>
<spring.version>5.3.0</spring.version>
<spring-data.version>Kay-SR8</spring-data.version>
<spring-security-version>5.3.10.RELEASE</spring-security-version>
<spring-security-version>5.5.7</spring-security-version>
<thymeleaf.version>3.0.13.RELEASE</thymeleaf.version>
<javers.version>5.11.1</javers.version>
<javers.version>5.15.0</javers.version>
<simple-users-version>0.5</simple-users-version>
<admin.username>admin</admin.username>
<admin.password>$2a$04$ug2wdYfAW8Ey/DwjUdPuLufgrMqbhNnTmr1QEUNZnoWF1xGitSBae</admin.password>
<staff.password>$2a$04$QhdsxRoZPJw/G06aDkP6COLARKtbdTxVvxtKPZUE0dFlNKFMZsXRe</staff.password>

<log.level>debug</log.level>

<db.driver>com.mysql.jdbc.Driver</db.driver>
Expand All @@ -41,6 +40,7 @@

<hibernate.show_sql></hibernate.show_sql>
<buildNumber>v0.16.1</buildNumber>
<baseUrl>http://localhost:8080</baseUrl>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -300,14 +300,14 @@

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.3.2.Final</version>
<artifactId>hibernate-core</artifactId>
<version>5.4.24.Final</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<version>8.0.28</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -421,4 +421,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.asu.diging.vspace.config;

public interface ConfigConstants {
public final static String EXHIBITION_LANGUAGE_LIST_PROPERTY= "exhibition-language-list";

public final static String LABEL= "label";

public final static String CODE= "code";

public final static String LANGUAGES= "languages";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package edu.asu.diging.vspace.config;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.stereotype.Component;

import edu.asu.diging.vspace.core.model.impl.ExhibitionLanguage;
import org.springframework.core.env.MutablePropertySources;


@Component
@PropertySource(value= "classpath:exhibitionLanguages.properties" , factory=JsonPropertySourceFactory.class)
@Configuration
public class ExhibitionLanguageConfig {

@Autowired
private Environment environment;

private List<Map> exhibitionLanguageList = new ArrayList<Map>();

/**
* Fetches the configured language list from environment property source and stores in exhibitionLanguageList
*
*/
@PostConstruct
public void init() {

org.springframework.core.env.PropertySource<?> propertySource = ((AbstractEnvironment) environment).getPropertySources().get(ConfigConstants.EXHIBITION_LANGUAGE_LIST_PROPERTY);
if( propertySource != null ) {
Map<String, Object> languageMap = (Map<String, Object>) propertySource.getSource();
exhibitionLanguageList = (List<Map>) languageMap.get(ConfigConstants.LANGUAGES);
}

}

public List<Map> getExhibitionLanguageList() {
return exhibitionLanguageList;
}
public void setExhibitionLanguageList(List<Map> exhibitionLanguageList) {
this.exhibitionLanguageList = exhibitionLanguageList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package edu.asu.diging.vspace.config;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;

import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonPropertySourceFactory implements PropertySourceFactory {


/**
* Converts language json read from properties file to a map and stores in property source.
*
*/
@Override
public org.springframework.core.env.PropertySource<?> createPropertySource(String name, EncodedResource resource)
throws IOException {
Map<String, Object> readValue = new ObjectMapper()
.readValue(resource.getInputStream(), Map.class);
return new MapPropertySource(ConfigConstants.EXHIBITION_LANGUAGE_LIST_PROPERTY, readValue);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void configure(HttpSecurity http) throws Exception {
.authorizeRequests()
// Anyone can access the urls
.antMatchers("/", "/exhibit/**", "/api/**", "/resources/**", "/login",
"/logout", "/register", "/reset/**", "/setup/admin", "/404").permitAll()
"/logout", "/register", "/reset/**", "/setup/admin", "/404","/preview/**").permitAll()
// The rest of the our application is protected.
.antMatchers("/users/**", "/admin/**", "/staff/user/**").hasRole("ADMIN")
.antMatchers("/staff/**").hasAnyRole("STAFF", "ADMIN")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package edu.asu.diging.vspace.core.aspects;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
Expand All @@ -13,6 +16,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import edu.asu.diging.vspace.core.auth.impl.AuthenticationFacade;
Expand All @@ -25,6 +31,7 @@
import edu.asu.diging.vspace.core.services.IExhibitionManager;
import edu.asu.diging.vspace.core.services.IModuleManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.web.exhibit.view.ExhibitionConstants;

@Component
@Aspect
Expand All @@ -49,22 +56,23 @@ public void setExhibition(JoinPoint jp) {
Class<?> returnType = signature.getReturnType();
// only if there is a model object injected and if we're returning a string
// (assuming that returning a string implies rendering of a view afterwards
if(args!=null && returnType==String.class) {
for(Object obj : args) {
if(obj instanceof Model && !(obj instanceof RedirectAttributes)) {
if(!((Model) obj).containsAttribute("exhibition")) {
if (args != null && returnType == String.class) {
for (Object obj : args) {
if (obj instanceof Model && !(obj instanceof RedirectAttributes)) {
if (!((Model) obj).containsAttribute("exhibition")) {
((Model) obj).addAttribute("exhibition", exhibitionManager.getStartExhibition());
}
if (!((Model) obj).containsAttribute("publishedSpaces")) {
List<ISpace> publishedSpaces=spaceManager.getSpacesWithStatus(SpaceStatus.PUBLISHED);
/* (non-Javadoc)
* Added to show spaces with null status and accommodate existing spaces with null space status
List<ISpace> publishedSpaces = spaceManager.getSpacesWithStatus(SpaceStatus.PUBLISHED);
/*
* (non-Javadoc) Added to show spaces with null status and accommodate existing
* spaces with null space status
*/
publishedSpaces.addAll(spaceManager.getSpacesWithStatus(null));
((Model) obj).addAttribute("publishedSpaces", publishedSpaces);
}
}
}
}
}
}

Expand All @@ -73,13 +81,14 @@ public Object showExhibition(ProceedingJoinPoint jp) throws Throwable {
Object[] args = jp.getArgs();
MethodSignature signature = (MethodSignature) jp.getSignature();
int indexOfModel = (Arrays.asList(signature.getParameterTypes())).indexOf(Model.class);
Exhibition exhibition = (Exhibition) exhibitionManager.getStartExhibition();
Exhibition exhibition = (Exhibition) exhibitionManager.getStartExhibition();
// If there is no exhibition, we go back to root url page.
if(exhibition==null) {
if (exhibition == null) {
return "redirect:/";
}
//If no exhibition mode has been setup for existing exhibition, we skip modes and aspects.
if(exhibition.getMode() == null) {
// If no exhibition mode has been setup for existing exhibition, we skip modes
// and aspects.
if (exhibition.getMode() == null) {
return jp.proceed();
}
Map<IdPrefix, String> ids = getIds(args, signature);
Expand All @@ -89,66 +98,77 @@ public Object showExhibition(ProceedingJoinPoint jp) throws Throwable {
}

/**
* Based on exhibition mode, get the redirect page or pass control to controller.
* @param jp The joinpoint variable, used to fetch request parameters and proceed with the request.
* @param spaceId Current spaceId that is requested to be viewed by user.
* @param moduleId The moduleId that the user has requested to view.
* @param modelIndex Index of the model information in the reuest parameters.
* @param exhibition Current exhibition that is being shown to user.
* @return returns the page to load upon aspect completion.
* @throws Throwable
* Based on exhibition mode, get the redirect page or pass control to
* controller.
*
* @param jp The joinpoint variable, used to fetch request parameters
* and proceed with the request.
* @param spaceId Current spaceId that is requested to be viewed by user.
* @param moduleId The moduleId that the user has requested to view.
* @param modelIndex Index of the model information in the reuest parameters.
* @param exhibition Current exhibition that is being shown to user.
* @return returns the page to load upon aspect completion.
* @throws Throwable
*/
private Object redirectRequest(ProceedingJoinPoint jp, String spaceId, String moduleId, int modelIndex, Exhibition exhibition) throws Throwable{
private Object redirectRequest(ProceedingJoinPoint jp, String spaceId, String moduleId, int modelIndex,
Exhibition exhibition) throws Throwable {
ISpace space = spaceManager.getSpace(spaceId);
IModule module = moduleManager.getModule(moduleId);
Object[] args = jp.getArgs();
ExhibitionModes exhibitionMode = exhibition.getMode();
// If exhibition is set to offline, set the custom message or default message.
if(exhibitionMode.equals(ExhibitionModes.OFFLINE)) {
String modeValue = exhibition.getCustomMessage().equals("") == false ? exhibition.getCustomMessage() : exhibitionMode.getValue();
if (exhibitionMode.equals(ExhibitionModes.OFFLINE)) {
String modeValue = exhibition.getCustomMessage().equals("") == false ? exhibition.getCustomMessage()
: exhibitionMode.getValue();
((Model) args[modelIndex]).addAttribute("modeValue", modeValue);
}
if(exhibition.isAboutPageConfigured()) {
if (exhibition.isAboutPageConfigured()) {
((Model) args[modelIndex]).addAttribute("aboutPageConfigured", true);
} else {
((Model) args[modelIndex]).addAttribute("aboutPageConfigured", false);
}
// If exhibition is set to maintenance, set the default message.
if(exhibitionMode.equals(ExhibitionModes.MAINTENANCE)) {
if (exhibitionMode.equals(ExhibitionModes.MAINTENANCE)) {
((Model) args[modelIndex]).addAttribute("modeValue", exhibitionMode.getValue());
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
.getRequest();
Map pathVariables = (Map) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
String previewId = (String) pathVariables.get(ExhibitionConstants.PREVIEW_ID);
// If user is not logged in and exhibition is not active, show maintenance page.
if(authFacade.getAuthenticatedUser()==null && !exhibitionMode.equals(ExhibitionModes.ACTIVE)) {
return "maintenance";
if (authFacade.getAuthenticatedUser() == null && !exhibitionMode.equals(ExhibitionModes.ACTIVE) && previewId==null) {
return "/exhibition/maintenance";
}
// If the space and module Id is not found, show message on screen.
if(space==null && module==null) {
if (space == null && module == null) {
return "redirect:/exhibit/404";
}
// If user is logged in and exhibition is not active, show exhibition with pop up message.
if(authFacade.getAuthenticatedUser()!=null && !exhibitionMode.equals(ExhibitionModes.ACTIVE)) {
// If user is logged in and exhibition is not active, show exhibition with pop
// up message.
if (authFacade.getAuthenticatedUser() != null && !exhibitionMode.equals(ExhibitionModes.ACTIVE)) {
return jp.proceed();
}
return jp.proceed();
}


/**
* Method to get the space or module id's from the request body.
*
* @param args The request parameters from the original request.
* @param signature Contains the information about the arguments present in args.
* @return A map with spaceId and moduleId from the request args.
* @param signature Contains the information about the arguments present in
* args.
* @return A map with spaceId and moduleId from the request args.
*/
private Map<IdPrefix, String> getIds(Object[] args, MethodSignature signature) {
private Map<IdPrefix, String> getIds(Object[] args, MethodSignature signature) {
Map<IdPrefix, String> res = new HashMap<>();
for(int i=0; i <signature.getParameterTypes().length; ++i) {
if(signature.getParameterTypes()[i].equals(String.class)) {
if(args[i] != null && ((String) args[i]).length() > 2) {
String prefix = ((String) args[i]).substring(0,3);
if(prefix.equalsIgnoreCase(IdPrefix.SPACEID.getValue())) {
for (int i = 0; i < signature.getParameterTypes().length; ++i) {
if (signature.getParameterTypes()[i].equals(String.class)) {
if (args[i] != null && ((String) args[i]).length() > 2) {
String prefix = ((String) args[i]).substring(0, 3);
if (prefix.equalsIgnoreCase(IdPrefix.SPACEID.getValue())) {
res.put(IdPrefix.SPACEID, (String) args[i]);
}
if(prefix.equalsIgnoreCase(IdPrefix.MODULEID.getValue())) {
if (prefix.equalsIgnoreCase(IdPrefix.MODULEID.getValue())) {
res.put(IdPrefix.MODULEID, (String) args[i]);
}
}
Expand Down
Loading

0 comments on commit f924cbb

Please sign in to comment.