SystemInformation
Hinzugefügt: * Klasse SystemInformation * Ausgabe der Informationen als bebop:systemInformation Fehlt: * Auslesen der Informationen aus einer Properties-Datei * Automatisches Erzeugen der Properties-Datei durch build-skipt git-svn-id: https://svn.libreccm.org/ccm/trunk@2284 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4064358881
commit
d57fe474a8
|
|
@ -30,6 +30,7 @@ import com.arsdigita.developersupport.DeveloperSupport;
|
|||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.profiler.Profiler;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.SystemInformation;
|
||||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -42,7 +43,6 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
@ -175,11 +175,7 @@ public class Page extends BlockStylable implements Container {
|
|||
* URL and use the HttpSession for the rest of the page state.
|
||||
*/
|
||||
private boolean m_useHttpSession = false;
|
||||
/**
|
||||
* HasMap for page generator information.
|
||||
*/
|
||||
private HashMap<String, String> m_pageGenerator = new HashMap<String, String>();
|
||||
|
||||
|
||||
/**
|
||||
* Returns
|
||||
* <code>true</code> if this page should export state through the
|
||||
|
|
@ -566,7 +562,7 @@ public class Page extends BlockStylable implements Container {
|
|||
exportAttributes(page);
|
||||
|
||||
/* Generator information */
|
||||
exportPageGenerator(page);
|
||||
exportSystemInformation(page);
|
||||
|
||||
Element title = page.newChildElement("bebop:title", BEBOP_XML_NS);
|
||||
title.setText(getTitle(ps).getLabel(ps));
|
||||
|
|
@ -892,28 +888,6 @@ public class Page extends BlockStylable implements Container {
|
|||
}
|
||||
}
|
||||
|
||||
final protected void addPageGeneratorInformation(String key, String value) {
|
||||
if (key != null && !key.isEmpty()) {
|
||||
m_pageGenerator.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
final protected String getPageGeneratorInformation(String key) {
|
||||
if (key != null && !key.isEmpty()) {
|
||||
return m_pageGenerator.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final protected String removePageGeneratorInformation(String key) {
|
||||
if (key != null && !key.isEmpty()) {
|
||||
return m_pageGenerator.remove(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export page generator information if set. The m_pageGenerator is a
|
||||
* HashMap containing the information as key value. In general this should
|
||||
|
|
@ -923,11 +897,12 @@ public class Page extends BlockStylable implements Container {
|
|||
*
|
||||
* @pre m_pageGenerator != null && !m_pageGenerator.isEmpty()
|
||||
*/
|
||||
final protected void exportPageGenerator(Element page) {
|
||||
if (m_pageGenerator != null && !m_pageGenerator.isEmpty()) {
|
||||
Element gen = page.newChildElement("bebop:pageGenerator", BEBOP_XML_NS);
|
||||
final protected void exportSystemInformation(Element page) {
|
||||
SystemInformation sysInfo = SystemInformation.getInstance();
|
||||
if (!sysInfo.isEmpty()) {
|
||||
Element gen = page.newChildElement("bebop:systemInformation", BEBOP_XML_NS);
|
||||
|
||||
Iterator<Map.Entry<String, String>> keyValues = ((Set<Map.Entry<String, String>>) m_pageGenerator.entrySet()).iterator();
|
||||
Iterator<Map.Entry<String, String>> keyValues = sysInfo.iterator();
|
||||
while (keyValues.hasNext()) {
|
||||
Map.Entry<String, String> entry = keyValues.next();
|
||||
gen.addAttribute(entry.getKey(), entry.getValue());
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import com.arsdigita.toolbox.CharsetEncodingProvider;
|
|||
import com.arsdigita.ui.admin.Admin;
|
||||
import com.arsdigita.ui.login.Login;
|
||||
import com.arsdigita.ui.permissions.Permissions;
|
||||
import com.arsdigita.util.SystemInformation;
|
||||
import com.arsdigita.util.URLRewriter;
|
||||
import com.arsdigita.web.ApplicationType;
|
||||
import com.arsdigita.web.Host;
|
||||
|
|
@ -188,8 +189,8 @@ public class Initializer extends CompoundInitializer {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Set system informations
|
||||
loadSystemInformation();
|
||||
|
||||
// register the document converters
|
||||
Converter converter = new PDFConverter();
|
||||
|
|
@ -228,4 +229,14 @@ public class Initializer extends CompoundInitializer {
|
|||
s_log.info("Core init(DomainInitEvent) done");
|
||||
}
|
||||
|
||||
private void loadSystemInformation() {
|
||||
SystemInformation sysInfo = SystemInformation.getInstance();
|
||||
|
||||
// Hardcoded for now
|
||||
sysInfo.put("version", "2.1.0");
|
||||
sysInfo.put("appname", "ScientificCMS");
|
||||
sysInfo.put("apphomepage", "www.scientificcms.org");
|
||||
sysInfo.lock();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||
*/
|
||||
public class SystemInformation implements Lockable {
|
||||
|
||||
private Map<String, String> systemInformation = new HashMap<String, String>();
|
||||
private boolean locked = false;
|
||||
/**
|
||||
* The one and only instance of this class
|
||||
*/
|
||||
private static final SystemInformation INSTANCE = new SystemInformation();
|
||||
|
||||
private SystemInformation() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The instance of this class.
|
||||
*/
|
||||
public static SystemInformation getInstance() {
|
||||
return SystemInformation.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put system information into the map. If this instance is locked, this method
|
||||
* throw an {@link AssertionError}.
|
||||
*
|
||||
* @param key Key for the Map. Also used as attribute name during output.
|
||||
* @param value Value
|
||||
* @throws IllegalArgumentException if key or value is null or empty
|
||||
*/
|
||||
final public void put(String key, String value) throws IllegalArgumentException {
|
||||
if (key == null || key.isEmpty()) {
|
||||
throw new IllegalArgumentException("Parameter key must not be null or empty.");
|
||||
}
|
||||
if (value == null || value.isEmpty()) {
|
||||
throw new IllegalArgumentException("Parameter value must not be null or empty.");
|
||||
}
|
||||
// Test if instance is not locked
|
||||
Assert.isUnlocked(this);
|
||||
systemInformation.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system informations by key.
|
||||
*
|
||||
* @param key Key for the map
|
||||
* @return value for key
|
||||
* @throws IllegalArgumentException if key is null or empty
|
||||
*/
|
||||
final public String get(String key) throws IllegalArgumentException {
|
||||
if (key == null || key.isEmpty()) {
|
||||
throw new IllegalArgumentException("Parameter key must not be null or empty.");
|
||||
}
|
||||
return systemInformation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get iterator of this map.
|
||||
*
|
||||
* @return iterator of map
|
||||
*/
|
||||
final public Iterator<Map.Entry<String, String>> iterator() {
|
||||
return ((Set<Map.Entry<String, String>>) systemInformation.entrySet()).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
final public boolean isEmpty() {
|
||||
return systemInformation.isEmpty();
|
||||
}
|
||||
/**
|
||||
* Lock this instance to prevent further changes.
|
||||
*/
|
||||
final public void lock() {
|
||||
locked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test, if this instance is locked.
|
||||
* @return locked
|
||||
*/
|
||||
final public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue