r2741 - in trunk: src/site/rst topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator topia-persistence/src/main/java/org/nuiton/topia/persistence topia-service-security/src/main/java/org/nuiton/topia/taas topia-service-security/src/main/xmi
Author: athimel Date: 2013-07-05 17:29:40 +0200 (Fri, 05 Jul 2013) New Revision: 2741 Url: http://nuiton.org/projects/topia/repository/revisions/2741 Log: fixes #2078 Remove the TopiaContext from TopiaEntityAbstract : If the entity is contextable, methods using TopiaContext are now generated in the entity abstract Modified: trunk/src/site/rst/migrate_to_3.0.rst trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityContextable.java trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java trunk/topia-service-security/src/main/xmi/TopiaSecurity.properties trunk/topia-service-security/src/main/xmi/TopiaSecurity.zargo Modified: trunk/src/site/rst/migrate_to_3.0.rst =================================================================== --- trunk/src/site/rst/migrate_to_3.0.rst 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/src/site/rst/migrate_to_3.0.rst 2013-07-05 15:29:40 UTC (rev 2741) @@ -1,3 +1,26 @@ +.. - +.. * #%L +.. * ToPIA +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2004 - 2013 CodeLutin +.. * %% +.. * This program is free software: you can redistribute it and/or modify +.. * it under the terms of the GNU Lesser General Public License as +.. * published by the Free Software Foundation, either version 3 of the +.. * License, or (at your option) any later version. +.. * +.. * This program is distributed in the hope that it will be useful, +.. * but WITHOUT ANY WARRANTY; without even the implied warranty of +.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.. * GNU General Lesser Public License for more details. +.. * +.. * You should have received a copy of the GNU General Lesser Public +.. * License along with this program. If not, see +.. * <http://www.gnu.org/licenses/lgpl-3.0.html>. +.. * #L% +.. - Migrer depuis ToPIA 2.x vers 3.0 ================================ Property changes on: trunk/src/site/rst/migrate_to_3.0.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -69,7 +69,7 @@ import org.nuiton.topia.event.TopiaTransactionListener; import org.nuiton.topia.event.TopiaTransactionVetoable; import org.nuiton.topia.persistence.TopiaEntity; -import org.nuiton.topia.persistence.TopiaEntityAbstract; +import org.nuiton.topia.persistence.TopiaEntityContextable; import org.nuiton.util.CategorisedListenerSet; import org.nuiton.util.ListenerSet; @@ -598,8 +598,8 @@ private void attachContext(Object entity, TopiaContextImplementor context) { - if (entity instanceof TopiaEntityAbstract) { - TopiaEntityAbstract entityAbstract = (TopiaEntityAbstract) entity; + if (entity instanceof TopiaEntityContextable) { + TopiaEntityContextable entityAbstract = (TopiaEntityContextable) entity; if (entityAbstract.getTopiaContext() == null) { try { entityAbstract.setTopiaContext(context); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -39,6 +39,7 @@ import org.nuiton.eugene.models.object.ObjectModelModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.eugene.models.object.ObjectModelParameter; +import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.persistence.EntityVisitor; @@ -272,6 +273,13 @@ addInterface(interfaceAlreadyDone, outputInterface, interfaze); + + } else if (TopiaGeneratorUtil.isContextable(input)) { + // Even if there is no need to implement TopiaEntity, it might be + // necessary to implement TopiaEntityContextable + addInterface(interfaceAlreadyDone, + outputInterface, + TopiaEntityContextable.class); } } @@ -335,19 +343,59 @@ if (TopiaGeneratorUtil.isContextable(input)) { + addImport(outputAbstract, TopiaContext.class); addImport(outputAbstract, TopiaContextImplementor.class); - ObjectModelOperation op = addOperation(outputAbstract, "update", "void", + // topiaContext attribute + ObjectModelAttribute topiaContextAttribute = addAttribute( + outputAbstract, "topiaContext", TopiaContext.class, null, + ObjectModelJavaModifier.PROTECTED, ObjectModelJavaModifier.TRANSIENT); + setDocumentation(topiaContextAttribute, + "TopiaContext instance associated with the current \n" + + "instance. For internal usage only"); + + ObjectModelOperation op = addOperation(outputAbstract, + "getTopiaContext", TopiaContext.class, ObjectModelJavaModifier.PUBLIC); + setDocumentation(op,"@since 3.0"); + addAnnotation(outputAbstract, op, Override.class.getSimpleName()); + setOperationBody(op, "" +/*{ + return topiaContext; + }*/ + ); + + op = addOperation(outputAbstract, + "setTopiaContext", "void", + ObjectModelJavaModifier.PUBLIC); addException(op, TopiaException.class); + addParameter(op, TopiaContext.class, "context"); + setDocumentation(op, +// "@param context The context to set.\n" + +// "@throws TopiaException if trying to replace a context\n" + + "@since 3.0"); + addAnnotation(outputAbstract, op, Override.class.getSimpleName()); + setOperationBody(op, "" +/*{ + if (topiaContext == null) { + topiaContext = context; +// } else { +// throw new TopiaRuntimeException("TopiaContext replacement is forbidden"); + } + }*/ + ); + + op = addOperation(outputAbstract, "update", "void", + ObjectModelJavaModifier.PUBLIC); + addException(op, TopiaException.class); // setDocumentation(op,"@since 2.5.3"); addAnnotation(outputAbstract, op, Override.class.getSimpleName()); setOperationBody(op, "" /*{ ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=input.getName()%>.class).update(this); -}*/ + }*/ ); - + op = addOperation(outputAbstract, "delete", "void", ObjectModelJavaModifier.PUBLIC); addException(op, TopiaException.class); // setDocumentation(op,"@since 2.5.3"); @@ -355,7 +403,7 @@ setOperationBody(op, "" /*{ ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=input.getName()%>.class).delete(this); -}*/ + }*/ ); } } @@ -1293,69 +1341,77 @@ addException(operation, TopiaException.class); addAnnotation(outputAbstract, operation, Override.class.getSimpleName()); - addImport(outputAbstract, ArrayList.class); - addImport(outputAbstract, List.class); + StringBuilder body; + if (!TopiaGeneratorUtil.isContextable(input)) { + body = new StringBuilder("" +/*{ + throw new UnsupportedOperationException("Since ToPIA 3.0, 'getComposite' is only available for contextable entities"); + }*/ + ); + } else { + addImport(outputAbstract, ArrayList.class); + addImport(outputAbstract, List.class); - StringBuilder body = new StringBuilder("" + body = new StringBuilder("" /*{ List<TopiaEntity> tmp = new ArrayList<TopiaEntity>(); // pour tous les attributs rechecher les composites et les class d'asso // on les ajoute dans tmp }*/ - ); - for (ObjectModelAttribute attr : input.getAttributes()) { + ); + for (ObjectModelAttribute attr : input.getAttributes()) { - if (attr.referenceClassifier() && - TopiaGeneratorUtil.isEntity(attr.getClassifier())) { + if (attr.referenceClassifier() && + TopiaGeneratorUtil.isEntity(attr.getClassifier())) { - if (attr.isComposite()) { - String attrName = attr.getName(); - String getterName = getJavaBeanMethodName("get", attrName); - if (TopiaGeneratorUtil.isNMultiplicity(attr)) { - body.append("" + if (attr.isComposite()) { + String attrName = attr.getName(); + String getterName = getJavaBeanMethodName("get", attrName); + if (TopiaGeneratorUtil.isNMultiplicity(attr)) { + body.append("" /*{ if (<%=getterName%>() != null) { tmp.addAll(<%=getterName%>()); } }*/ - ); - } else { - body.append("" + ); + } else { + body.append("" /*{ tmp.add(<%=getterName%>()); }*/ - ); - } - } else if (attr.hasAssociationClass()) { - String assocAttrName = TopiaGeneratorUtil.getAssocAttrName( - attr); - String assocClassFQN = TopiaGeneratorUtil.getSimpleName( - attr.getAssociationClass().getQualifiedName()); - String ref = "this." + TopiaGeneratorUtil.toLowerCaseFirstLetter( - assocAttrName); - if (!TopiaGeneratorUtil.isNMultiplicity(attr)) { - body.append("" + ); + } + } else if (attr.hasAssociationClass()) { + String assocAttrName = TopiaGeneratorUtil.getAssocAttrName( + attr); + String assocClassFQN = TopiaGeneratorUtil.getSimpleName( + attr.getAssociationClass().getQualifiedName()); + String ref = "this." + TopiaGeneratorUtil.toLowerCaseFirstLetter( + assocAttrName); + if (!TopiaGeneratorUtil.isNMultiplicity(attr)) { + body.append("" /*{ if (<%=ref%> != null) { tmp.add(<%=ref%>); } }*/ - ); - } else { - ObjectModelAttribute reverse = attr.getReverseAttribute(); - String reverseAttrName = reverse.getName(); - // On utilise pas l'attribut car il est potentiellement - // pas a jour, car pour les asso avec cardinalité - // personne ne fait de add. Ce qui est normal, mais - // pour pouvoir faire tout de meme des delete en cascade - // sur les asso, le champs est dans le mapping - // hibernate et donc il le faut aussi dans la classe - // sinon hibernate rale lorsqu'il charge l'objet -// if (<%=ref%> != null) { -// tmp.addAll(<%=ref%>); -// } + ); + } else { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + String reverseAttrName = reverse.getName(); + // On utilise pas l'attribut car il est potentiellement + // pas a jour, car pour les asso avec cardinalité + // personne ne fait de add. Ce qui est normal, mais + // pour pouvoir faire tout de meme des delete en cascade + // sur les asso, le champs est dans le mapping + // hibernate et donc il le faut aussi dans la classe + // sinon hibernate rale lorsqu'il charge l'objet + // if (<%=ref%> != null) { + // tmp.addAll(<%=ref%>); + // } - addImport(outputAbstract, TopiaContextImplementor.class); - body.append("" + addImport(outputAbstract, TopiaContextImplementor.class); + body.append("" /*{ { org.nuiton.topia.persistence.TopiaDAO<<%=assocClassFQN%>> dao = ((TopiaContextImplementor) getTopiaContext()).getDAO(<%=assocClassFQN%>.class); @@ -1365,12 +1421,12 @@ } } }*/ - ); + ); + } } } } - } - body.append("" + body.append("" /*{ // on refait un tour sur chaque entity de tmp pour recuperer leur // composite @@ -1383,7 +1439,8 @@ } return result; }*/ - ); + ); + } setOperationBody(operation, body.length() == 0 ? " " : body.toString()); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -273,10 +273,13 @@ try { // first set topiaId String topiaId = TopiaId.create(entityClass); - TopiaEntityAbstract entityAbstract = (TopiaEntityAbstract) entity; - entityAbstract.setTopiaId(topiaId); - entityAbstract.setTopiaContext(getContext()); + entity.setTopiaId(topiaId); + if (entity instanceof TopiaEntityContextable) { + TopiaEntityContextable contextable = (TopiaEntityContextable)entity; + contextable.setTopiaContext(getContext()); + } + // save entity getSession().save(entity); getContext().getFiresSupport().warnOnUpdateEntity(entity); @@ -326,9 +329,12 @@ // etre des TopiaEntity if (result instanceof TopiaEntity) { String topiaId = TopiaId.create(entityClass); - TopiaEntityAbstract entity = (TopiaEntityAbstract) result; - entity.setTopiaId(topiaId); - entity.setTopiaContext(getContext()); + result.setTopiaId(topiaId); + + if (result instanceof TopiaEntityContextable) { + TopiaEntityContextable contextable = (TopiaEntityContextable)result; + contextable.setTopiaContext(getContext()); + } } try { for (Map.Entry<String, Object> e : properties.entrySet()) { Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -87,7 +87,7 @@ public E create(Object... properties) throws TopiaException { Map<String, Object> map = new HashMap<String, Object>(); Object propertyName = null; - Object value = null; + Object value; try { for (int i = 0; i < properties.length; ) { propertyName = properties[i++]; @@ -441,9 +441,12 @@ // etre des TopiaEntity if (result instanceof TopiaEntity) { String topiaId = TopiaId.create(entityClass); - TopiaEntityAbstract entity = (TopiaEntityAbstract) result; - entity.setTopiaId(topiaId); - entity.setTopiaContext(getContext()); + result.setTopiaId(topiaId); + + if (result instanceof TopiaEntityContextable) { + TopiaEntityContextable contextable = (TopiaEntityContextable)result; + contextable.setTopiaContext(getContext()); + } } try { for (Map.Entry<String, Object> e : properties.entrySet()) { Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -25,10 +25,6 @@ package org.nuiton.topia.persistence; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.framework.TopiaContextImplementor; - import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.beans.VetoableChangeListener; @@ -36,6 +32,11 @@ import java.util.Date; import java.util.List; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.framework.TopiaFiresSupport; + /** * Classe de base de toutes les entités, cela permet de concentrer le code * technique dans cette classe. L'identifiant peut-etre n'importe quoi Aucune @@ -47,7 +48,6 @@ */ public abstract class TopiaEntityAbstract implements TopiaEntity { - /** serialVersionUID. */ private static final long serialVersionUID = -7458577454878852241L; protected String topiaId; @@ -56,7 +56,7 @@ protected Date topiaCreateDate = new Date(); - transient protected TopiaContext topiaContext; + transient protected TopiaFiresSupport fireSupport; transient protected VetoableChangeSupport readVetoables; @@ -68,7 +68,7 @@ /** * Initialize {@link #readVetoables} at first use or after deserialisation. - * + * * @return readVetoables */ protected VetoableChangeSupport getReadVetoableChangeSupport() { @@ -80,7 +80,7 @@ /** * Initialize {@link #readListeners} at first use or after deserialisation. - * + * * @return readListeners */ protected PropertyChangeSupport getReadPropertyChangeSupport() { @@ -92,7 +92,7 @@ /** * Initialize {@link #writeVetoables} at first use or after deserialisation. - * + * * @return writeVetoables */ protected VetoableChangeSupport getWriteVetoableChangeSupport() { @@ -104,7 +104,7 @@ /** * Initialize {@link #writeListeners} at first use or after deserialisation. - * + * * @return writeListeners */ protected PropertyChangeSupport getWritePropertyChangeSupport() { @@ -113,7 +113,7 @@ } return writeListeners; } - + @Override public String getTopiaId() { return topiaId; @@ -144,22 +144,6 @@ this.topiaCreateDate = topiaCreateDate; } - public TopiaContext getTopiaContext() { - return topiaContext; - } - - /** - * @param context The context to set. - * @throws TopiaException if any pb ? - */ - public void setTopiaContext(TopiaContext context) throws TopiaException { - if (topiaContext == null) { - topiaContext = context; - } else { - throw new TopiaException("Remplacement du contexte interdit"); - } - } - @Override public List<TopiaEntity> getComposite() throws TopiaException { throw new UnsupportedOperationException(); @@ -206,60 +190,68 @@ return result; } + protected TopiaFiresSupport getFireSupportOrNull() { + if (fireSupport == null) { + if (this instanceof TopiaEntityContextable) { + TopiaEntityContextable contextable = (TopiaEntityContextable) this; + TopiaContext context = contextable.getTopiaContext(); + if (context instanceof TopiaContextImplementor) { + TopiaContextImplementor contextImpl = (TopiaContextImplementor) context; + fireSupport = contextImpl.getFiresSupport(); + } + } + } + return fireSupport; + } + protected void fireOnPreRead(String propertyName, Object value) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPreRead(getReadVetoableChangeSupport(), + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPreRead(getReadVetoableChangeSupport(), this, propertyName, value); } } protected void fireOnPostRead(String propertyName, Object value) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPostRead(getReadPropertyChangeSupport(), + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPostRead(getReadPropertyChangeSupport(), this, propertyName, value); } } protected void fireOnPostRead(String propertyName, int index, Object value) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPostRead(getReadPropertyChangeSupport(), + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPostRead(getReadPropertyChangeSupport(), this, propertyName, index, value); } } protected void fireOnPreWrite(String propertyName, Object oldValue, Object newValue) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPreWrite(getWriteVetoableChangeSupport(), + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPreWrite(getWriteVetoableChangeSupport(), this, propertyName, oldValue, newValue); } } protected void fireOnPostWrite(String propertyName, Object oldValue, Object newValue) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPostWrite( + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPostWrite( getWritePropertyChangeSupport(), this, propertyName, oldValue, newValue); } } protected void fireOnPostWrite(String propertyName, int index, Object oldValue, Object newValue) { - TopiaContextImplementor contextImplementor = - (TopiaContextImplementor) getTopiaContext(); - if (contextImplementor != null) { - contextImplementor.getFiresSupport().fireOnPostWrite( + TopiaFiresSupport firesSupport = getFireSupportOrNull(); + if (firesSupport != null) { + firesSupport.fireOnPostWrite( getWritePropertyChangeSupport(), this, propertyName, index, oldValue, newValue); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityContextable.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityContextable.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityContextable.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -31,20 +31,24 @@ /** * {@link TopiaEntity} with {@link TopiaContext} support (injected by * {@link TopiaContext} into entities). - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public interface TopiaEntityContextable extends TopiaEntity { - - String TOPIA_CONTEXT = "topiaContext"; + String PROPERTY_TOPIA_CONTEXT = "topiaContext"; + + /** @deprecated since 3.0, will be removed in 3.1, use {@link TopiaEntityContextable#PROPERTY_TOPIA_CONTEXT} instead */ + @Deprecated + String TOPIA_CONTEXT = PROPERTY_TOPIA_CONTEXT; + /** * Set topia context. - * + * * @param topiaContext topia context * @throws TopiaException if current topia entity context is not null */ @@ -52,22 +56,19 @@ /** * Get topia context. - * + * * @return topia context */ TopiaContext getTopiaContext(); - + /** * Update entity in persistence context. - * - * @throws TopiaException */ - void update() throws TopiaException; - + void update(); + /** * Delete entity in persistence context. - * - * @throws TopiaException */ - void delete() throws TopiaException; + void delete(); + } Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java 2013-07-05 15:29:40 UTC (rev 2741) @@ -50,6 +50,7 @@ import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaEntityAbstract; +import org.nuiton.topia.persistence.TopiaEntityContextable; import org.nuiton.topia.persistence.TopiaId; import org.nuiton.topia.taas.entities.TaasAuthorizationImpl; import org.nuiton.topia.taas.entities.TaasPrincipalImpl; @@ -75,6 +76,8 @@ import java.util.Properties; import java.util.Set; +import com.google.common.collect.Lists; + import static org.nuiton.topia.taas.TaasUtil.getPrincipalNames; /** @@ -455,13 +458,17 @@ } List<Permission> permissions; - try { - TopiaContextImplementor transaction = (TopiaContextImplementor) - ((TopiaEntityAbstract)entity).getTopiaContext(); - TopiaDAO<?> dao = transaction.getDAO(klass); - permissions = dao.getRequestPermission(topiaId, actions); - } catch (TopiaException e) { - throw new SecurityException("Error in getRequestPermission for " + klass.getName(), e); + if (entity instanceof TopiaEntityContextable) { + try { + TopiaContext topiaContext = ((TopiaEntityContextable)entity).getTopiaContext(); + TopiaContextImplementor transaction = (TopiaContextImplementor)topiaContext; + TopiaDAO<?> dao = transaction.getDAO(klass); + permissions = dao.getRequestPermission(topiaId, actions); + } catch (TopiaException e) { + throw new SecurityException("Error in getRequestPermission for " + klass.getName(), e); + } + } else { + permissions = Lists.newArrayList(); } return permissions; } Modified: trunk/topia-service-security/src/main/xmi/TopiaSecurity.properties =================================================================== --- trunk/topia-service-security/src/main/xmi/TopiaSecurity.properties 2013-07-05 15:01:09 UTC (rev 2740) +++ trunk/topia-service-security/src/main/xmi/TopiaSecurity.properties 2013-07-05 15:29:40 UTC (rev 2741) @@ -26,4 +26,6 @@ model.tagvalue.java.util.Set=serializable org.nuiton.topia.taas.entities.TaasUser.attribute.principals.tagvalue.lazy=false -doNotGenerateBooleanGetMethods=true \ No newline at end of file +doNotGenerateBooleanGetMethods=true + +org.nuiton.topia.security.entities.authorization.TopiaAssociationAuthorization.class.tagvalue.contextable=true Modified: trunk/topia-service-security/src/main/xmi/TopiaSecurity.zargo =================================================================== (Binary files differ)
participants (1)
-
athimel@users.nuiton.org