Author: chris.laprun(a)jboss.com
Date: 2011-10-17 13:34:08 -0400 (Mon, 17 Oct 2011)
New Revision: 7751
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java
Log:
- Added RegistrationMapping.getParent method and use it instead of hacking the JCR path to
retrieve the parent Consumer.
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java 2011-10-17
17:16:10 UTC (rev 7750)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java 2011-10-17
17:34:08 UTC (rev 7751)
@@ -423,25 +423,8 @@
}
else
{
- // extract parent consumer and get the registration from it
- final String path = mapping.getPath();
- final String[] elements = path.split("/");
- final String consumerId = elements[elements.length - 2]; // consumer id is
previous before last
-
- final Consumer consumer = getModel(consumerId, Consumer.class,
ConsumerMapping.class, session);
-
- if (consumer != null)
- {
- for (Registration registration : consumer.getRegistrations())
- {
- if (registration.getPersistentKey().equals(registrationId))
- {
- return registration;
- }
- }
- }
-
- return null;
+ final ConsumerMapping parent = mapping.getParent();
+ return parent.toModel(null, this).getRegistration(registrationId);
}
}
catch (Exception e)
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java 2011-10-17
17:16:10 UTC (rev 7750)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java 2011-10-17
17:34:08 UTC (rev 7751)
@@ -25,6 +25,7 @@
import org.chromattic.api.annotations.Create;
import org.chromattic.api.annotations.Id;
+import org.chromattic.api.annotations.ManyToOne;
import org.chromattic.api.annotations.MappedBy;
import org.chromattic.api.annotations.OneToMany;
import org.chromattic.api.annotations.OneToOne;
@@ -90,6 +91,9 @@
@Path
public abstract String getPath();
+ @ManyToOne
+ public abstract ConsumerMapping getParent();
+
/**
* At this point, this RegistrationMapping should already have been added to its
parent
*
Show replies by date