Buggy code:
@ Service public class CollectionServiceImpl extends ScollectionServiceImpl implements CollectionService { @ Autowired private CollectionRepository collectionRepository ; @ Autowired private MailHandler mailHandler ; @ Autowired private CollectionEventLog collectionEventLog ; @ Autowired private TaxonomyRespository taxonomyRespository ; @ Autowired private StorageRepository storageRepository ; @ Autowired private UserService userService ; @ Autowired private RedisService redisService ; @ Autowired private CollaboratorRepository collaboratorRepository ; @ Autowired private PartyService partyService ; private static final Logger LOGGER = LoggerFactory . getLogger ( CollectionServiceImpl . class ) ; @ Override public ActionResponseDTO < CollectionItem > createQuestionWithCollectionItem ( String collectionId , String data , User user , String mediaFileName , String sourceReference ) throws Exception { } private ActionResponseDTO < CollectionItem > updateQuestionWithCollectionItem ( CollectionItem collectionItem , String data , List < Integer > deleteAssets , User user , String mediaFileName ) throws Exception { } @ Override public ActionResponseDTO < CollectionItem > updateQuestionWithCollectionItem ( String collectionItemId , String data , List < Integer > deleteAssets , User user , String mediaFileName ) throws Exception { } @ Override public ActionResponseDTO < CollectionItem > updateQuestionWithCollectionItem ( String collectionId , String resourceId , String data , List < Integer > deleteAssets , User user , String mediaFileName ) throws Exception { } @ Override public void deleteQuestionWithCollectionItem ( String collectionId , String resourceId ) { } @ Override public ActionResponseDTO < CollectionItem > moveCollectionToFolder ( String sourceId , String targetId , User user ) throws Exception { ActionResponseDTO < CollectionItem > responseDTO = null ; Collection source = collectionRepository . getCollectionByGooruOid ( sourceId , null ) ; if ( source == null ) { throw new org . ednovo . gooru . core . exception . NotFoundException ( generateErrorMessage ( GL0056 , _COLLECTION ) ) ; } CollectionItem collectionItem = new CollectionItem ( ) ; collectionItem . setCollection ( source ) ; CollectionItem sourceCollectionItem = this . getCollectionRepository ( ) . findCollectionItemByGooruOid ( sourceId , user . getPartyUid ( ) , CLASSPAGE ) ; if ( ( sourceCollectionItem != null ) && ( ( sourceCollectionItem . getItemType ( ) ) != null ) ) { collectionItem . setItemType ( sourceCollectionItem . getItemType ( ) ) ; } collectionItem . setPlannedEndDate ( sourceCollectionItem . getPlannedEndDate ( ) ) ; collectionItem . setEstimatedTime ( sourceCollectionItem . getEstimatedTime ( ) ) ; collectionItem . setAssignmentCompleted ( sourceCollectionItem . getAssignmentCompleted ( ) ) ; if ( ! ( user . getPartyUid ( ) . equalsIgnoreCase ( collectionItem . getCollection ( ) . getUser ( ) . getPartyUid ( ) ) ) ) { UserContentAssoc userContentAssocs = this . getCollaboratorRepository ( ) . findCollaboratorById ( sourceId , user . getPartyUid ( ) ) ; if ( userContentAssocs != null ) { collectionItem . setItemType ( COLLABORATOR ) ; } } String collectionGooruOid = null ; if ( sourceCollectionItem != null ) { collectionGooruOid = sourceCollectionItem . getCollection ( ) . getGooruOid ( ) ; <START_BUG> deleteCollectionItem ( sourceCollectionItem . getCollectionItemId ( ) , user ) ; <END_BUG> } if ( targetId != null ) { responseDTO = this . createCollectionItem ( sourceId , targetId , collectionItem , user , FOLDER . getCollectionType ( ) , false ) ; } else { responseDTO = this . createCollectionItem ( sourceId , null , collectionItem , user , SHElf . getCollectionType ( ) , false ) ; } if ( collectionGooruOid != null ) { updateFolderSharing ( collectionGooruOid ) ; List < String > parenFolders = this . getParentCollection ( collectionGooruOid , user . getPartyUid ( ) , false ) ; for ( String folderGooruOid : parenFolders ) { updateFolderSharing ( folderGooruOid ) ; } } getAsyncExecutor ( ) . deleteFromCache ( ( ( ( V2_ORGANIZE_DATA ) + ( collectionItem . getCollection ( ) . getUser ( ) . getPartyUid ( ) ) ) + "*" ) ) ; getAsyncExecutor ( ) . deleteFromCache ( ( ( ( V2_ORGANIZE_DATA ) + ( user . getPartyUid ( ) ) ) + "*" ) ) ; try { this . getCollectionEventLog ( ) . getEventLogs ( responseDTO . getModel ( ) , true , user , responseDTO . getModel ( ) . getCollection ( ) . getCollectionType ( ) , sourceCollectionItem ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return responseDTO ; } @ Override public ActionResponseDTO < CollectionItem > createQuestionWithCollectionItem ( String collectionId , AssessmentQuestion assessmentQuestion , User user , String mediaFileName ) throws Exception { } @ Override public List < CollectionItem > createCollectionItems ( List < String > collectionsIds , String resourceId , User user ) throws Exception { } @ Override public List < Map < String , Object > > getMyShelf ( String gooruUid , Integer limit , Integer offset , String sharing , String collectionType , Integer itemLimit , boolean fetchChildItem , String topLevelCollectionType , String orderBy ) { } public List < Map < String , Object > > getFolderItem ( String gooruOid , String sharing , String type , String collectionType , Integer itemLimit , boolean fetchChildItem , String orderBy ) { } @ Override public List < Map < String , Object > > getFolderItems ( String gooruOid , Integer limit , Integer offset , String sharing , String collectionType , String orderBy , Integer itemLimit , boolean fetchChildItem , String sortOrder ) { } @ Override public Map < String , Object > getFolderList ( Integer limit , Integer offset , String gooruOid , String title , String username ) { } @ Override public SearchResults < Code > getCollectionStandards ( Integer codeId , String query , Integer limit , Integer offset , User user ) { } private Errors validateUpdateCollectionItem ( CollectionItem collectionItem ) throws Exception { } @ Override public List < CollectionItem > assignCollection ( String classpageId , String collectionId , User user , String direction , String planedEndDate , Boolean isRequired , String minimumScore , String estimatedTime , Boolean showAnswerByQuestions , Boolean showAnswerEnd , Boolean showHints ) throws Exception { }

Fix:
deleteCollectionItem ( sourceCollectionItem . getCollectionItemId ( ) , user , true ) ;