mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
Merge pull request #1363 from tuub/DS-3107
DS-3107: NewsService should allow localized news files
This commit is contained in:
@@ -16,12 +16,15 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.core.service.NewsService;
|
import org.dspace.core.service.NewsService;
|
||||||
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulate access to the news texts.
|
* Encapsulate access to the news texts.
|
||||||
@@ -34,9 +37,30 @@ public class NewsServiceImpl implements NewsService
|
|||||||
|
|
||||||
private List<String> acceptableFilenames;
|
private List<String> acceptableFilenames;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
private ConfigurationService configurationService;
|
||||||
|
|
||||||
public void setAcceptableFilenames(List<String> acceptableFilenames) {
|
public void setAcceptableFilenames(List<String> acceptableFilenames) {
|
||||||
this.acceptableFilenames = acceptableFilenames;
|
this.acceptableFilenames = addLocalesToAcceptableFilenames(acceptableFilenames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<String> addLocalesToAcceptableFilenames(List<String> acceptableFilenames){
|
||||||
|
String [] locales = configurationService.getArrayProperty("webui.supported.locales");
|
||||||
|
List<String> newAcceptableFilenames = new ArrayList<>();
|
||||||
|
newAcceptableFilenames.addAll(acceptableFilenames);
|
||||||
|
for(String local : locales){
|
||||||
|
for(String acceptableFilename : acceptableFilenames){
|
||||||
|
int lastPoint = acceptableFilename.lastIndexOf(".");
|
||||||
|
newAcceptableFilenames.add(
|
||||||
|
acceptableFilename.substring(0, lastPoint)
|
||||||
|
+ "_"
|
||||||
|
+ local
|
||||||
|
+ acceptableFilename.substring(lastPoint));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newAcceptableFilenames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Not instantiable. */
|
/** Not instantiable. */
|
||||||
protected NewsServiceImpl() {}
|
protected NewsServiceImpl() {}
|
||||||
|
Reference in New Issue
Block a user