opencms days 2014 - how techem handles international customer portals
TRANSCRIPT
Techem. The world of intelligent energy and water saving solutions
How Techem handles international customer portals
About me: Torsten Berger
Senior Java Developer
Techem Energy Services GmbH
I am using OpenCms for the development of our customer portals with business applications since 2009.
2 The world of intelligent energy and water saving solutions
Our task: to use energy wisely
The Situation
Reducing climate harming CO2 emissions worldwide is a necessity
for us all. Resources, such as oil, gas and water, are in ever shortening supply and are becoming increasingly expensive.
The challenge
Saving energy and reducing water consumption consciously and intelligently.
The Techem solution
Sustainable, comprehensive energy and water management – bringing benefits for the environment and for our customers.
3 The world of intelligent energy and water saving solutions
Techem, your partner full of energy
Techem in figures
• Successfully in the market for over 60 years
• Service provider for almost ten million apartments
• More than 47.2 million measuring devices in use
• World market leader with over 25.4 million radio measuring devices
Save energy and water with Techem
• 22 billion kilowatthours and 6.1 million tons of CO2 thanks to Techem energy saving solutions
• Worldwide 37 million cubic metres less waterconsumption per year with technology from Techem
Source: Figures based on the Felsmann study (billing savings = approx. 20 %) and on the basis of the current Techem 2013 energy reference data.
4 The world of intelligent energy and water saving solutions
We are there for you when you need us
Techem is a global leader in the provision of management solutions and billing of energy and water in properties.
Techem is there for its customers in more than 20 countries.
With almost 100 locations, we have a blanket presence across the German domestic market.
In total, over 3.200 Techem employeesare committed to providing the best possible service for our customers and for the environment.
5 The world of intelligent energy and water saving solutions
Online Services: the Techem Portal
All information with a mouse click
• Available around the clock
• More flexibility, better overview
• Lower administrative costs, less paperwork
Convenient solutions
• Billing Online, Archive Online
• Info Center, Online Orders
• Techem Monitoring
• adapterm Cockpit
6 The world of intelligent energy and water saving solutions
Portlet: Style in OpenCms
Style information provided by OpenCms Modul
• Portlets do not have separate css files anymore
• OpenCms Pages and Portlets use the same css files
• Portlet Showcase with all used components get styled not the portlet
• Styling is done external by an agency
9 The world of intelligent energy and water saving solutions
Portlet for OpenCms: Where do I get it
https://github.com/eonas
• opencmsinstaller
• opencmsportaldriver
• addressbookportlet
• opencmsportal
• https://github.com/eonas/opencmsportal/wiki
10 The world of intelligent energy and water saving solutions
TMAC for Portlets: TranslationManangementAndConfiguration
11 The world of intelligent energy and water saving solutions
Application
Translations
Country
Configuration
Default German Default EnglishCountry Languages
e.g. columnse.g. Address Default Configuration
Hardware: Architectur New <> Old
12 The world of intelligent energy and water saving solutions
OpenCMSMaster
OpenCMSSlave1
OpenCMSSlave2
Proxy1Proxy2
Portal User
OCEE-Cluster
Loadbalancer
https / Firewall
LDAP Server
Old World
• Country = seperate Cluster
New World
• Country = Site in Cluster
Scripting: Rhino <> OpenCmsShell
13 The world of intelligent energy and water saving solutions
22 Countries / Sites
Rhino = Javascript support in Java 6
Provides full access back into OpenCms Java Code
OpenCmsShell
automated import / export Do some XML Modifications
<%@ page import="org.opencms.file.CmsObject" %><%@ page import="org.opencms.jsp.CmsJspBean" %><%@ page import="javax.script.ScriptEngine" %><%@ page import="javax.script.ScriptEngineManager" %><%@ page import="java.io.ByteArrayOutputStream" %><%@ page import="java.io.PrintWriter" %><%@page buffer="none" session="false" %><%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><% ServletInputStream inputStream = request.getInputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); byte[] bb = new byte[1024]; int len;
while ( (len = inputStream.read(bb)) != 1 ) { buffer.write(bb, 0, len); } inputStream.close();
String script = new String(buffer.toByteArray(), "utf8");
CmsJspBean cmsBean = new CmsJspBean(); cmsBean.init(pageContext, request, response); final CmsObject cmsobject = cmsBean.getCmsObject();
response.setContentType("text/plain"); PrintWriter writer = response.getWriter();
ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.getContext().setWriter(writer); engine.getContext().setErrorWriter(writer);
engine.put("cms", cmsBean); engine.put("cmsObject", cmsobject);
writer.write("Start\n"); try { engine.eval(script); } catch ( Exception ex ) { ex.printStackTrace(writer); } writer.write("Stop\n"); writer.close();%>
Scripting: Enable OpenCms for JavaScript
• This Jsp e.g. „/system/script/javascript.jsp“ in OpenCms executes the transfered JavaScript in an OpenCms Context.
• Lets see next page for how to call this file.
14
Scripting: The other side
15
package de.eonas.opencms.remotescript;
import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.URL;import java.net.URLConnection;
import org.apache.commons.io.IOUtils;
public class Client {
public static void main(String[] args) throws Exception {Client client = new Client();
client.execute();}
public void execute() throws IOException {URL u = new URL("http://localhost:8080/cms/system/script/javascript.jsp");URLConnection urlConnection = u.openConnection();urlConnection.addRequestProperty("ContentType", "text/plain");urlConnection.setDoInput(true);urlConnection.setDoOutput(true);urlConnection.connect();
OutputStream outputStream = urlConnection.getOutputStream();copy(outputStream, "/variablen.js");copy(outputStream, "/functions.js");copy(outputStream, "/do.js");outputStream.close();
InputStream inputStream = urlConnection.getInputStream();IOUtils.copy(inputStream, System.out);
}
private void copy(OutputStream outputStream, String file) throws IOException {InputStream resourceAsStream = this.getClass().getResourceAsStream(file);IOUtils.copy(resourceAsStream, outputStream);resourceAsStream.close();
}}
• This Javacode transfers the Javascript files via post request to OpenCms.
• Lets see next page for the new functionality via the included JavaScript.
Scripting: JavaScript Example to execute
Time for a Demo....
• Use content template „/shared/demo“
• Create a new country with different locale trees
• Customise properties on locale subsidemap
• Switch „target“in containerpages from shared elements to new country elements
• Customise Property Navigationtext
• Customise Property Description
• And many more posibilities
• Create Permissions for new Country
• Make Sibling to real file
16 The world of intelligent energy and water saving solutions
...login('Admin', 'admin');project('Offline');
var siteLand = '/sites/kp_demo';var sprachen = ['en', 'de', 'da'];
copyFromShared(siteLand, sprachen, true);customizeNavTextProperty(siteLand, 'en');customizeDescriptionProperty(siteLand, 'en');...