Commit d5be0aa3af99959624e8715ea6966a9017886c97

Authored by Fernando Ribeiro
1 parent 5ed3dd6560

DS-3063 Ensure proper access to news files

Added the pt files because it will throw an internal error if they doesen't exist
dspace-api/src/main/java/org/dspace/core/NewsServiceImpl.java
... ... @@ -0,0 +1,22 @@
  1 +package org.dspace.core;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.dspace.core.service.NewsService;
  6 +
  7 +public class NewsServiceImpl implements NewsService {
  8 + private List<String> acceptableFilenames;
  9 +
  10 + public void setAcceptableFilenames(List<String> acceptableFilenames) {
  11 + this.acceptableFilenames = acceptableFilenames;
  12 + }
  13 +
  14 + @Override
  15 + public boolean validate(String newsName) {
  16 + if (acceptableFilenames != null) {
  17 + return acceptableFilenames.contains(newsName);
  18 + }
  19 + return false;
  20 + }
  21 +
  22 +}
... ...
dspace-api/src/main/java/org/dspace/core/service/NewsService.java
... ... @@ -0,0 +1,5 @@
  1 +package org.dspace.core.service;
  2 +
  3 +public interface NewsService {
  4 + boolean validate(String newsName);
  5 +}
... ...
dspace/config/spring/api/core-services.xml
... ... @@ -0,0 +1,24 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!--
  3 + The contents of this file are subject to the license and copyright
  4 + detailed in the LICENSE and NOTICE files at the root of the source
  5 + tree and available online at
  6 + http://www.dspace.org/license/
  7 +-->
  8 +<beans xmlns="http://www.springframework.org/schema/beans"
  9 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10 + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" default-lazy-init="true">
  11 +
  12 + <bean class="org.dspace.core.NewsServiceImpl"
  13 + id="org.dspace.core.service.NewsService">
  14 + <property name="acceptableFilenames">
  15 + <list>
  16 + <value>news-top.html</value>
  17 + <value>news-side.html</value>
  18 + <value>news-top_pt.html</value>
  19 + <value>news-side_pt.html</value>
  20 + </list>
  21 + </property>
  22 + </bean>
  23 +
  24 +</beans>
0 25 \ No newline at end of file
... ...