core/src/main/java/org/sakaiproject/nakamura/lite/content/ContentManagerImpl.java
public void move(String from, String to) throws AccessDeniedException, StorageClientException {
        // to move, get the structure object out and modify, recreating parent
        // objects as necessary.
        long t = System.currentTimeMillis();
        try {
            checkOpen();
            accessControlManager.check(Security.ZONE_CONTENT, from, Permissions.CAN_ANYTHING);
            accessControlManager.check(Security.ZONE_CONTENT, to, Permissions.CAN_READ.combine(Permissions.CAN_WRITE));
            Map<String, Object> fromStructure = Maps.newHashMap(getCached(keySpace, contentColumnFamily, from));
            if (!exists(fromStructure)) {
                throw new StorageClientException("The source content to move from " + from
                        + " does not exist, move operation failed");
            }
            if (exists(fromStructure)) {
                String contentId = (String) fromStructure.get(STRUCTURE_UUID_FIELD);
                Map<String, Object> content = getCached(keySpace, contentColumnFamily, contentId);
                if (content == null || content.size() == 0 && TRUE.equals(content.get(DELETED_FIELD))) {
                    throw new StorageClientException("The source content to move from " + from
                            + " does not exist, move operation failed");
                }
            }
            Map<String, Object> toStructure = getCached(keySpace, contentColumnFamily, to);
            if (exists(toStructure)) {
                String contentId = (String) toStructure.get(STRUCTURE_UUID_FIELD);
                Map<String, Object> content = getCached(keySpace, contentColumnFamily, contentId);
                if (exists(content)) {
                    throw new StorageClientException("The destination content to move to " + to + "  exists, move operation failed");
                }
            }
            String idStore = (String) fromStructure.get(STRUCTURE_UUID_FIELD);

            // move the content to the new location, then delete the old.
            if (!StorageClientUtils.isRoot(to)) {
                // if not a root, modify the new parent location, creating the
                // structured if necessary
                String parent = StorageClientUtils.getParentObjectPath(to);
                Map<String, Object> parentToStructure = getCached(keySpace, contentColumnFamily, parent);
                if (!exists(parentToStructure)) {
                    // create a new parent
                    Content content = new Content(parent, null);
                    update(content);
                }

            }
            // update the content data to reflect the new primary location.
            putCached(keySpace, contentColumnFamily, idStore, ImmutableMap.of(PATH_FIELD, (Object) to), false);

            // insert the new to Structure and remove the from
            fromStructure.put(PATH_FIELD, to);
            putCached(keySpace, contentColumnFamily, to, fromStructure, true);

            // remove the old from.
            putCached(keySpace, contentColumnFamily, from, ImmutableMap.of(DELETED_FIELD, (Object) TRUE), false);
            // move does not add resourceTypes to events.
            eventListener.onDelete(Security.ZONE_CONTENT, from, accessControlManager.getCurrentUserId(), null, null, "op:move");
            eventListener.onUpdate(Security.ZONE_CONTENT, to, accessControlManager.getCurrentUserId(), null, true, null, "op:move");
        } finally {
            statsService.apiCall(ContentManagerImpl.class.getName(), "move", System.currentTimeMillis() - t);
        }

    }
