Revision eec49400
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java | ||
---|---|---|
18 | 18 |
import java.util.Set; |
19 | 19 |
import java.util.TreeMap; |
20 | 20 |
import java.util.TreeSet; |
21 |
import java.util.UUID; |
|
21 | 22 |
|
22 | 23 |
import org.hibernate.collection.internal.PersistentBag; |
23 | 24 |
import org.hibernate.collection.internal.PersistentList; |
... | ... | |
30 | 31 |
import org.hibernate.proxy.LazyInitializer; |
31 | 32 |
import org.springframework.util.ReflectionUtils; |
32 | 33 |
|
34 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
35 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
33 | 36 |
import eu.etaxonomy.cdm.model.common.PersistentMultiLanguageText; |
34 | 37 |
import eu.etaxonomy.taxeditor.remoting.CdmRemotingException; |
35 | 38 |
|
... | ... | |
168 | 171 |
return false; |
169 | 172 |
} |
170 | 173 |
|
174 |
public static Object remoteLoadPersistentCollectionIfProxy(Object o, UUID ownerUuid, String fieldName) throws ClassNotFoundException { |
|
175 |
if(o != null && o instanceof HibernateProxy) { |
|
176 |
LazyInitializer hli = ((HibernateProxy)o).getHibernateLazyInitializer(); |
|
177 |
if(hli.isUninitialized()) { |
|
178 |
return CdmApplicationState.getCachedCommonService().find((Class<CdmBase>)Class.forName(hli.getEntityName()), |
|
179 |
((Integer)hli.getIdentifier()).intValue()); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
if(o != null && o instanceof PersistentCollection) { |
|
184 |
PersistentCollection pc = ((PersistentCollection)o); |
|
185 |
if(!pc.wasInitialized()) { |
|
186 |
return CdmApplicationState.getCachedCommonService().initializeCollection(ownerUuid, fieldName); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
return o; |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
171 | 196 |
public static void setRoleValueInOwner(Object owner, String role, Object value) { |
172 | 197 |
if(role == null || role.isEmpty()) { |
173 | 198 |
throw new CdmRemotingException("Role cannot be null or an empty string"); |
Also available in: Unified diff
#5010 : Initial commit to fix duplicate entry issue when creating new key node