if ( ! isGlobal( iobj.getClass() )) { altered |= managedGroup( locked, privileged, iobj, previousDetails, currentDetails, newDetails); }  if ( ! isGlobal( iobj.getClass() )) { altered |= managedEvent( locked, privileged, iobj, previousDetails, currentDetails, newDetails); }  }  if ( iobj instanceof IMutable ) { Integer version = ((IMutable) iobj).getVersion(); if ( version == null || version.intValue() < 0 );      }  return altered ? newDetails : previousDetails;  }
final Details currentDetails = iobj.getDetails(); Details newDetails = CurrentDetails.createDetails();     if (previousDetails == null) { if (currentDetails != null) { newDetails = null; altered = true; if (log.isDebugEnabled()) { log.debug("Setting details on " + iobj + " to null like original"); } } }    else if (currentDetails == null) { newDetails = new Details(previousDetails); altered = true; if (log.isDebugEnabled()) { log.debug("Setting details on " + iobj + " to copy of original details."); }        } else {  boolean locked = false; boolean privileged = false;  if (previousDetails.getPermissions().isSet(Flag.LOCKED)) locked = true;  if (hasPrivilegedToken(iobj)) privileged = true;    altered |= managedPermissions(locked, privileged, iobj, previousDetails, currentDetails, newDetails);  if (!isGlobal(iobj.getClass())) { altered |= managedOwner(locked, privileged, iobj, previousDetails, currentDetails, newDetails); }  if (!isGlobal(iobj.getClass())) { altered |= managedGroup(locked, privileged, iobj, previousDetails, currentDetails, newDetails); }  if (!isGlobal(iobj.getClass())) { altered |= managedEvent(locked, privileged, iobj, previousDetails, currentDetails, newDetails); }  }  if (iobj instanceof IMutable) { Integer version = ((IMutable) iobj).getVersion(); if (version == null || version.intValue() < 0) ;      }  return altered ? newDetails : previousDetails;  }
    public Details managedDetails( final IObject iobj, final Details previousDetails )    {    	checkReady("managedDetails");    	        if ( iobj.getId() == null)            throw new ValidationException(                    "Id required on all detached instances.");    	// Note: privileged check moved into the if statement below.    	    	// check if the newDetails variable has been reset or if the instance    	// has been changed.    	boolean altered = false;    	    	final            Details currentDetails = iobj.getDetails();    	/* not final! */ Details newDetails = CurrentDetails.createDetails();          	        // This happens if all fields of details are null (which can't happen)        // And is so uninteresting for all of our checks. The object can't be         // locked and nothing can be edited. Just return null.        if ( previousDetails == null )         {            if ( currentDetails != null )            {                newDetails = null;                altered = true;                if ( log.isDebugEnabled() )                {                    log.debug("Setting details on "+                            iobj+" to null like original");                }            }        }        // Also uninteresting. If the users say nothing, then the originals.        // Probably common since users don't worry about this information.        else if ( currentDetails == null )        {        	newDetails = new Details( previousDetails );            altered = true;            if ( log.isDebugEnabled() )            {                log.debug("Setting details on "+                        iobj+" to copy of original details.");            }                    // Now we have to make sure certain things do not happen. The following        // take into account whether or not the entity is privileged (has a token),        // is locked in the database, and who the current user and group are.        } else {                    	boolean locked = false;        	boolean privileged = false;        	        	if ( previousDetails.getPermissions().isSet( Flag.LOCKED ))        		locked = true;        	        	if ( hasPrivilegedToken( iobj ))        		privileged = true;        	        	// isGlobal implies nothing (currently) about permissions        	// see mapping.vm for more.        	altered |= managedPermissions( locked, privileged,        			iobj, previousDetails, currentDetails, newDetails);        	            if ( ! isGlobal( iobj.getClass() )) // implies that owner doesn't matter             {            	altered |= managedOwner( locked, privileged,            			iobj, previousDetails, currentDetails, newDetails);            }            if ( ! isGlobal( iobj.getClass() )) // implies that group doesn't matter            {            	altered |= managedGroup( locked, privileged,            			iobj, previousDetails, currentDetails, newDetails);            }                        if ( ! isGlobal( iobj.getClass() )) // implies that event doesn't matter    		{            	altered |= managedEvent( locked, privileged,            			iobj, previousDetails, currentDetails, newDetails);    		}                    }                if ( iobj instanceof IMutable )        {            Integer version = ((IMutable) iobj).getVersion();            if ( version == null || version.intValue() < 0 );//                throw new ValidationException(//                        "Version must properly be set on managed objects :\n"+//                        obj.toString()//                        );                //TODO        }                return altered ? newDetails : previousDetails;                }