core/src/main/java/org/sakaiproject/nakamura/lite/content/ContentManagerImpl.java
public void link(String from, String to) throws AccessDeniedException, StorageClientException {
        // a link places a pointer to the content in the parent of from, but
        // does not delete or modify the structure of to.
        // read from is required and write to.
        long t = System.currentTimeMillis();
        try {
            checkOpen();
            accessControlManager.check(Security.ZONE_CONTENT, to, Permissions.CAN_READ);
            accessControlManager.check(Security.ZONE_CONTENT, from, Permissions.CAN_READ.combine(Permissions.CAN_WRITE));
            Map<String, Object> toStructure = getCached(keySpace, contentColumnFamily, to);
            if (!exists(toStructure)) {
                throw new StorageClientException("The source content to link from " + to + " does not exist, link operation failed");
            }
            Map<String, Object> fromStructure = getCached(keySpace, contentColumnFamily, from);
            if (exists(fromStructure)) {
                throw new StorageClientException("The destination content to link to " + from + "  exists, link operation failed");
            }

            if (StorageClientUtils.isRoot(from)) {
                throw new StorageClientException("The link " + to + "  is a root, not possible to create a soft link");
            }

            // create a new structure object pointing back to the shared
            // location

            Object idStore = toStructure.get(STRUCTURE_UUID_FIELD);
            // if not a root, modify the new parent location, creating the
            // structured if necessary
            String parent = StorageClientUtils.getParentObjectPath(from);
            Map<String, Object> parentToStructure = getCached(keySpace, contentColumnFamily, parent);
            if (!exists(parentToStructure)) {
                // create a new parent
                Content content = new Content(parent, null);
                update(content);
            }

            // create the new object for the path, pointing to the Object
            putCached(keySpace, contentColumnFamily, from, ImmutableMap.of(STRUCTURE_UUID_FIELD, idStore, PATH_FIELD, from,
                    LINKED_PATH_FIELD, to, DELETED_FIELD, new RemoveProperty()), true);
        } finally {
            statsService.apiCall(ContentManagerImpl.class.getName(), "link", System.currentTimeMillis() - t);
        }

    }
public void link(String from, String to) throws AccessDeniedException, StorageClientException {
        // a link places a pointer to the content in the parent of from, but
        // does not delete or modify the structure of to.
        // read from is required and write to.
        long t = System.currentTimeMillis();
        try {
            checkOpen();
            accessControlManager.check(Security.ZONE_CONTENT, to, Permissions.CAN_READ);
            accessControlManager.check(Security.ZONE_CONTENT, from, Permissions.CAN_READ.combine(Permissions.CAN_WRITE));
            Map<String, Object> toStructure = getCached(keySpace, contentColumnFamily, to);
            if (!exists(toStructure)) {
                throw new StorageClientException("The source content to link from " + to + " does not exist, link operation failed");
            }
            Map<String, Object> fromStructure = getCached(keySpace, contentColumnFamily, from);
            if (exists(fromStructure)) {
                throw new StorageClientException("The destination content to link to " + from + "  exists, link operation failed");
            }

            if (StorageClientUtils.isRoot(from)) {
                throw new StorageClientException("The link " + to + "  is a root, not possible to create a soft link");
            }

            // create a new structure object pointing back to the shared
            // location

            Object idStore = toStructure.get(STRUCTURE_UUID_FIELD);
            // if not a root, modify the new parent location, creating the
            // structured if necessary
            String parent = StorageClientUtils.getParentObjectPath(from);
            Map<String, Object> parentToStructure = getCached(keySpace, contentColumnFamily, parent);
            if (!exists(parentToStructure)) {
                // create a new parent
                Content content = new Content(parent, null);
                update(content);
            }

            // create the new object for the path, pointing to the Object
            putCached(keySpace, contentColumnFamily, from, ImmutableMap.of(STRUCTURE_UUID_FIELD, idStore, PATH_FIELD, from,
                    LINKED_PATH_FIELD, to, DELETED_FIELD, new RemoveProperty()), true);
        } finally {
            statsService.apiCall(ContentManagerImpl.class.getName(), "link", System.currentTimeMillis() - t);
        }

    }
public void link ( String from , String to ) throws AccessDeniedException , StorageClientException { // a link places a pointer to the content in the parent of from, but // does not delete or modify the structure of to. // read from is required and write to. long t = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; accessControlManager . check ( Security . ZONE_CONTENT , to , Permissions . CAN_READ ) ; accessControlManager . check ( Security . ZONE_CONTENT , from , Permissions . CAN_READ . combine ( Permissions . CAN_WRITE ) ) ; Map < String , Object > toStructure = getCached ( keySpace , contentColumnFamily , to ) ; if ( ! exists ( toStructure ) ) { throw new StorageClientException ( "The source content to link from " + to + " does not exist, link operation failed" ) ; } Map < String , Object > fromStructure = getCached ( keySpace , contentColumnFamily , from ) ; if ( exists ( fromStructure ) ) { throw new StorageClientException ( "The destination content to link to " + from + "  exists, link operation failed" ) ; } if ( StorageClientUtils . isRoot ( from ) ) { throw new StorageClientException ( "The link " + to + "  is a root, not possible to create a soft link" ) ; } // create a new structure object pointing back to the shared // location Object idStore = toStructure . get ( STRUCTURE_UUID_FIELD ) ; // if not a root, modify the new parent location, creating the // structured if necessary String parent = StorageClientUtils . getParentObjectPath ( from ) ; Map < String , Object > parentToStructure = getCached ( keySpace , contentColumnFamily , parent ) ; if ( ! exists ( parentToStructure ) ) { // create a new parent Content content = new Content ( parent , null ) ; update ( content ) ; } // create the new object for the path, pointing to the Object putCached ( keySpace , contentColumnFamily , from , ImmutableMap . of ( STRUCTURE_UUID_FIELD , idStore , PATH_FIELD , from , LINKED_PATH_FIELD , to , DELETED_FIELD , new RemoveProperty ( ) ) , true ) ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "link" , System . currentTimeMillis ( ) - t ) ; } }
TODO: Unit test
TODO : Unit test