Modified: portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java?view=diff&rev=533883&r1=533882&r2=533883 ============================================================================== --- portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java (original) +++ portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java Mon Apr 30 16:41:09 2007 @@ -18,146 +18,392 @@ package org.apache.jetspeed.serializer.objects; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.jetspeed.serializer.JetspeedSerializedData; import javolution.xml.XMLFormat; import javolution.xml.stream.XMLStreamException; -public abstract class JSSnapshot +public class JSSnapshot implements JetspeedSerializedData { - + public static final int softwareVersion = 1; - private String name; + public static final int softwareSubVersion = 0; - private int savedVersion; + private String name; - private int savedSubversion; + private int savedVersion; - private String dateCreated; - - private String dataSource; - - - /** - * check the software version and subvversion against the saved - * version...and verify whether it is compatible... - * - * @return the current software can process this file - */ - public boolean checkVersion() - { - return true; - } - - public JSSnapshot() - { - System.out.println(this.getClass().getName() + " created"); - } - - public JSSnapshot(String name) - { - this.name = name; - } - - - - - /** - * @return Returns the name. - */ - public final String getName() - { - return name; - } - - - /** - * @return Returns the softwareSubVersion. - */ - public abstract int getSoftwareSubVersion(); - - /** - * @return Returns the softwareVersion. - */ - public abstract int getSoftwareVersion(); - - /** - * @return Returns the dataSource. - */ - public final String getDataSource() - { - return dataSource; - } - - /** - * @param dataSource - * The dataSource to set. - */ - public final void setDataSource(String dataSource) - { - this.dataSource = dataSource; - } - - /** - * @return Returns the dateCreated. - */ - public final String getDateCreated() - { - return dateCreated; - } - - /** - * @param dateCreated - * The dateCreated to set. - */ - public final void setDateCreated(String dateCreated) - { - this.dateCreated = dateCreated; - } - - - /** - * @return Returns the savedSubversion. - */ - public final int getSavedSubversion() - { - return savedSubversion; - } - - /** - * @param savedSubversion - * The savedSubversion to set. - */ - public final void setSavedSubversion(int savedSubversion) - { - this.savedSubversion = savedSubversion; - } - - /** - * @return Returns the savedVersion. - */ - public final int getSavedVersion() - { - return savedVersion; - } - - /** - * @param savedVersion - * The savedVersion to set. - */ - public final void setSavedVersion(int savedVersion) - { - this.savedVersion = savedVersion; - } - - /** - * @param name - * The name to set. - */ - public final void setName(String name) - { - this.name = name; - } + private int savedSubversion; + private String dateCreated; + + private String dataSource; + + private String encryption; + + private JSMimeTypes mimeTypes; + + private JSMediaTypes mediaTypes; + + private JSClients clients; + + private JSCapabilities capabilities; + + private JSRoles roles; + + private JSGroups groups; + + private JSUsers users; + + private JSPermissions permissions; + + private JSProfilingRules rules; + + private String defaultRule; + + private JSApplications applications; + + /** + * check the software version and subvversion against the saved + * version...and verify whether it is compatible... + * + * @return the current software can process this file + */ + public boolean checkVersion() + { + return true; + } + + public JSSnapshot() + { + System.out.println(this.getClass().getName() + " created"); + + mimeTypes = new JSMimeTypes(); + mediaTypes = new JSMediaTypes(); + clients = new JSClients(); + capabilities = new JSCapabilities(); + roles = new JSRoles(); + groups = new JSGroups(); + users = new JSUsers(); + permissions = new JSPermissions(); + rules = new JSProfilingRules(); + applications = new JSApplications(); + } + + public JSSnapshot(String name) + { + this(); + setName(name); + } + + /** + * @return Returns the name. + */ + public String getName() + { + return name; + } + + /** + * @param name + * The name to set. + */ + public void setName(String name) + { + this.name = name; + } + + /** + * @return Returns the softwareSubVersion. + */ + public int getSoftwareSubVersion() + { + return softwareSubVersion; + } + + /** + * @return Returns the softwareVersion. + */ + public int getSoftwareVersion() + { + return softwareVersion; + } + + /** + * @return Returns the dataSource. + */ + public String getDataSource() + { + return dataSource; + } + + /** + * @param dataSource + * The dataSource to set. + */ + public void setDataSource(String dataSource) + { + this.dataSource = dataSource; + } + + /** + * @return Returns the dateCreated. + */ + public String getDateCreated() + { + return dateCreated; + } + + /** + * @param dateCreated + * The dateCreated to set. + */ + public void setDateCreated(String dateCreated) + { + this.dateCreated = dateCreated; + } + + /** + * @return Returns the savedSubversion. + */ + public int getSavedSubversion() + { + return savedSubversion; + } + + /** + * @param savedSubversion + * The savedSubversion to set. + */ + public void setSavedSubversion(int savedSubversion) + { + this.savedSubversion = savedSubversion; + } + + /** + * @return Returns the savedVersion. + */ + public int getSavedVersion() + { + return savedVersion; + } + + /** + * @param savedVersion + * The savedVersion to set. + */ + public void setSavedVersion(int savedVersion) + { + this.savedVersion = savedVersion; + } + + /** + * @return Returns the groups. + */ + public JSGroups getGroups() + { + return groups; + } + + /** + * @param groups + * The groups to set. + */ + public void setGroups(JSGroups groups) + { + this.groups = groups; + } + + /** + * @return Returns the roles. + */ + public JSRoles getRoles() + { + return roles; + } + + /** + * @param roles + * The roles to set. + */ + public void setRoles(JSRoles roles) + { + this.roles = roles; + } + + /** + * @return Returns the roles. + */ + public JSUsers getUsers() + { + return users; + } + + /** + * @return Returns the encryption. + */ + public String getEncryption() + { + return encryption; + } + + /** + * @param encryption + * The encryption to set. + */ + public void setEncryption(String encryption) + { + this.encryption = encryption; + } + + + /** + * @return Returns the capabilities. + */ + public JSCapabilities getCapabilities() + { + return capabilities; + } + + /** + * @param capabilities + * The capabilities to set. + */ + public void setCapabilities(JSCapabilities capabilities) + { + this.capabilities = capabilities; + } + + /** + * @return Returns the clients. + */ + public JSClients getClients() + { + return clients; + } + + /** + * @param clients + * The clients to set. + */ + public void setClients(JSClients clients) + { + this.clients = clients; + } + + + + /** + * @return Returns the mediaTypes. + */ + public JSMediaTypes getMediaTypes() + { + return mediaTypes; + } + + /** + * @param mediaTypes + * The mediaTypes to set. + */ + public void setMediaTypes(JSMediaTypes mediaTypes) + { + this.mediaTypes = mediaTypes; + } + + /** + * @return Returns the mimeTypes. + */ + public JSMimeTypes getMimeTypes() + { + return mimeTypes; + } + + /** + * @param mimeTypes + * The mimeTypes to set. + */ + public void setMimeTypes(JSMimeTypes mimeTypes) + { + this.mimeTypes = mimeTypes; + } + + + + + /** + * @param users + * The users to set. + */ + public void setUsers(JSUsers users) + { + this.users = users; + } + + /** + * @return Returns the permissions. + */ + public JSPermissions getPermissions() + { + return permissions; + } + + /** + * @param permissions + * The permissions to set. + */ + public void setPermissions(JSPermissions permissions) + { + this.permissions = permissions; + } + + /** + * @return Returns the rules. + */ + public JSProfilingRules getRules() + { + return rules; + } + + /** + * @param rules + * The rules to set. + */ + public void setRules(JSProfilingRules rules) + { + this.rules = rules; + } + + /** + * @return Returns the defaultRule. + */ + public String getDefaultRule() + { + return defaultRule; + } + + /** + * @param defaultRule + * The defaultRule to set. + */ + public void setDefaultRule(String defaultRule) + { + this.defaultRule = defaultRule; + } + + + public JSApplications getApplications() + { + return applications; + } + + /** + * @param applications + * The applications to set. + */ + public void setApplications(JSApplications applications) + { + this.applications = applications; + } /*************************************************************************** @@ -166,10 +412,9 @@ protected static final XMLFormat XML = new XMLFormat(JSSnapshot.class) { - public void write(Object o, OutputElement xml) - throws XMLStreamException + public void write(Object o, OutputElement xml) throws XMLStreamException { - + try { JSSnapshot g = (JSSnapshot) o; @@ -180,34 +425,132 @@ /** named fields HERE */ - xml.add(String.valueOf(g.getSoftwareVersion()), - "softwareVersion"); - xml.add(String.valueOf(g.getSoftwareSubVersion()), - "softwareSubVersion"); - } catch (Exception e) + xml.add(String.valueOf(g.getSoftwareVersion()), "softwareVersion"); + xml.add(String.valueOf(g.getSoftwareSubVersion()), "softwareSubVersion"); + if ( g.getDefaultRule() != null ) + { + xml.add(g.getDefaultRule(), "default_rule", String.class); + } + + if ( g.getEncryption() != null ) + { + xml.add(g.getEncryption(),"encryption",String.class); + } + + /** implicitly named (through binding) fields here */ + if ( !g.getMimeTypes().isEmpty() ) + { + xml.add(g.getMimeTypes()); + } + if ( !g.getMediaTypes().isEmpty() ) + { + xml.add(g.getMediaTypes()); + } + if ( !g.getCapabilities().isEmpty() ) + { + xml.add(g.getCapabilities()); + } + if ( !g.getClients().isEmpty() ) + { + xml.add(g.getClients()); + } + if ( !g.getRoles().isEmpty() ) + { + xml.add(g.getRoles()); + } + if ( !g.getGroups().isEmpty() ) + { + xml.add(g.getGroups()); + } + if ( !g.getUsers().isEmpty() ) + { + xml.add(g.getUsers()); + } + if ( !g.getPermissions().isEmpty() ) + { + xml.add(g.getPermissions()); + } + if ( !g.getRules().isEmpty() ) + { + xml.add(g.getRules()); + } + if ( !g.getApplications().isEmpty() ) + { + xml.add(g.getApplications()); + } + } + catch (Exception e) { e.printStackTrace(); + if ( e instanceof XMLStreamException ) + { + throw (XMLStreamException)e; + } + throw new XMLStreamException(e); } } - public void read(InputElement xml, Object o) + public void read(InputElement xml, Object o) throws XMLStreamException { try { JSSnapshot g = (JSSnapshot) o; g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown")); - Object o1 = xml.get("softwareVersion",String.class); - if (o1 instanceof String) + Object o1 = xml.get("softwareVersion", String.class); + if (o1 != null && o1 instanceof String) + { g.savedVersion = Integer.parseInt(((String) o1)); - o1 = xml.get("softwareSubVersion",String.class); - if (o1 instanceof String) + } + o1 = xml.get("softwareSubVersion", String.class); + if (o1 != null && o1 instanceof String) + { g.savedSubversion = Integer.parseInt(((String) o1)); - } catch (Exception e) + } + o1 = xml.get("default_rule",String.class); + if (o1 != null && o1 instanceof String) + { + g.defaultRule = StringEscapeUtils.unescapeHtml((String) o1); + } + o1 = xml.get("encryption",String.class); + if (o1 != null && o1 instanceof String) + { + g.encryption = StringEscapeUtils.unescapeHtml((String) o1); + } + while (xml.hasNext()) + { + o1 = xml.getNext(); // mime + + if (o1 instanceof JSMimeTypes) + g.mimeTypes = (JSMimeTypes) o1; + else if (o1 instanceof JSMediaTypes) + g.mediaTypes = (JSMediaTypes) o1; + else if (o1 instanceof JSClients) + g.clients = (JSClients) o1; + else if (o1 instanceof JSCapabilities) + g.capabilities = (JSCapabilities) o1; + else if (o1 instanceof JSRoles) + g.roles = (JSRoles) o1; + else if (o1 instanceof JSGroups) + g.groups = (JSGroups) o1; + else if (o1 instanceof JSUsers) + g.users = (JSUsers) o1; + else if (o1 instanceof JSPermissions) + g.permissions = (JSPermissions) o1; + else if (o1 instanceof JSProfilingRules) + g.rules = (JSProfilingRules) o1; + else if (o1 instanceof JSApplications) + g.applications = (JSApplications) o1; + } + } + catch (Exception e) { e.printStackTrace(); + if ( e instanceof XMLStreamException ) + { + throw (XMLStreamException)e; + } + throw new XMLStreamException(e); } } }; - - }
Added: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java?view=auto&rev=533883 ============================================================================== --- portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java (added) +++ portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java Mon Apr 30 16:41:09 2007 @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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; + +/** + * Jetspeed Component Serializer + * + * @author <a href="mailto:[EMAIL PROTECTED]">Ate Douma</a> + * @version $Id$ + */ +public interface JetspeedComponentSerializer +{ + void processImport(JetspeedSerializedData data, Map settings) throws SerializerException; + void processExport(JetspeedSerializedData data, Map settings) throws SerializerException; + void deleteData(Map settings) throws SerializerException; +} Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedComponentSerializer.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java?view=auto&rev=533883 ============================================================================== --- portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java (added) +++ portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java Mon Apr 30 16:41:09 2007 @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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; + +/** + * Jetspeed Serialized Data + * + * @author <a href="mailto:[EMAIL PROTECTED]">Ate Douma</a> + * @version $Id$ + * + */ +public interface JetspeedSerializedData +{ + String getName(); + int getSoftwareVersion(); + int getSoftwareSubVersion(); + String getDateCreated(); +} Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializedData.java ------------------------------------------------------------------------------ svn:keywords = Id Modified: portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java?view=diff&rev=533883&r1=533882&r2=533883 ============================================================================== --- portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java (original) +++ portals/jetspeed-2/branches/J2-M2-REDUX/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java Mon Apr 30 16:41:09 2007 @@ -16,10 +16,9 @@ */ package org.apache.jetspeed.serializer; +import java.util.List; import java.util.Map; -import org.apache.jetspeed.components.ComponentManager; - /** * Jetspeed Serializer * <p> @@ -43,81 +42,54 @@ /** Password handling */ /** Error in determening correct password handling */ - public final static short ERROR_DECODING = -1; + short ERROR_DECODING = -1; /** the passwords are in clear text */ - public final static short NO_DECODING = 0; + 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; + 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; + short DECODING_SUPPORTED = 2; /** the passwords are encoded and the current provider is DIFFERENT.... */ - public final static short INVALID_PASSWORDS = 3; + 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_PROCESS_PORTAL_PREFERENCES = "process_portal_preferences" - .intern(); - - public final static String KEY_OVERWRITE_EXISTING = "overwrite_existing" - .intern(); - - public final static String KEY_BACKUP_BEFORE_PROCESS = "backup_before_process" - .intern(); - - /** export/import instructions secondary*/ - public final static String KEY_PROCESS_ENTITIES = "process_entities".intern(); - public final static String KEY_PROCESS_PREFERENCES = "process_preferences".intern(); - - + String KEY_PROCESS_USERS = "process_users"; + String KEY_PROCESS_CAPABILITIES = "process_capabilities"; + String KEY_PROCESS_PROFILER = "process_profiler"; + String KEY_PROCESS_USER_PREFERENCES = "process_user_preferences"; + String KEY_PROCESS_PORTAL_PREFERENCES = "process_portal_preferences"; + String KEY_PROCESS_ENTITIES = "process_entities"; + String KEY_PROCESS_PREFERENCES = "process_preferences"; + String KEY_LOGGER = "logger"; + String KEY_OVERWRITE_EXISTING = "overwrite_existing"; + String KEY_BACKUP_BEFORE_PROCESS = "backup_before_process"; /**<p> the main tag in the XML file */ - public final static String TAG_SNAPSHOT = "Snapshot"; - public final static String TAG_SECONDARYSNAPSHOT = "SecondaryData"; + String TAG_SNAPSHOT = "Snapshot"; + + List getSerializers(); + Map getDefaultSettings(); /** - * 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 + * Main routine to export the set of data elements and write them to the + * named XML file. * - * @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 + * @param name + * of the snapshot + * @param exportFileName */ - public void initializeComponentManager(String appRoot, String[] bootConfig, - String[] appConfig) throws SerializerException; + void exportData(String name, String exportFileName) throws SerializerException; /** * Main routine to export the set of data elements and write them to the @@ -140,13 +112,22 @@ * @param settings * optional Map overwriting default export behavior */ - public void exportData(String name, String exportFileName, Map settings) - throws SerializerException; + 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. + * current environment. + * + * @param importFileName + * @param settings + * optional Map overwriting default import behavior + * @return + */ + void importData(String importFileName) throws SerializerException; + + /** + * Main routine to import the set of data elements and write them to the + * current environment. * <p> * Existing entries (like users) etc. will be overwritten with the provided * data. @@ -167,27 +148,22 @@ * optional Map overwriting default import behavior * @return */ - public void importData(String importFileName, Map settings) - throws SerializerException; + void importData(String importFileName, Map settings) throws SerializerException; + + void deleteData() throws SerializerException; + void deleteData(Map settings) throws SerializerException; /** * Set the default indent for the XML output * * @param indent */ - public void setDefaultIndent(String indent); + 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(); - + String getDefaultIndent(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
