Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-14003

SOLR4 duplicating results when changing permissions

    Details

      Description

      When changing the permissions during the property editing Solr4 duplicates the indexes.
      Attached an AMP and its source code, with a Java Behaviour resetting the node permission on a property update

      org.alfresco.demoamp.BooleanPropertyChangeBehaviour
      	@Override
      	public void onUpdateProperties(NodeRef nodeRef,Map<QName, Serializable> before, Map<QName, Serializable> after) {
      
      		logger.debug("BooleanPropertyChangeBehaviour.onUpdateProperties called");
      
      		if(nodeService.hasAspect(nodeRef, QName.createQName("my.new.model","customAspect"))){
      
      			Boolean beforeVal = (Boolean)before.get(myBooleanProperty);
      			Boolean afterVal = (Boolean)after.get(myBooleanProperty);
      			logger.debug("beforeVal: "+beforeVal);
      			logger.debug("afterVal: "+afterVal);
      
      			if (!EqualsHelper.nullSafeEquals(beforeVal, afterVal)){
      				logger.debug("Setting Permissions");
      				AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
      				permissionService.setInheritParentPermissions(nodeRef, false);
      				permissionService.deletePermissions(nodeRef);
      				permissionService.setPermission(nodeRef, "test_user", PermissionService.CONSUMER, true);
      			}
      		}
      	}
      

      [STEPS TO REPRODUCE]
      1. Install Alfresco 5.0.1.1 with Solr 4
      2. Apply the attached repo AMP
      3. Add in your share-config-custom.xml:

          <config evaluator="aspect" condition="my:customAspect">
           	<forms>
          	  	<form>
          	     	<field-visibility>
                      	<show id="my:boolean" />
               		</field-visibility>
           		</form>
         		</forms>
      	</config>	
      
        <config evaluator="string-compare" condition="DocumentLibrary" >
            <aspects>
               <visible>
                  <aspect name="cm:generalclassifiable" />
                  <aspect name="cm:complianceable" />
                  <aspect name="cm:dublincore" />
                  <aspect name="cm:effectivity" />
                  <aspect name="cm:summarizable" />
                  <aspect name="cm:versionable" />
                  <aspect name="cm:templatable" />
                  <aspect name="cm:emailed" />
                  <aspect name="emailserver:aliasable" />
                  <aspect name="cm:taggable" />
                  <aspect name="app:inlineeditable" />
                  <aspect name="gd:googleEditable" />
                  <aspect name="cm:geographic" />
                  <aspect name="exif:exif" />
                  <aspect name="audio:audio" />
                  <aspect name="cm:indexControl" />
                  <aspect name="dp:restrictable" />
                  <aspect name="my:customAspect" />
               </visible>
            </aspects>
         </config>
      

      3. Start Alfresco
      4. Log into Share with admin user
      5. Create a user called "test_user"
      6. Create a file in the Document Library called "permissiontest"
      7. Apply the "my:customAspect" to the previously created node
      8. Edit properties and change the value of the property "my:boolean"
      9. Save
      10. Repeat steps 8 & 9 a couple of time
      11. Go to the Admin Tool page -> Node Browser
      12. Perform the following searches:
      +@cm\:name:"permissiontest"
      +@cm\:name:"permissiontest" +@my\:boolean:true
      +@cm\:name:"permissiontest" +@my\:boolean:value

      [Expected behaviour]
      Searches should return 1 or 0 documents

      [Observed behaviour]
      Searches return multiple results, always the same node

      [Notes]

      • It doesn't seem to be reproducible with Solr1 and Alfresco5.0.1
      • Workaround:
        Removing all permissions one by one
        Set<AccessPermission> perms = permissionService.getAllSetPermissions(nodeRef);
        for (AccessPermission perm : perms) { permissionService.deletePermission(nodeRef, perm.getAuthority(), perm.getPermission()); }

        instead of
        permissionService.deletePermissions(nodeRef);
        Does NOT cause the issue

        Attachments

        1. alfresco.log
          45 kB
        2. custom aspect.JPG
          custom aspect.JPG
          47 kB
        3. properties .JPG
          properties .JPG
          42 kB
        4. repo-amp.amp
          11 kB
        5. repo-amp.zip
          18 kB

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  closedbugs Closed Bugs
                  Reporter:
                  mmancuso Marco Mancuso [X] (Inactive)
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 1 day
                    1d

                      Structure Helper Panel