weaver 2004/10/12 12:59:31 Modified: components/registry/src/java/META-INF ojb_repository.xml components/registry/src/java/org/apache/jetspeed/components/portletregistry PortletRegistryComponentImpl.java Log: see: http://nagoya.apache.org/jira/browse/JS2-141 and http://nagoya.apache.org/jira/browse/JS2-142 Revision Changes Path 1.17 +7 -7 jakarta-jetspeed-2/components/registry/src/java/META-INF/ojb_repository.xml Index: ojb_repository.xml =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/META-INF/ojb_repository.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- ojb_repository.xml 1 Oct 2004 22:46:22 -0000 1.16 +++ ojb_repository.xml 12 Oct 2004 19:59:30 -0000 1.17 @@ -185,7 +185,7 @@ <collection-descriptor name="portlets" element-class-ref="org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" @@ -374,7 +374,7 @@ <collection-descriptor name="displayNames" element-class-ref="org.apache.jetspeed.om.impl.PortletDisplayNameImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" > @@ -385,7 +385,7 @@ <collection-descriptor name="languageSet" element-class-ref="org.apache.jetspeed.om.impl.LanguageImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" > @@ -396,7 +396,7 @@ <collection-descriptor name="contentTypes" element-class-ref="org.apache.jetspeed.om.portlet.impl.ContentTypeImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" > @@ -409,7 +409,7 @@ name="parameterSet" proxy="true" element-class-ref="org.apache.jetspeed.om.impl.PortletInitParameterImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" > @@ -422,7 +422,7 @@ <collection-descriptor name="securityRoleRefSet" element-class-ref="org.apache.jetspeed.om.impl.SecurityRoleRefImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" @@ -433,7 +433,7 @@ <collection-descriptor name="descriptions" element-class-ref="org.apache.jetspeed.om.impl.PortletDescriptionImpl" - auto-delete="false" + auto-delete="true" auto-update = "true" auto-retrieve = "true" > 1.16 +63 -116 jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistryComponentImpl.java Index: PortletRegistryComponentImpl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistryComponentImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PortletRegistryComponentImpl.java 16 Aug 2004 18:29:17 -0000 1.15 +++ PortletRegistryComponentImpl.java 12 Oct 2004 19:59:31 -0000 1.16 @@ -33,19 +33,12 @@ import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; import org.apache.jetspeed.om.impl.LanguageImpl; -import org.apache.jetspeed.om.impl.PortletDescriptionImpl; -import org.apache.jetspeed.om.impl.PortletDisplayNameImpl; -import org.apache.jetspeed.om.impl.PortletInitParameterImpl; -import org.apache.jetspeed.om.impl.SecurityRoleRefImpl; -import org.apache.jetspeed.om.portlet.impl.ContentTypeImpl; import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl; import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl; -import org.apache.jetspeed.om.portlet.impl.PortletDefinitionLocalizedFieldImpl; -import org.apache.jetspeed.om.portlet.impl.StoreablePortletDefinitionDelegate; import org.apache.pluto.om.common.Language; import org.apache.pluto.om.common.ObjectID; import org.apache.pluto.om.portlet.PortletApplicationDefinition; - +import org.apache.pluto.om.portlet.PortletDefinition; /** * <p> @@ -66,7 +59,8 @@ * <td>persistence.store.name</td> * <td>true</td> * <td>jetspeed</td> - * <td>Name of the persistence store that will be used for persistence operations.</td> + * <td>Name of the persistence store that will be used for persistence + * operations.</td> * </tr> * </table> * @@ -78,24 +72,24 @@ { /** The logger. */ private static final Log log = LogFactory.getLog(PortletRegistryComponentImpl.class); - - /** + + /** * The separator used to create a unique portlet name as * {portletApplication}::{portlet} */ static final String PORTLET_UNIQUE_NAME_SEPARATOR = "::"; protected static final String KEY_STORE_NAME = "persistence.store.name"; - + private Class portletDefClass; private Class portletAppClass; - + private PersistenceStore persistenceStore; /** * */ - public PortletRegistryComponentImpl(PersistenceStore persistenceStore) throws RegistryException + public PortletRegistryComponentImpl( PersistenceStore persistenceStore ) throws RegistryException { if (persistenceStore == null) { @@ -104,6 +98,8 @@ this.persistenceStore = persistenceStore; portletDefClass = PortletDefinitionImpl.class; portletAppClass = PortletApplicationDefinitionImpl.class; + + PortletDefinitionImpl.setPortletRegistry(this); } /** @@ -111,8 +107,9 @@ * createLanguage * </p> * - * @see org.apache.jetspeed.registry.PortletRegistryComponentImpl#createLanguage(java.util.Locale, java.lang.String, - * java.lang.String, java.lang.String, java.util.Collection) + * @see org.apache.jetspeed.registry.PortletRegistryComponentImpl#createLanguage(java.util.Locale, + * java.lang.String, java.lang.String, java.lang.String, + * java.util.Collection) * @param locale * @param title * @param shortTitle @@ -121,8 +118,8 @@ * @return @throws * RegistryException */ - public Language createLanguage(Locale locale, String title, String shortTitle, String description, Collection keywords) - throws RegistryException + public Language createLanguage( Locale locale, String title, String shortTitle, String description, + Collection keywords ) throws RegistryException { try { @@ -180,7 +177,7 @@ * @param id * @return */ - public MutablePortletApplication getPortletApplication(ObjectID id) + public MutablePortletApplication getPortletApplication( ObjectID id ) { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -190,7 +187,7 @@ return (MutablePortletApplication) postLoad(store.getObjectByQuery(query)); } - private void prepareTransaction(PersistenceStore store) + private void prepareTransaction( PersistenceStore store ) { if (store.getTransaction() == null || !store.getTransaction().isOpen()) { @@ -207,7 +204,7 @@ * @param name * @return */ - public MutablePortletApplication getPortletApplication(String name) + public MutablePortletApplication getPortletApplication( String name ) { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -226,7 +223,7 @@ * @param ident * @return */ - public MutablePortletApplication getPortletApplicationByIdentifier(String ident) + public MutablePortletApplication getPortletApplicationByIdentifier( String ident ) { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -272,7 +269,7 @@ * @param ident * @return */ - public PortletDefinitionComposite getPortletDefinitionByIdentifier(String ident) + public PortletDefinitionComposite getPortletDefinitionByIdentifier( String ident ) { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -284,12 +281,11 @@ { if (portlet.getPortletApplicationDefinition() == null) { - final String msg = - "getPortletDefinitionByIdentifier() returned a PortletDefinition that has no parent PortletApplication."; + final String msg = "getPortletDefinitionByIdentifier() returned a PortletDefinition that has no parent PortletApplication."; log.error(msg); throw new IllegalStateException(msg); } - return getStoreableInstance((PortletDefinitionComposite) postLoad(portlet)); + return (PortletDefinitionComposite) postLoad(portlet); } else { @@ -306,7 +302,7 @@ * @param name * @return */ - public PortletDefinitionComposite getPortletDefinitionByUniqueName(String name) + public PortletDefinitionComposite getPortletDefinitionByUniqueName( String name ) { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -330,14 +326,13 @@ MutablePortletApplication app = (MutablePortletApplication) store.getObjectByQuery(query); if (null == app) { - final String msg = - "getPortletDefinitionByUniqueName() returned a PortletDefinition that has no parent PortletApplication."; + final String msg = "getPortletDefinitionByUniqueName() returned a PortletDefinition that has no parent PortletApplication."; log.error(msg); throw new IllegalStateException(msg); } portlet.setPortletApplicationDefinition(app); } - return getStoreableInstance((PortletDefinitionComposite)postLoad(portlet)); + return (PortletDefinitionComposite) postLoad(portlet); } else { @@ -354,7 +349,7 @@ * @param appIdentity * @return */ - public boolean portletApplicationExists(String appIdentity) + public boolean portletApplicationExists( String appIdentity ) { return getPortletApplicationByIdentifier(appIdentity) != null; } @@ -368,7 +363,7 @@ * @param portletIndentity * @return */ - public boolean portletDefinitionExists(String portletIdentity) + public boolean portletDefinitionExists( String portletIdentity ) { return getPortletDefinitionByIdentifier(portletIdentity) != null; } @@ -384,7 +379,7 @@ * @param app * @return */ - public boolean portletDefinitionExists(String portletName, MutablePortletApplication app) + public boolean portletDefinitionExists( String portletName, MutablePortletApplication app ) { return getPortletDefinitionByUniqueName(app.getName() + "::" + portletName) != null; } @@ -398,7 +393,7 @@ * @param newApp * @throws RegistryException */ - public void registerPortletApplication(PortletApplicationDefinition newApp) throws RegistryException + public void registerPortletApplication( PortletApplicationDefinition newApp ) throws RegistryException { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); @@ -422,82 +417,30 @@ * @param app * @throws TransactionStateException */ - public void removeApplication(PortletApplicationDefinition app) throws RegistryException + public void removeApplication( PortletApplicationDefinition app ) throws RegistryException { PersistenceStore store = getPersistenceStore(); prepareTransaction(store); - Filter filter = store.newFilter(); + String appNodePath = MutablePortletApplication.PREFS_ROOT + "/" + ((MutablePortletApplication) app).getName(); try { - Iterator portlets = app.getPortletDefinitionList().iterator(); - while (portlets.hasNext()) + if (Preferences.systemRoot().nodeExists(appNodePath)) { - PortletDefinitionImpl curPortlet = (PortletDefinitionImpl) portlets.next(); - - filter.addEqualTo("parentId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(PortletDefinitionLocalizedFieldImpl.class, filter)); - store.getTransaction().checkpoint(); - - filter = store.newFilter(); - filter.addEqualTo("parentId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(PortletDisplayNameImpl.class, filter)); - store.getTransaction().checkpoint(); - - filter = store.newFilter(); - filter.addEqualTo("portletId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(LanguageImpl.class, filter)); - store.getTransaction().checkpoint(); - - filter = store.newFilter(); - filter.addEqualTo("portletId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(ContentTypeImpl.class, filter)); - store.getTransaction().checkpoint(); - - filter = store.newFilter(); - filter.addEqualTo("parentId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(PortletInitParameterImpl.class, filter)); - store.getTransaction().checkpoint(); - -// filter = store.newFilter(); -// filter.addEqualTo("parentId", new Long(curPortlet.getOID())); -// -// store.getTransaction().checkpoint(); - - String appNodePath = MutablePortletApplication.PREFS_ROOT + "/" +((MutablePortletApplication)app).getName(); - try - { - if(Preferences.systemRoot().nodeExists(appNodePath)) - { - Preferences node = Preferences.systemRoot().node(appNodePath); - log.info("Removing Application preference node "+node.absolutePath()); - node.removeNode(); - } - } - catch (BackingStoreException e) - { - throw new RegistryException(e.toString(), e); - } - - filter = store.newFilter(); - filter.addEqualTo("portletId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(SecurityRoleRefImpl.class, filter)); - store.getTransaction().checkpoint(); + Preferences node = Preferences.systemRoot().node(appNodePath); + log.info("Removing Application preference node " + node.absolutePath()); + node.removeNode(); + } + } + catch (BackingStoreException e) + { + throw new RegistryException(e.toString(), e); + } - filter = store.newFilter(); - filter.addEqualTo("parentId", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(PortletDescriptionImpl.class, filter)); - store.getTransaction().checkpoint(); + try + { + store.deletePersistent(app); - filter = store.newFilter(); - filter.addEqualTo("id", new Long(curPortlet.getOID())); - store.deleteAll(store.newQuery(PortletDefinitionImpl.class, filter)); - store.getTransaction().checkpoint(); - } - filter = store.newFilter(); - filter.addEqualTo("id", new Long(app.getId().toString())); - store.deleteAll(store.newQuery(MutablePortletApplication.class, filter)); - store.getTransaction().checkpoint(); } catch (LockFailedException e) { @@ -514,7 +457,7 @@ * @param app * @throws RegistryException */ - public void updatePortletApplication(PortletApplicationDefinition app) throws RegistryException + public void updatePortletApplication( PortletApplicationDefinition app ) throws RegistryException { try { @@ -529,19 +472,7 @@ } } - public PortletDefinitionComposite getStoreableInstance(PortletDefinitionComposite portlet) - { - if (portlet != null) - { - return new StoreablePortletDefinitionDelegate(portlet, getPersistenceStore()); - } - else - { - return null; - } - } - - private Object postLoad(Object obj) + private Object postLoad( Object obj ) { if (obj == null) { @@ -560,4 +491,20 @@ } return obj; } -} + + public void savePortletDefinition( PortletDefinition portlet ) throws RegistryException + { + try + { + PersistenceStore store = getPersistenceStore(); + prepareTransaction(store); + store.lockForWrite(portlet); + store.getTransaction().checkpoint(); + } + catch (LockFailedException e) + { + throw new RegistryException("Unable to lock PortletDefintion for update: " + e.toString(), e); + } + + } +} \ No newline at end of file
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]