You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2006/11/02 23:05:43 UTC
svn commit: r470541 - in
/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed:
components/ serializer/
Author: taylor
Date: Thu Nov 2 14:05:42 2006
New Revision: 470541
URL: http://svn.apache.org/viewvc?view=rev&rev=470541
Log:
http://issues.apache.org/jira/browse/JS2-461 - Serializer component
patch from Hajo Birthelmer (hajo@bluesunrise.com)
phase 1 of 2 patches
* serializer interfaces
* move Component interfaces to jetspeed-api
Added:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManagement.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManager.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ContainerManagement.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/SerializerException.java
Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManagement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManagement.java?view=auto&rev=470541
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManagement.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManagement.java Thu Nov 2 14:05:42 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components;
+
+/**
+ * ComponentManagement
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ComponentManagement.java 225607 2005-07-27 20:25:36Z weaver $
+ */
+public interface ComponentManagement
+{
+ Object getComponent(Object componentName);
+
+ Object getComponent(Object containerName, Object componentName);
+
+ void addComponent(String name, Object bean);
+}
Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManager.java?view=auto&rev=470541
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManager.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ComponentManager.java Thu Nov 2 14:05:42 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components;
+
+/**
+ * <p>
+ * ComponentManager
+ * </p>
+ * <p>
+ *
+ * </p>
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: ComponentManager.java 187034 2004-07-20 13:42:06Z weaver $
+ *
+ */
+public interface ComponentManager extends ComponentManagement, ContainerManagement
+{
+
+}
Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ContainerManagement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ContainerManagement.java?view=auto&rev=470541
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ContainerManagement.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/ContainerManagement.java Thu Nov 2 14:05:42 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components;
+
+import java.util.Collection;
+
+/**
+ * ContainerManagement
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ContainerManagement.java 225607 2005-07-27 20:25:36Z weaver $
+ */
+public interface ContainerManagement
+{
+ Object getContainer(String containerName);
+
+ Object getRootContainer();
+
+ Collection getContainers();
+
+ void stop();
+
+ void start();
+}
Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/JetspeedSerializer.java?view=auto&rev=470541
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/JetspeedSerializer.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/JetspeedSerializer.java Thu Nov 2 14:05:42 2006
@@ -0,0 +1,183 @@
+/**
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.serializer;
+
+import java.util.Map;
+
+import org.apache.jetspeed.components.ComponentManager;
+
+/**
+ * Jetspeed Serializer
+ * <p>
+ * The Serializer is capable of reading and writing the current content of the
+ * Jetspeed environment to and from XML files. The component can be used from a
+ * standalone java application for seeding a new database or from a running
+ * portal as an administrative backup/restore function.
+ * <p>
+ * The XML file needs to indicate whether passwords used in credentials
+ * are plain text or whether they are encoded. The import algoritm can determine -
+ * prior to reading users - which encode/decode scheme was used and if <none> or
+ * <implements PasswordEncodingService> then we store plain passwords (Note that
+ * that alone requires the resulting XML to be encoded!!!!!)
+ *
+ * @author <a href="mailto:hajo@bluesunrise.com">Hajo Birthelmer</a>
+ * @version $Id: JetspeedSerializer.java 0 2006-10-31 22:51:28Z hjb $
+ *
+ */
+public interface JetspeedSerializer
+{
+
+ /** Password handling */
+ /** Error in determening correct password handling */
+ public final static short ERROR_DECODING = -1;
+
+ /** the passwords are in clear text */
+ public final static short NO_DECODING = 0;
+
+ /**
+ * the passwords are encoded and the provider is the same as the data
+ * source, but is a 1-way algorithm
+ */
+ public final static short PASSTHRU_REQUIRED = 1;
+
+ /**
+ * the passwords are encoded and the provider is the same as the data source
+ * and we have a 2-way algorithm
+ */
+ public final static short DECODING_SUPPORTED = 2;
+
+ /** the passwords are encoded and the current provider is DIFFERENT.... */
+ public final static short INVALID_PASSWORDS = 3;
+
+ /** export/import instructions */
+
+ public final static String KEY_PROCESS_USERS = "process_users".intern();
+
+ public final static String KEY_PROCESS_CAPABILITIES = "process_capabilities"
+ .intern();
+
+ public final static String KEY_PROCESS_PROFILER = "process_profiler"
+ .intern();
+
+ public final static String KEY_PROCESS_USER_PREFERENCES = "process_user_preferences"
+ .intern();
+
+ public final static String KEY_OVERWRITE_EXISTING = "overwrite_existing"
+ .intern();
+
+ public final static String KEY_BACKUP_BEFORE_PROCESS = "backup_before_process"
+ .intern();
+
+ /**<p> the main tag in the XML file */
+ public final static String TAG_SNAPSHOT = "Snapshot";
+
+ /**
+ * hand the serializer an existing component manager to access the
+ * environment
+ *
+ * @param cm
+ */
+ public void setComponentManager(ComponentManager cm)
+ throws SerializerException;
+
+ /**
+ * Create a component manager with the list of primary components (boot),
+ * the application components and the root path of the application
+ *
+ * @param appRoot
+ * working directory
+ * @param bootConfig
+ * boot (primary) file or files (wildcards are allowed)
+ * @param appConfig
+ * application (secondary) file or files (wildcards are allowed)
+ * @return a newly initiated component manager
+ * @throws SerializerException
+ */
+ public void initializeComponentManager(String appRoot, String[] bootConfig,
+ String[] appConfig) throws SerializerException;
+
+ /**
+ * Main routine to export the set of data elements and write them to the
+ * named XML file. The default behavior of the serializer is that all
+ * available data is extracted and the target file gets created or
+ * overwritten
+ * <p>
+ * The caller can adjust the default behavior by passign in a map of flags.
+ * Each map entry is keyed by a key Constant and the associated Boolean
+ * value, for exammple KEY_PROCESS_USER_PREFERENCES, Boolean.FALSE would
+ * cause the serializer to skip user preferences.
+ * <p>
+ * Note that ProfilingRules require the users . Hence turning off User
+ * collection will automatically turn off the Profiling rules
+ *
+ *
+ * @param name
+ * of the snapshot
+ * @param exportFileName
+ * @param settings
+ * optional Map overwriting default export behavior
+ */
+ public void exportData(String name, String exportFileName, Map settings)
+ throws SerializerException;
+
+ /**
+ * Main routine to import the set of data elements and write them to the
+ * current environment. The default behavior of the serializer is that all
+ * available data is read and written to the current environment.
+ * <p>
+ * Existing entries (like users) etc. will be overwritten with the provided
+ * data.
+ * <p>
+ * The caller can adjust the default behavior by passign in a map of flags.
+ * Each map entry is keyed by a key Constant and the associated Boolean
+ * value, for exammple KEY_PROCESS_USER_PREFERENCES, Boolean.FALSE would
+ * cause the serializer to skip user preferences.
+ * <p>
+ * Note that settings are valid throughout each invocation. Therefore if a
+ * caller wants to preserve current users and only add new entries while at
+ * the same time overwrite all profiling rules, exportData has to be invoked
+ * twice - once to process only the users with the no-overwrite option and
+ * once to process the profiling rules
+ *
+ * @param importFileName
+ * @param settings
+ * optional Map overwriting default import behavior
+ * @return
+ */
+ public void importData(String importFileName, Map settings)
+ throws SerializerException;
+
+ /**
+ * Set the default indent for the XML output
+ *
+ * @param indent
+ */
+ public void setDefaultIndent(String indent);
+
+ /**
+ * Get the current indent setting for XML files
+ *
+ * @return the current indent setting
+ */
+ public String getDefaultIndent();
+
+ /**
+ * reelase the resources etc.
+ *
+ */
+ public void closeUp();
+
+}
Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/SerializerException.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/SerializerException.java?view=auto&rev=470541
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/SerializerException.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/serializer/SerializerException.java Thu Nov 2 14:05:42 2006
@@ -0,0 +1,92 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.serializer;
+
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.i18n.KeyedMessage;
+
+/**
+ * <p>Exception throwns by members of the security service.</p>
+ *
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ */
+public class SerializerException extends JetspeedException
+{
+ /** The serial version uid. */
+ private static final long serialVersionUID = -8823877029853488431L;
+
+ /** <p>Component Manager does not exist exception message.</p> */
+ public static final KeyedMessage COMPONENTMANAGER_DOES_NOT_EXIST = new KeyedMessage("The component manager {0} does not exist.");
+
+ /** <p>Creating the serilized Object failed </p> */
+ public static final KeyedMessage GET_EXISTING_OBJECTS = new KeyedMessage("Get existing objects for {0} failed with message {1}");
+
+ /** <p>Creating the serilized Object failed </p> */
+ public static final KeyedMessage CREATE_SERIALIZED_OBJECT_FAILED = new KeyedMessage("Creating a serialized representation of {0} failed with message {1}");
+
+ /** <p>Component Manager already initialized</p> */
+ public static final KeyedMessage COMPONENT_MANAGER_EXISTS = new KeyedMessage("Component Manager already established");
+
+
+ /** <p>Filename already exists</p> */
+ public static final KeyedMessage FILE_ALREADY_EXISTS = new KeyedMessage("File {0} already exists");
+
+ /** <p>Filename already exists</p> */
+ public static final KeyedMessage FILE_BACKUP_FAILED = new KeyedMessage("File {0} backup failed. Could create new name.");
+
+ /** <p>io error</p> */
+ public static final KeyedMessage FILE_PROCESSING_ERROR = new KeyedMessage("Error processing File {0} : {1}");
+ /** <p>writer error</p> */
+ public static final KeyedMessage FILE_WRITER_ERROR = new KeyedMessage("Error creating Writer for {0} : {1}");
+ /** <p>reader error</p> */
+ public static final KeyedMessage FILE_READER_ERROR = new KeyedMessage("Error creating Reader for {0} : {1}");
+
+ /** <p>version problem - version in XML file is not compatible with current environment </p> */
+ public static final KeyedMessage INCOMPETIBLE_VERSION = new KeyedMessage("Incompetible version in {0} : CurrentVersion = {1}, RequestedVersion = {2}");
+
+
+ /**
+ * <p>Default Constructor.</p>
+ */
+ public SerializerException()
+ {
+ super();
+ }
+
+ public SerializerException(Throwable t)
+ {
+ super(t);
+ }
+
+ /**
+ * <p>Constructor with exception message.</p>
+ * @param message The exception message.
+ */
+ public SerializerException(KeyedMessage typedMessage)
+ {
+ super(typedMessage);
+ }
+
+ /**
+ * <p>Constructor with exception message and nested exception.</p>
+ * @param msg The exception message.
+ * @param nested Nested exception.
+ */
+ public SerializerException(KeyedMessage msg, Throwable nested)
+ {
+ super(msg, nested);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org