1 (function (GCN) {
  2 
  3 	'use strict';
  4 
  5 	/**
  6 	 * @private
  7 	 * @const
  8 	 * @type {number}
  9 	 */
 10 	var TYPE_ID = 10008;
 11 
 12 	/**
 13 	 * @private
 14 	 * @const
 15 	 * @type {object.<string, boolean>} Default file settings.
 16 	 */
 17 	var DEFAULT_SETTINGS = {
 18 		// Load file for updating
 19 		update: true
 20 	};
 21 
 22 	/**
 23 	 * @class
 24 	 * @name FileAPI
 25 	 * @extends ContentObjectAPI
 26 	 * @extends TagContainerAPI
 27 	 * 
 28 	 * @param {number|string}
 29 	 *            id of the file to be loaded
 30 	 * @param {function(ContentObjectAPI))=}
 31 	 *            success Optional success callback that will receive this
 32 	 *            object as its only argument.
 33 	 * @param {function(GCNError):boolean=}
 34 	 *            error Optional custom error handler.
 35 	 * @param {object}
 36 	 *            settings currently there are no additional settings to be used
 37 	 */
 38 	var FileAPI = GCN.defineChainback({
 39 		/** @lends FileAPI */
 40 
 41 		__chainbacktype__: 'FileAPI',
 42 		_extends: [ GCN.ContentObjectAPI, GCN.TagContainerAPI ],
 43 		_type: 'file',
 44 
 45 		/**
 46 		 * Writable properties for the folder object. Currently the following
 47 		 * attributes are writeable: cdate, description, folderId, name.
 48 		 * WARNING: changing the folderId might not work as expected.
 49 		 * 
 50 		 * @type {Array.string}
 51 		 */
 52 		WRITEABLE_PROPS: [ 'cdate',
 53 		                    'description',
 54 		                    'folderId', // @TODO Check if moving is implemented
 55 							            // correctly.
 56 		                    'name' ],
 57 
 58 		/**
 59 		 * <p>
 60 		 * Retrieve the URL of this file's binary contents. You can use this to
 61 		 * download the file from the server or to display an image.
 62 		 * </p>
 63 		 * <p>
 64 		 * <b>WARNING!</b> Never ever store this URL in a page for users to
 65 		 * load an image or to provide a download link. You should always refer
 66 		 * to published files from the backend. Referencing a file directly
 67 		 * using this link will put heavy load on you Gentics Content.Node CMS
 68 		 * Server.
 69 		 * </p>
 70 		 * 
 71 		 * @function
 72 		 * @name binURL
 73 		 * @memberOf FileAPI
 74 		 * @return {string} Source URL of this file.
 75 		 */
 76 		'!binURL': function () {
 77 			return (
 78 				GCN.settings.BACKEND_PATH + '/rest/file/content/load/'
 79 				+ this.id() + '?sid=' + GCN.sid
 80 				+ GCN._getChannelParameter(this, '&')
 81 			);
 82 		},
 83 
 84 		/**
 85 		 * @see ContentObjectAPI.!_loadParams
 86 		 */
 87 		'!_loadParams': function () {
 88 			return jQuery.extend(DEFAULT_SETTINGS, this._settings);
 89 		}
 90 	});
 91 
 92 	/**
 93 	* Creates a new instance of FileAPI. See the {@link FileAPI} constructor for detailed information.
 94 	* 
 95 	* @function
 96 	* @name file
 97 	* @memberOf GCN
 98 	* @see FileAPI
 99 	*/
100 	GCN.file = GCN.exposeAPI(FileAPI);
101 	GCN.FileAPI = FileAPI;
102 
103 }(GCN));
104