             let escapeUrl = self.document["path"]!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
             return hostUrl + "/api/delivery" + escapeUrl + "/index.html"
         case .URL:
-            return self.document["url"] as! String
+            return self.document["url"] as? String
         default:
-            return ""
+            return nil
         }
     }
     

    @return String.
    */

    public func getUrl () -> String {
        
        switch(self.subtype) {
        case .FILE:

    Get Url to a file variant
    @return String.
    */
    public func getVariantUrl (name: String) -> String? {

        if(CONTENT_TYPES.FILE == self.subtype && hasVariant(name)){
            if let url = getUrl() {
                return url + "?variant=" + name.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
            }
        }
        
        return nil
    }
    
    public func hasVariant(name: String) -> Bool {
        if let variants = self.document["variants"] as? [[String:AnyObject]] {
            for variant in variants {
                if(variant["name"] as! String == name){
                    return true
                }
            }
        }
        return false;
    }

}
