*** empty log message ***
This commit is contained in:
73
src/venice-base/com/silverwrist/venice/ButtonType.java
Normal file
73
src/venice-base/com/silverwrist/venice/ButtonType.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.commons.lang.enum.*;
|
||||
|
||||
public final class ButtonType extends Enum
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* The actual enumeration values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final ButtonType IMAGE = new ButtonType("IMAGE");
|
||||
public static final ButtonType INPUT = new ButtonType("INPUT");
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ButtonType(String name)
|
||||
{
|
||||
super(name);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Standard static method implementations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static ButtonType getEnum(String name)
|
||||
{
|
||||
return (ButtonType)getEnum(ButtonType.class,name);
|
||||
|
||||
} // end getEnum
|
||||
|
||||
public static Map getEnumMap()
|
||||
{
|
||||
return getEnumMap(ButtonType.class);
|
||||
|
||||
} // end getEnumMap
|
||||
|
||||
public static List getEnumList()
|
||||
{
|
||||
return getEnumList(ButtonType.class);
|
||||
|
||||
} // end getEnumList
|
||||
|
||||
public static Iterator iterator()
|
||||
{
|
||||
return iterator(ButtonType.class);
|
||||
|
||||
} // end iterator
|
||||
|
||||
} // end class ButtonType
|
||||
61
src/venice-base/com/silverwrist/venice/VeniceNamespaces.java
Normal file
61
src/venice-base/com/silverwrist/venice/VeniceNamespaces.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice;
|
||||
|
||||
public interface VeniceNamespaces
|
||||
{
|
||||
public static final String FRAME_LAF_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/21/frame.look.and.feel";
|
||||
|
||||
public static final String SESSION_INFO_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/22/session.info";
|
||||
|
||||
public static final String STYLESHEET_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/22/stylesheets";
|
||||
|
||||
public static final String MAIL_PROPS_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/28/mail.properties";
|
||||
|
||||
public static final String CONTENT_LAF_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/28/content.look.and.feel";
|
||||
|
||||
// public static final String VENICE_OBJECT_NAMESPACE =
|
||||
// "http://www.silverwrist.com/NS/venice/2002/12/28/venice.objects";
|
||||
|
||||
public static final String REQUEST_INFO_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/29/request.info";
|
||||
|
||||
public static final String SESSION_CONTROL_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/30/session.control";
|
||||
|
||||
public static final String SYSTEM_EVENT_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/31/system.events";
|
||||
|
||||
public static final String USER_EVENT_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/31/user.events";
|
||||
|
||||
public static final String USER_SETTINGS_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/31/user.settings";
|
||||
|
||||
public static final String USER_PROFILE_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2002/12/31/user.profile";
|
||||
|
||||
public static final String MAIL_MESSAGES_NAMESPACE =
|
||||
"http://www.silverwrist.com/NS/venice/2003/01/03/system.mail.messages";
|
||||
|
||||
} // end interface VeniceNamespaces
|
||||
24
src/venice-base/com/silverwrist/venice/VeniceVersion.java
Normal file
24
src/venice-base/com/silverwrist/venice/VeniceVersion.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice;
|
||||
|
||||
public final class VeniceVersion
|
||||
{
|
||||
public static final String VERSION = "0.05";
|
||||
|
||||
} // end class VeniceVersion
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class StartupShutdownAuditor implements NamedObject, ComponentInitialize, ComponentShutdown, ApplicationListener
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(StartupShutdownAuditor.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name;
|
||||
private AuditRecordFactory m_audit;
|
||||
private ComponentShutdown m_shut_event;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public StartupShutdownAuditor()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("StartupShutdownAuditor initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in StartupShutdownAuditor",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the audit record provider.
|
||||
m_audit = (AuditRecordFactory)(services.queryService(AuditRecordFactory.class));
|
||||
|
||||
// Register us as an application listener.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
m_shut_event = reg.registerApplicationListener(this);
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut_event.shutdown();
|
||||
m_shut_event = null;
|
||||
m_audit = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ApplicationListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void applicationInitialized(ApplicationEvent event)
|
||||
{
|
||||
AuditRecordCompose rec =
|
||||
m_audit.createSystemAuditRecord(VeniceNamespaces.SYSTEM_EVENT_NAMESPACE,"system.startup");
|
||||
rec.write();
|
||||
|
||||
} // end applicationInitialized
|
||||
|
||||
public void applicationExiting(ApplicationEvent event)
|
||||
{
|
||||
AuditRecordCompose rec =
|
||||
m_audit.createSystemAuditRecord(VeniceNamespaces.SYSTEM_EVENT_NAMESPACE,"system.shutdown");
|
||||
rec.write();
|
||||
|
||||
} // end applicationExiting
|
||||
|
||||
} // end class StartupShutdownAuditor
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class UserDefaultNamespaceHolder
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, UserDefaultPropertyNamespace,
|
||||
UserDefaultPropertyNamespaceRegistration
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(UserDefaultNamespaceHolder.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name;
|
||||
private Vector m_ns_list = new Vector();
|
||||
private ComponentShutdown m_shut1;
|
||||
private ComponentShutdown m_shut2;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public UserDefaultNamespaceHolder()
|
||||
{
|
||||
m_ns_list.add(VeniceNamespaces.USER_SETTINGS_NAMESPACE);
|
||||
m_ns_list.add(VeniceNamespaces.USER_PROFILE_NAMESPACE);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("UserDefaultNamespaceHolder initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in UserDefaultNamespaceHolder",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Create ServiceProvider interfaces.
|
||||
SingletonServiceProvider runtime_svcs =
|
||||
new SingletonServiceProvider("UserDefaultNamespaceHolder",UserDefaultPropertyNamespace.class,this);
|
||||
SingletonServiceProvider init_svcs =
|
||||
new SingletonServiceProvider("UserDefaultNamespaceHolder",runtime_svcs,
|
||||
UserDefaultPropertyNamespaceRegistration.class,this);
|
||||
|
||||
// Hook the services provided by Dynamo.
|
||||
HookServiceProviders hooker = (HookServiceProviders)(services.queryService(HookServiceProviders.class));
|
||||
m_shut1 = hooker.hookInitServiceProvider(init_svcs);
|
||||
m_shut2 = hooker.hookRuntimeServiceProvider(runtime_svcs);
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shuts down the component associated with this interface, in a component-specific manner.
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut2.shutdown();
|
||||
m_shut2 = null;
|
||||
m_shut1.shutdown();
|
||||
m_shut1 = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface UserDefaultPropertyNamespace
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Collection getDefaultPropertyNamespaces()
|
||||
{
|
||||
ArrayList rc = new ArrayList(m_ns_list);
|
||||
return Collections.unmodifiableList(rc);
|
||||
|
||||
} // end getDefaultPropertyNamespaces
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface UserDefaultPropertyNamespaceRegistration
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ComponentShutdown registerUserDefaultPropertyNamespace(String namespace)
|
||||
{
|
||||
m_ns_list.add(namespace);
|
||||
return new ShutdownVectorRemove(m_ns_list,namespace);
|
||||
|
||||
} // end registerUserDefaultPropertyNamespace
|
||||
|
||||
} // end class UserDefaultNamespaceHolder
|
||||
@@ -0,0 +1,28 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
regy.already=An object with the name "{0}" has already been registered in the Venice object registry.
|
||||
dlgLAF.init=Unable to initialize the Venice dialog look-and-feel object.
|
||||
cheader.fail=Unable to get content header object: {0}
|
||||
xtitle.auth=Authentication Error
|
||||
xtitle.dbase=Database Error
|
||||
xtitle.dlg=Dialog Error
|
||||
xtitle.secure=Security Violation
|
||||
xtitle.mail=Mail Error
|
||||
xtitle.script=Scripting Error
|
||||
xtitle.style=Style Sheet Error
|
||||
xtitle.valid=Validation Error
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.db.UserPropertyTranslator;
|
||||
import com.silverwrist.dynamo.db.UserPropertyTranslatorInstall;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRendererConfig;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.VeniceVersion;
|
||||
import com.silverwrist.venice.content.*;
|
||||
import com.silverwrist.venice.dialog.*;
|
||||
import com.silverwrist.venice.frame.FrameAssembler;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
import com.silverwrist.venice.menu.*;
|
||||
import com.silverwrist.venice.script.*;
|
||||
import com.silverwrist.venice.session.VeniceSessionManager;
|
||||
|
||||
public class VeniceApplication implements ComponentShutdown, Application, StylesheetMapper
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class implementing initialization code
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private class AppInit implements ComponentInitialize
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
AppInit()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface ComponentInitialize
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"application");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// load the stylesheet mappings
|
||||
Element sect = loader.getSubElement(config_root,"stylesheet-mappings");
|
||||
List l = loader.getMatchingSubElements(sect,"stylesheet");
|
||||
Iterator it = l.iterator();
|
||||
while (it.hasNext())
|
||||
{ // load the stylesheet mappings
|
||||
Element elt = (Element)(it.next());
|
||||
m_stylesheet_mappings.put(loader.getAttribute(elt,"path"),loader.getAttribute(elt,"prefix"));
|
||||
|
||||
} // end while
|
||||
|
||||
logger.info("Venice application '" + m_name + "' configuration initialized");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Install the exception translator.
|
||||
ExceptionTranslatorRegistration etreg =
|
||||
(ExceptionTranslatorRegistration)(services.queryService(ExceptionTranslatorRegistration.class));
|
||||
m_shutdown_list.addFirst(etreg.registerExceptionTranslator(new VeniceExceptionTranslator()));
|
||||
|
||||
// Install the user property translator.
|
||||
UserPropertyTranslatorInstall upti =
|
||||
(UserPropertyTranslatorInstall)(GetObjectUtils.getDynamoComponent(services,
|
||||
UserPropertyTranslatorInstall.class,"users"));
|
||||
upti.installUserPropertyTranslator(new VeniceUserPropertyTranslator());
|
||||
|
||||
// Customize the script engine.
|
||||
ScriptEngineConfig sconf = (ScriptEngineConfig)(services.queryService(ScriptEngineConfig.class));
|
||||
m_shutdown_list.addFirst(sconf.addDeclaredObject("vcast",new LibraryVeniceCast(),
|
||||
LibraryVeniceCast.class));
|
||||
m_shutdown_list.addFirst(sconf.addDeclaredObject("vlib",new LibraryVenice(),LibraryVenice.class));
|
||||
|
||||
// Customize the Velocity renderer.
|
||||
VelocityRendererConfig vrcon =
|
||||
(VelocityRendererConfig)(services.queryService(VelocityRendererConfig.class));
|
||||
m_shutdown_list.addFirst(vrcon.addStandardComponentClass("datefmt",DateFormatterTopHalf.class));
|
||||
|
||||
// Done with initialization
|
||||
logger.info("Venice application '" + m_name + "' initialization done");
|
||||
|
||||
} // end initialize
|
||||
|
||||
} // end class AppInit
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(VeniceApplication.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name; // the name of this object
|
||||
private HashMap m_stylesheet_mappings = new HashMap(); // stylesheet hash mappings
|
||||
private LinkedList m_shutdown_list = new LinkedList(); // shutdown list
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public VeniceApplication()
|
||||
{
|
||||
logger.info("Constructing new VeniceApplication");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
logger.info("Venice application '" + m_name + "' shutting down!");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("(" + m_shutdown_list.size() + " app-level component(s) to shutdown)");
|
||||
|
||||
while (m_shutdown_list.size()>0)
|
||||
{ // shut down all components on the shutdown list
|
||||
ComponentShutdown cs = (ComponentShutdown)(m_shutdown_list.removeFirst());
|
||||
cs.shutdown();
|
||||
|
||||
} // end while
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass)
|
||||
{
|
||||
if (klass==ComponentInitialize.class)
|
||||
return (ComponentInitialize)(new AppInit());
|
||||
if (klass==StylesheetMapper.class)
|
||||
return (StylesheetMapper)this;
|
||||
throw new NoSuchServiceException("VeniceApplication",klass);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @param serviceid ID for the service to be requested, to further discriminate between requests.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass, String serviceid)
|
||||
{
|
||||
try
|
||||
{ // try querying without the service ID
|
||||
return queryService(klass);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // throw a real exception
|
||||
throw new NoSuchServiceException(e.getContext(),klass,serviceid,e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end queryService
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface Application
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getIdentity()
|
||||
{
|
||||
return "Venice/" + VeniceVersion.VERSION;
|
||||
|
||||
} // end getIdentity
|
||||
|
||||
public Object getNullContentError(Request r)
|
||||
{
|
||||
return new ErrorBox(null,"Null content returned from request " + r.getContextPath()
|
||||
+ r.getRequestPath() + "!!");
|
||||
|
||||
} // end getNullContentError
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface StylesheetMapper
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getStylesheetPrefix(String path)
|
||||
{
|
||||
return (String)(m_stylesheet_mappings.get(path));
|
||||
|
||||
} // end getStylesheetPrefix
|
||||
|
||||
} // end class VeniceApplication
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.image.ImageNormalizerException;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.content.*;
|
||||
import com.silverwrist.venice.except.*;
|
||||
|
||||
class VeniceExceptionTranslator implements ExceptionTranslator
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
VeniceExceptionTranslator()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ExceptionTranslator
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object translateException(Request r, Exception e)
|
||||
{
|
||||
// get the title for this exception
|
||||
String title = null;
|
||||
if (e instanceof AuthenticationException)
|
||||
title = "xtitle.auth";
|
||||
else if (e instanceof DatabaseException)
|
||||
title = "xtitle.dbase";
|
||||
else if (e instanceof DialogException)
|
||||
title = "xtitle.dlg";
|
||||
else if (e instanceof DynamoSecurityException)
|
||||
title = "xtitle.secure";
|
||||
else if (e instanceof MailException)
|
||||
title = "xtitle.mail";
|
||||
else if (e instanceof ScriptingException)
|
||||
title = "xtitle.script";
|
||||
else if (e instanceof StyleSheetException)
|
||||
title = "xtitle.style";
|
||||
else if (e instanceof ValidationException)
|
||||
title = "xtitle.valid";
|
||||
else if (e instanceof ImageNormalizerException)
|
||||
title = "xtitle.image";
|
||||
|
||||
// get the error locations
|
||||
String onerr = (String)(PropertyUtils.getPropertyNoErr(r,VeniceNamespaces.REQUEST_INFO_NAMESPACE,
|
||||
"on.error"));
|
||||
String onerr_type = (String)(PropertyUtils.getPropertyNoErr(r,VeniceNamespaces.REQUEST_INFO_NAMESPACE,
|
||||
"on.error.type"));
|
||||
String prefix = "";
|
||||
if (title!=null)
|
||||
{ // look up actual title in resource bundle
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.app.VeniceAppMessages",
|
||||
Locale.getDefault());
|
||||
title = b.getString(title);
|
||||
|
||||
} // end if
|
||||
else
|
||||
prefix = e.getClass().getName() + ": ";
|
||||
|
||||
if (onerr!=null)
|
||||
return new ErrorBox(title,prefix + e.getMessage(),onerr_type,onerr);
|
||||
else
|
||||
return new ErrorBox(title,prefix + e.getMessage());
|
||||
|
||||
} // end translateException
|
||||
|
||||
} // end class VeniceExceptionTranslator
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import com.silverwrist.dynamo.db.UserPropertyTranslator;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
class VeniceUserPropertyTranslator implements UserPropertyTranslator
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
VeniceUserPropertyTranslator()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface UserPropertyTranslator
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getUserFullName(DynamoUser user)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String s = (String)(PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"name.prefix"));
|
||||
if (s!=null)
|
||||
buf.append(s).append(" ");
|
||||
buf.append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.given").toString()).append(" ");
|
||||
Character ch = (Character)(PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"name.mi"));
|
||||
if (ch!=null)
|
||||
buf.append(ch).append(". ");
|
||||
buf.append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.family").toString());
|
||||
s = (String)(PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.suffix"));
|
||||
if (s!=null)
|
||||
buf.append(" ").append(s);
|
||||
return buf.toString();
|
||||
|
||||
} // end getUserFullName
|
||||
|
||||
} // end class VeniceUserPropertyTranslator
|
||||
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.io.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRendererConfig;
|
||||
import com.silverwrist.venice.ButtonType;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class ButtonSupplier
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, DynamicUpdateListener, ServiceProvider,
|
||||
ButtonProvider, TextRenderer
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class implementing Velocity button provider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public class StdButton
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
StdButton()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* External operations
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public Object getButton(String type, String name)
|
||||
{
|
||||
return getButtonRenderObject(ButtonType.getEnum(type.trim().toUpperCase()),name);
|
||||
|
||||
} // end getButton
|
||||
|
||||
} // end class StdButton
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(ButtonSupplier.class);
|
||||
|
||||
private static final String NAMESPACE = VeniceNamespaces.CONTENT_LAF_NAMESPACE;
|
||||
|
||||
private static final String PROP_SUBDIR = "subdir.buttons";
|
||||
private static final String PROP_WIDTH = "std.button.width";
|
||||
private static final String PROP_HEIGHT = "std.button.height";
|
||||
private static final String PROP_PREFIX_BUTTON = "bn.";
|
||||
private static final String PROP_PREFIX_CAPTION = "bnc.";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name = null; // name of this object
|
||||
private ObjectProvider m_props; // property set provider
|
||||
private ComponentShutdown m_shut_event; // shutdown for event listener
|
||||
private ComponentShutdown m_shut_render; // shutdown for renderer
|
||||
private ComponentShutdown m_shut_vr; // shutdown for Velocity object
|
||||
private String m_subdir; // subdirectory in which button images are
|
||||
private int m_width; // width of buttons
|
||||
private int m_height; // height of buttons
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ButtonSupplier()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final String getInitString(String name) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to the property provider
|
||||
return (String)(m_props.getObject(NAMESPACE,name));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // the property value isn't present? yIkes!
|
||||
ConfigException ce = new ConfigException(ButtonSupplier.class,"ContentMessages","prop.missing",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // not a String? for shame!
|
||||
ConfigException ce = new ConfigException(ButtonSupplier.class,"ContentMessages","prop.wrongType",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getInitString
|
||||
|
||||
private final int getInitInteger(String name) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to the property provider
|
||||
return ((Integer)(m_props.getObject(NAMESPACE,name))).intValue();
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // the property value isn't present? yIkes!
|
||||
ConfigException ce = new ConfigException(ButtonSupplier.class,"ContentMessages","prop.missing",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // not an Integer? for shame!
|
||||
ConfigException ce = new ConfigException(ButtonSupplier.class,"ContentMessages","prop.wrongType",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getInitInteger
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("ButtonSupplier initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the global properties object
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"global-properties");
|
||||
gprops = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in ButtonSupplier",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the standard properties provider.
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,gprops));
|
||||
try
|
||||
{ // get the "properties" service from that object
|
||||
m_props = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"properties"));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
logger.fatal("Unable to find global properties object \"" + gprops + "\"",e);
|
||||
throw new ConfigException(ButtonSupplier.class,"ContentMessages","init.noProp",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the initial property values for our most used properties.
|
||||
m_subdir = getInitString(PROP_SUBDIR);
|
||||
m_width = getInitInteger(PROP_WIDTH);
|
||||
m_height = getInitInteger(PROP_HEIGHT);
|
||||
|
||||
// Register with the event listener to monitor those property values.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
m_shut_event = reg.registerDynamicUpdateListener(GlobalPropertyUpdateEvent.class,this);
|
||||
|
||||
// Register us as being a renderer for ButtonToken objects (which we generate).
|
||||
RendererRegistration rr = (RendererRegistration)(services.queryService(RendererRegistration.class));
|
||||
m_shut_render = rr.registerRenderer(ButtonToken.class,this);
|
||||
|
||||
// Add an object to the standard objects available to Velocity.
|
||||
VelocityRendererConfig vrcon =
|
||||
(VelocityRendererConfig)(services.queryService(VelocityRendererConfig.class));
|
||||
m_shut_vr = vrcon.addStandardComponentInstance("button",new StdButton());
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut_vr.shutdown();
|
||||
m_shut_vr = null;
|
||||
m_shut_event.shutdown();
|
||||
m_shut_event = null;
|
||||
m_shut_render.shutdown();
|
||||
m_shut_render = null;
|
||||
m_props = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
GlobalPropertyUpdateEvent event = (GlobalPropertyUpdateEvent)evt;
|
||||
if (NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // see if this is one of the properties we monitor
|
||||
try
|
||||
{ // reuse the "initialization" getters here
|
||||
if (PROP_SUBDIR.equals(event.getPropertyName()))
|
||||
{ // process new subdirectory
|
||||
String s = getInitString(PROP_SUBDIR);
|
||||
m_subdir = s;
|
||||
|
||||
} // end if
|
||||
else if (PROP_WIDTH.equals(event.getPropertyName()))
|
||||
{ // process new width
|
||||
int x = getInitInteger(PROP_WIDTH);
|
||||
m_width = x;
|
||||
|
||||
} // end else if
|
||||
else if (PROP_HEIGHT.equals(event.getPropertyName()))
|
||||
{ // process new height
|
||||
int x = getInitInteger(PROP_HEIGHT);
|
||||
m_height = x;
|
||||
|
||||
} // end else if
|
||||
|
||||
} // end try
|
||||
catch (ConfigException ce)
|
||||
{ // property get failed - don't change the value
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass)
|
||||
{
|
||||
if (klass==ButtonProvider.class)
|
||||
return (ButtonProvider)this;
|
||||
throw new NoSuchServiceException(getName(),klass);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @param serviceid ID for the service to be requested, to further discriminate between requests.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass, String serviceid)
|
||||
{
|
||||
if (klass==ButtonProvider.class)
|
||||
return (ButtonProvider)this;
|
||||
throw new NoSuchServiceException(getName(),klass,serviceid);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ButtonProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object getButtonRenderObject(ButtonType type, String name)
|
||||
{
|
||||
try
|
||||
{ // get the button image name and return our object
|
||||
String image_name = (String)(m_props.getObject(NAMESPACE,PROP_PREFIX_BUTTON + name));
|
||||
String caption = (String)(m_props.getObject(NAMESPACE,PROP_PREFIX_CAPTION + name));
|
||||
return new ButtonToken(type,name,image_name,caption);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // encapsulate the error message so we'll get it later
|
||||
RenderingException re = new RenderingException(ButtonSupplier.class,"ContentMessages",
|
||||
"button.missing",e);
|
||||
re.setParameter(0,name);
|
||||
return new RenderingExceptionWrapper(re);
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // encapsulate the error message so we'll get it later
|
||||
RenderingException re = new RenderingException(ButtonSupplier.class,"ContentMessages",
|
||||
"button.wrongType",e);
|
||||
re.setParameter(0,name);
|
||||
return new RenderingExceptionWrapper(re);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getButtonRenderObject
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface TextRenderer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(Object obj, TextRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
URLRewriter rewrite = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
PrintWriter wr = control.getWriter();
|
||||
ButtonToken token = (ButtonToken)obj;
|
||||
|
||||
// get the full URL of the image
|
||||
String image_url = rewrite.rewriteURL("IMAGE",m_subdir + "/" + token.getImageName());
|
||||
|
||||
// render as <image/> tag
|
||||
if (ButtonType.IMAGE.equals(token.getType()))
|
||||
wr.write("<img src=\"" + image_url + "\" alt=\"[" + token.getCaption() + "]\" width = \"" + m_width
|
||||
+ "\" height=\"" + m_height + "\" border=\"0\" />");
|
||||
|
||||
// render as <input type="image"/> tag
|
||||
if (ButtonType.INPUT.equals(token.getType()))
|
||||
wr.write("<input type=\"image\" src=\"" + image_url + "\" name=\"" + token.getName() + "\" alt=\""
|
||||
+ token.getCaption() + "\" width=\"" + m_width + "\" height=\"" + m_height
|
||||
+ "\" border=\"0\" />");
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class ButtonSupplier
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import com.silverwrist.venice.ButtonType;
|
||||
|
||||
class ButtonToken
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ButtonType m_type;
|
||||
private String m_name;
|
||||
private String m_image_name;
|
||||
private String m_caption;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ButtonToken(ButtonType type, String name, String image_name, String caption)
|
||||
{
|
||||
m_type = type;
|
||||
m_name = name;
|
||||
m_image_name = image_name;
|
||||
m_caption = caption;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ButtonType getType()
|
||||
{
|
||||
return m_type;
|
||||
|
||||
} // end getType
|
||||
|
||||
String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
String getImageName()
|
||||
{
|
||||
return m_image_name;
|
||||
|
||||
} // end getImageName
|
||||
|
||||
String getCaption()
|
||||
{
|
||||
return m_caption;
|
||||
|
||||
} // end getCaption
|
||||
|
||||
} // end class ButtonToken
|
||||
@@ -0,0 +1,29 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
init.noBlock=Unable to load the standard global block provider.
|
||||
init.noProp=Unable to load the standard global properties provider.
|
||||
prop.missing=Unable to load the value of standard property "{0}".
|
||||
prop.wrongType=The value of property "{0}" is of the wrong type.
|
||||
button.missing=The definition for button image "{0}" is missing.
|
||||
button.wrongType=The definition for button image "{0}" is the wrong type.
|
||||
default.errorBox.title=Error!
|
||||
render.errorBox=Unable to render an error box: {0}\nBox title was: {1}\nBox message was: {2}
|
||||
activity.never=Never
|
||||
activity.today=Today, {0}
|
||||
activity.yesterday=Yesterday, {0}
|
||||
activity.daysago={0} days ago
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
abstract class DateFormatterBottomHalf
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected DateFormatterBottomHalf()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
abstract Locale getLocale();
|
||||
|
||||
abstract TimeZone getTimeZone();
|
||||
|
||||
} // end class DateFormatterBottomHalf
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class DateFormatterTopHalf
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final String NAMESPACE = VeniceNamespaces.SESSION_INFO_NAMESPACE;
|
||||
public static final String PROPERTY = "date.formatter.bh";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private DateFormatterBottomHalf m_bh = null; // bottom half we get our data from
|
||||
private DateFormat m_display_date = null; // format to use for displaying dates
|
||||
private DateFormat m_activity_time = null; // format to use for activity string times
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public DateFormatterTopHalf(ServiceProvider sp)
|
||||
{
|
||||
try
|
||||
{ // get the SessionInfoProvider and the SessionInfo from the services
|
||||
SessionInfoProvider sip = (SessionInfoProvider)(sp.queryService(SessionInfoProvider.class));
|
||||
SessionInfo session = sip.getSessionInfo();
|
||||
|
||||
// now get the bottom half!
|
||||
m_bh = (DateFormatterBottomHalf)(session.getObject(NAMESPACE,PROPERTY));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // ignore this exception
|
||||
} // end catch
|
||||
catch (NoSuchObjectException e)
|
||||
{ // ignore this exception
|
||||
} // end catch
|
||||
|
||||
if (m_bh==null) // default this!
|
||||
m_bh = new DefaultDateFormatterBottomHalf(sp);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String formatDate(java.util.Date date)
|
||||
{
|
||||
synchronized (this)
|
||||
{ // create the display date formatter if we don't yet have it
|
||||
if (m_display_date==null)
|
||||
{ // create the display date formatter
|
||||
m_display_date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,m_bh.getLocale());
|
||||
m_display_date.setTimeZone(m_bh.getTimeZone());
|
||||
|
||||
} // end if
|
||||
|
||||
} // end synchronized block
|
||||
|
||||
return m_display_date.format(date);
|
||||
|
||||
} // end formatDate
|
||||
|
||||
public String getActivityString(Date date)
|
||||
{
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.content.ContentMessages",
|
||||
Locale.getDefault());
|
||||
if (date==null)
|
||||
return b.getString("activity.never"); // safeguard
|
||||
|
||||
// Set up the two calendars we'll use for comparison.
|
||||
Calendar c_last = new GregorianCalendar(m_bh.getTimeZone(),m_bh.getLocale());
|
||||
c_last.setTime(date);
|
||||
Calendar c_now = new GregorianCalendar(m_bh.getTimeZone(),m_bh.getLocale());
|
||||
|
||||
// Determine the exact number of days in the delta.
|
||||
int delta_days = 0;
|
||||
while ( (c_last.get(Calendar.YEAR)!=c_now.get(Calendar.YEAR))
|
||||
|| (c_last.get(Calendar.DAY_OF_YEAR)!=c_now.get(Calendar.DAY_OF_YEAR)))
|
||||
{ // advance until we're pointing at the same year and the same day of the year
|
||||
delta_days++;
|
||||
c_last.add(Calendar.DAY_OF_YEAR,1);
|
||||
|
||||
} // end while
|
||||
|
||||
// For today or yesterday, we want to paste the time in as well.
|
||||
String s = null;
|
||||
if (delta_days<=1)
|
||||
{ // set up to convert the time into a string
|
||||
synchronized (this)
|
||||
{ // make sure we don't accidentally create the object twice
|
||||
if (m_activity_time==null)
|
||||
{ // get the "activity" time formatter
|
||||
m_activity_time = DateFormat.getTimeInstance(DateFormat.MEDIUM,m_bh.getLocale());
|
||||
m_activity_time.setTimeZone(m_bh.getTimeZone());
|
||||
|
||||
} // end if
|
||||
|
||||
} // end synchronized block
|
||||
|
||||
s = m_activity_time.format(date);
|
||||
|
||||
} // end if
|
||||
|
||||
// Return the actual activity string.
|
||||
String pattern = null;
|
||||
Object[] args = new Object[1];
|
||||
if (delta_days==0)
|
||||
{ // "Today, 12:34:56"
|
||||
pattern = b.getString("activity.today");
|
||||
args[0] = s;
|
||||
|
||||
} // end if
|
||||
else if (delta_days==1)
|
||||
{ // "Yesterday, 12:34:56"
|
||||
pattern = b.getString("activity.yesterday");
|
||||
args[0] = s;
|
||||
|
||||
} // end else if
|
||||
else
|
||||
{ // "N days ago"
|
||||
pattern = b.getString("activity.daysago");
|
||||
args[0] = String.valueOf(delta_days);
|
||||
|
||||
} // end else
|
||||
|
||||
return MessageFormat.format(pattern,args);
|
||||
|
||||
} // end getActivityString
|
||||
|
||||
} // end class DateFormatterTopHalf
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class DefaultDateFormatterBottomHalf extends DateFormatterBottomHalf
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String NAMESPACE = VeniceNamespaces.USER_SETTINGS_NAMESPACE;
|
||||
private static final String PROP_LOCALE = "locale";
|
||||
private static final String PROP_TIMEZONE = "timezone";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Locale m_locale; // the locale we're guarding
|
||||
private TimeZone m_timezone; // the timezone we're guarding
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public DefaultDateFormatterBottomHalf(ServiceProvider services)
|
||||
{
|
||||
// Get the global object provider.
|
||||
ObjectProvider props = null;
|
||||
try
|
||||
{ // get the "properties" service from that object
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,"globals"));
|
||||
props = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"properties"));
|
||||
|
||||
} // end try
|
||||
catch (ConfigException e)
|
||||
{ // this shouldn't happen, but...
|
||||
m_locale = Locale.getDefault();
|
||||
m_timezone = new SimpleTimeZone(0,"UTC");
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
m_locale = Locale.getDefault();
|
||||
m_timezone = new SimpleTimeZone(0,"UTC");
|
||||
return;
|
||||
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // get the default user locale
|
||||
m_locale = (Locale)(props.getObject(NAMESPACE,PROP_LOCALE));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // fall back on error
|
||||
m_locale = Locale.getDefault();
|
||||
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // get the default user timezone
|
||||
m_timezone = (TimeZone)(props.getObject(NAMESPACE,PROP_TIMEZONE));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // fall back on error
|
||||
m_timezone = new SimpleTimeZone(0,"UTC");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class DateFormatterBottomHalf
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Locale getLocale()
|
||||
{
|
||||
return m_locale;
|
||||
|
||||
} // end getLocale
|
||||
|
||||
TimeZone getTimeZone()
|
||||
{
|
||||
return m_timezone;
|
||||
|
||||
} // end getTimeZone
|
||||
|
||||
} // end class DefaultDateFormatterBottomHalf
|
||||
326
src/venice-base/com/silverwrist/venice/content/ErrorBox.java
Normal file
326
src/venice-base/com/silverwrist/venice/content/ErrorBox.java
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.frame.FramedContent;
|
||||
|
||||
/**
|
||||
* A content object that implements an error message box. The error message consists of a title, a message,
|
||||
* an optional exception (the stack trace of which is rendered within HTML comments), and an optional "back"
|
||||
* link. It is rendered inside the standard Venice frame.
|
||||
* <P>Most scripting code will use the library function
|
||||
* {@link com.silverwrist.venice.script.LibraryVenice#stdErrorBox(com.silverwrist.dynamo.iface.Request,java.lang.String,java.lang.String) vlib.stdErrorBox()}
|
||||
* to generate one of these, rather than constructing an <CODE>ErrorBox</CODE> instance directly.
|
||||
* <P>The <CODE>ErrorBox</CODE> is rendered by
|
||||
* {@link com.silverwrist.venice.content.StandardContentSupplier StandardContentSupplier}.
|
||||
*
|
||||
* @author Eric J. Bowersox <erbo@silcom.com>
|
||||
* @version X
|
||||
*/
|
||||
public class ErrorBox implements FramedContent
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_title; // error box title
|
||||
private String m_message; // error box message
|
||||
private Throwable m_except; // exception to be dealt with
|
||||
private String m_back_type; // back link type
|
||||
private String m_back; // back link URL
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
* @param back_type The URL rewriter type of the back link. If this is <CODE>null</CODE>, it is assumed to be
|
||||
* "SERVLET".
|
||||
* @param back The URL to use for a back link.
|
||||
*/
|
||||
public ErrorBox(String title, String message, String back_type, String back)
|
||||
{
|
||||
setTitle(title);
|
||||
m_message = message;
|
||||
m_except = null;
|
||||
m_back_type = ((back_type==null) ? "SERVLET" : back_type);
|
||||
m_back = back;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
* @param back The URL to use for a back link, assumed to be a "SERVLET" URL.
|
||||
*/
|
||||
public ErrorBox(String title, String message, String back)
|
||||
{
|
||||
this(title,message,"SERVLET",back);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
*/
|
||||
public ErrorBox(String title, String message)
|
||||
{
|
||||
setTitle(title);
|
||||
m_message = message;
|
||||
m_except = null;
|
||||
m_back_type = null;
|
||||
m_back = null;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
* @param back_type The URL rewriter type of the back link. If this is <CODE>null</CODE>, it is assumed to be
|
||||
* "SERVLET".
|
||||
* @param back The URL to use for a back link.
|
||||
*/
|
||||
public ErrorBox(String title, Throwable t, String back_type, String back)
|
||||
{
|
||||
this(title,t.getMessage(),t,back_type,back);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
* @param back The URL to use for a back link, assumed to be a "SERVLET" URL.
|
||||
*/
|
||||
public ErrorBox(String title, Throwable t, String back)
|
||||
{
|
||||
this(title,t.getMessage(),t,"SERVLET",back);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
*/
|
||||
public ErrorBox(String title, Throwable t)
|
||||
{
|
||||
this(title,t.getMessage(),t);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
* @param back_type The URL rewriter type of the back link. If this is <CODE>null</CODE>, it is assumed to be
|
||||
* "SERVLET".
|
||||
* @param back The URL to use for a back link.
|
||||
*/
|
||||
public ErrorBox(String title, String message, Throwable t, String back_type, String back)
|
||||
{
|
||||
setTitle(title);
|
||||
m_message = message;
|
||||
m_except = t;
|
||||
m_back_type = ((back_type==null) ? "SERVLET" : back_type);
|
||||
m_back = back;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
* @param back The URL to use for a back link, assumed to be a "SERVLET" URL.
|
||||
*/
|
||||
public ErrorBox(String title, String message, Throwable t, String back)
|
||||
{
|
||||
this(title,message,t,"SERVLET",back);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title Title for the error message. If this is <CODE>null</CODE>, a default title will be used.
|
||||
* @param message The error message text itself.
|
||||
* @param t The <CODE>Throwable</CODE> that caused this error; its stack trace will be rendered in HTML comments
|
||||
* to the output.
|
||||
*/
|
||||
public ErrorBox(String title, String message, Throwable t)
|
||||
{
|
||||
setTitle(title);
|
||||
m_message = message;
|
||||
m_except = t;
|
||||
m_back_type = null;
|
||||
m_back = null;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the title of the <CODE>ErrorBox</CODE>.
|
||||
*
|
||||
* @param title The title to use. If this is <CODE>null/CODE>, a default title will be used.
|
||||
*/
|
||||
private final void setTitle(String title)
|
||||
{
|
||||
if (title==null)
|
||||
{ // set the title to the default
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.content.ContentMessages",
|
||||
Locale.getDefault());
|
||||
m_title = b.getString("default.errorBox.title");
|
||||
|
||||
} // end if
|
||||
else // just use the one passed in
|
||||
m_title = title;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the desired menu selector for this page. This value is <CODE>null</CODE>, which means the current
|
||||
* menu selector is not changed.
|
||||
*
|
||||
* @return The desired menu selector (<CODE>null</CODE>).
|
||||
*/
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
/**
|
||||
* Returns the desired title for the page. This title is concatenated with the <EM>site title</EM> (set in
|
||||
* global properties) to form the actual page title that gets sent to the browser.
|
||||
*
|
||||
* @return The desired page title.
|
||||
*/
|
||||
public String getPageTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/**
|
||||
* Returns the desired quick ID for the page. This value is <CODE>null</CODE>, which means the page quick ID
|
||||
* is not used.
|
||||
*
|
||||
* @return The desired page quick ID (<CODE>null</CODE>).
|
||||
*/
|
||||
public String getPageQID()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the title of the error message box.
|
||||
*
|
||||
* @return The title of the error message box.
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
/**
|
||||
* Returns the error message text.
|
||||
*
|
||||
* @return The error message text.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return m_message;
|
||||
|
||||
} // end getMessage
|
||||
|
||||
/**
|
||||
* Returns the <CODE>Throwable</CODE> wrapped by this <CODE>ErrorBox</CODE>, if any.
|
||||
*
|
||||
* @return The <CODE>Throwable</CODE> wrapped by this <CODE>ErrorBox</CODE>, or <CODE>null</CODE> if there is none.
|
||||
*/
|
||||
public Throwable getException()
|
||||
{
|
||||
return m_except;
|
||||
|
||||
} // end getException
|
||||
|
||||
/**
|
||||
* Returns the link type of the "back" link for this error message, if any.
|
||||
*
|
||||
* @return The link type of the "back" link for this error message, or <CODE>null</CODE> if there is none.
|
||||
*/
|
||||
public String getBackType()
|
||||
{
|
||||
return m_back_type;
|
||||
|
||||
} // end getBackType
|
||||
|
||||
/**
|
||||
* Returns the link URL of the "back" link for this error message, if any.
|
||||
*
|
||||
* @return The link URL of the "back" link for this error message, or <CODE>null</CODE> if there is none.
|
||||
*/
|
||||
public String getBackLink()
|
||||
{
|
||||
return m_back;
|
||||
|
||||
} // end getBackLink
|
||||
|
||||
} // end class ErrorBox
|
||||
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRendererConfig;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
import com.silverwrist.venice.util.*;
|
||||
|
||||
public class StandardContentSupplier
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, ServiceProvider, ContentBlockProvider,
|
||||
TextRenderer
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal object implementing Velocity operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public class ContentOps
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
ContentOps()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* External operations
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public Object header1(String title) throws DatabaseException
|
||||
{
|
||||
ContentBlock rc = getContentBlock("content.header");
|
||||
rc.setContentParameter("title",title);
|
||||
return rc;
|
||||
|
||||
} // end header1
|
||||
|
||||
public Object header2(String title, String subtitle) throws DatabaseException
|
||||
{
|
||||
ContentBlock rc = getContentBlock("content.header");
|
||||
rc.setContentParameter("title",title);
|
||||
rc.setContentParameter("subtitle",subtitle);
|
||||
return rc;
|
||||
|
||||
} // end header1
|
||||
|
||||
} // end class ContentOps
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Logger logger = Logger.getLogger(StandardContentSupplier.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name = null; // name of the object
|
||||
private ObjectProvider m_blocks; // global blocks provider
|
||||
private ComponentShutdown m_shut_1; // shut down renderer
|
||||
private ComponentShutdown m_shut_2; // shut down Velocity object
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public StandardContentSupplier()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("StandardContentSupplier initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the global properties object
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"global-properties");
|
||||
gprops = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in StandardContentSupplier",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the standard block provider.
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,gprops));
|
||||
try
|
||||
{ // get the "blocks" service from that object
|
||||
m_blocks = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"blocks"));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
logger.fatal("Unable to find global properties object \"" + gprops + "\"",e);
|
||||
throw new ConfigException(StandardContentSupplier.class,"ContentMessages","init.noBlock",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Register this object as a renderer for some objects.
|
||||
RendererRegistration rr = (RendererRegistration)(services.queryService(RendererRegistration.class));
|
||||
m_shut_1 = rr.registerRenderer(ErrorBox.class,this);
|
||||
|
||||
// Add an object to the standard objects available to Velocity.
|
||||
VelocityRendererConfig vrcon =
|
||||
(VelocityRendererConfig)(services.queryService(VelocityRendererConfig.class));
|
||||
m_shut_2 = vrcon.addStandardComponentInstance("content",new ContentOps());
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut_2.shutdown();
|
||||
m_shut_2 = null;
|
||||
m_shut_1.shutdown();
|
||||
m_shut_1 = null;
|
||||
m_blocks = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass)
|
||||
{
|
||||
if (klass==ContentBlockProvider.class)
|
||||
return (ContentBlockProvider)this;
|
||||
throw new NoSuchServiceException(getName(),klass);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @param serviceid ID for the service to be requested, to further discriminate between requests.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass, String serviceid)
|
||||
{
|
||||
if (klass==ContentBlockProvider.class)
|
||||
return (ContentBlockProvider)this;
|
||||
throw new NoSuchServiceException(getName(),klass,serviceid);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentBlockProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public ContentBlock getContentBlock(String name) throws DatabaseException
|
||||
{
|
||||
try
|
||||
{ // get the content block and wrap it in an object
|
||||
String block = m_blocks.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,name).toString();
|
||||
return new StringTemplateContentBlock(block,name);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // unwrap the DatabaseException if there's one in there
|
||||
if (e.getCause() instanceof DatabaseException)
|
||||
throw (DatabaseException)(e.getCause());
|
||||
else
|
||||
throw e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getContentBlock
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface TextRenderer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(Object obj, TextRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
if (obj instanceof ErrorBox)
|
||||
{ // render an ErrorBox
|
||||
ErrorBox ebox = (ErrorBox)obj;
|
||||
try
|
||||
{ // get the error box template out of the database
|
||||
ContentBlock blk = this.getContentBlock("error.box");
|
||||
blk.setContentParameter("title",ebox.getTitle());
|
||||
blk.setContentParameter("message",ebox.getMessage());
|
||||
if (ebox.getException()!=null)
|
||||
blk.setContentParameter("except",ebox.getException());
|
||||
if (ebox.getBackLink()!=null)
|
||||
{ // set the "back" and "backtype" parameters
|
||||
blk.setContentParameter("backtype",ebox.getBackType());
|
||||
blk.setContentParameter("back",ebox.getBackLink());
|
||||
|
||||
} // end if
|
||||
|
||||
control.renderSubObject(blk); // render the block
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException e)
|
||||
{ // translate this into a rendering exception
|
||||
RenderingException re = new RenderingException(StandardContentSupplier.class,"ContentMessages",
|
||||
"render.errorBox",e);
|
||||
re.setParameter(0,e.getMessage());
|
||||
re.setParameter(1,ebox.getTitle());
|
||||
re.setParameter(2,ebox.getMessage());
|
||||
throw re;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class StandardContentSupplier
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRenderable;
|
||||
import com.silverwrist.venice.ButtonType;
|
||||
import com.silverwrist.venice.frame.FramedContent;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class StdTextMessage implements FramedContent, VelocityRenderable
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final List MY_PARAMETERS;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ContentBlock m_header; // header to display
|
||||
private String m_title = null; // title for box
|
||||
private String m_subtitle = null; // subtitle for box
|
||||
private Object m_content = null; // content for box
|
||||
private ButtonProvider m_buttonprov; // button provider
|
||||
private ArrayList m_buttons = new ArrayList(); // list of buttons to display
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public StdTextMessage(ServiceProvider services) throws DatabaseException
|
||||
{
|
||||
// Get the header content block.
|
||||
ObjectProvider oprov = (ObjectProvider)(services.queryService(ObjectProvider.class));
|
||||
ServiceProvider sp = (ServiceProvider)(oprov.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-content"));
|
||||
ContentBlockProvider cblkp = (ContentBlockProvider)(sp.queryService(ContentBlockProvider.class));
|
||||
m_header = cblkp.getContentBlock("content.header");
|
||||
|
||||
// Get a reference to the button provider.
|
||||
sp = (ServiceProvider)(oprov.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-buttons"));
|
||||
m_buttonprov = (ButtonProvider)(sp.queryService(ButtonProvider.class));
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
public String getPageTitle()
|
||||
{
|
||||
if (m_subtitle==null)
|
||||
return m_title;
|
||||
else
|
||||
return m_title + " - " + m_subtitle;
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
if (key.equals("header"))
|
||||
return m_header;
|
||||
if (key.equals("content"))
|
||||
return m_content;
|
||||
if (key.equals("buttons"))
|
||||
return Collections.unmodifiableList(m_buttons);
|
||||
return null;
|
||||
|
||||
} // end getParameter
|
||||
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
return MY_PARAMETERS;
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return "text/html";
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return "common/stdtextmessage.vm";
|
||||
|
||||
} // end getTemplateName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
m_header.setContentParameter("title",title);
|
||||
m_title = title;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
public String getSubtitle()
|
||||
{
|
||||
return m_subtitle;
|
||||
|
||||
} // end getSubtitle
|
||||
|
||||
public void setSubtitle(String subtitle)
|
||||
{
|
||||
m_header.setContentParameter("subtitle",subtitle);
|
||||
m_subtitle = subtitle;
|
||||
|
||||
} // end setSubtitle
|
||||
|
||||
public Object getContent()
|
||||
{
|
||||
return m_content;
|
||||
|
||||
} // end getContent
|
||||
|
||||
public void setContent(Object content)
|
||||
{
|
||||
m_content = content;
|
||||
|
||||
} // end setContent
|
||||
|
||||
public void addButton(String linktype, String link, String button)
|
||||
{
|
||||
HashMap map = new HashMap();
|
||||
map.put("linktype",linktype);
|
||||
map.put("link",link);
|
||||
map.put("image",m_buttonprov.getButtonRenderObject(ButtonType.IMAGE,button));
|
||||
m_buttons.add(Collections.unmodifiableMap(map));
|
||||
|
||||
} // end addButton
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static initializer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
{
|
||||
ArrayList tmp = new ArrayList();
|
||||
tmp.add("header");
|
||||
tmp.add("content");
|
||||
tmp.add("buttons");
|
||||
tmp.trimToSize();
|
||||
MY_PARAMETERS = Collections.unmodifiableList(tmp);
|
||||
|
||||
} // end static initializer
|
||||
|
||||
} // end class StdTextMessage
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class UserDateFormatterBottomHalf extends DateFormatterBottomHalf
|
||||
implements SessionValueBindListener, DynamicUpdateListener
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String NAMESPACE = VeniceNamespaces.USER_SETTINGS_NAMESPACE;
|
||||
private static final String PROP_LOCALE = "locale";
|
||||
private static final String PROP_TIMEZONE = "timezone";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int m_uid; // UID we're linked to
|
||||
private ObjectProvider m_props; // source for user properties
|
||||
private Locale m_locale; // the locale we're guarding
|
||||
private TimeZone m_timezone; // the timezone we're guarding
|
||||
private ComponentShutdown m_shut_listener; // shutdown event listener
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public UserDateFormatterBottomHalf(Request r, DynamoUser user)
|
||||
{
|
||||
super();
|
||||
m_uid = user.getUID();
|
||||
m_props = user;
|
||||
|
||||
// Get the initial values we're guarding.
|
||||
m_locale = retrieveLocale();
|
||||
m_timezone = retrieveTimeZone();
|
||||
|
||||
// Set up a listener to monitor for changes in those values.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(r.queryService(EventListenerRegistration.class));
|
||||
m_shut_listener = reg.registerDynamicUpdateListener(UserPropertyUpdateEvent.class,this);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final void destroy()
|
||||
{
|
||||
m_shut_listener.shutdown();
|
||||
m_shut_listener = null;
|
||||
m_props = null;
|
||||
|
||||
} // end destroy
|
||||
|
||||
private final Locale retrieveLocale()
|
||||
{
|
||||
return (Locale)(m_props.getObject(NAMESPACE,PROP_LOCALE));
|
||||
|
||||
} // end retrieveLocale
|
||||
|
||||
private final TimeZone retrieveTimeZone()
|
||||
{
|
||||
return (TimeZone)(m_props.getObject(NAMESPACE,PROP_TIMEZONE));
|
||||
|
||||
} // end retrieveTimeZone
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class DateFormatterBottomHalf
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Locale getLocale()
|
||||
{
|
||||
return m_locale;
|
||||
|
||||
} // end getLocale
|
||||
|
||||
TimeZone getTimeZone()
|
||||
{
|
||||
return m_timezone;
|
||||
|
||||
} // end getTimeZone
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SessionValueBindListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void valueAdded(SessionValueBindEvent event)
|
||||
{ // do nothing
|
||||
} // end valueAdded
|
||||
|
||||
public void valueRemoved(SessionValueBindEvent event)
|
||||
{
|
||||
destroy();
|
||||
|
||||
} // end valueRemoved
|
||||
|
||||
public void valueReplaced(SessionValueBindEvent event)
|
||||
{
|
||||
destroy();
|
||||
|
||||
} // end valueReplaced
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
UserPropertyUpdateEvent event = (UserPropertyUpdateEvent)evt;
|
||||
if ((event.getUID()==m_uid) && NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // try to update our properties
|
||||
try
|
||||
{ // match one of the two property names
|
||||
if (PROP_LOCALE.equals(event.getPropertyName()))
|
||||
{ // re-get the locale
|
||||
Locale loc = retrieveLocale();
|
||||
m_locale = loc;
|
||||
|
||||
} // end if
|
||||
else if (PROP_TIMEZONE.equals(event.getPropertyName()))
|
||||
{ // re-get the timezone
|
||||
TimeZone tz = retrieveTimeZone();
|
||||
m_timezone = tz;
|
||||
|
||||
} // end else if
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // do nothing here
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
} // end class UserDateFormatterBottomHalf
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.io.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class UserPhotoRenderer
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, DynamicUpdateListener, ServiceProvider,
|
||||
RenderImage
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal rendering object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class RenderObject implements SelfRenderable
|
||||
{
|
||||
/*====================================================================
|
||||
* Attributes
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
private String m_url;
|
||||
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
RenderObject(String url)
|
||||
{
|
||||
m_url = url;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface SelfRenderable
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
renderImageTag(control.getTextRender(),m_url);
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class RenderObject
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(UserPhotoRenderer.class);
|
||||
|
||||
private static final String NAMESPACE = VeniceNamespaces.CONTENT_LAF_NAMESPACE;
|
||||
private static final String PROP_WIDTH = "user.photo.width";
|
||||
private static final String PROP_HEIGHT = "user.photo.height";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name = null; // object name
|
||||
private ObjectProvider m_props; // pointer to global property provider
|
||||
private ComponentShutdown m_shut_event; // event handler shutdown
|
||||
private int m_width; // width for user photos
|
||||
private int m_height; // height for user photos
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public UserPhotoRenderer()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final int getInitInteger(String name) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to the property provider
|
||||
return ((Integer)(m_props.getObject(NAMESPACE,name))).intValue();
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // the property value isn't present? yIkes!
|
||||
ConfigException ce = new ConfigException(UserPhotoRenderer.class,"ContentMessages","prop.missing",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // not an Integer? for shame!
|
||||
ConfigException ce = new ConfigException(UserPhotoRenderer.class,"ContentMessages","prop.wrongType",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getInitInteger
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("UserPhotoRenderer initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the global properties object
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"global-properties");
|
||||
gprops = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in UserPhotoRenderer",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the standard properties provider.
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,gprops));
|
||||
try
|
||||
{ // get the "properties" service from that object
|
||||
m_props = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"properties"));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
logger.fatal("Unable to find global properties object \"" + gprops + "\"",e);
|
||||
throw new ConfigException(UserPhotoRenderer.class,"ContentMessages","init.noProp",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the initial property values for our properties.
|
||||
m_width = getInitInteger(PROP_WIDTH);
|
||||
m_height = getInitInteger(PROP_HEIGHT);
|
||||
|
||||
// Register with the event listener to monitor those property values.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
m_shut_event = reg.registerDynamicUpdateListener(GlobalPropertyUpdateEvent.class,this);
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut_event.shutdown();
|
||||
m_shut_event = null;
|
||||
m_props = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
GlobalPropertyUpdateEvent event = (GlobalPropertyUpdateEvent)evt;
|
||||
if (NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // see if this is one of the properties we monitor
|
||||
try
|
||||
{ // reuse the "initialization" getters here
|
||||
if (PROP_WIDTH.equals(event.getPropertyName()))
|
||||
{ // process new width
|
||||
int x = getInitInteger(PROP_WIDTH);
|
||||
m_width = x;
|
||||
|
||||
} // end else if
|
||||
else if (PROP_HEIGHT.equals(event.getPropertyName()))
|
||||
{ // process new height
|
||||
int x = getInitInteger(PROP_HEIGHT);
|
||||
m_height = x;
|
||||
|
||||
} // end else if
|
||||
|
||||
} // end try
|
||||
catch (ConfigException ce)
|
||||
{ // property get failed - don't change the value
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass)
|
||||
{
|
||||
if (klass==RenderImage.class)
|
||||
return (RenderImage)this;
|
||||
throw new NoSuchServiceException(getName(),klass);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/**
|
||||
* Queries this object for a specified service.
|
||||
*
|
||||
* @param klass The class of the object that should be returned as a service.
|
||||
* @param serviceid ID for the service to be requested, to further discriminate between requests.
|
||||
* @return A service object. The service object is guaranteed to be of the class
|
||||
* specified by <CODE>klass</CODE>; that is, if <CODE>queryService(klass)</CODE>
|
||||
* yields some object <CODE>x</CODE>, then the expression <CODE>klass.isInstance(x)</CODE>
|
||||
* is true.
|
||||
* @exception com.silverwrist.dynamo.except.NoSuchServiceException If no service is available in
|
||||
* the specified class.
|
||||
*/
|
||||
public Object queryService(Class klass, String serviceid)
|
||||
{
|
||||
if (klass==RenderImage.class)
|
||||
return (RenderImage)this;
|
||||
throw new NoSuchServiceException(getName(),klass,serviceid);
|
||||
|
||||
} // end queryService
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface RenderImage
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderImageTag(TextRenderControl control, String url) throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
wr.write("<img src=\"" + url + "\" alt=\"\" width=\"" + m_width + "\" height=\"" + m_height
|
||||
+ "\" border=\"0\" />");
|
||||
|
||||
} // end renderImageTag
|
||||
|
||||
public Object getRenderingObject(String url)
|
||||
{
|
||||
return new RenderObject(url);
|
||||
|
||||
} // end getRenderingObject
|
||||
|
||||
} // end class UserPhotoRenderer
|
||||
230
src/venice-base/com/silverwrist/venice/content/VelocityView.java
Normal file
230
src/venice-base/com/silverwrist/venice/content/VelocityView.java
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.content;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityParamSupplier;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRenderable;
|
||||
import com.silverwrist.venice.frame.FramedContent;
|
||||
|
||||
/**
|
||||
* A "view object" that implements a rendering of a Velocity template, with parameters, inside of the standard
|
||||
* Venice frame.
|
||||
*
|
||||
* @author Eric J. Bowersox <erbo@silcom.com>
|
||||
* @version X
|
||||
*/
|
||||
public class VelocityView implements VelocityRenderable, FramedContent
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_title; // title for the page
|
||||
private String m_templ; // name of template resource to use
|
||||
private Hashtable m_params = new Hashtable(); // parameters to give to Velocity
|
||||
private String m_menu_sel = null; // menu selector for the page
|
||||
private String m_qid = null; // quick ID for the page
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>VelocityView</CODE>.
|
||||
*
|
||||
* @param title Title to use for the page.
|
||||
* @param templ Name of the resource from which the Velocity template will be loaded.
|
||||
*/
|
||||
public VelocityView(String title, String templ)
|
||||
{
|
||||
m_title = title;
|
||||
m_templ = templ;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the value of a parameter set on the object.
|
||||
*
|
||||
* @param key The name of the parameter to look up.
|
||||
* @return The parameter's value, or <CODE>null</CODE> if the parameter was not set.
|
||||
*/
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
return m_params.get(key);
|
||||
|
||||
} // end getParameter
|
||||
|
||||
/**
|
||||
* Returns a <CODE>java.util.Collection</CODE> of all parameter names currently defined on this object.
|
||||
*
|
||||
* @return A collection of all parameter names currently defined.
|
||||
*/
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
HashSet rc = new HashSet(m_params.keySet());
|
||||
return Collections.unmodifiableSet(rc);
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the MIME type of the output to be rendered. Usually, this will be "text/html".
|
||||
*
|
||||
* @return The MIME type of the output.
|
||||
*/
|
||||
public String getMimeType()
|
||||
{
|
||||
return "text/html";
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
/**
|
||||
* Returns the resource name of the Velocity template to be used in rendering this object. This pathname
|
||||
* is interpreted relative to the "resource root path" specified in the Velocity renderer's configuration.
|
||||
* The template engine loads it via the standard
|
||||
* {@link com.silverwrist.dynamo.iface.ResourceProvider ResourceProvider}, and then applies the parameters
|
||||
* contained in this object to it.
|
||||
*
|
||||
* @return The resource pathname of the Velocity template to use.
|
||||
*/
|
||||
public String getTemplateName()
|
||||
{
|
||||
return m_templ;
|
||||
|
||||
} // end getTemplateName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the desired menu selector for this page. The <EM>menu selector</EM> is a string that specifies
|
||||
* which menu is to be displayed on the left menu bar, in addition to the "global menu." This value may
|
||||
* be <CODE>null</CODE>, in which case the current menu selector is not changed.
|
||||
*
|
||||
* @return The desired menu selector.
|
||||
*/
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return m_menu_sel;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
/**
|
||||
* Returns the desired title for the page. This title is concatenated with the <EM>site title</EM> (set in
|
||||
* global properties) to form the actual page title that gets sent to the browser.
|
||||
*
|
||||
* @return The desired page title.
|
||||
*/
|
||||
public String getPageTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/**
|
||||
* Returns the desired quick ID for the page. The <EM>page quick ID</EM> is a small text string which can be used
|
||||
* to "tag" the page with a unique identifier, for use with external tools such as offsite hit counters.
|
||||
* If this value is <CODE>null</CODE>, the quick ID is not used for this page.
|
||||
*
|
||||
* @return The desired page quick ID.
|
||||
*/
|
||||
public String getPageQID()
|
||||
{
|
||||
return m_qid;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the value of a parameter on the object.
|
||||
*
|
||||
* @param key The name of the parameter to set.
|
||||
* @param value The value of the parameter to set, or <CODE>null</CODE> to remove the parameter.
|
||||
*/
|
||||
public void setParameter(String key, Object value)
|
||||
{
|
||||
if (value!=null)
|
||||
m_params.put(key,value);
|
||||
else
|
||||
m_params.remove(key);
|
||||
|
||||
} // end getParameter
|
||||
|
||||
/**
|
||||
* Sets the resource name of the Velocity template to use for rendering this object.
|
||||
*
|
||||
* @param name The resource name of the Velocity template.
|
||||
*/
|
||||
public void setTemplateName(String name)
|
||||
{
|
||||
m_templ = name;
|
||||
|
||||
} // end setTemplateName
|
||||
|
||||
/**
|
||||
* Sets the desired menu selector for this page.
|
||||
*
|
||||
* @param s The desired menu selector for the page.
|
||||
*/
|
||||
public void setMenuSelector(String s)
|
||||
{
|
||||
m_menu_sel = s;
|
||||
|
||||
} // end setMenuSelector
|
||||
|
||||
/**
|
||||
* Sets the desired title for this page.
|
||||
*
|
||||
* @param s The desired title for the page.
|
||||
*/
|
||||
public void setPageTitle(String s)
|
||||
{
|
||||
m_title = s;
|
||||
|
||||
} // end setPageTitle
|
||||
|
||||
/**
|
||||
* Sets the desired quick ID for this page.
|
||||
*
|
||||
* @param s The desired quick ID for the page.
|
||||
*/
|
||||
public void setPageQID(String s)
|
||||
{
|
||||
m_qid = s;
|
||||
|
||||
} // end setPageQID
|
||||
|
||||
} // end class VelocityView
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.dialog;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.dialog.BaseDialogField;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
class UserPhotoField extends BaseDialogField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_photo_url = null;
|
||||
private String m_link_url;
|
||||
private String m_link_type;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
UserPhotoField(Element elt) throws DialogException
|
||||
{
|
||||
super(false,elt);
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
try
|
||||
{ // get link URL and link type
|
||||
m_link_url = loader.getAttribute(elt,"link");
|
||||
m_link_type = loader.getAttribute(elt,"type");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // translate to DialogException
|
||||
throw new DialogException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Load caption 2 from messages
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.dialog.VeniceDialogMessages",
|
||||
Locale.getDefault());
|
||||
setCaption2(b.getString("userphoto.caption2"));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected UserPhotoField(UserPhotoField other)
|
||||
{
|
||||
super(other);
|
||||
m_photo_url = null;
|
||||
m_link_url = other.m_link_url;
|
||||
m_link_type = other.m_link_type;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class BaseDialogField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void renderField(TextRenderControl control, Map render_params)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
if (isEnabled())
|
||||
{ // write the opening <A> tag
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(m_link_type,StringUtils.replaceAllVariables(m_link_url,render_params))
|
||||
+ "\">");
|
||||
|
||||
} // end if
|
||||
|
||||
// write the <IMG> tag by running it through the standard user photo renderer
|
||||
ObjectProvider oprov = (ObjectProvider)(control.queryService(ObjectProvider.class));
|
||||
ServiceProvider sp = (ServiceProvider)(oprov.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-userphoto"));
|
||||
RenderImage rimg = (RenderImage)(sp.queryService(RenderImage.class));
|
||||
rimg.renderImageTag(control,m_photo_url);
|
||||
|
||||
// write the </A> tag
|
||||
if (isEnabled())
|
||||
wr.write("</a>");
|
||||
|
||||
} // end renderField
|
||||
|
||||
protected void validateContents(Request r, Object data) throws ValidationException
|
||||
{ // do nothing
|
||||
} // end validateContents
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new UserPhotoField(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
public Object getValue()
|
||||
{
|
||||
return m_photo_url;
|
||||
|
||||
} // end getValue
|
||||
|
||||
public boolean containsValue()
|
||||
{
|
||||
return (m_photo_url!=null);
|
||||
|
||||
} // end containsValue
|
||||
|
||||
public void setValue(Object obj)
|
||||
{
|
||||
m_photo_url = ((obj==null) ? null : obj.toString());
|
||||
|
||||
} // end setValue
|
||||
|
||||
public void setValueFrom(Request r)
|
||||
{ // do nothing - this doesn't get handled in the usual way
|
||||
} // end setValueFrom
|
||||
|
||||
public void reset()
|
||||
{ // do nothing
|
||||
} // end reset
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class BaseDialogField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected boolean isNull(Object value)
|
||||
{
|
||||
return false;
|
||||
|
||||
} // end isNull
|
||||
|
||||
public int getFlags()
|
||||
{
|
||||
return 0;
|
||||
|
||||
} // end getFlags
|
||||
|
||||
} // end class UserPhotoField
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.dialog;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
public class VeniceDialogItemFactory implements DialogItemFactory
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public VeniceDialogItemFactory()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DialogItemFactory
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public DialogItem createDialogItem(Element elt, DialogPLAF plaf) throws DialogException
|
||||
{
|
||||
String tagname = elt.getTagName();
|
||||
if (tagname.equals("userphoto"))
|
||||
return new UserPhotoField(elt);
|
||||
|
||||
throw new UnknownDialogFieldException(tagname,elt);
|
||||
|
||||
} // end createDialogItem
|
||||
|
||||
} // end class VeniceDialogItemFactory
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.dialog;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.ButtonType;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class VeniceDialogManager implements NamedObject, ComponentInitialize, ComponentShutdown, DialogPLAF
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(VeniceDialogManager.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name;
|
||||
private ButtonProvider m_buttonprov;
|
||||
private ContentBlockProvider m_cbprov;
|
||||
private LinkedList m_shutdown_list = new LinkedList();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public VeniceDialogManager()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("VeniceDialogManager initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String button_prov = null, content_prov = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the names of the default providers
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"providers");
|
||||
button_prov = loader.getAttribute(foo,"button");
|
||||
content_prov = loader.getAttribute(foo,"content");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in StandardContentSupplier",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the initial objects.
|
||||
m_buttonprov = (ButtonProvider)(GetObjectUtils.getDynamoComponent(services,ButtonProvider.class,button_prov));
|
||||
m_cbprov = (ContentBlockProvider)(GetObjectUtils.getDynamoComponent(services,ContentBlockProvider.class,
|
||||
content_prov));
|
||||
|
||||
// Register ourselves as providing the new dialog look-and-feel.
|
||||
DialogFactoryConfig dlg_conf = (DialogFactoryConfig)(services.queryService(DialogFactoryConfig.class));
|
||||
dlg_conf.setDialogPLAF(this);
|
||||
|
||||
// Register our own field types.
|
||||
VeniceDialogItemFactory itemfact = new VeniceDialogItemFactory();
|
||||
m_shutdown_list.addFirst(dlg_conf.registerDialogItem("userphoto",itemfact));
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
while (m_shutdown_list.size()>0)
|
||||
{ // shut down all components on the shutdown list
|
||||
ComponentShutdown cs = (ComponentShutdown)(m_shutdown_list.removeFirst());
|
||||
cs.shutdown();
|
||||
|
||||
} // end while
|
||||
|
||||
m_buttonprov = null;
|
||||
m_cbprov = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DialogPLAF
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object getButtonRendering(String button_name)
|
||||
{
|
||||
return m_buttonprov.getButtonRenderObject(ButtonType.INPUT,button_name);
|
||||
|
||||
} // end getButtonRendering
|
||||
|
||||
public boolean isButtonClicked(Request r, String button_name)
|
||||
{
|
||||
RequestHelper rh = new RequestHelper(r);
|
||||
return rh.isImageButtonClicked(button_name);
|
||||
|
||||
} // end isButtonClicked
|
||||
|
||||
public Object getContentHeader(String title, String subtitle)
|
||||
{
|
||||
try
|
||||
{ // get and return the header block
|
||||
ContentBlock rc = m_cbprov.getContentBlock("content.header");
|
||||
rc.setContentParameter("title",title);
|
||||
if (subtitle!=null)
|
||||
rc.setContentParameter("subtitle",subtitle);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException de)
|
||||
{ // return a RenderingExceptionWrapper instead
|
||||
RenderingException re = new RenderingException(VeniceDialogManager.class,"VeniceDialogMessages",
|
||||
"cheader.fail",de);
|
||||
re.setParameter(0,de.getMessage());
|
||||
return new RenderingExceptionWrapper(re);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getContentHeader
|
||||
|
||||
} // end class VeniceDialogManager
|
||||
@@ -0,0 +1,19 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
userphoto.caption2=(click to change)
|
||||
cheader.fail=Unable to get content header object: {0}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.except;
|
||||
|
||||
import com.silverwrist.dynamo.except.ExternalException;
|
||||
|
||||
public class StyleSheetException extends ExternalException
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public StyleSheetException(Class caller, String bundle, String message_id)
|
||||
{
|
||||
super(caller,bundle,message_id);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public StyleSheetException(Class caller, String bundle, String message_id, Throwable inner)
|
||||
{
|
||||
super(caller,bundle,message_id,inner);
|
||||
|
||||
} // end constructor
|
||||
|
||||
} // end class StyleSheetException
|
||||
441
src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java
Normal file
441
src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.RequestType;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityParamSupplier;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRendererConfig;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
import com.silverwrist.venice.session.SessionInfoParams;
|
||||
|
||||
public class FrameAssembler
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, OutputObjectFilter, DynamicUpdateListener,
|
||||
FrameParameters
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class that supplies rendering parameters for the frame
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private class BaseParams implements VelocityParamSupplier
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
BaseParams()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
return m_globals.get(key);
|
||||
|
||||
} // end getParameter
|
||||
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
return Collections.unmodifiableSet(m_globals.keySet());
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
} // end class BaseParams
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class that supplies additional operations for the Velocity engine
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public class VelocityOps
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
VelocityOps()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* External operations
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public boolean getShowComments()
|
||||
{
|
||||
return m_show_comments;
|
||||
|
||||
} // end showComments
|
||||
|
||||
} // end class VelocityOps
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(FrameAssembler.class);
|
||||
|
||||
private static final Map PROP_TO_VELOCITY;
|
||||
private static final Map PROP_TO_TYPE;
|
||||
|
||||
private static final Pattern PAT_LINEBREAK = Pattern.compile("\\r*\\n");
|
||||
|
||||
private static final int[] NO_ACLS = new int[0];
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name; // this object's name
|
||||
private ObjectProvider m_props; // global properties
|
||||
private ObjectProvider m_blocks; // global blocks
|
||||
private MenuProvider m_menu_prov; // menu provider
|
||||
private String m_frame_template; // frame template parameter
|
||||
private HashMap m_globals = new HashMap(); // globals fed to Velocity
|
||||
private BaseParams m_base_params; // base parameters object
|
||||
private boolean m_footer_breaks; // add line breaks to footer?
|
||||
private boolean m_show_comments; // show HTML comments?
|
||||
private ComponentShutdown m_shut_event; // shutdown event handler
|
||||
private ComponentShutdown m_shut_vr; // shutdown Velocity rendering component
|
||||
private ComponentShutdown m_shut_fasm; // shutdown FrameAssembler
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public FrameAssembler()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final Object initLoadProperty(String name, Class expected_class) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to getObject
|
||||
Object rc = m_props.getObject(NAMESPACE,name);
|
||||
if (!(expected_class.isInstance(rc)))
|
||||
{ // not the right class!
|
||||
ConfigException ce = new ConfigException(FrameAssembler.class,"FrameMessages","property.wrongClass");
|
||||
ce.setParameter(0,name);
|
||||
ce.setParameter(1,expected_class.getName());
|
||||
throw ce;
|
||||
|
||||
} // end if
|
||||
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // translate into ConfigException and reflect it back
|
||||
ConfigException ce = new ConfigException(FrameAssembler.class,"FrameMessages","property.notFound",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end initLoadProperty
|
||||
|
||||
private final void setupOptions(OptionSet set)
|
||||
{
|
||||
m_show_comments = set.get(OPT_COMMENTS);
|
||||
m_globals.put("ms_copyright_violations",Boolean.valueOf(set.get(OPT_SMARTTAG)));
|
||||
m_footer_breaks = set.get(OPT_FOOTER_BREAKS);
|
||||
|
||||
} // end setupOptions
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "the FrameAssembler";
|
||||
|
||||
} // end toString
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("FrameAssembler initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null, name_menu = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the global properties object
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"global-properties");
|
||||
gprops = loader.getAttribute(foo,"object");
|
||||
|
||||
// get the name of the menu manager
|
||||
foo = loader.getSubElement(config_root_h,"providers");
|
||||
name_menu = loader.getAttribute(foo,"menu");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in FrameAssembler",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the global data manager object.
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,gprops));
|
||||
try
|
||||
{ // get the "properties" and "blocks" services from that object
|
||||
m_props = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"properties"));
|
||||
m_blocks = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"blocks"));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
throw new ConfigException(FrameAssembler.class,"FrameMessages","init.noGlobals",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Set up the initial values of the global properties.
|
||||
Iterator it = PROP_TO_VELOCITY.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{ // scan through maps and load globals
|
||||
Map.Entry ntry = (Map.Entry)(it.next());
|
||||
String key = ntry.getKey().toString();
|
||||
m_globals.put(ntry.getValue().toString(),initLoadProperty(key,(Class)(PROP_TO_TYPE.get(key))));
|
||||
|
||||
} // end while
|
||||
|
||||
// Set up the frame template.
|
||||
m_frame_template = (String)initLoadProperty(PARAM_FRAME_TEMPLATE_NAME,String.class);
|
||||
|
||||
// Set up the initial values for the option set.
|
||||
setupOptions((OptionSet)initLoadProperty(PARAM_OPTIONSET,OptionSet.class));
|
||||
|
||||
m_base_params = new BaseParams(); // create base parameter object
|
||||
|
||||
// Load the menu provider.
|
||||
m_menu_prov = (MenuProvider)(GetObjectUtils.getDynamoComponent(services,MenuProvider.class,name_menu));
|
||||
|
||||
// Register to receive global property update events.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
m_shut_event = reg.registerDynamicUpdateListener(GlobalPropertyUpdateEvent.class,this);
|
||||
|
||||
// Add an object to the standard objects available to Velocity.
|
||||
VelocityRendererConfig vrcon =
|
||||
(VelocityRendererConfig)(services.queryService(VelocityRendererConfig.class));
|
||||
m_shut_vr = vrcon.addStandardComponentInstance("frame",new VelocityOps());
|
||||
|
||||
// Register this object as a filter for output.
|
||||
OutputObjectFilterRegistration freg =
|
||||
(OutputObjectFilterRegistration)(services.queryService(OutputObjectFilterRegistration.class));
|
||||
m_shut_fasm = freg.registerOutputObjectFilter(this);
|
||||
|
||||
logger.info("FrameAssembler init complete");
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_shut_fasm.shutdown();
|
||||
m_shut_fasm = null;
|
||||
m_shut_vr.shutdown();
|
||||
m_shut_vr = null;
|
||||
m_shut_event.shutdown();
|
||||
m_shut_event = null;
|
||||
m_base_params = null;
|
||||
m_menu_prov = null;
|
||||
m_props = null;
|
||||
m_blocks = null;
|
||||
m_globals.clear();
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface OutputObjectFilter
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object filterObject(Object input, Request r) throws RenderingException
|
||||
{
|
||||
if (RequestType.HTTP.equals(r.getType()) && (input instanceof FramedContent))
|
||||
{ // we need to retrieve the user from the session
|
||||
try
|
||||
{ // get the user
|
||||
RequestHelper rh = new RequestHelper(r);
|
||||
SessionInfo session = rh.getSession();
|
||||
DynamoUser user = (DynamoUser)(session.getObject(SessionInfoParams.NAMESPACE,
|
||||
SessionInfoParams.ATTR_USER));
|
||||
|
||||
// get the request-borne data
|
||||
String location = (String)(r.getObject(SessionInfoParams.REQ_NAMESPACE,
|
||||
SessionInfoParams.RATTR_LOCATION));
|
||||
Boolean display_login = (Boolean)(r.getObject(SessionInfoParams.REQ_NAMESPACE,
|
||||
SessionInfoParams.RATTR_DISPLAY_LOGIN));
|
||||
|
||||
// get the menus
|
||||
MenuRenderObject fixed_menu = m_menu_prov.getLeftMenu(user,VeniceNamespaces.FRAME_LAF_NAMESPACE,
|
||||
"fixed.menu",NO_ACLS);
|
||||
|
||||
// get the footer and optionally insert line breaks
|
||||
String footer = (String)(m_blocks.getObject(NAMESPACE,BLOCK_FOOTER));
|
||||
if (m_footer_breaks)
|
||||
// set up the regular expression system to replace carriage returns to insert a <br />
|
||||
footer = PAT_LINEBREAK.matcher(footer).replaceAll("<br />\r\n");
|
||||
|
||||
return new FrameRendering((FramedContent)input,m_frame_template,m_base_params,user,location,
|
||||
display_login,fixed_menu,footer);
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException e)
|
||||
{ // rethrow it as a RenderingException
|
||||
throw new RenderingException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
return null;
|
||||
|
||||
} // end filterObject
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
GlobalPropertyUpdateEvent event = (GlobalPropertyUpdateEvent)evt;
|
||||
if (NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // see if this is one of the properties we monitor
|
||||
String key = (String)(PROP_TO_VELOCITY.get(event.getPropertyName()));
|
||||
if (key!=null)
|
||||
m_globals.put(key,m_props.getObject(NAMESPACE,event.getPropertyName()));
|
||||
|
||||
if (PARAM_FRAME_TEMPLATE_NAME.equals(event.getPropertyName()))
|
||||
m_frame_template = (String)(m_props.getObject(NAMESPACE,event.getPropertyName()));
|
||||
|
||||
if (PARAM_OPTIONSET.equals(event.getPropertyName()))
|
||||
setupOptions((OptionSet)(m_props.getObject(NAMESPACE,event.getPropertyName())));
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static initializer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
{ // Initialize the mapping from property names to Velocity parameter names.
|
||||
HashMap tmp = new HashMap();
|
||||
HashMap tmp2 = new HashMap();
|
||||
tmp.put(PARAM_SITE_TITLE,"sitetitle");
|
||||
tmp2.put(PARAM_SITE_TITLE,String.class);
|
||||
tmp.put(PARAM_SITE_URL,"siteurl");
|
||||
tmp2.put(PARAM_SITE_URL,String.class);
|
||||
tmp.put(PARAM_SITE_LOGO_URL,"logourl");
|
||||
tmp2.put(PARAM_SITE_LOGO_URL,String.class);
|
||||
tmp.put(PARAM_SITE_LOGO_URL_TYPE,"logourltype");
|
||||
tmp2.put(PARAM_SITE_LOGO_URL_TYPE,String.class);
|
||||
tmp.put(PARAM_SITE_LOGO_WIDTH,"logowidth");
|
||||
tmp2.put(PARAM_SITE_LOGO_WIDTH,Integer.class);
|
||||
tmp.put(PARAM_SITE_LOGO_HEIGHT,"logoheight");
|
||||
tmp2.put(PARAM_SITE_LOGO_HEIGHT,Integer.class);
|
||||
tmp.put(PARAM_FOOTER_LOGO_SCALE,"flogoscale");
|
||||
tmp2.put(PARAM_FOOTER_LOGO_SCALE,Integer.class);
|
||||
tmp.put(PARAM_PAGEICON_URL,"pgicon_url");
|
||||
tmp2.put(PARAM_PAGEICON_URL,String.class);
|
||||
tmp.put(PARAM_PAGEICON_URL_TYPE,"pgicon_ltyp");
|
||||
tmp2.put(PARAM_PAGEICON_URL_TYPE,String.class);
|
||||
tmp.put(PARAM_PAGEICON_TYPE,"pgicon_mime");
|
||||
tmp2.put(PARAM_PAGEICON_TYPE,String.class);
|
||||
tmp.put(PARAM_FAVICON_URL,"favicon_url");
|
||||
tmp2.put(PARAM_FAVICON_URL,String.class);
|
||||
tmp.put(PARAM_FAVICON_URL_TYPE,"favicon_ltyp");
|
||||
tmp2.put(PARAM_FAVICON_URL_TYPE,String.class);
|
||||
PROP_TO_VELOCITY = Collections.unmodifiableMap(tmp);
|
||||
PROP_TO_TYPE = Collections.unmodifiableMap(tmp2);
|
||||
|
||||
} // end static initializer
|
||||
|
||||
} // end class FrameAssembler
|
||||
109
src/venice-base/com/silverwrist/venice/frame/FrameDialog.java
Normal file
109
src/venice-base/com/silverwrist/venice/frame/FrameDialog.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
public class FrameDialog implements FramedContent, SelfRenderable
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Dialog m_dialog;
|
||||
private String m_menu_sel = null;
|
||||
private String m_qid = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public FrameDialog(Dialog dialog)
|
||||
{
|
||||
m_dialog = dialog;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public FrameDialog(Dialog dialog, String menu_sel)
|
||||
{
|
||||
m_dialog = dialog;
|
||||
m_menu_sel = menu_sel;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return m_menu_sel;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
public String getPageTitle()
|
||||
{
|
||||
String s = m_dialog.getSubtitle();
|
||||
if (s==null)
|
||||
return m_dialog.getTitle();
|
||||
StringBuffer buf = new StringBuffer(m_dialog.getTitle());
|
||||
buf.append(" - ").append(s);
|
||||
return buf.toString();
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return m_qid;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SelfRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
m_dialog.render(control.getTextRender());
|
||||
|
||||
} // end render
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setMenuSelector(String s)
|
||||
{
|
||||
m_menu_sel = s;
|
||||
|
||||
} // end setMenuSelector
|
||||
|
||||
public void setPageQID(String s)
|
||||
{
|
||||
m_qid = s;
|
||||
|
||||
} // end setPageQID
|
||||
|
||||
} // end class FrameDialog
|
||||
@@ -0,0 +1,23 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
init.noGlobals=Unable to find the global properties provider (should be named "globals").
|
||||
property.notFound=Unable to get value of frame property "{0}".
|
||||
property.wrongClass=Value of property "{0}" is not of class "{1}".
|
||||
ss.noPrefix=Configuration error: no stylesheet prefix configured for servlet path {0}.
|
||||
ss.noTemplate=No stylesheet template name found for property "{0}".
|
||||
ss.renderFail=Unable to render stylesheet template {0}: {1}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public interface FrameParameters
|
||||
{
|
||||
public static final String NAMESPACE = VeniceNamespaces.FRAME_LAF_NAMESPACE;
|
||||
|
||||
public static final String PARAM_SITE_TITLE = "site.title";
|
||||
|
||||
public static final String PARAM_OPTIONSET = "optionset";
|
||||
|
||||
public static final String PARAM_SITE_URL = "site.url";
|
||||
|
||||
public static final String PARAM_SITE_LOGO_URL = "site.logo.url";
|
||||
|
||||
public static final String PARAM_SITE_LOGO_URL_TYPE = "site.logo.url.type";
|
||||
|
||||
public static final String PARAM_SITE_LOGO_WIDTH = "site.logo.width";
|
||||
|
||||
public static final String PARAM_SITE_LOGO_HEIGHT = "site.logo.height";
|
||||
|
||||
public static final String PARAM_FRAME_TEMPLATE_NAME = "frame.template";
|
||||
|
||||
public static final String PARAM_FOOTER_LOGO_SCALE = "footer.logo.scale";
|
||||
|
||||
public static final String PARAM_PAGEICON_URL = "page.icon.url";
|
||||
|
||||
public static final String PARAM_PAGEICON_URL_TYPE = "page.icon.url.type";
|
||||
|
||||
public static final String PARAM_PAGEICON_TYPE = "page.icon.type";
|
||||
|
||||
public static final String PARAM_FAVICON_URL = "page.favicon.url";
|
||||
|
||||
public static final String PARAM_FAVICON_URL_TYPE = "page.favicon.url.type";
|
||||
|
||||
public static final String BLOCK_FOOTER = "footer";
|
||||
|
||||
public static final int OPT_COMMENTS = 0;
|
||||
public static final int OPT_SMARTTAG = 1;
|
||||
public static final int OPT_FOOTER_BREAKS = 2;
|
||||
|
||||
} // end interface FrameParameters
|
||||
102
src/venice-base/com/silverwrist/venice/frame/FrameRendering.java
Normal file
102
src/venice-base/com/silverwrist/venice/frame/FrameRendering.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityParamSupplier;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRenderable;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
class FrameRendering implements VelocityRenderable
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_templ;
|
||||
private VelocityParamSupplier m_base_params;
|
||||
private HashMap m_local_vars = new HashMap();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
FrameRendering(FramedContent content, String templ, VelocityParamSupplier base_params, DynamoUser user,
|
||||
String location, Boolean display_login, MenuRenderObject fixed_menu, String footer)
|
||||
{
|
||||
m_templ = templ;
|
||||
m_base_params = base_params;
|
||||
m_local_vars.put("content",content);
|
||||
m_local_vars.put("pagetitle",content.getPageTitle());
|
||||
m_local_vars.put("qid",content.getPageQID());
|
||||
m_local_vars.put("user",user);
|
||||
m_local_vars.put("unverified",
|
||||
Boolean.valueOf(PropertyUtils.hasProperty(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,
|
||||
"confirmation.number")));
|
||||
m_local_vars.put("location",location);
|
||||
m_local_vars.put("display_login",display_login);
|
||||
m_local_vars.put("fixed_menu",fixed_menu);
|
||||
m_local_vars.put("footer_text",footer);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
Object rc = m_local_vars.get(key);
|
||||
if (rc==null)
|
||||
rc = m_base_params.getParameter(key);
|
||||
return rc;
|
||||
|
||||
} // end getParameter
|
||||
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
HashSet rc = new HashSet(m_local_vars.keySet());
|
||||
rc.addAll(m_base_params.getParameterNames());
|
||||
return Collections.unmodifiableSet(rc);
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return "text/html";
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return m_templ;
|
||||
|
||||
} // end getTemplateName
|
||||
|
||||
} // end class FrameRendering
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
/**
|
||||
* An interface implemented by content objects that are to be rendered inside the Venice frame.
|
||||
* The Venice frame provides the outer border, top bar with basic links and ad banner, left bar with
|
||||
* menus, and page footer with standard text and graphics.
|
||||
* <P>Objects implementing this interface are intercepted by an
|
||||
* {@link com.silverwrist.dynamo.iface.OutputObjectFilter OutputObjectFilter} installed by the
|
||||
* {@link com.silverwrist.venice.frame.FrameAssembler FrameAssembler} class, and are wrapped in an object
|
||||
* ({@link com.silverwrist.venice.frame.FrameRendering FrameRendering}), which then renders it as part
|
||||
* of its rendering process.
|
||||
*
|
||||
* @author Eric J. Bowersox <erbo@silcom.com>
|
||||
* @version X
|
||||
*/
|
||||
public interface FramedContent
|
||||
{
|
||||
/**
|
||||
* Returns the desired menu selector for this page. The <EM>menu selector</EM> is a string that specifies
|
||||
* which menu is to be displayed on the left menu bar, in addition to the "global menu." This value may
|
||||
* be <CODE>null</CODE>, in which case the current menu selector is not changed.
|
||||
*
|
||||
* @return The desired menu selector.
|
||||
*/
|
||||
public String getMenuSelector();
|
||||
|
||||
/**
|
||||
* Returns the desired title for the page. This title is concatenated with the <EM>site title</EM> (set in
|
||||
* global properties) to form the actual page title that gets sent to the browser.
|
||||
*
|
||||
* @return The desired page title.
|
||||
*/
|
||||
public String getPageTitle();
|
||||
|
||||
/**
|
||||
* Returns the desired quick ID for the page. The <EM>page quick ID</EM> is a small text string which can be used
|
||||
* to "tag" the page with a unique identifier, for use with external tools such as offsite hit counters.
|
||||
* If this value is <CODE>null</CODE>, the quick ID is not used for this page.
|
||||
*
|
||||
* @return The desired page quick ID.
|
||||
*/
|
||||
public String getPageQID();
|
||||
|
||||
} // end interface FramedContent
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.io.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
class StyleSheetData
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_css_data;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
StyleSheetData(String css_data)
|
||||
{
|
||||
m_css_data = css_data;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void render(TextRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
control.setContentType("text/css");
|
||||
PrintWriter wr = control.getWriter();
|
||||
wr.write(m_css_data);
|
||||
wr.print("\n");
|
||||
wr.flush();
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class StyleSheetData
|
||||
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.apache.commons.collections.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.servlet.ServletBase;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityRenderable;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.except.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
import com.silverwrist.venice.session.SessionInfoParams;
|
||||
|
||||
public class StyleSheetServlet extends ServletBase
|
||||
implements ComponentShutdown, TextRenderer, DynamicUpdateListener
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Inner class implementing the template for rendering.
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private class StyleSheetTemplate implements VelocityRenderable
|
||||
{
|
||||
/*====================================================================
|
||||
* Attributes
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
private String m_template_name;
|
||||
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
StyleSheetTemplate(String template_name)
|
||||
{
|
||||
m_template_name = template_name;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getParameter
|
||||
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
return Collections.EMPTY_SET;
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*====================================================================
|
||||
* Implementations from interface VelocityRenderable
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return "text/css";
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return m_template_name;
|
||||
|
||||
} // end getTemplateName
|
||||
|
||||
} // end class StyleSheetTemplate
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(StyleSheetServlet.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ObjectProvider m_props;
|
||||
private ReferenceMap m_cache = new ReferenceMap(ReferenceMap.HARD,ReferenceMap.SOFT);
|
||||
private Object m_cache_sync = new Object();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected Object process(Request r, Application app) throws Exception
|
||||
{
|
||||
// Get the first half of the sheet property name, based on the request servlet name.
|
||||
StylesheetMapper mapper = (StylesheetMapper)(app.queryService(StylesheetMapper.class));
|
||||
String prop1 = mapper.getStylesheetPrefix(r.getRequestPath());
|
||||
if (prop1==null)
|
||||
{ // no configuration - throw this
|
||||
logger.error("stylesheet prefix for " + r.getRequestPath() + " not configured");
|
||||
StyleSheetException sse = new StyleSheetException(StyleSheetServlet.class,"FrameMessages","ss.noPrefix");
|
||||
sse.setParameter(0,r.getRequestPath());
|
||||
throw sse;
|
||||
|
||||
} // end if
|
||||
|
||||
// Get the second half of the sheet property name - the stylesheet type as noted
|
||||
// in the session.
|
||||
RequestHelper rh = new RequestHelper(r);
|
||||
SessionInfo session = rh.getSession();
|
||||
String prop2 = null;
|
||||
try
|
||||
{ // get the property name
|
||||
prop2 = (String)(session.getObject(SessionInfoParams.NAMESPACE,
|
||||
SessionInfoParams.ATTR_STYLESHEET_SELECTOR));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // property not found
|
||||
logger.warn("session stylesheet selector not found, defaulting to 'normal'");
|
||||
prop2 = "normal"; // default value
|
||||
|
||||
} // end catch
|
||||
|
||||
String propname = "sheet." + prop1 + "." + prop2; // this is the full property name
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Stylesheet property name: " + propname);
|
||||
|
||||
StyleSheetData rc = null;
|
||||
synchronized (m_cache_sync)
|
||||
{ // See if the stylesheet is cached.
|
||||
rc = (StyleSheetData)(m_cache.get(propname));
|
||||
if (rc==null)
|
||||
{ // generate the style sheet data and cache it
|
||||
String template_name = null;
|
||||
try
|
||||
{ // get the template name
|
||||
template_name = (String)(m_props.getObject(VeniceNamespaces.STYLESHEET_NAMESPACE,propname));
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Rendering template name: " + template_name);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // property not found - throw an exception
|
||||
logger.error("did not find stylesheet property with name " + propname,e);
|
||||
StyleSheetException sse = new StyleSheetException(StyleSheetServlet.class,"FrameMessages",
|
||||
"ss.noTemplate",e);
|
||||
sse.setParameter(0,propname);
|
||||
throw sse;
|
||||
|
||||
} // end catch
|
||||
|
||||
// create and render the template
|
||||
StyleSheetTemplate templ = new StyleSheetTemplate(template_name);
|
||||
RenderImmediate rimm = (RenderImmediate)(r.queryService(RenderImmediate.class));
|
||||
try
|
||||
{ // render the stylesheet template and create the StyleSheetData object
|
||||
rc = new StyleSheetData(rimm.renderTextObject(templ));
|
||||
|
||||
} // end try
|
||||
catch (IOException e)
|
||||
{ // throw this as an exception
|
||||
logger.error("RenderImmediate on stylesheet " + template_name + " threw IOException",e);
|
||||
StyleSheetException sse = new StyleSheetException(StyleSheetServlet.class,"FrameMessages",
|
||||
"ss.renderFail",e);
|
||||
sse.setParameter(0,template_name);
|
||||
sse.setParameter(1,e.getMessage());
|
||||
throw sse;
|
||||
|
||||
} // end catch
|
||||
catch (RenderingException e)
|
||||
{ // throw this as an exception
|
||||
logger.error("RenderImmediate on stylesheet " + template_name + " threw RenderingException",e);
|
||||
StyleSheetException sse = new StyleSheetException(StyleSheetServlet.class,"FrameMessages",
|
||||
"ss.renderFail",e);
|
||||
sse.setParameter(0,template_name);
|
||||
sse.setParameter(1,e.getMessage());
|
||||
throw sse;
|
||||
|
||||
} // end catch
|
||||
|
||||
m_cache.put(propname,rc); // cache the new data
|
||||
|
||||
} // end if
|
||||
|
||||
} // end synchronized block
|
||||
|
||||
return rc; // return the style sheet data
|
||||
|
||||
} // end process
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void initServlet(ServiceProvider services) throws DynamoException
|
||||
{
|
||||
logger.info("Starting up StyleSheetServlet");
|
||||
|
||||
// Get the global properties provider.
|
||||
ServiceProvider gprop_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,"globals"));
|
||||
m_props = (ObjectProvider)(gprop_sp.queryService(ObjectProvider.class,"properties"));
|
||||
|
||||
// Register this class as being a renderer for StyleSheetData.
|
||||
RendererRegistration rreg = (RendererRegistration)(services.queryService(RendererRegistration.class));
|
||||
addShutdownHook(rreg.registerRenderer(StyleSheetData.class,this));
|
||||
|
||||
// Register to receive global property update events.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
addShutdownHook(reg.registerDynamicUpdateListener(GlobalPropertyUpdateEvent.class,this));
|
||||
|
||||
logger.info("StyleSheetServlet initialized");
|
||||
|
||||
} // end initServlet
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_props = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface TextRenderer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(Object obj, TextRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
((StyleSheetData)obj).render(control);
|
||||
|
||||
} // end render
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
GlobalPropertyUpdateEvent event = (GlobalPropertyUpdateEvent)evt;
|
||||
if (VeniceNamespaces.STYLESHEET_NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // a stylesheet template name has changed...
|
||||
synchronized (m_cache_sync)
|
||||
{ // un-cache the corresponding stylesheet data
|
||||
m_cache.remove(event.getPropertyName());
|
||||
|
||||
} // end synchronized block
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
} // end class StyleSheetServlet
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.frame;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
public class TempFramedContent implements FramedContent, SelfRenderable
|
||||
{
|
||||
private Object m_obj;
|
||||
|
||||
public TempFramedContent(Object obj)
|
||||
{
|
||||
m_obj = obj;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return "";
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
public String getPageTitle()
|
||||
{
|
||||
return "TempFramedContent";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return "";
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
control.getTextRender().renderSubObject(m_obj);
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class TempFramedContent
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import com.silverwrist.venice.ButtonType;
|
||||
|
||||
public interface ButtonProvider
|
||||
{
|
||||
public Object getButtonRenderObject(ButtonType type, String name);
|
||||
|
||||
} // end interface ButtonProvider
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
public interface ContentBlock
|
||||
{
|
||||
public void setContentParameter(String name, Object obj);
|
||||
|
||||
} // end interface ContentBlock
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import com.silverwrist.dynamo.except.DatabaseException;
|
||||
|
||||
public interface ContentBlockProvider
|
||||
{
|
||||
public ContentBlock getContentBlock(String name) throws DatabaseException;
|
||||
|
||||
} // end interface ContentBlockProvider
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import com.silverwrist.dynamo.except.DatabaseException;
|
||||
import com.silverwrist.dynamo.iface.DynamoUser;
|
||||
|
||||
public interface MenuProvider
|
||||
{
|
||||
public MenuRenderObject getStandardMenu(DynamoUser caller, String namespace, String name, int[] acl_ids)
|
||||
throws DatabaseException;
|
||||
|
||||
public MenuRenderObject getLeftMenu(DynamoUser caller, String namespace, String name, int[] acl_ids)
|
||||
throws DatabaseException;
|
||||
|
||||
} // end interface MenuProvider
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
public interface MenuRenderObject
|
||||
{
|
||||
public void setVariable(String name, String value);
|
||||
|
||||
} // end interface MenuRenderObject
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.dynamo.except.RenderingException;
|
||||
import com.silverwrist.dynamo.iface.TextRenderControl;
|
||||
|
||||
public interface RenderImage
|
||||
{
|
||||
public void renderImageTag(TextRenderControl control, String url) throws IOException, RenderingException;
|
||||
|
||||
public Object getRenderingObject(String url);
|
||||
|
||||
} // end interface RenderImage
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
public interface StylesheetMapper
|
||||
{
|
||||
public String getStylesheetPrefix(String path);
|
||||
|
||||
} // end interface StylesheetMapper
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface UserDefaultPropertyNamespace
|
||||
{
|
||||
public Collection getDefaultPropertyNamespaces();
|
||||
|
||||
} // end interface UserDefaultPropertyNamespace
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.iface;
|
||||
|
||||
import com.silverwrist.dynamo.iface.ComponentShutdown;
|
||||
|
||||
public interface UserDefaultPropertyNamespaceRegistration
|
||||
{
|
||||
public ComponentShutdown registerUserDefaultPropertyNamespace(String namespace);
|
||||
|
||||
} // end interface UserDefaultPropertyNamespaceRegistration
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
class LeftMenuRendering implements MenuRenderObject, SelfRenderable
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private MenuDefinition m_menudef;
|
||||
private boolean[] m_showitem;
|
||||
private HashMap m_local_vars;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
LeftMenuRendering(DynamoUser caller, MenuDefinition def, SecurityReferenceMonitor srm, int[] acl_ids)
|
||||
throws DatabaseException
|
||||
{
|
||||
m_menudef = def;
|
||||
int count = def.getItemCount();
|
||||
m_showitem = new boolean[count];
|
||||
for (int i=0; i<count; i++)
|
||||
{ // get the "show item" flags
|
||||
MenuItemDefinition item = def.getItem(i);
|
||||
m_showitem[i] = item.itemAppears(caller,srm,acl_ids);
|
||||
|
||||
} // end for
|
||||
|
||||
m_local_vars = new HashMap(def.getVarDefaults());
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final void renderTextItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
String s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write("class=\"frameleft\" >");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderTextItem
|
||||
|
||||
private final void renderHeaderItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
wr.write("<b>");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
String s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write("class=\"frameleft\" >");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("</b><br />\n");
|
||||
|
||||
} // end renderHeaderItem
|
||||
|
||||
private final void renderImageItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
String s;
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write(" class=\"frameleft\">");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
String[] data = StringUtils.split(item.getText(),",",4);
|
||||
wr.write("<img src=\"" + rewriter.rewriteURL(data[2],StringUtils.replaceAllVariables(data[3],m_local_vars))
|
||||
+ "\"");
|
||||
s = item.getTitle();
|
||||
if (s==null)
|
||||
wr.write(" alt=\"\"");
|
||||
else
|
||||
wr.write(" alt=\"" + s + "\" title=\"" + s + "\"");
|
||||
wr.write(" width=\"" + data[0] + "\" height=\"" + data[1] + "\" border=\"0\" />");
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderImageItem
|
||||
|
||||
private final void renderSeparatorItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderSeparatorItem
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface MenuRenderObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setVariable(String name, String value)
|
||||
{
|
||||
if (m_menudef.isVariable(name))
|
||||
m_local_vars.put(name,value);
|
||||
|
||||
} // end setVariable
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SelfRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
TextRenderControl tctrl = control.getTextRender();
|
||||
PrintWriter wr = tctrl.getWriter();
|
||||
if (m_menudef.getTitle()!=null)
|
||||
{ // write the title and subtitle
|
||||
wr.write("<b>" + StringUtils.encodeHTML(m_menudef.getTitle()) + "</b><br />\n");
|
||||
if (m_menudef.getSubtitle()!=null)
|
||||
wr.write(StringUtils.encodeHTML(m_menudef.getSubtitle()) + "<br />\n");
|
||||
|
||||
} // end if
|
||||
|
||||
for (int i=0; i<m_showitem.length; i++)
|
||||
{ // render each menu item in turn
|
||||
MenuItemDefinition item = m_menudef.getItem(i);
|
||||
if (m_showitem[i] && item.itemDefined(m_local_vars))
|
||||
{ // render this item
|
||||
String s = item.getItemType();
|
||||
if (s.equalsIgnoreCase("TEXT"))
|
||||
renderTextItem(tctrl,item);
|
||||
if (s.equalsIgnoreCase("HEADER"))
|
||||
renderHeaderItem(tctrl,item);
|
||||
if (s.equalsIgnoreCase("IMAGE"))
|
||||
renderImageItem(tctrl,item);
|
||||
if (s.equalsIgnoreCase("SEPARATOR"))
|
||||
renderSeparatorItem(tctrl,item);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class LeftMenuRendering
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||
import com.silverwrist.dynamo.db.OpsBase;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
abstract class MenuDatabaseOps extends OpsBase
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private NamespaceCache m_ns_cache;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected MenuDatabaseOps(DBConnectionPool pool)
|
||||
{
|
||||
super(pool);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected final int namespaceNameToId(String name) throws DatabaseException
|
||||
{
|
||||
return m_ns_cache.namespaceNameToId(name);
|
||||
|
||||
} // end namespaceNameToId
|
||||
|
||||
protected final String namespaceIdToName(int id) throws DatabaseException
|
||||
{
|
||||
return m_ns_cache.namespaceIdToName(id);
|
||||
|
||||
} // end namespaceIdToName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
abstract MenuDefinition getMenu(String namespace, String name) throws DatabaseException;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void setNamespaceCache(NamespaceCache nsc)
|
||||
{
|
||||
m_ns_cache = nsc;
|
||||
|
||||
} // end setNamespaceCache
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static MenuDatabaseOps get(DBConnectionPool pool) throws ConfigException
|
||||
{
|
||||
return (MenuDatabaseOps)get(pool,MenuDatabaseOps.class.getClassLoader(),
|
||||
MenuDatabaseOps.class.getName() + "_","MenuDatabaseOps");
|
||||
|
||||
} // end get
|
||||
|
||||
} // end class MenuDatabaseOps
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import java.sql.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
public class MenuDatabaseOps_mysql extends MenuDatabaseOps
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public MenuDatabaseOps_mysql(DBConnectionPool pool)
|
||||
{
|
||||
super(pool);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class MenuDatabaseOps
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MenuDefinition getMenu(String namespace, String name) throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// create the statement to retrieve the base data
|
||||
stmt = conn.prepareStatement("SELECT m.menuid, m.title, m.subtitle FROM menus m, namespaces n "
|
||||
+ "WHERE m.menu_nsid = n.nsid AND n.namespace = ? AND m.menu_name = ?;");
|
||||
stmt.setString(1,namespace);
|
||||
stmt.setString(2,name);
|
||||
rs = stmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
return null; // not found
|
||||
|
||||
// get the ID and create the initial menu definition
|
||||
int id = rs.getInt(1);
|
||||
MenuDefinition def = new MenuDefinition(id,namespace,name,rs.getString(2),rs.getString(3));
|
||||
|
||||
// shut down things for the next operation
|
||||
SQLUtils.shutdown(rs);
|
||||
rs = null;
|
||||
SQLUtils.shutdown(stmt);
|
||||
|
||||
// get the variable definitions
|
||||
stmt = conn.prepareStatement("SELECT var_name, default_val FROM menuvars WHERE menuid = ?;");
|
||||
stmt.setInt(1,id);
|
||||
rs = stmt.executeQuery();
|
||||
while (rs.next())
|
||||
def.addVariableDef(rs.getString(1),rs.getString(2));
|
||||
|
||||
// shut down things for the next operation
|
||||
SQLUtils.shutdown(rs);
|
||||
rs = null;
|
||||
SQLUtils.shutdown(stmt);
|
||||
|
||||
// get the menu items
|
||||
stmt = conn.prepareStatement("SELECT itemtype, enable, indent, text, linktype, link, target, title, "
|
||||
+ "on_click, perm_nsid, perm_name, ifdef_var, ifndef_var FROM menuitems "
|
||||
+ "WHERE menuid = ? ORDER BY sequence;");
|
||||
stmt.setInt(1,id);
|
||||
rs = stmt.executeQuery();
|
||||
while (rs.next())
|
||||
{ // get the namespace and add the item definition
|
||||
int nsid = rs.getInt(10);
|
||||
String ns = (rs.wasNull() ? null : namespaceIdToName(nsid));
|
||||
MenuItemDefinition item = new MenuItemDefinition(rs.getString(1),(rs.getInt(2)!=0),rs.getInt(3),
|
||||
rs.getString(4),rs.getString(5),rs.getString(6),
|
||||
rs.getString(7),rs.getString(8),rs.getString(9),ns,
|
||||
rs.getString(11),rs.getString(12),rs.getString(13));
|
||||
def.addItemDef(item);
|
||||
|
||||
} // end while
|
||||
|
||||
return def;
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getMenu
|
||||
|
||||
} // end class MenuDatabaseOps_mysql
|
||||
125
src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java
Normal file
125
src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MenuDefinition
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int m_id;
|
||||
private String m_namespace;
|
||||
private String m_name;
|
||||
private String m_title;
|
||||
private String m_subtitle;
|
||||
private HashSet m_vars = new HashSet();
|
||||
private HashMap m_defaults = new HashMap();
|
||||
private ArrayList m_items = new ArrayList();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MenuDefinition(int id, String namespace, String name, String title, String subtitle)
|
||||
{
|
||||
m_id = id;
|
||||
m_namespace = namespace;
|
||||
m_name = name;
|
||||
m_title = title;
|
||||
m_subtitle = subtitle;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void addVariableDef(String name, String default_val)
|
||||
{
|
||||
m_vars.add(name);
|
||||
if (default_val!=null)
|
||||
m_defaults.put(name,default_val);
|
||||
|
||||
} // end addVariableDef
|
||||
|
||||
void addItemDef(MenuItemDefinition item)
|
||||
{
|
||||
m_items.add(item);
|
||||
|
||||
} // end addItemDef
|
||||
|
||||
Map getVarDefaults()
|
||||
{
|
||||
return Collections.unmodifiableMap(m_defaults);
|
||||
|
||||
} // end getVarDefaults
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getNamespace()
|
||||
{
|
||||
return m_namespace;
|
||||
|
||||
} // end getNamespace
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
public String getSubtitle()
|
||||
{
|
||||
return m_subtitle;
|
||||
|
||||
} // end getSubtitle
|
||||
|
||||
public boolean isVariable(String name)
|
||||
{
|
||||
return m_vars.contains(name);
|
||||
|
||||
} // end isVariable
|
||||
|
||||
public int getItemCount()
|
||||
{
|
||||
return m_items.size();
|
||||
|
||||
} // end getItemCount
|
||||
|
||||
public MenuItemDefinition getItem(int ndx)
|
||||
{
|
||||
return (MenuItemDefinition)(m_items.get(ndx));
|
||||
|
||||
} // end getItem
|
||||
|
||||
} // end class MenuDefinition
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
|
||||
public class MenuItemDefinition
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_type;
|
||||
private boolean m_enable;
|
||||
private int m_indent;
|
||||
private String m_text;
|
||||
private String m_linktype;
|
||||
private String m_link;
|
||||
private String m_target;
|
||||
private String m_title;
|
||||
private String m_on_click;
|
||||
private String m_perm_namespace;
|
||||
private String m_perm_name;
|
||||
private String m_ifdef_var;
|
||||
private String m_ifndef_var;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MenuItemDefinition(String type, boolean enable, int indent, String text, String linktype, String link,
|
||||
String target, String title, String on_click, String perm_namespace, String perm_name,
|
||||
String ifdef_var, String ifndef_var)
|
||||
{
|
||||
m_type = type;
|
||||
m_enable = enable;
|
||||
m_indent = indent;
|
||||
m_text = text;
|
||||
m_linktype = linktype;
|
||||
m_link = link;
|
||||
if ((m_link!=null) && (m_linktype==null))
|
||||
m_linktype = "ABSOLUTE";
|
||||
m_target = target;
|
||||
m_title = title;
|
||||
m_on_click = on_click;
|
||||
m_perm_namespace = perm_namespace;
|
||||
m_perm_name = perm_name;
|
||||
m_ifdef_var = ifdef_var;
|
||||
m_ifndef_var = ifndef_var;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
boolean itemAppears(DynamoUser caller, SecurityReferenceMonitor srm, int[] acl_ids) throws DatabaseException
|
||||
{
|
||||
if ((m_perm_namespace==null) && (m_perm_name==null))
|
||||
return true;
|
||||
for (int i=0; i<acl_ids.length; i++)
|
||||
{ // test each of the ACL IDs in turn
|
||||
if (srm.testPermission(acl_ids[i],caller,m_perm_namespace,m_perm_name))
|
||||
return true;
|
||||
|
||||
} // end for
|
||||
|
||||
return false;
|
||||
|
||||
} // end itemAppears
|
||||
|
||||
boolean itemDefined(Map vars)
|
||||
{
|
||||
boolean r1, r2;
|
||||
if (m_ifdef_var==null)
|
||||
r1 = true;
|
||||
else
|
||||
r1 = vars.containsKey(m_ifdef_var);
|
||||
if (m_ifndef_var==null)
|
||||
r2 = true;
|
||||
else
|
||||
r2 = !(vars.containsKey(m_ifndef_var));
|
||||
return (r1 && r2);
|
||||
|
||||
} // end itemDefined
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getItemType()
|
||||
{
|
||||
return m_type;
|
||||
|
||||
} // end getItemType
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return m_enable;
|
||||
|
||||
} // end isEnabled
|
||||
|
||||
public int getIndentLevel()
|
||||
{
|
||||
return m_indent;
|
||||
|
||||
} // end getIndentLevel
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return m_text;
|
||||
|
||||
} // end getText
|
||||
|
||||
public String getLinkType()
|
||||
{
|
||||
return m_linktype;
|
||||
|
||||
} // end getLinkType
|
||||
|
||||
public String getLink()
|
||||
{
|
||||
return m_link;
|
||||
|
||||
} // end getLink
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return m_target;
|
||||
|
||||
} // end getTarget
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getTitle
|
||||
|
||||
public String getOnClick()
|
||||
{
|
||||
return m_on_click;
|
||||
|
||||
} // end getOnClick
|
||||
|
||||
} // end class MenuItemDefinition
|
||||
188
src/venice-base/com/silverwrist/venice/menu/MenuManager.java
Normal file
188
src/venice-base/com/silverwrist/venice/menu/MenuManager.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class MenuManager implements NamedObject, ComponentInitialize, ComponentShutdown, MenuProvider
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(MenuManager.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name = null;
|
||||
private NamespaceCache m_ns_cache;
|
||||
private SecurityReferenceMonitor m_srm;
|
||||
private MenuDatabaseOps m_ops;
|
||||
private HardSoftCache m_menudef_cache;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public MenuManager()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public synchronized String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("MenuManager initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String name_pool = null, name_cache = null, name_srm = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the database pool and namespace cache
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"database");
|
||||
name_pool = loader.getAttribute(foo,"connection");
|
||||
name_cache = loader.getAttribute(foo,"namespaces");
|
||||
|
||||
// get the name of the security reference monitor
|
||||
foo = loader.getSubElement(config_root_h,"security");
|
||||
name_srm = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in StandardContentSupplier",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the database connection pool.
|
||||
DBConnectionPool pool = GetObjectUtils.getDatabaseConnection(services,name_pool);
|
||||
|
||||
// Get the namespace cache.
|
||||
m_ns_cache = (NamespaceCache)(GetObjectUtils.getDynamoComponent(services,NamespaceCache.class,name_cache));
|
||||
|
||||
// Get the security reference monitor.
|
||||
m_srm =
|
||||
(SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class,
|
||||
name_srm));
|
||||
|
||||
// Get the menu database operations.
|
||||
m_ops = MenuDatabaseOps.get(pool);
|
||||
m_ops.setNamespaceCache(m_ns_cache);
|
||||
|
||||
// Create the menu definition cache.
|
||||
m_menudef_cache = new HardSoftCache(3,10);
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_ns_cache = null;
|
||||
m_srm = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface MenuProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public MenuRenderObject getStandardMenu(DynamoUser caller, String namespace, String name, int[] acl_ids)
|
||||
throws DatabaseException
|
||||
{
|
||||
QualifiedNameKey key = new QualifiedNameKey(namespace,name);
|
||||
MenuDefinition mdef = (MenuDefinition)(m_menudef_cache.get(key));
|
||||
if (mdef==null)
|
||||
{ // get it and add it to the cache
|
||||
mdef = m_ops.getMenu(namespace,name);
|
||||
m_menudef_cache.put(key,mdef);
|
||||
|
||||
} // end if
|
||||
|
||||
return new StandardMenuRendering(caller,mdef,m_srm,acl_ids);
|
||||
|
||||
} // end getStandardMenu
|
||||
|
||||
public MenuRenderObject getLeftMenu(DynamoUser caller, String namespace, String name, int[] acl_ids)
|
||||
throws DatabaseException
|
||||
{
|
||||
QualifiedNameKey key = new QualifiedNameKey(namespace,name);
|
||||
MenuDefinition mdef = (MenuDefinition)(m_menudef_cache.get(key));
|
||||
if (mdef==null)
|
||||
{ // get it and add it to the cache
|
||||
mdef = m_ops.getMenu(namespace,name);
|
||||
m_menudef_cache.put(key,mdef);
|
||||
|
||||
} // end if
|
||||
|
||||
return new LeftMenuRendering(caller,mdef,m_srm,acl_ids);
|
||||
|
||||
} // end getLeftMenu
|
||||
|
||||
} // end class MenuManager
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.menu;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.venice.frame.FramedContent;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
class StandardMenuRendering implements MenuRenderObject, SelfRenderable, FramedContent
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private MenuDefinition m_menudef;
|
||||
private boolean[] m_showitem;
|
||||
private HashMap m_local_vars;
|
||||
private ContentBlock m_bullet = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
StandardMenuRendering(DynamoUser caller, MenuDefinition def, SecurityReferenceMonitor srm, int[] acl_ids)
|
||||
throws DatabaseException
|
||||
{
|
||||
m_menudef = def;
|
||||
int count = def.getItemCount();
|
||||
m_showitem = new boolean[count];
|
||||
for (int i=0; i<count; i++)
|
||||
{ // get the "show item" flags
|
||||
MenuItemDefinition item = def.getItem(i);
|
||||
m_showitem[i] = item.itemAppears(caller,srm,acl_ids);
|
||||
|
||||
} // end for
|
||||
|
||||
m_local_vars = new HashMap(def.getVarDefaults());
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final void renderTextItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
control.renderSubObject(m_bullet);
|
||||
wr.write(" ");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
String s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write(">");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderTextItem
|
||||
|
||||
private final void renderHeaderItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
wr.write("<span style=\"font-weight: bold; text-decoration: underline;\">");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
String s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write(">");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("</span><br />\n");
|
||||
|
||||
} // end renderHeaderItem
|
||||
|
||||
private final void renderImageItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
|
||||
String s;
|
||||
PrintWriter wr = control.getWriter();
|
||||
for (int i=0; i<item.getIndentLevel(); i++)
|
||||
wr.write(" ");
|
||||
if (item.isEnabled() && (item.getLink()!=null))
|
||||
{ // write the link
|
||||
wr.write("<a href=\""
|
||||
+ rewriter.rewriteURL(item.getLinkType(),
|
||||
StringUtils.replaceAllVariables(item.getLink(),m_local_vars)) + "\"");
|
||||
s = item.getTarget();
|
||||
if (s!=null)
|
||||
wr.write(" target=\"" + s + "\"");
|
||||
s = item.getTitle();
|
||||
if (s!=null)
|
||||
wr.write(" title=\"" + s + "\"");
|
||||
s = item.getOnClick();
|
||||
if (s!=null)
|
||||
wr.write(" onClick=\"" + s + "\"");
|
||||
wr.write(">");
|
||||
|
||||
} // end if
|
||||
else // just disable the text
|
||||
wr.write("<span style=\"color: silver;\">");
|
||||
String[] data = StringUtils.split(item.getText(),",",4);
|
||||
wr.write("<img src=\"" + rewriter.rewriteURL(data[2],StringUtils.replaceAllVariables(data[3],m_local_vars))
|
||||
+ "\"");
|
||||
s = item.getTitle();
|
||||
if (s==null)
|
||||
wr.write(" alt=\"\"");
|
||||
else
|
||||
wr.write(" alt=\"" + s + "\" title=\"" + s + "\"");
|
||||
wr.write(" width=\"" + data[0] + "\" height=\"" + data[1] + "\" border=\"0\" />");
|
||||
if (item.isEnabled())
|
||||
wr.write("</a>");
|
||||
else
|
||||
wr.write("</span>");
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderImageItem
|
||||
|
||||
private final void renderSeparatorItem(TextRenderControl control, MenuItemDefinition item)
|
||||
throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getWriter();
|
||||
wr.write("<br />\n");
|
||||
|
||||
} // end renderSeparatorItem
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface MenuRenderObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setVariable(String name, String value)
|
||||
{
|
||||
if (m_menudef.isVariable(name))
|
||||
m_local_vars.put(name,value);
|
||||
|
||||
} // end setVariable
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SelfRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
ObjectProvider op = (ObjectProvider)(control.queryService(ObjectProvider.class));
|
||||
ServiceProvider tmp_sp = (ServiceProvider)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-content"));
|
||||
ContentBlockProvider cblkp = (ContentBlockProvider)(tmp_sp.queryService(ContentBlockProvider.class));
|
||||
ContentBlock header = null;
|
||||
try
|
||||
{ // get a header block
|
||||
header = cblkp.getContentBlock("content.header");
|
||||
if (m_bullet==null)
|
||||
m_bullet = cblkp.getContentBlock("std.bullet");
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException e)
|
||||
{ // header block failed
|
||||
throw new RenderingException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// set the parameters for the content header
|
||||
header.setContentParameter("title",StringUtils.replaceAllVariables(m_menudef.getTitle(),m_local_vars));
|
||||
String s = m_menudef.getSubtitle();
|
||||
if (s!=null)
|
||||
header.setContentParameter("subtitle",StringUtils.replaceAllVariables(s,m_local_vars));
|
||||
|
||||
// render the header
|
||||
TextRenderControl tctl = control.getTextRender();
|
||||
tctl.renderSubObject(header);
|
||||
|
||||
PrintWriter wr = tctl.getWriter();
|
||||
wr.write("<div class=\"content\">\n");
|
||||
|
||||
for (int i=0; i<m_showitem.length; i++)
|
||||
{ // render each menu item in turn
|
||||
MenuItemDefinition item = m_menudef.getItem(i);
|
||||
if (m_showitem[i] && item.itemDefined(m_local_vars))
|
||||
{ // render this item
|
||||
s = item.getItemType();
|
||||
if (s.equalsIgnoreCase("TEXT"))
|
||||
renderTextItem(tctl,item);
|
||||
if (s.equalsIgnoreCase("HEADER"))
|
||||
renderHeaderItem(tctl,item);
|
||||
if (s.equalsIgnoreCase("IMAGE"))
|
||||
renderImageItem(tctl,item);
|
||||
if (s.equalsIgnoreCase("SEPARATOR"))
|
||||
renderSeparatorItem(tctl,item);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
wr.write("</div>\n");
|
||||
|
||||
} // end render
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
public String getPageTitle()
|
||||
{
|
||||
return m_menudef.getTitle();
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
} // end class StandardMenuRendering
|
||||
215
src/venice-base/com/silverwrist/venice/script/LibraryVenice.java
Normal file
215
src/venice-base/com/silverwrist/venice/script/LibraryVenice.java
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.script;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.db.UserManagement;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
import com.silverwrist.venice.content.*;
|
||||
import com.silverwrist.venice.session.SessionInfoParams;
|
||||
|
||||
public class LibraryVenice
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final int CONFIRM_MIN = 1000000;
|
||||
public static final int CONFIRM_MAX = 9999999;
|
||||
|
||||
private static final String ALPHABET =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
|
||||
private static final char[] ALPHA_ARRAY = ALPHABET.toCharArray();
|
||||
|
||||
private static final String[] SYLLABARY = {
|
||||
"ba", "be", "bi", "bo", "bu",
|
||||
"da", "de", "di", "do", "du",
|
||||
"cha", "chi", "cho", "chu",
|
||||
"fa", "fe", "fi", "fo", "fu",
|
||||
"ga", "ge", "gi", "go", "gu",
|
||||
"ha", "he", "hi", "ho", "hu",
|
||||
"ja", "je", "ji", "jo", "ju",
|
||||
"ka", "ke", "ki", "ko", "ku",
|
||||
"la", "le", "li", "lo", "lu",
|
||||
"ma", "me", "mi", "mo", "mu",
|
||||
"na", "ne", "ni", "no", "nu",
|
||||
"pa", "pe", "pi", "po", "pu",
|
||||
"ra", "re", "ri", "ro", "ru",
|
||||
"sa", "se", "si", "so", "su",
|
||||
"sha", "she", "sho", "shu",
|
||||
"ta", "te", "ti", "to", "tu",
|
||||
"va", "ve", "vi", "vo", "vu",
|
||||
"wa", "we", "wi", "wo", "wu",
|
||||
"ya", "ye", "yi", "yo", "yu",
|
||||
"za", "ze", "zi", "zo", "zu"
|
||||
}; // 98 syllables
|
||||
|
||||
private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Random m_rng;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public LibraryVenice()
|
||||
{
|
||||
m_rng = new Random();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String dialogFrameTitle(Dialog dlg)
|
||||
{
|
||||
String s = dlg.getSubtitle();
|
||||
if (s==null)
|
||||
return dlg.getTitle();
|
||||
StringBuffer buf = new StringBuffer(dlg.getTitle());
|
||||
buf.append(" - ").append(s);
|
||||
return buf.toString();
|
||||
|
||||
} // end dialogFrameTitle
|
||||
|
||||
public String getLocation(Request req)
|
||||
{
|
||||
return (String)(req.getObject(SessionInfoParams.REQ_NAMESPACE,SessionInfoParams.RATTR_LOCATION));
|
||||
|
||||
} // end getLocation
|
||||
|
||||
public DynamoUser getUser(SessionInfo session)
|
||||
{
|
||||
return (DynamoUser)(session.getObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_USER));
|
||||
|
||||
} // end getUser
|
||||
|
||||
public DynamoUser getUser(Request request)
|
||||
{
|
||||
SessionInfoProvider prov = (SessionInfoProvider)(request.queryService(SessionInfoProvider.class));
|
||||
return this.getUser(prov.getSessionInfo());
|
||||
|
||||
} // end getUser
|
||||
|
||||
public DynamoUser lookupUser(Request req, String name) throws DatabaseException
|
||||
{
|
||||
if (StringUtils.isEmpty(name))
|
||||
return null;
|
||||
ObjectProvider op = (ObjectProvider)(req.queryService(ObjectProvider.class));
|
||||
UserManagement umgmt = (UserManagement)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"users"));
|
||||
return umgmt.getUser(name);
|
||||
|
||||
} // end lookupUser
|
||||
|
||||
public DynamoUser lookupUser(Request req, int uid) throws DatabaseException
|
||||
{
|
||||
if (uid<=0)
|
||||
return null;
|
||||
ObjectProvider op = (ObjectProvider)(req.queryService(ObjectProvider.class));
|
||||
UserManagement umgmt = (UserManagement)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"users"));
|
||||
return umgmt.getUser(uid);
|
||||
|
||||
} // end lookupUser
|
||||
|
||||
public int randomConfirmationNumber()
|
||||
{
|
||||
return m_rng.nextInt(CONFIRM_MAX - CONFIRM_MIN + 1) + CONFIRM_MIN;
|
||||
|
||||
} // end randomConfirmationNumber
|
||||
|
||||
public String randomPassword()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int i;
|
||||
for (i=0; i<4; i++) // 4 random syllables
|
||||
buf.append(SYLLABARY[m_rng.nextInt(SYLLABARY.length)]);
|
||||
for (i=0; i<3; i++) // 3 random digits
|
||||
buf.append(DIGITS[m_rng.nextInt(DIGITS.length)]);
|
||||
return buf.toString();
|
||||
// total possible number of passwords = 92,236,816,000
|
||||
|
||||
} // end randomPassword
|
||||
|
||||
public String randomRecoveryAuth()
|
||||
{
|
||||
return String.valueOf(m_rng.nextInt(Integer.MAX_VALUE));
|
||||
|
||||
} // end randomRecoveryAuth
|
||||
|
||||
public String randomString(int len)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(len);
|
||||
for (int i=0; i<len; i++)
|
||||
buf.append(ALPHA_ARRAY[m_rng.nextInt(ALPHA_ARRAY.length)]);
|
||||
return buf.toString();
|
||||
|
||||
} // end randomString
|
||||
|
||||
public void setLocation(Request req, String location)
|
||||
{
|
||||
req.setObject(SessionInfoParams.REQ_NAMESPACE,SessionInfoParams.RATTR_LOCATION,location);
|
||||
|
||||
} // end setLocation
|
||||
|
||||
public void setDisplayLogin(Request req, boolean flag)
|
||||
{
|
||||
req.setObject(SessionInfoParams.REQ_NAMESPACE,SessionInfoParams.RATTR_DISPLAY_LOGIN,
|
||||
Boolean.valueOf(flag));
|
||||
|
||||
} // end setDisplayLogin
|
||||
|
||||
public void setOnError(Request req, String on_error)
|
||||
{
|
||||
req.setObject(VeniceNamespaces.REQUEST_INFO_NAMESPACE,"on.error",on_error);
|
||||
|
||||
} // end setOnError
|
||||
|
||||
public void setOnErrorType(Request req, String on_error)
|
||||
{
|
||||
req.setObject(VeniceNamespaces.REQUEST_INFO_NAMESPACE,"on.error.type",on_error);
|
||||
|
||||
} // end setOnErrorType
|
||||
|
||||
public ErrorBox stdErrorBox(Request req, String title, String message)
|
||||
{
|
||||
String onerr = (String)(PropertyUtils.getPropertyNoErr(req,VeniceNamespaces.REQUEST_INFO_NAMESPACE,
|
||||
"on.error"));
|
||||
String onerr_type = (String)(PropertyUtils.getPropertyNoErr(req,VeniceNamespaces.REQUEST_INFO_NAMESPACE,
|
||||
"on.error.type"));
|
||||
if (onerr!=null)
|
||||
return new ErrorBox(title,message,onerr_type,onerr);
|
||||
else
|
||||
return new ErrorBox(title,message);
|
||||
|
||||
} // end stdErrorBox
|
||||
|
||||
} // end class LibraryVenice
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.script;
|
||||
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class LibraryVeniceCast
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public LibraryVeniceCast()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final Object query(Object obj, Class klass)
|
||||
{
|
||||
if (klass.isInstance(obj))
|
||||
return obj;
|
||||
if (obj instanceof ServiceProvider)
|
||||
{ // try using ServiceProvider
|
||||
try
|
||||
{ // query for this object as a service
|
||||
return ((ServiceProvider)obj).queryService(klass);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // do nothing with this exception
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
throw new ClassCastException("object is not an instance of " + klass.getName());
|
||||
|
||||
} // end query
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public final SecureObjectStore getGlobalBlocksStore(Request r)
|
||||
{
|
||||
ObjectProvider op = (ObjectProvider)(r.queryService(ObjectProvider.class));
|
||||
ServiceProvider sp = (ServiceProvider)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"globals"));
|
||||
return (SecureObjectStore)(sp.queryService(SecureObjectStore.class,"blocks"));
|
||||
|
||||
} // end getGlobalPropertiesStore
|
||||
|
||||
public final SecureObjectStore getGlobalPropertiesStore(Request r)
|
||||
{
|
||||
ObjectProvider op = (ObjectProvider)(r.queryService(ObjectProvider.class));
|
||||
ServiceProvider sp = (ServiceProvider)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"globals"));
|
||||
return (SecureObjectStore)(sp.queryService(SecureObjectStore.class,"properties"));
|
||||
|
||||
} // end getGlobalPropertiesStore
|
||||
|
||||
public final ButtonProvider queryButtonProvider(Object obj)
|
||||
{
|
||||
return (ButtonProvider)query(obj,ButtonProvider.class);
|
||||
|
||||
} // end queryButtonProvider
|
||||
|
||||
public final ContentBlockProvider queryContentBlockProvider(Object obj)
|
||||
{
|
||||
return (ContentBlockProvider)query(obj,ContentBlockProvider.class);
|
||||
|
||||
} // end queryContentBlockProvider
|
||||
|
||||
public final RenderImage queryRenderImage(Object obj)
|
||||
{
|
||||
return (RenderImage)query(obj,RenderImage.class);
|
||||
|
||||
} // end queryRenderImage
|
||||
|
||||
public final UserDefaultPropertyNamespace queryUserDefaultPropertyNamespace(Object obj)
|
||||
{
|
||||
return (UserDefaultPropertyNamespace)query(obj,UserDefaultPropertyNamespace.class);
|
||||
|
||||
} // end queryUserDefaultPropertyNamespace
|
||||
|
||||
} // end class LibraryVeniceCast
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlet;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
class BinaryPageData extends PageData
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_type;
|
||||
private int m_length;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BinaryPageData(File file, String type) throws IOException
|
||||
{
|
||||
super(file);
|
||||
m_type = type;
|
||||
m_length = (int)(file.length());
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class PageData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
BinaryRenderControl c = control.getBinaryRender();
|
||||
c.setContentType(m_type);
|
||||
c.setContentLength(m_length);
|
||||
InputStream in = null;
|
||||
OutputStream out = c.getStream();
|
||||
try
|
||||
{ // copy the data out!
|
||||
in = new FileInputStream(m_file);
|
||||
IOUtils.copy(in,out);
|
||||
out.flush();
|
||||
|
||||
} // end try
|
||||
finally
|
||||
{ // close the file stream when we're done
|
||||
IOUtils.shutdown(in);
|
||||
|
||||
} // end finally;
|
||||
|
||||
} // end render
|
||||
|
||||
} // end class BinaryPageData
|
||||
179
src/venice-base/com/silverwrist/venice/servlet/FrameServlet.java
Normal file
179
src/venice-base/com/silverwrist/venice/servlet/FrameServlet.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlet;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.HttpStatusCode;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.servlet.ServletBase;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
|
||||
public class FrameServlet extends ServletBase
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final int DEFAULT_HARD_LIMIT = 5;
|
||||
private static final int DEFAULT_SOFT_LIMIT = 10;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private File m_base_directory; // base directory from where we get static pages
|
||||
private HardSoftCache m_cache; // cache for static page information
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected Object process(Request r, Application app) throws Exception
|
||||
{
|
||||
String page_name = r.getExtraPath().substring(1);
|
||||
PageData pd = (PageData)(m_cache.get(page_name));
|
||||
if (pd!=null)
|
||||
{ // found page data - test to see if it's been modified
|
||||
if (pd.isModified())
|
||||
{ // data is modified - kick it out of the cache
|
||||
m_cache.remove(page_name);
|
||||
pd = null;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if
|
||||
|
||||
if (pd==null)
|
||||
{ // Start by getting the File associated with this page name.
|
||||
File page_file = new File(m_base_directory,page_name);
|
||||
if (!(page_file.canRead())) // can't read the farking file!
|
||||
return new HttpErrorMessage(HttpStatusCode.E_NOTFOUND);
|
||||
|
||||
// Figure out whether this is actually "frameable" content.
|
||||
MIMETypeMapper mapper = (MIMETypeMapper)(r.queryService(MIMETypeMapper.class));
|
||||
String type = mapper.getMIMEType(page_name);
|
||||
boolean is_text = type.startsWith("text/html");
|
||||
|
||||
try
|
||||
{ // Create the page data and cache it.
|
||||
if (is_text)
|
||||
{ // only cache the text pages
|
||||
pd = new TextPageData(page_file,r.getRequestPath() + r.getExtraPath());
|
||||
m_cache.put(page_name,pd);
|
||||
|
||||
} // end if
|
||||
else // just output binary data
|
||||
pd = new BinaryPageData(page_file,type);
|
||||
|
||||
} // end try
|
||||
catch (IOException e)
|
||||
{ // if there's an error reading the page data, send back a 500 Internal Server Error
|
||||
return new HttpErrorMessage(HttpStatusCode.E_INTERNAL,e.getMessage());
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
return pd; // return the PageData to be rendered
|
||||
|
||||
} // end process
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void initServlet(ServiceProvider services) throws DynamoException
|
||||
{
|
||||
// Start by getting the base directory.
|
||||
ObjectProvider oprov = (ObjectProvider)(services.queryService(ObjectProvider.class));
|
||||
String base_dir = (String)(oprov.getObject(Namespaces.SUBSTRATE_NAMESPACE,
|
||||
ApplicationSubstrate.OBJ_BASE_PATH));
|
||||
|
||||
// Now try and get the content prefix and append it to that base path.
|
||||
try
|
||||
{ // retrieve the prefix for the frame servlet
|
||||
String pfx = (String)(oprov.getObject(Namespaces.SERVLET_INIT_NAMESPACE,"content.prefix"));
|
||||
if (!(pfx.startsWith("/")))
|
||||
base_dir += "/";
|
||||
base_dir += pfx;
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // leave the base path as it is
|
||||
} // end catch
|
||||
|
||||
m_base_directory = new File(base_dir);
|
||||
if (!(m_base_directory.isDirectory()))
|
||||
{ // it's not a directory - throw an exception!
|
||||
ConfigException ce = new ConfigException(FrameServlet.class,"FrameServletMessages",
|
||||
"basepath.notDirectory");
|
||||
ce.setParameter(0,m_base_directory.getAbsolutePath());
|
||||
throw ce;
|
||||
|
||||
} // end if
|
||||
|
||||
int hard_limit = DEFAULT_HARD_LIMIT;
|
||||
try
|
||||
{ // get the hard limit from the configuration and parse it
|
||||
String s = (String)(oprov.getObject(Namespaces.SERVLET_INIT_NAMESPACE,"cache.hard.limit"));
|
||||
hard_limit = Integer.parseInt(s);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // if the hard limit is not present, default it
|
||||
hard_limit = DEFAULT_HARD_LIMIT;
|
||||
|
||||
} // end catch
|
||||
catch (NumberFormatException e)
|
||||
{ // if it's not an integer, that's an error
|
||||
throw new ConfigException(FrameServlet.class,"FrameServletMessages","hardlimit.notInteger");
|
||||
|
||||
} // end catch
|
||||
|
||||
int soft_limit = DEFAULT_SOFT_LIMIT;
|
||||
try
|
||||
{ // get the soft limit from the configuration and parse it
|
||||
String s = (String)(oprov.getObject(Namespaces.SERVLET_INIT_NAMESPACE,"cache.soft.limit"));
|
||||
soft_limit = Integer.parseInt(s);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // if the soft limit is not present, default it
|
||||
soft_limit = DEFAULT_SOFT_LIMIT;
|
||||
|
||||
} // end catch
|
||||
catch (NumberFormatException e)
|
||||
{ // if it's not an integer, that's an error
|
||||
throw new ConfigException(FrameServlet.class,"FrameServletMessages","softlimit.notInteger");
|
||||
|
||||
} // end catch
|
||||
|
||||
// Create the cache.
|
||||
m_cache = new HardSoftCache(hard_limit,soft_limit);
|
||||
|
||||
} // end initServlet
|
||||
|
||||
} // end class FrameServlet
|
||||
@@ -0,0 +1,21 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
basepath.notDirectory=The configured frame content base path "{0}" is not a directory.
|
||||
hardlimit.notInteger=The configured cache hard limit is not an integer.
|
||||
softlimit.notInteger=The configured cache hard limit is not an integer.
|
||||
frame.noContent=(No content)
|
||||
70
src/venice-base/com/silverwrist/venice/servlet/PageData.java
Normal file
70
src/venice-base/com/silverwrist/venice/servlet/PageData.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlet;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
abstract class PageData implements SelfRenderable
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected File m_file; // underlying File object
|
||||
private long m_lastmod; // initial "last modified" time
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected PageData(File file) throws IOException
|
||||
{
|
||||
m_file = file;
|
||||
m_lastmod = m_file.lastModified();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract operations from interface SelfRenderable
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public abstract void render(SelfRenderControl control) throws IOException, RenderingException;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
boolean isModified()
|
||||
{
|
||||
long tmp = m_file.lastModified();
|
||||
if (tmp==0)
|
||||
return true;
|
||||
else
|
||||
return (tmp>m_lastmod);
|
||||
|
||||
} // end isModified
|
||||
|
||||
} // end class PageData
|
||||
145
src/venice-base/com/silverwrist/venice/servlet/TextPageData.java
Normal file
145
src/venice-base/com/silverwrist/venice/servlet/TextPageData.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlet;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.frame.FramedContent;
|
||||
|
||||
class TextPageData extends PageData implements FramedContent
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_title; // title string
|
||||
private String m_body; // body text
|
||||
private String m_qid; // page QID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
TextPageData(File file, String request_path) throws IOException
|
||||
{
|
||||
super(file);
|
||||
|
||||
// Read in the file data.
|
||||
StringBuffer raw = IOUtils.loadText(file);
|
||||
|
||||
// make the upper-case search page and use that to locate the page title and body
|
||||
String search = raw.toString().toUpperCase();
|
||||
m_title = searchBetweenTags(raw,search,"TITLE");
|
||||
m_body = searchBetweenTags(raw,search,"BODY");
|
||||
|
||||
if (m_body==null)
|
||||
{ // default the body if it doesn't exist
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.servlet.FrameServletMessages",
|
||||
Locale.getDefault());
|
||||
m_body = b.getString("frame.noContent");
|
||||
|
||||
} // end if
|
||||
|
||||
if (m_title==null)
|
||||
{ // default the title as well
|
||||
int p = request_path.lastIndexOf('/');
|
||||
if (p<0)
|
||||
m_title = request_path;
|
||||
else
|
||||
m_title = request_path.substring(p+1);
|
||||
|
||||
} // end if
|
||||
|
||||
// Determine the page QID.
|
||||
if (request_path.startsWith("/"))
|
||||
m_qid = request_path.substring(1);
|
||||
else
|
||||
m_qid = request_path;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String searchBetweenTags(StringBuffer data, String search, String tagname)
|
||||
{
|
||||
tagname = tagname.toUpperCase();
|
||||
String start = "<" + tagname;
|
||||
String end = "</" + tagname + ">";
|
||||
|
||||
int startpos = search.indexOf(start);
|
||||
if (startpos<0)
|
||||
return null;
|
||||
startpos += start.length();
|
||||
|
||||
int bkt_pos = search.indexOf('>',startpos);
|
||||
if (bkt_pos<0)
|
||||
return null;
|
||||
|
||||
int end_pos = search.indexOf(end,++bkt_pos);
|
||||
if (end_pos<0)
|
||||
return data.substring(bkt_pos);
|
||||
else
|
||||
return data.substring(bkt_pos,end_pos);
|
||||
|
||||
} // end searchBetweenTags
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class PageData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(SelfRenderControl control) throws IOException, RenderingException
|
||||
{
|
||||
PrintWriter wr = control.getTextRender().getWriter();
|
||||
wr.write(m_body);
|
||||
wr.flush();
|
||||
|
||||
} // end render
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FramedContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMenuSelector()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getMenuSelector
|
||||
|
||||
public String getPageTitle()
|
||||
{
|
||||
return m_title;
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return m_qid;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
} // end class TextPageData
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlet;
|
||||
|
||||
import java.io.*;
|
||||
import com.silverwrist.dynamo.HttpStatusCode;
|
||||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.db.UserManagement;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.servlet.ServletBase;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
|
||||
public class UserServlet extends ServletBase
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected Object process(Request r, Application app) throws Exception
|
||||
{
|
||||
// Look up the user.
|
||||
ObjectProvider op = (ObjectProvider)(r.queryService(ObjectProvider.class));
|
||||
UserManagement umgmt = (UserManagement)(op.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"users"));
|
||||
DynamoUser user = umgmt.getUser(r.getExtraPath().substring(1));
|
||||
if (user==null)
|
||||
return new HttpErrorMessage(HttpStatusCode.E_NOTFOUND);
|
||||
|
||||
// Execute the script that produces the view.
|
||||
r.setObject("temp:","user",user);
|
||||
ScriptExecute exec = (ScriptExecute)(r.queryService(ScriptExecute.class));
|
||||
return exec.executeScript(r,"/util/create_profile.js");
|
||||
|
||||
} // end process
|
||||
|
||||
} // end class UserServlet
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
class CookieAuthenticator implements Authenticator
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
CookieAuthenticator()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface Authenticator
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public boolean authenticate(String stored_data, String input_data) throws AuthenticationException
|
||||
{
|
||||
return stored_data.equals(input_data);
|
||||
|
||||
} // end authenticate
|
||||
|
||||
public String processInputData(String input_data) throws AuthenticationException
|
||||
{
|
||||
return input_data;
|
||||
|
||||
} // end processInputData
|
||||
|
||||
} // end class CookieAuthenticator
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
|
||||
class PasswordRecoveryAuthenticator implements Authenticator
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceSessionManager m_sm;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
PasswordRecoveryAuthenticator(VeniceSessionManager sm)
|
||||
{
|
||||
m_sm = sm;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface Authenticator
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public boolean authenticate(String stored_data, String input_data) throws AuthenticationException
|
||||
{
|
||||
if (!(stored_data.equals(input_data)))
|
||||
return false;
|
||||
try
|
||||
{ // check the timestamp on the data
|
||||
int pos = input_data.indexOf('.');
|
||||
if (pos<0)
|
||||
return false;
|
||||
long timestamp = Long.parseLong(input_data.substring(pos+1));
|
||||
if ((System.currentTimeMillis() - timestamp)>m_sm.getPasswordRecoveryTime())
|
||||
return false;
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException e)
|
||||
{ // number parse is wrong
|
||||
return false;
|
||||
|
||||
} // end catch
|
||||
|
||||
return true;
|
||||
|
||||
} // end authenticate
|
||||
|
||||
public String processInputData(String input_data) throws AuthenticationException
|
||||
{
|
||||
return input_data;
|
||||
|
||||
} // end processInputData
|
||||
|
||||
} // end class PasswordRecoveryAuthenticator
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
|
||||
class PasswordRecoveryRequest extends FilterRequest
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Map m_params;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
PasswordRecoveryRequest(Request r, Integer uid, String auth)
|
||||
{
|
||||
super(r);
|
||||
HashMap p = new HashMap();
|
||||
p.put("uid",uid);
|
||||
p.put("auth",auth);
|
||||
m_params = Collections.unmodifiableMap(p);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class FilterRequest
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Map getParameters()
|
||||
{
|
||||
return m_params;
|
||||
|
||||
} // end getParameters
|
||||
|
||||
public Class getParametersEntryClass()
|
||||
{
|
||||
return Object.class;
|
||||
|
||||
} // end getParametersEntryClass
|
||||
|
||||
} // end class PasswordRecoveryRequest
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.servlet.ServletBase;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.content.*;
|
||||
|
||||
public class PasswordRecoveryServlet extends ServletBase
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class ServletBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected Object process(Request r, Application app) throws Exception
|
||||
{
|
||||
// Get the parameters.
|
||||
String tmp = r.getExtraPath().substring(1);
|
||||
int pos = tmp.indexOf('/');
|
||||
if (pos<0)
|
||||
{ // error!
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.session.SessionMessages",
|
||||
Locale.getDefault());
|
||||
return new ErrorBox(null,b.getString("pwrec.badformat"));
|
||||
|
||||
} // end if
|
||||
|
||||
Integer uid = null;
|
||||
String auth = null;
|
||||
try
|
||||
{ // create user ID and authorization string
|
||||
uid = new Integer(tmp.substring(0,pos));
|
||||
auth = tmp.substring(pos+1);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException e)
|
||||
{ // cannot parse the UID
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.session.SessionMessages",
|
||||
Locale.getDefault());
|
||||
return new ErrorBox(null,b.getString("pwrec.badformat"));
|
||||
|
||||
} // end catch
|
||||
|
||||
// Call the script that implements this function.
|
||||
ScriptExecute exec = (ScriptExecute)(r.queryService(ScriptExecute.class));
|
||||
return exec.executeScript(new PasswordRecoveryRequest(r,uid,auth),"/util/password_recovery.js");
|
||||
|
||||
} // end process
|
||||
|
||||
} // end class PasswordRecoveryServlet
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public interface SessionInfoParams
|
||||
{
|
||||
public static final String NAMESPACE = VeniceNamespaces.SESSION_INFO_NAMESPACE;
|
||||
|
||||
public static final String REQ_NAMESPACE = VeniceNamespaces.REQUEST_INFO_NAMESPACE;
|
||||
|
||||
public static final String ATTR_USER = "user";
|
||||
|
||||
public static final String ATTR_STYLESHEET_SELECTOR = "stylesheet.sel";
|
||||
|
||||
public static final String ATTR_COOKIE_AUTH_SOURCE = "cookie.auth.source";
|
||||
|
||||
public static final String RATTR_LOCATION = "location";
|
||||
|
||||
public static final String RATTR_DISPLAY_LOGIN = "display.login";
|
||||
|
||||
} // end interface SessionInfoParams
|
||||
@@ -0,0 +1,22 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
no.anon=Unable to retrieve "anonymous" user account.
|
||||
init.noProp=Unable to load the standard global properties provider.
|
||||
prop.missing=Unable to load the value of standard property "{0}".
|
||||
prop.wrongType=The value of property "{0}" is of the wrong type.
|
||||
pwrec.badformat=Invalid password recovery request.
|
||||
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.session;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.RequestType;
|
||||
import com.silverwrist.dynamo.db.UserManagement;
|
||||
import com.silverwrist.dynamo.event.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class VeniceSessionManager
|
||||
implements NamedObject, ComponentInitialize, ComponentShutdown, SessionInfoListener, RequestPreprocessor,
|
||||
DynamicUpdateListener, SessionInfoParams
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class implementing "venice_session" operations in the script engine
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public class VeniceSessionOpsImpl
|
||||
{
|
||||
/*====================================================================
|
||||
* Constructor
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
VeniceSessionOpsImpl()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*====================================================================
|
||||
* External operations
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public String getLoginCookieName()
|
||||
{
|
||||
return m_cookie_name;
|
||||
|
||||
} // end getLoginCookieName
|
||||
|
||||
public int getLoginCookieAge()
|
||||
{
|
||||
return m_cookie_maxage * 86400; // convert to seconds
|
||||
|
||||
} // end getLoginCookieAge
|
||||
|
||||
} // end class VeniceSessionOpsImpl
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(VeniceSessionManager.class);
|
||||
|
||||
private static final String CONTROL_NAMESPACE = VeniceNamespaces.SESSION_CONTROL_NAMESPACE;
|
||||
|
||||
private static final String PROP_SESSION_INIT_SCRIPT = "session.init.script";
|
||||
private static final String PROP_LOGIN_COOKIE = "login.cookie";
|
||||
private static final String PROP_LOGIN_COOKIE_MAXAGE = "login.cookie.maxage";
|
||||
private static final String PROP_PASSWORD_RECOVERY_TIME = "password.recovery.time";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name; // name of this object
|
||||
private DynamoUser m_anonymous; // anonymous user
|
||||
private ObjectProvider m_props; // global properties provider
|
||||
private String m_session_init_script; // session initialization script
|
||||
private String m_cookie_name; // name of login cookie
|
||||
private int m_cookie_maxage; // maximum age of cookie (in days)
|
||||
private int m_pass_recovery_time; // password recovery time (in minutes)
|
||||
private LinkedList m_shutdown_list = new LinkedList(); // shutdown list
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public VeniceSessionManager()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final String getInitString(String name) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to the property provider
|
||||
return (String)(m_props.getObject(CONTROL_NAMESPACE,name));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // the property value isn't present? yIkes!
|
||||
ConfigException ce = new ConfigException(VeniceSessionManager.class,"SessionMessages","prop.missing",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // not a String? for shame!
|
||||
ConfigException ce = new ConfigException(VeniceSessionManager.class,"SessionMessages",
|
||||
"prop.wrongType",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getInitString
|
||||
|
||||
private final int getInitInteger(String name) throws ConfigException
|
||||
{
|
||||
try
|
||||
{ // call through to the property provider
|
||||
return ((Integer)(m_props.getObject(CONTROL_NAMESPACE,name))).intValue();
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // the property value isn't present? yIkes!
|
||||
ConfigException ce = new ConfigException(VeniceSessionManager.class,"SessionMessages","prop.missing",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
catch (ClassCastException e)
|
||||
{ // not an Integer? for shame!
|
||||
ConfigException ce = new ConfigException(VeniceSessionManager.class,"SessionMessages",
|
||||
"prop.wrongType",e);
|
||||
ce.setParameter(0,name);
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getInitString
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "the VeniceSessionManager";
|
||||
|
||||
} // end toString
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("VeniceSessionManager initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String gprops = null, users = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the global properties object
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"global-properties");
|
||||
gprops = loader.getAttribute(foo,"object");
|
||||
|
||||
// get the name of the users object
|
||||
foo = loader.getSubElement(config_root_h,"user-manager");
|
||||
users = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in VeniceSessionManager",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the standard properties provider.
|
||||
ServiceProvider gdm_sp =
|
||||
(ServiceProvider)(GetObjectUtils.getDynamoComponent(services,ServiceProvider.class,gprops));
|
||||
try
|
||||
{ // get the "properties" service from that object
|
||||
m_props = (ObjectProvider)(gdm_sp.queryService(ObjectProvider.class,"properties"));
|
||||
|
||||
} // end try
|
||||
catch (NoSuchServiceException e)
|
||||
{ // this shouldn't happen, but...
|
||||
throw new ConfigException(VeniceSessionManager.class,"SessionMessages","init.noProp",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the values of the session properties.
|
||||
m_session_init_script = getInitString(PROP_SESSION_INIT_SCRIPT);
|
||||
m_cookie_name = getInitString(PROP_LOGIN_COOKIE);
|
||||
m_cookie_maxage = getInitInteger(PROP_LOGIN_COOKIE_MAXAGE);
|
||||
m_pass_recovery_time = getInitInteger(PROP_PASSWORD_RECOVERY_TIME);
|
||||
|
||||
try
|
||||
{ // Get the "anonymous" user context and save a reference to it.
|
||||
UserManagement umgmt =
|
||||
(UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,users));
|
||||
m_anonymous = umgmt.getAnonymousUser();
|
||||
|
||||
} // end try
|
||||
catch (DatabaseException e)
|
||||
{ // translate to ConfigException
|
||||
throw new ConfigException(VeniceSessionManager.class,"SessionMessages","no.anon",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Register a scripting object that exposes the session properties to scripts.
|
||||
ScriptEngineConfig sconf = (ScriptEngineConfig)(services.queryService(ScriptEngineConfig.class));
|
||||
m_shutdown_list.addFirst(sconf.addDeclaredObject("venice_session",new VeniceSessionOpsImpl(),
|
||||
VeniceSessionOpsImpl.class));
|
||||
|
||||
// Register our "cookie" authenticator and password recovery authenticator.
|
||||
AuthenticatorRegistration authreg =
|
||||
(AuthenticatorRegistration)(services.queryService(AuthenticatorRegistration.class));
|
||||
m_shutdown_list.addFirst(authreg.registerAuthenticator(CONTROL_NAMESPACE,"cookie",
|
||||
new CookieAuthenticator()));
|
||||
m_shutdown_list.addFirst(authreg.registerAuthenticator(CONTROL_NAMESPACE,"password.recovery",
|
||||
new PasswordRecoveryAuthenticator(this)));
|
||||
|
||||
// Register this object to listen to session info events and property update events.
|
||||
EventListenerRegistration reg =
|
||||
(EventListenerRegistration)(services.queryService(EventListenerRegistration.class));
|
||||
m_shutdown_list.addFirst(reg.registerSessionInfoListener(this));
|
||||
m_shutdown_list.addFirst(reg.registerDynamicUpdateListener(GlobalPropertyUpdateEvent.class,this));
|
||||
|
||||
// Register this object to preprocess requests.
|
||||
RequestPreprocessorRegistration rpreg =
|
||||
(RequestPreprocessorRegistration)(services.queryService(RequestPreprocessorRegistration.class));
|
||||
m_shutdown_list.addFirst(rpreg.registerRequestPreprocessor(this));
|
||||
|
||||
logger.info("VeniceSessionManager initialized");
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
logger.info("Shutting down VeniceSessionManager");
|
||||
while (m_shutdown_list.size()>0)
|
||||
{ // shut down everything on the shutdown list
|
||||
ComponentShutdown cs = (ComponentShutdown)(m_shutdown_list.removeFirst());
|
||||
cs.shutdown();
|
||||
|
||||
} // end while
|
||||
|
||||
m_props = null;
|
||||
m_anonymous = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface SessionInfoListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void sessionInitialized(SessionInfoEvent event)
|
||||
{
|
||||
SessionInfo session = event.getSession();
|
||||
|
||||
// Add the "anonymous" user context to this session.
|
||||
session.setObject(NAMESPACE,ATTR_USER,m_anonymous);
|
||||
|
||||
// Add the default stylesheet selector to the session.
|
||||
session.setObject(NAMESPACE,ATTR_STYLESHEET_SELECTOR,"normal");
|
||||
|
||||
try
|
||||
{ // Execute the session-initialization script.
|
||||
Request r = event.getRequest();
|
||||
ScriptExecute exec = (ScriptExecute)(r.queryService(ScriptExecute.class));
|
||||
exec.executeScript(r,m_session_init_script);
|
||||
|
||||
} // end try
|
||||
catch (ScriptingException e)
|
||||
{ // just log this exception
|
||||
logger.error("Session initialization script failed",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end sessionInitialized
|
||||
|
||||
public void sessionExiting(SessionInfoEvent event)
|
||||
{ // don't use this notification
|
||||
} // end sessionExiting
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface RequestPreprocessor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void preprocessRequest(Request r)
|
||||
{
|
||||
if (RequestType.HTTP.equals(r.getType()))
|
||||
{ // only need to worry about any of this in HTTP requests
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("VeniceSessionManager preprocessing request: " + r);
|
||||
|
||||
RequestHelper rh = new RequestHelper(r);
|
||||
SessionInfo session = rh.getSession();
|
||||
try
|
||||
{ // look for the stylesheet selector
|
||||
session.getObject(NAMESPACE,ATTR_STYLESHEET_SELECTOR);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // TEMP: until we can sniff the browser
|
||||
session.setObject(NAMESPACE,ATTR_STYLESHEET_SELECTOR,"normal");
|
||||
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // see if the "location" has been set yet
|
||||
r.getObject(REQ_NAMESPACE,RATTR_LOCATION);
|
||||
|
||||
} // end r
|
||||
catch (NoSuchObjectException e)
|
||||
{ // Create the initial "location" request data.
|
||||
StringBuffer loc_buf = new StringBuffer(r.getRequestPath());
|
||||
if (loc_buf.charAt(0)=='/')
|
||||
loc_buf.delete(0,1);
|
||||
String tmp = r.getExtraPath();
|
||||
if (tmp!=null)
|
||||
loc_buf.append(tmp);
|
||||
tmp = r.getQueryString();
|
||||
if (tmp!=null)
|
||||
loc_buf.append('?').append(tmp);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Setting location: " + loc_buf.toString());
|
||||
r.setObject(REQ_NAMESPACE,RATTR_LOCATION,loc_buf.toString());
|
||||
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // see if "display login" has already been set
|
||||
r.getObject(REQ_NAMESPACE,RATTR_DISPLAY_LOGIN);
|
||||
|
||||
} // end try
|
||||
catch (NoSuchObjectException e)
|
||||
{ // Set the "display login" flag.
|
||||
r.setObject(REQ_NAMESPACE,RATTR_DISPLAY_LOGIN,Boolean.TRUE);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end preprocessRequest
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicUpdateListener
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void updateReceived(DynamicUpdateEvent evt)
|
||||
{
|
||||
GlobalPropertyUpdateEvent event = (GlobalPropertyUpdateEvent)evt;
|
||||
if (CONTROL_NAMESPACE.equals(event.getPropertyNamespace()))
|
||||
{ // see if this is one of the properties we monitor
|
||||
try
|
||||
{ // reuse the "initialization" getters here
|
||||
if (PROP_SESSION_INIT_SCRIPT.equals(event.getPropertyName()))
|
||||
{ // process new initialization script
|
||||
String s = getInitString(PROP_SESSION_INIT_SCRIPT);
|
||||
m_session_init_script = s;
|
||||
|
||||
} // end if
|
||||
else if (PROP_LOGIN_COOKIE.equals(event.getPropertyName()))
|
||||
{ // process new cookie name
|
||||
String s = getInitString(PROP_LOGIN_COOKIE);
|
||||
m_cookie_name = s;
|
||||
|
||||
} // end else if
|
||||
else if (PROP_LOGIN_COOKIE_MAXAGE.equals(event.getPropertyName()))
|
||||
{ // process new cookie maximum age
|
||||
int x = getInitInteger(PROP_LOGIN_COOKIE_MAXAGE);
|
||||
m_cookie_maxage = x;
|
||||
|
||||
} // end else if
|
||||
else if (PROP_PASSWORD_RECOVERY_TIME.equals(event.getPropertyName()))
|
||||
{ // process new password recovery time
|
||||
int x = getInitInteger(PROP_PASSWORD_RECOVERY_TIME);
|
||||
m_pass_recovery_time = x;
|
||||
|
||||
} // end else if
|
||||
|
||||
} // end try
|
||||
catch (ConfigException ce)
|
||||
{ // property get failed - don't change the value
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
} // end updateReceived
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
long getPasswordRecoveryTime()
|
||||
{
|
||||
return (long)(m_pass_recovery_time * 60000L);
|
||||
|
||||
} // end getPasswordRecoveryTime
|
||||
|
||||
} // end class VeniceSessionManager
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.util;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.velocity.VelocityOwnTemplate;
|
||||
import com.silverwrist.venice.iface.ContentBlock;
|
||||
|
||||
public class StringTemplateContentBlock implements VelocityOwnTemplate, ContentBlock
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_mime_type;
|
||||
private String m_template;
|
||||
private String m_identifier;
|
||||
private HashMap m_params = new HashMap();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public StringTemplateContentBlock(String template, String identifier, String mime_type)
|
||||
{
|
||||
m_mime_type = mime_type;
|
||||
m_template = template;
|
||||
m_identifier = identifier;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public StringTemplateContentBlock(String template, String identifier)
|
||||
{
|
||||
this(template,identifier,"text/html");
|
||||
|
||||
} // end constructor
|
||||
|
||||
public StringTemplateContentBlock(String template)
|
||||
{
|
||||
this(template,"StringTemplateContentBlock","text/html");
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_template;
|
||||
|
||||
} // end toString
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityParamSupplier
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object getParameter(String key)
|
||||
{
|
||||
return m_params.get(key);
|
||||
|
||||
} // end getParameter
|
||||
|
||||
public Collection getParameterNames()
|
||||
{
|
||||
return Collections.unmodifiableSet(m_params.keySet());
|
||||
|
||||
} // end getParameterNames
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VelocityOwnTemplate
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return m_mime_type;
|
||||
|
||||
} // end getMimeType
|
||||
|
||||
public String getTemplate()
|
||||
{
|
||||
return m_template;
|
||||
|
||||
} // end getTemplate
|
||||
|
||||
public String getIdentifier()
|
||||
{
|
||||
return m_identifier;
|
||||
|
||||
} // end getIdentifier
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentBlock
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setContentParameter(String name, Object obj)
|
||||
{
|
||||
m_params.put(name,obj);
|
||||
|
||||
} // end setContentParameter
|
||||
|
||||
} // end class StringTemplateContentBlock
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.xmlrpc;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.xmlrpc.*;
|
||||
|
||||
public class VeniceCreateSession implements XmlRpcDispatcher, XmlRpcTypeNames
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final List SUPPORTED_METHODS;
|
||||
private static final List SIGNATURES;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public VeniceCreateSession()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface XmlRpcDispatcher
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getSessionIDParamValue(Request r, Application app)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getSessionIDParamValue
|
||||
|
||||
public Object dispatchXmlRpcCall(Request r, Application app) throws Exception, FaultCode
|
||||
{
|
||||
if (r.getParameters().size()!=0)
|
||||
throw new XmlRpcParameterError("parameter count mismatch");
|
||||
XmlRpcCreateSession creator = (XmlRpcCreateSession)(r.queryService(XmlRpcCreateSession.class));
|
||||
SessionInfo session = creator.createNewSession(r);
|
||||
return session.getID();
|
||||
|
||||
} // end dispatchXmlRpcCall
|
||||
|
||||
public Collection getSupportedMethods(Request r)
|
||||
{
|
||||
return SUPPORTED_METHODS;
|
||||
|
||||
} // end getSupportedMethods
|
||||
|
||||
public List getMethodSignature(Request r, String method) throws FaultCode
|
||||
{
|
||||
return SIGNATURES;
|
||||
|
||||
} // end getMethodSignature
|
||||
|
||||
public String getMethodHelp(Request r, String method) throws FaultCode
|
||||
{
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.xmlrpc.VeniceXmlRpcMessages",
|
||||
Locale.getDefault());
|
||||
return b.getString("help.createSess");
|
||||
|
||||
} // end getMethodHelp
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static initializer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
{ // create the supported methods list
|
||||
SUPPORTED_METHODS = Collections.singletonList("venice:session.create");
|
||||
|
||||
// create the signatures list
|
||||
List l = Collections.singletonList(TYPE_STRING);
|
||||
SIGNATURES = Collections.singletonList(l);
|
||||
|
||||
} // end static initializer
|
||||
|
||||
} // end class VeniceCreateSession
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.xmlrpc;
|
||||
|
||||
public interface VeniceFaultCodes
|
||||
{
|
||||
public static final int IS_LOGGEDIN = 1000;
|
||||
|
||||
public static final int IS_NOT_LOGGEDIN = 1001;
|
||||
|
||||
public static final int USER_NOTFOUND = 1002;
|
||||
|
||||
public static final int USER_NOLOGIN = 1003;
|
||||
|
||||
public static final int USER_LOCKED = 1004;
|
||||
|
||||
public static final int USER_NOAUTH = 1005;
|
||||
|
||||
} // end interface VeniceFaultCodes
|
||||
@@ -0,0 +1,19 @@
|
||||
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
# (the "License"); you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
# language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Venice Web Communities System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
# Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# ---------------------------------------------------------------------------------
|
||||
# This file has been localized for the en_US locale
|
||||
help.createSess=Creates a new Venice session. \r\n\
|
||||
Returns: The identifier of the new session. This is passed to most other Venice API functions.
|
||||
Reference in New Issue
Block a user