1 /* 2 * Copyright 2000-2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.jetspeed.om.profile; 18 19 import org.apache.jetspeed.services.psmlmanager.PsmlManagerService; 20 21 /*** 22 Represents a Profile object specially for importing PSML from one service to another (ex. file -> db or db -> file) 23 For getDocument, the provider service provides the PSML document. 24 For saveDocument, the consumer service writes the PSML document. 25 26 @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> 27 @version $Id: ImportProfile.java,v 1.4 2004/02/23 03:05:01 jford Exp $ 28 */ 29 30 public class ImportProfile extends BaseProfile implements Profile 31 { 32 private final PsmlManagerService provider; 33 private final PsmlManagerService consumer; 34 35 public ImportProfile(PsmlManagerService provider, PsmlManagerService consumer) 36 { 37 super(); 38 this.provider = provider; 39 this.consumer = consumer; 40 } 41 42 public ImportProfile(PsmlManagerService provider, PsmlManagerService consumer, ProfileLocator locator) 43 { 44 super(locator); 45 this.provider = provider; 46 this.consumer = consumer; 47 } 48 49 /*** 50 * @see Object#clone 51 * @return an instance copy of this object 52 */ 53 public Object clone() throws java.lang.CloneNotSupportedException 54 { 55 return super.clone(); 56 } 57 58 /*** 59 Gets the root set of portlets for this profile object. 60 61 @return The root portlet set for this profile. 62 */ 63 public PSMLDocument getDocument() 64 { 65 synchronized (this) 66 { 67 if ((this.document == null) || (this.document.getPortlets() == null)) 68 { 69 this.document = provider.getDocument(this); 70 } 71 } 72 return this.document; 73 } 74 75 /*** 76 stores the resource by merging and rewriting the psml file 77 78 @throws ProfileException if an error occurs storing the profile 79 */ 80 public void store() throws ProfileException 81 { 82 if (document != null) 83 { 84 consumer.store(this); 85 } 86 } 87 88 }