public void move(String from, String to) throws AccessDeniedException, StorageClientException {
        // to move, get the structure object out and modify, recreating parent
        // objects as necessary.
        long t = System.currentTimeMillis();
        try {
            checkOpen();
            accessControlManager.check(Security.ZONE_CONTENT, from, Permissions.CAN_ANYTHING);
            accessControlManager.check(Security.ZONE_CONTENT, to, Permissions.CAN_READ.combine(Permissions.CAN_WRITE));
            Map<String, Object> fromStructure = Maps.newHashMap(getCached(keySpace, contentColumnFamily, from));
            if (!exists(fromStructure)) {
                throw new StorageClientException("The source content to move from " + from
                        + " does not exist, move operation failed");
            }
            if (exists(fromStructure)) {
                String contentId = (String) fromStructure.get(STRUCTURE_UUID_FIELD);
                Map<String, Object> content = getCached(keySpace, contentColumnFamily, contentId);
                if (content == null || content.size() == 0 && TRUE.equals(content.get(DELETED_FIELD))) {
                    throw new StorageClientException("The source content to move from " + from
                            + " does not exist, move operation failed");
                }
            }
            Map<String, Object> toStructure = getCached(keySpace, contentColumnFamily, to);
            if (exists(toStructure)) {
                String contentId = (String) toStructure.get(STRUCTURE_UUID_FIELD);
                Map<String, Object> content = getCached(keySpace, contentColumnFamily, contentId);
                if (exists(content)) {
                    throw new StorageClientException("The destination content to move to " + to + "  exists, move operation failed");
                }
            }
            String idStore = (String) fromStructure.get(STRUCTURE_UUID_FIELD);

            // move the content to the new location, then delete the old.
            if (!StorageClientUtils.isRoot(to)) {
                // if not a root, modify the new parent location, creating the
                // structured if necessary
                String parent = StorageClientUtils.getParentObjectPath(to);
                Map<String, Object> parentToStructure = getCached(keySpace, contentColumnFamily, parent);
                if (!exists(parentToStructure)) {
                    // create a new parent
                    Content content = new Content(parent, null);
                    update(content);
                }

            }
            // update the content data to reflect the new primary location.
            putCached(keySpace, contentColumnFamily, idStore, ImmutableMap.of(PATH_FIELD, (Object) to), false);

            // insert the new to Structure and remove the from
            fromStructure.put(PATH_FIELD, to);
            putCached(keySpace, contentColumnFamily, to, fromStructure, true);

            // remove the old from.
            putCached(keySpace, contentColumnFamily, from, ImmutableMap.of(DELETED_FIELD, (Object) TRUE), false);
            // move does not add resourceTypes to events.
            eventListener.onDelete(Security.ZONE_CONTENT, from, accessControlManager.getCurrentUserId(), null, null, "op:move");
            eventListener.onUpdate(Security.ZONE_CONTENT, to, accessControlManager.getCurrentUserId(), null, true, null, "op:move");
        } finally {
            statsService.apiCall(ContentManagerImpl.class.getName(), "move", System.currentTimeMillis() - t);
        }

    }
public void move ( String from , String to ) throws AccessDeniedException , StorageClientException { // to move, get the structure object out and modify, recreating parent // objects as necessary. long t = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; accessControlManager . check ( Security . ZONE_CONTENT , from , Permissions . CAN_ANYTHING ) ; accessControlManager . check ( Security . ZONE_CONTENT , to , Permissions . CAN_READ . combine ( Permissions . CAN_WRITE ) ) ; Map < String , Object > fromStructure = Maps . newHashMap ( getCached ( keySpace , contentColumnFamily , from ) ) ; if ( ! exists ( fromStructure ) ) { throw new StorageClientException ( "The source content to move from " + from + " does not exist, move operation failed" ) ; } if ( exists ( fromStructure ) ) { String contentId = ( String ) fromStructure . get ( STRUCTURE_UUID_FIELD ) ; Map < String , Object > content = getCached ( keySpace , contentColumnFamily , contentId ) ; if ( content == null || content . size ( ) == 0 && TRUE . equals ( content . get ( DELETED_FIELD ) ) ) { throw new StorageClientException ( "The source content to move from " + from + " does not exist, move operation failed" ) ; } } Map < String , Object > toStructure = getCached ( keySpace , contentColumnFamily , to ) ; if ( exists ( toStructure ) ) { String contentId = ( String ) toStructure . get ( STRUCTURE_UUID_FIELD ) ; Map < String , Object > content = getCached ( keySpace , contentColumnFamily , contentId ) ; if ( exists ( content ) ) { throw new StorageClientException ( "The destination content to move to " + to + "  exists, move operation failed" ) ; } } String idStore = ( String ) fromStructure . get ( STRUCTURE_UUID_FIELD ) ; // move the content to the new location, then delete the old. if ( ! StorageClientUtils . isRoot ( to ) ) { // if not a root, modify the new parent location, creating the // structured if necessary String parent = StorageClientUtils . getParentObjectPath ( to ) ; Map < String , Object > parentToStructure = getCached ( keySpace , contentColumnFamily , parent ) ; if ( ! exists ( parentToStructure ) ) { // create a new parent Content content = new Content ( parent , null ) ; update ( content ) ; } } // update the content data to reflect the new primary location. putCached ( keySpace , contentColumnFamily , idStore , ImmutableMap . of ( PATH_FIELD , ( Object ) to ) , false ) ; // insert the new to Structure and remove the from fromStructure . put ( PATH_FIELD , to ) ; putCached ( keySpace , contentColumnFamily , to , fromStructure , true ) ; // remove the old from. putCached ( keySpace , contentColumnFamily , from , ImmutableMap . of ( DELETED_FIELD , ( Object ) TRUE ) , false ) ; // move does not add resourceTypes to events. eventListener . onDelete ( Security . ZONE_CONTENT , from , accessControlManager . getCurrentUserId ( ) , null , null , "op:move" ) ; eventListener . onUpdate ( Security . ZONE_CONTENT , to , accessControlManager . getCurrentUserId ( ) , null , true , null , "op:move" ) ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "move" , System . currentTimeMillis ( ) - t ) ; } }
TODO: Unit test
TODO : Unit test