- The informations about application types and application instances in the new ApplicationsTab in /ccm/admin are now displayed using a com.arsdigita.bebop.PropertySheet.

- Some minor cleanup on other classes.


git-svn-id: https://svn.libreccm.org/ccm/trunk@2219 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-06-19 08:16:11 +00:00
parent 373c237941
commit b0936eb10e
13 changed files with 465 additions and 259 deletions

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.bebop;
import java.util.Iterator;
@ -38,28 +37,22 @@ import com.arsdigita.bebop.util.BebopConstants;
*
* @version $Id: BoxPanel.java 287 2005-02-22 00:29:02Z sskracic $
* */
public class BoxPanel extends SimpleContainer
implements BebopConstants
{
public class BoxPanel extends SimpleContainer implements BebopConstants {
/**
* Specifies that components should be laid out left to right.
*/
public final static int HORIZONTAL = 1;
/**
* Specifies that components should be laid out top to bottom.
*/
public final static int VERTICAL = 2;
private static final String WIDTH_ATTR = "width";
private static final String BORDER_ATTR = "border";
private int m_axis;
private boolean m_centering;
// Instance methods
/**
* Creates a box panel that lays out its components from top to bottom.
* The components are not centered.
@ -102,18 +95,18 @@ public class BoxPanel extends SimpleContainer
* &lt;/bebop:boxPanel></code>
*/
public void generateXML(PageState state, Element parent) {
if ( isVisible(state) ) {
if (isVisible(state)) {
Element panel = parent.newChildElement(BEBOP_BOXPANEL, BEBOP_XML_NS);
// or: rowPanel/columPanel?
panel.addAttribute("center", String.valueOf(m_centering));
panel.addAttribute("axis", String.valueOf(m_axis));
exportAttributes(panel);
for (Iterator i = children(); i.hasNext(); ) {
for (Iterator i = children(); i.hasNext();) {
Component c = (Component) i.next();
if ( c.isVisible(state) ) {
if ( c instanceof Hidden ) {
if (c.isVisible(state)) {
if (c instanceof Hidden) {
c.generateXML(state, parent);
} else {
Element cell = panel.newChildElement(BEBOP_CELL, BEBOP_XML_NS);
@ -148,7 +141,6 @@ public class BoxPanel extends SimpleContainer
// setAttribute(BORDER_ATTR, "0");
// }
// }
/**
*
* Sets the width of the border to draw around the components. This value

View File

@ -85,8 +85,8 @@ public class URLService {
* to produce a valid non-null URL.
*/
public static String locate(OID oid)
throws URLFinderNotFoundException, NoValidURLException {
return locate(oid,null);
throws URLFinderNotFoundException, NoValidURLException {
return locate(oid, null);
}
/**
@ -104,24 +104,20 @@ public class URLService {
* to produce a valid non-null URL.
*/
public static String locate(OID oid, String context)
throws URLFinderNotFoundException, NoValidURLException{
throws URLFinderNotFoundException, NoValidURLException {
URLFinder f = getFinder(oid.getObjectType());
if (f==null) {
throw new URLFinderNotFoundException("There is no URLFinder " +
"registered for " +
"data object type " +
oid.getObjectType().getQualifiedName());
if (f == null) {
throw new URLFinderNotFoundException("There is no URLFinder " + "registered for " + "data object type "
+ oid.getObjectType().getQualifiedName());
}
// Determine the URL using the objects URLFinder
String url = (context == null) ? f.find(oid) : f.find(oid,context);
String url = (context == null) ? f.find(oid) : f.find(oid, context);
if (url == null) {
throw new NoValidURLException("The URLFinder for " +
oid.getObjectType().getQualifiedName() +
"produced a null URL for " +
oid);
throw new NoValidURLException("The URLFinder for " + oid.getObjectType().getQualifiedName()
+ "produced a null URL for " + oid);
}
return url;
}
@ -173,9 +169,7 @@ public class URLService {
/**
* Returns the URLFinder registered for the given object type.
**/
public synchronized static
URLFinder getRegisteredFinder(ObjectType objectType)
{
public synchronized static URLFinder getRegisteredFinder(ObjectType objectType) {
return (URLFinder) s_finders.get(objectType);
}
@ -184,9 +178,7 @@ public class URLService {
* Returns the URLFinder registered for the given object type.
*
**/
public synchronized static
URLFinder getRegisteredFinder(String objectType)
{
public synchronized static URLFinder getRegisteredFinder(String objectType) {
MetadataRoot meta = SessionManager.getMetadataRoot();
return (URLFinder) s_finders.get(meta.getObjectType(objectType));
}
@ -207,7 +199,7 @@ public class URLService {
**/
public synchronized static URLFinder getFinder(ObjectType objectType) {
ObjectType type = objectType;
while (type!=null && !s_finders.containsKey(type)) {
while (type != null && !s_finders.containsKey(type)) {
type = type.getSupertype();
}
return (URLFinder) s_finders.get(type);
@ -224,28 +216,28 @@ public class URLService {
public static OID getNonencodedOID(HttpServletRequest sreq) {
if (sreq == null) {
return null;
}
if (sreq == null) {
return null;
}
String query = sreq.getQueryString();
String query = sreq.getQueryString();
if (query == null) {
return null;
}
if (query == null) {
return null;
}
int start = query.indexOf(OID_START);
if (start == -1) {
return null;
}
start = start+OID_START.length();
int start = query.indexOf(OID_START);
if (start == -1) {
return null;
}
start = start + OID_START.length();
int end = query.indexOf(OID_END);
if (end == -1) {
end = query.length();
}
int end = query.indexOf(OID_END);
if (end == -1) {
end = query.length();
}
return OID.valueOf(query.substring(start, end));
return OID.valueOf(query.substring(start, end));
}
public static final String OID_START = "oid=";

View File

@ -108,7 +108,7 @@ ui.admin.applications.ApplicationInstancePane.path.label=Pfad der Applikation
ui.admin.applications.ApplicationInstancePane.desc.label=Beschreibung
ui.admin.applications.ApplicationInstancePane.info.heading=Daten der Instanz
ui.admin.MultiInstanceApplicationPane.manage.heading=Einstellungen der Instanz bearbeiten
ui.admin.MultiInstancePane.manage.no_instance_admin_pane_found=Kein Administrationsformular f\u00fcr Instanzen des Applikationstyps '{0}' gefunden. M\u00f6glicherweise noch nicht implementiert.
ui.admin.MultiInstancePane.manage.no_instance_admin_pane_found=Kein Administrationsformular f\u00fcr Instanzen des Applikationstyps {0} gefunden. M\u00f6glicherweise noch nicht implementiert.
ui.admin.applications.ApplicationInfoSection.title.label=Titel
ui.admin.applications.ApplicationInfoSection.app_class.label=Applikationsklasse
ui.admin.applications.ApplicationInfoSection.singleton.label=Singleton
@ -122,8 +122,8 @@ ui.admin.applicationsMultiInstanceApplicationPane.instances.table.col_url.header
ui.admin.applicationsMultiInstanceApplicationPane.instances.table.col_desc.header=Beschreibung
ui.admin.MultiInstanceApplicationPane.instances=Instanzen
ui.admin.MultiInstanceApplicationPane.manage_instances.heading=Instanzen verwalten
ui.admin.MultiInstancePane.manage.no_create_form_found=Keine Formular zum verwalten von Applikationen des Types '{0}' gefunden.
ui.admin.MultiInstancePane.manage.no_create_form_found=Keine Formular zum verwalten von Applikationen des Types {0} gefunden.
ui.admin.MultiInstanceApplicationPane.create_instance=Neue instanz anlegen
ui.admin.SingletonApplicationPane.manage.heading=Eigenschaften bearbeiten
ui.admin.SingletonApplicationPane.manage.no_admin_pane_found=Keine Admin-Formular f\u00fcr Applikationen des Types '{0}' gefunden
ui.admin.SingletonApplicationPane.manage.no_admin_pane_found=Keine Admin-Formular f\u00fcr Applikationen des Types {0} gefunden
ui.admin.applications.ApplicationInfoSection.desc.label=Beschreibung

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) 2013 Jens Pelzetter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.PropertySheetModel;
import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Application;
import com.arsdigita.web.ApplicationCollection;
import com.arsdigita.web.ApplicationType;
/**
* A property sheet model for displaying informations about an {@link ApplicationType} using a {@link PropertySheet}.
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class ApplicationInfoPropertySheetModel implements PropertySheetModel {
private static final int APP_TITLE = 0;
private static final int APP_CLASS = 1;
private static final int APP_SINGLETON = 2;
private static final int APP_DESC = 3;
private static final int SINGLETON_PATH = 4;
private final ApplicationType applicationType;
private int currentIndex = -1;
public ApplicationInfoPropertySheetModel(final ApplicationType applicationType) {
this.applicationType = applicationType;
}
public boolean nextRow() {
if (applicationType.isSingleton() && currentIndex < SINGLETON_PATH) {
currentIndex++;
return true;
} else if (!applicationType.isSingleton() && currentIndex < APP_DESC) {
currentIndex++;
return true;
} else {
return false;
}
}
public String getLabel() {
switch (currentIndex) {
case APP_TITLE:
return (String) GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.title.label").
localize();
case APP_CLASS:
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.app_class.label").
localize();
case APP_SINGLETON:
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.singleton.label").
localize();
case APP_DESC:
return (String) GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.desc.label").
localize();
case SINGLETON_PATH:
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.singleton_instance.path.label").localize();
default:
return "";
}
}
public GlobalizedMessage getGlobalizedLabel() {
switch (currentIndex) {
case APP_TITLE:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.title.label");
case APP_CLASS:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.app_class.label");
case APP_SINGLETON:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.singleton.label");
case APP_DESC:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInfoSection.desc.label");
case SINGLETON_PATH:
return GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.singleton_instance.path.label");
default:
return GlobalizationUtil.globalize("unknown");
}
}
public String getValue() {
switch (currentIndex) {
case APP_TITLE:
return applicationType.getTitle();
case APP_CLASS:
return applicationType.getApplicationObjectType();
case APP_SINGLETON:
if (applicationType.isSingleton()) {
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.singleton.yes").
localize();
} else {
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.singleton.no").
localize();
}
case APP_DESC:
return applicationType.getDescription();
case SINGLETON_PATH:
final String path;
final ApplicationCollection instances = Application.retrieveAllApplications(applicationType.
getApplicationObjectType());
if (instances.next()) {
path = instances.getApplication().getPath();
} else {
path = "";
}
instances.close();
return path;
default:
return "";
}
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2013 Jens Pelzetter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.PropertySheet;
import com.arsdigita.bebop.PropertySheetModel;
import com.arsdigita.bebop.PropertySheetModelBuilder;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.web.ApplicationType;
/**
* {@link PropertySheetModelBuilder} implementation for the the {@link ApplicationInfoPropertySheetModel}.
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class ApplicationInfoPropertySheetModelBuilder extends LockableImpl implements PropertySheetModelBuilder {
private final ApplicationType applicationType;
public ApplicationInfoPropertySheetModelBuilder(final ApplicationType applicationType) {
super();
this.applicationType = applicationType;
}
public PropertySheetModel makeModel(final PropertySheet sheet, final PageState state) {
return new ApplicationInfoPropertySheetModel(applicationType);
}
}

View File

@ -19,6 +19,7 @@
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PropertySheet;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.ui.admin.GlobalizationUtil;
@ -37,18 +38,9 @@ public class ApplicationInstancePane extends SegmentedPanel {
public ApplicationInstancePane(final Application appInstance, final SimpleContainer appAdminPane) {
super();
final InfoPanel appInstInfoPanel = new InfoPanel();
appInstInfoPanel.addLine("ui.admin.applications.ApplicationInstancePane.title.label",
appInstance.getTitle());
if (appInstance.getParentApplication() != null) {
appInstInfoPanel.addLine("ui.admin.applications.ApplicationInstancePane.parent_app.label",
appInstance.getParentApplication().getPath());
}
appInstInfoPanel.addLine("ui.admin.applications.ApplicationInstancePane.path.label",
appInstance.getPath());
appInstInfoPanel.addLine("ui.admin.applications.ApplicationInstancePane.desc.label",
appInstance.getDescription());
final PropertySheet appInstInfoPanel = new PropertySheet(new ApplicationInstancePropertySheetModelBuilder(
appInstance));
addSegment(new Label(GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInstancePane.info.heading")),

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2013 Jens Pelzetter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.PropertySheet;
import com.arsdigita.bebop.PropertySheetModel;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.web.Application;
/**
* A {@link PropertySheetModel} implementation for displaying informations about an instance of an application
* using a {@link PropertySheet}.
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class ApplicationInstancePropertySheetModel implements PropertySheetModel {
private static final int INST_TITLE = 0;
private static final int INST_PARENT = 1;
private static final int INST_PATH = 2;
private static final int INST_DESC = 3;
private final Application application;
private int currentIndex = -1;
public ApplicationInstancePropertySheetModel(final Application application) {
this.application = application;
}
public boolean nextRow() {
currentIndex++;
return currentIndex < INST_DESC;
}
public String getLabel() {
switch (currentIndex) {
case INST_TITLE:
return (String) GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.title.label").
localize();
case INST_PARENT:
return (String) GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInstancePane.parent_app.label").localize();
case INST_PATH:
return (String) GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.path.label").
localize();
case INST_DESC:
return (String) GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.desc.label").
localize();
default:
return "";
}
}
public GlobalizedMessage getGlobalizedLabel() {
switch (currentIndex) {
case INST_TITLE:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.title.label");
case INST_PARENT:
return GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInstancePane.parent_app.label");
case INST_PATH:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.path.label");
case INST_DESC:
return GlobalizationUtil.globalize("ui.admin.applications.ApplicationInstancePane.desc.label");
default:
return GlobalizationUtil.globalize("unknown");
}
}
public String getValue() {
switch (currentIndex) {
case INST_TITLE:
return application.getTitle();
case INST_PARENT:
if (application.getParentApplication() == null) {
return "";
} else {
return application.getParentApplication().getPath();
}
case INST_PATH:
return application.getPath();
case INST_DESC:
return application.getDescription();
default:
return "";
}
}
}

View File

@ -18,33 +18,32 @@
*/
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.GridPanel;
import com.arsdigita.bebop.Label;
import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.PropertySheet;
import com.arsdigita.bebop.PropertySheetModel;
import com.arsdigita.bebop.PropertySheetModelBuilder;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.web.Application;
/**
* A helper class for creating a column panel with two labels in each row.
* {@link PropertySheetModelBuilder} implementation for the {@link ApplicationInstancePropertySheetModel}.
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class InfoPanel extends GridPanel {
public class ApplicationInstancePropertySheetModelBuilder extends LockableImpl implements PropertySheetModelBuilder {
public InfoPanel() {
super(2);
private final Application application;
public ApplicationInstancePropertySheetModelBuilder(final Application application) {
super();
this.application = application;
}
public void addLine(final String labelKey, final String data) {
addLine(labelKey, data, false);
public PropertySheetModel makeModel(final PropertySheet sheet, final PageState state) {
return new ApplicationInstancePropertySheetModel(application);
}
public void addLine(final String labelKey, final String data, final boolean globalizeData) {
add(new Label(GlobalizationUtil.globalize(labelKey)));
if (globalizeData) {
add(new Label(GlobalizationUtil.globalize(data)));
} else {
add(new Label(data));
}
}
}

View File

@ -19,10 +19,9 @@
package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PropertySheet;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.web.Application;
import com.arsdigita.web.ApplicationCollection;
import com.arsdigita.web.ApplicationType;
/**
@ -33,44 +32,12 @@ import com.arsdigita.web.ApplicationType;
* @version $Id$
*/
public class BaseApplicationPane extends SegmentedPanel {
//private final ApplicationType applicationType;
public BaseApplicationPane(final ApplicationType applicationType) {
super();
//this.applicationType = applicationType;
final InfoPanel appInfoPanel = new InfoPanel();
appInfoPanel.addLine("ui.admin.applications.ApplicationInfoSection.title.label",
applicationType.getTitle());
appInfoPanel.addLine("ui.admin.applications.ApplicationInfoSection.app_class.label",
applicationType.getApplicationObjectType());
if (applicationType.isSingleton()) {
appInfoPanel.addLine("ui.admin.applications.ApplicationInfoSection.singleton.label",
"ui.admin.applications.ApplicationInfoSection.singleton.yes",
true);
} else {
appInfoPanel.addLine("ui.admin.applications.ApplicationInfoSection.singleton.label",
"ui.admin.applications.ApplicationInfoSection.singleton.no",
true);
}
appInfoPanel.addLine("ui.admin.applications.ApplicationInfoSection.desc.label",
applicationType.getDescription());
if (applicationType.isSingleton()) {
final ApplicationCollection applications = Application.retrieveAllApplications(applicationType.
getApplicationObjectType());
if (applications.next()) {
appInfoPanel.addLine(
"ui.admin.applications.ApplicationInfoSection.singleton_instance.path.label",
applications.getApplication().getPath());
} else {
appInfoPanel.addLine(
"ui.admin.applications.ApplicationInfoSection.singleton_instance.path.label",
"ui.admin.applications.ApplicationInfoSection.singleton_instance.no_instance_found");
}
applications.close();
}
final PropertySheet appInfoPanel = new PropertySheet(new ApplicationInfoPropertySheetModelBuilder(
applicationType));
addSegment(new Label(GlobalizationUtil.globalize(
"ui.admin.applications.ApplicationInfoSection.heading")),
appInfoPanel);

View File

@ -30,14 +30,15 @@ import com.arsdigita.globalization.GlobalizedMessage;
* @version $Revision: #6 $ $Date: 2004/08/16 $
*/
public class GlobalizationUtil implements Globalized {
private static final String BUNDLE_NAME = "com.arsdigita.ui.UIResources";
public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
public static GlobalizedMessage globalize(String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
public static GlobalizedMessage globalize(final String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
public static GlobalizedMessage globalize(final String key, final Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}
}

View File

@ -51,16 +51,13 @@ import org.apache.log4j.Logger;
public class ApplicationType extends ResourceType {
/** The logging object for this class. */
private static final Logger s_log = Logger.getLogger
(ApplicationType.class);
private static final Logger s_log = Logger.getLogger(ApplicationType.class);
/**
* The fully qualified model name of the underlying data object, which in
* this case is the same as the Java type (full qualified class name).
*/
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.web.ApplicationType";
boolean m_legacyFree = true;
/**
@ -73,7 +70,7 @@ public class ApplicationType extends ResourceType {
*/
public ApplicationType(DataObject dataObject) {
super(dataObject);
m_legacyFree = true;
m_legacyFree = true;
}
protected ApplicationType(String dataObjectType) {
@ -104,9 +101,9 @@ public class ApplicationType extends ResourceType {
* @param createContainerGroup
*/
protected ApplicationType(final String objectType,
final String title,
final String applicationObjectType,
final boolean createContainerGroup) {
final String title,
final String applicationObjectType,
final boolean createContainerGroup) {
this(objectType); // creates and returns an empty data object
Assert.exists(title, "String title");
@ -116,7 +113,7 @@ public class ApplicationType extends ResourceType {
setApplicationObjectType(applicationObjectType);
setDefaults();
if (createContainerGroup) {
createGroup();
}
@ -128,7 +125,6 @@ public class ApplicationType extends ResourceType {
return BASE_DATA_OBJECT_TYPE;
}
/**
* Set defaults for an apoplication type during its initial creation.
* May be modified later during the process of loading an application
@ -187,8 +183,6 @@ public class ApplicationType extends ResourceType {
this(BASE_DATA_OBJECT_TYPE, title, applicationObjectType);
}
/**
*
* @param id
@ -197,8 +191,7 @@ public class ApplicationType extends ResourceType {
public static ApplicationType retrieveApplicationType(BigDecimal id) {
Assert.exists(id, "id");
return ApplicationType.retrieveApplicationType
(new OID(ApplicationType.BASE_DATA_OBJECT_TYPE, id));
return ApplicationType.retrieveApplicationType(new OID(ApplicationType.BASE_DATA_OBJECT_TYPE, id));
}
// Param oid cannot be null.
@ -213,33 +206,29 @@ public class ApplicationType extends ResourceType {
}
// Param dataObject cannot be null. Can return null?
public static ApplicationType retrieveApplicationType
(DataObject dataObject) {
public static ApplicationType retrieveApplicationType(DataObject dataObject) {
Assert.exists(dataObject, "dataObject");
return new ApplicationType(dataObject);
}
/**
*
* @param applicationObjectType
* @return Can return null.
*/
public static ApplicationType retrieveApplicationTypeForApplication
(String applicationObjectType) {
public static ApplicationType retrieveApplicationTypeForApplication(String applicationObjectType) {
Assert.exists(applicationObjectType, "applicationObjectType");
DataCollection collection =
SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
collection.addEqualsFilter("objectType", applicationObjectType);
ApplicationType applicationType = null;
if (collection.next()) {
applicationType = ApplicationType.retrieveApplicationType
(collection.getDataObject());
applicationType = ApplicationType.retrieveApplicationType(collection.getDataObject());
}
collection.close();
@ -253,7 +242,7 @@ public class ApplicationType extends ResourceType {
*/
public static ApplicationTypeCollection retrieveAllApplicationTypes() {
DataCollection collection =
SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
Assert.exists(collection, "collection");
@ -270,7 +259,6 @@ public class ApplicationType extends ResourceType {
//
// Member properties
//
/**
*
* @return
@ -295,7 +283,6 @@ public class ApplicationType extends ResourceType {
set("title", title);
}
/**
*
* @return Can return null.
@ -320,7 +307,6 @@ public class ApplicationType extends ResourceType {
//
// return result.booleanValue();
// }
// /**
// * @deprecated with no replacement.
// * @throws UnsupportedOperationException when this method is
@ -332,10 +318,8 @@ public class ApplicationType extends ResourceType {
// throw new UnsupportedOperationException
// ("This method is only supported for legacy application types");
// }
// set("isWorkspaceApplication", new Boolean(isWorkspaceApplication));
// }
// Deprecated in the context of ApplicationType, see comment above!
// public boolean hasFullPageView() {
// final Boolean result = (Boolean) get("hasFullPageView");
@ -344,7 +328,6 @@ public class ApplicationType extends ResourceType {
//
// return result.booleanValue();
// }
// /**
// * @deprecated with no replacement.
// * @throws UnsupportedOperationException when this method is
@ -359,18 +342,14 @@ public class ApplicationType extends ResourceType {
//
// set("hasFullPageView", new Boolean(hasFullPageView));
// }
// /**
// * @deprecated with no replacement.
// */
// public boolean hasEmbeddedView() {
// final Boolean result = (Boolean) get("hasEmbeddedView");
// Assert.exists(result, "Boolean result");
// return result.booleanValue();
// }
// /**
// * @deprecated with no replacement.
// * @throws UnsupportedOperationException when this method is
@ -382,10 +361,8 @@ public class ApplicationType extends ResourceType {
// throw new UnsupportedOperationException
// ("This method is only supported for legacy application types");
// }
// set("hasEmbeddedView", new Boolean(hasEmbeddedView));
// }
// Can return null.
public String getProfile() {
String profile = (String) get("profile");
@ -398,7 +375,6 @@ public class ApplicationType extends ResourceType {
set("profile", profile);
}
/**
* <p>Get the list of relevant privileges for this
* ApplicationType.</p>
@ -410,11 +386,11 @@ public class ApplicationType extends ResourceType {
LinkedList result = new LinkedList();
DataAssociationCursor dac =
((DataAssociation) get("relevantPrivileges")).cursor();
((DataAssociation) get("relevantPrivileges")).cursor();
while (dac.next()) {
PrivilegeDescriptor priv =
PrivilegeDescriptor.get((String)dac.get("privilege"));
PrivilegeDescriptor.get((String) dac.get("privilege"));
result.add(priv);
}
@ -470,7 +446,7 @@ public class ApplicationType extends ResourceType {
* @return object typ (fully qualified classname) as string
*/
public String getApplicationObjectType() {
String objectType = (String)get("objectType");
String objectType = (String) get("objectType");
Assert.exists(objectType);
@ -504,8 +480,8 @@ public class ApplicationType extends ResourceType {
// the class name without leading package name.
public String getName() {
s_log.debug("Expect XSL templates at " + StringUtils.urlize(getTitle()));
return StringUtils.urlize(getTitle());
s_log.debug("Expect XSL templates at " + StringUtils.urlize(getTitle()));
return StringUtils.urlize(getTitle());
}
@ -545,31 +521,28 @@ public class ApplicationType extends ResourceType {
@Override
public BigDecimal getID() {
BigDecimal id = (BigDecimal)get("id");
BigDecimal id = (BigDecimal) get("id");
Assert.exists(id, "id");
return id;
}
//
// Other
//
private BigDecimal generateID() throws PersistenceException {
try {
return Sequences.getNextValue();
} catch (SQLException e) {
final String errorMsg = "Unable to generate a unique " +
"id.";
final String errorMsg = "Unable to generate a unique " + "id.";
s_log.error(errorMsg);
throw new PersistenceException(errorMsg);
}
}
public void setGroup(Group group) {
setAssociation("containerGroup", group);
setAssociation("containerGroup", group);
}
/**
* Create a group in user administration for this application type. This
* group is used as a container (hence the name in pdl/table col) for
@ -577,15 +550,14 @@ public class ApplicationType extends ResourceType {
* It is named using the application types title followed by the constant
* "groups". No localisation yet!
*/
public void createGroup () {
Assert.isEqual(getGroup(), null, "Group has already been created for " +
"Application Type " + getTitle());
public void createGroup() {
Assert.isEqual(getGroup(), null, "Group has already been created for " + "Application Type " + getTitle());
Group group = new Group();
group.setName(getTitle() + " Groups");
setAssociation("containerGroup", group);
}
/**
* Group associated with this application type. Usually
* used as a container group to keep group admin tidy.
@ -593,9 +565,10 @@ public class ApplicationType extends ResourceType {
* @return null if no group is associated with this application type
*/
public Group getGroup() {
return (Group) DomainObjectFactory.newInstance(
(DataObject) get("containerGroup"));
return (Group) DomainObjectFactory.newInstance(
(DataObject) get("containerGroup"));
}
}

View File

@ -102,7 +102,7 @@ public class OIDRedirectServlet extends BaseServlet {
String context = sreq.getParameter("context");
String url = URLService.locate(oid, context);
/* Addition by JensP: */
/* Addition by Jensp: */
Map<?, ?> parameters = sreq.getParameterMap();
StringBuilder urlParams = new StringBuilder();
for (Map.Entry<?, ?> entry : parameters.entrySet()) {

View File

@ -56,68 +56,67 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
private RequestLocal m_parentResource;
private RequestLocal m_currentResource;
private ApplicationType m_applicationType;
private TextField m_url;
private TextField m_title;
private TextArea m_desc;
private boolean m_createApplicationGroup = false;
public ApplicationConfigFormSection(ResourceType resType,
RequestLocal parentAppRL,
boolean createApplicationGroup) {
this(resType, parentAppRL);
m_createApplicationGroup = createApplicationGroup;
}
public ApplicationConfigFormSection(ResourceType resType,
RequestLocal parentAppRL,
boolean createApplicationGroup) {
this (resType, parentAppRL);
m_createApplicationGroup = createApplicationGroup;
}
public ApplicationConfigFormSection(ResourceType resType,
RequestLocal parentAppRL) {
m_applicationType = (ApplicationType)resType;
m_applicationType = (ApplicationType) resType;
m_parentResource = parentAppRL;
m_applicationType.disconnect();
m_applicationType.disconnect();
setup();
}
public ApplicationConfigFormSection(RequestLocal application) {
m_currentResource = application;
setup();
}
private void setup() {
addInitListener(new FormInitListener() {
public void init(FormSectionEvent e)
public void init(FormSectionEvent e)
throws FormProcessException {
PageState state = e.getPageState();
if (m_currentResource != null) {
Application application =
(Application)m_currentResource.get(state);
initWidgets(state, application);
} else {
initWidgets(state, null);
}
PageState state = e.getPageState();
if (m_currentResource != null) {
Application application =
(Application) m_currentResource.get(state);
initWidgets(state, application);
} else {
initWidgets(state, null);
}
});
}
});
addValidationListener(new FormValidationListener() {
public void validate(FormSectionEvent e)
public void validate(FormSectionEvent e)
throws FormProcessException {
PageState state = e.getPageState();
if (m_currentResource != null) {
Application application =
(Application)m_currentResource.get(state);
validateWidgets(state, application);
} else {
validateWidgets(state, null);
}
PageState state = e.getPageState();
if (m_currentResource != null) {
Application application =
(Application) m_currentResource.get(state);
validateWidgets(state, application);
} else {
validateWidgets(state, null);
}
});
}
});
addWidgets();
}
/**
* Adds basic form widgets for URL, title
* and description properties. Override this
@ -138,7 +137,7 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
m_desc.setRows(5);
m_desc.setCols(35);
m_desc.addValidationListener(new StringInRangeValidationListener(0, 4000));
add(new Label("URL:", Label.BOLD), ColumnPanel.RIGHT);
add(m_url);
add(new Label("Title:", Label.BOLD), ColumnPanel.RIGHT);
@ -146,18 +145,18 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
add(new Label("Description:", Label.BOLD), ColumnPanel.RIGHT);
add(m_desc);
}
/**
* Initialize the form fields
* @param application the application being edited, if any
*/
protected void initWidgets(PageState state,
Application application)
throws FormProcessException {
throws FormProcessException {
if (application != null) {
String path = application.getPath();
String url = path.substring(path.lastIndexOf("/") +1);
String url = path.substring(path.lastIndexOf("/") + 1);
m_url.setValue(state, url);
m_title.setValue(state, application.getTitle());
@ -168,31 +167,31 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
m_desc.setValue(state, m_applicationType.getDescription());
}
}
/**
* Validates the form fields
* @param application the application being edited
*/
protected void validateWidgets(PageState state,
Application application)
throws FormProcessException {
Application application)
throws FormProcessException {
String url = (String) m_url.getValue(state);
String url = (String)m_url.getValue(state);
// Change this part
if ( url.indexOf("/") != -1) {
if (url.indexOf("/") != -1) {
throw new FormProcessException("The url cannot contain '/'");
}
// amended cg - prevent null pointer exception when
// saving edit of child application
// amended cg - prevent null pointer exception when
// saving edit of child application
Application parent;
if (m_parentResource != null) {
parent = (Application)m_parentResource.get(state);
parent = (Application) m_parentResource.get(state);
} else {
parent = application.getParentApplication();
}
String path;
if (parent != null) {
path = parent.getPath() + "/" + url;
@ -202,47 +201,48 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE,
url)) {
throw new FormProcessException(
"An application already exists with that name");
"An application already exists with that name");
}
}
public Resource createResource(PageState state) {
Application parent = (Application)m_parentResource.get(state);
Application parent = (Application) m_parentResource.get(state);
Application application = Application.createApplication(
m_applicationType,
(String)m_url.getValue(state),
(String)m_title.getValue(state),
parent,
m_createApplicationGroup);
m_applicationType,
(String) m_url.getValue(state),
(String) m_title.getValue(state),
parent,
m_createApplicationGroup);
try {
processWidgets(state, application);
} catch (FormProcessException ex) {
throw new UncheckedWrapperException("cannot create resource", ex);
}
return application;
}
public void modifyResource(PageState state) {
Application application = (Application)m_currentResource.get(state);
Application application = (Application) m_currentResource.get(state);
try {
processWidgets(state, application);
} catch (FormProcessException ex) {
throw new UncheckedWrapperException("cannot create resource", ex);
}
}
/**
* Processes the form submission
* @param application the application being edited, or newly created
*/
protected void processWidgets(PageState state,
Application application)
throws FormProcessException {
application.setTitle((String)m_title.getValue(state));
application.setDescription((String)m_desc.getValue(state));
throws FormProcessException {
application.setTitle((String) m_title.getValue(state));
application.setDescription((String) m_desc.getValue(state));
}
}