|
1 | | -import {EwsXmlReader} from "../Core/EwsXmlReader"; |
| 1 | +import { Convert } from "../ExtensionMethods"; |
| 2 | +import { EwsLogging } from "../Core/EwsLogging"; |
| 3 | +import { XmlElementNames } from "../Core/XmlElementNames"; |
2 | 4 |
|
| 5 | +/** |
| 6 | + * Represents a sharing location. |
| 7 | + * @sealed |
| 8 | + */ |
3 | 9 | export class DocumentSharingLocation { |
4 | | - ServiceUrl: string; |
5 | | - LocationUrl: string; |
6 | | - DisplayName: string; |
7 | | - SupportedFileExtensions: string[];// System.Collections.Generic.IEnumerable<string>; |
8 | | - ExternalAccessAllowed: boolean; |
9 | | - AnonymousAccessAllowed: boolean; |
10 | | - CanModifyPermissions: boolean; |
11 | | - IsDefault: boolean; |
12 | | - private serviceUrl: string; |
13 | | - private locationUrl: string; |
14 | | - private displayName: string; |
15 | | - private supportedFileExtensions: string[];// System.Collections.Generic.IEnumerable<string>; |
16 | | - private externalAccessAllowed: boolean; |
17 | | - private anonymousAccessAllowed: boolean; |
18 | | - private canModifyPermissions: boolean; |
19 | | - private isDefault: boolean; |
20 | | - //LoadFromXml(reader: EwsXmlReader): DocumentSharingLocation { throw new Error("DocumentSharingLocation.ts - LoadFromXml : Not implemented."); } |
21 | | - static LoadFromJson(obj: any): DocumentSharingLocation { throw new Error("this was skipped at dev time, fix this"); } |
| 10 | + /** |
| 11 | + * The URL of the web service to use to manipulate documents at the sharing location. |
| 12 | + */ |
| 13 | + private serviceUrl: string = null; |
22 | 14 |
|
| 15 | + /** |
| 16 | + * The URL of the sharing location (for viewing the contents in a web browser). |
| 17 | + */ |
| 18 | + private locationUrl: string = null; |
| 19 | + |
| 20 | + /** |
| 21 | + * The display name of the location. |
| 22 | + */ |
| 23 | + private displayName: string = null; |
| 24 | + |
| 25 | + /** |
| 26 | + * The set of file extensions that are allowed at the location. |
| 27 | + */ |
| 28 | + private supportedFileExtensions: string[] = []; |
| 29 | + |
| 30 | + /** |
| 31 | + * Indicates whether external users (outside the enterprise/tenant) can view documents at the location. |
| 32 | + */ |
| 33 | + private externalAccessAllowed: boolean = false; |
| 34 | + |
| 35 | + /** |
| 36 | + * Indicates whether anonymous users can view documents at the location. |
| 37 | + */ |
| 38 | + private anonymousAccessAllowed: boolean = false; |
| 39 | + |
| 40 | + /** |
| 41 | + * Indicates whether the user can modify permissions for documents at the location. |
| 42 | + */ |
| 43 | + private canModifyPermissions: boolean = false; |
| 44 | + |
| 45 | + /** |
| 46 | + * Indicates whether this location is the user's default location. This will generally be their My Site. |
| 47 | + */ |
| 48 | + private isDefault: boolean = false; |
| 49 | + |
| 50 | + // ref: no need to have setter for all properties as all of them are private, can directly be assigned to private variables. |
| 51 | + |
| 52 | + /** |
| 53 | + * Gets the URL of the web service to use to manipulate documents at the sharing location. |
| 54 | + */ |
| 55 | + get ServiceUrl(): string { |
| 56 | + return this.serviceUrl; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Gets the URL of the sharing location (for viewing the contents in a web browser). |
| 61 | + */ |
| 62 | + get LocationUrl(): string { |
| 63 | + return this.locationUrl; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Gets the display name of the location. |
| 68 | + */ |
| 69 | + get DisplayName(): string { |
| 70 | + return this.displayName; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Gets the space-separated list of file extensions that are allowed at the location. |
| 75 | + * @remarks Example: "docx pptx xlsx" |
| 76 | + */ |
| 77 | + get SupportedFileExtensions(): string[] { |
| 78 | + return this.supportedFileExtensions; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Gets a flag indicating whether external users (outside the enterprise/tenant) can view documents at the location. |
| 83 | + */ |
| 84 | + get ExternalAccessAllowed(): boolean { |
| 85 | + return this.externalAccessAllowed; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Gets a flag indicating whether anonymous users can view documents at the location. |
| 90 | + */ |
| 91 | + get AnonymousAccessAllowed(): boolean { |
| 92 | + return this.anonymousAccessAllowed; |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Gets a flag indicating whether the user can modify permissions for documents at the location. |
| 97 | + * @remarks This will be true for the user's "My Site," for example. However, documents at team and project sites will typically be ACLed by the site owner, so the user will not be able to modify permissions. This will most likely by false even if the caller is the owner, to avoid surprises. They should go to SharePoint to modify permissions for team and project sites. |
| 98 | + */ |
| 99 | + get CanModifyPermissions(): boolean { |
| 100 | + return this.canModifyPermissions; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Gets a flag indicating whether this location is the user's default location. This will generally be their My Site. |
| 105 | + */ |
| 106 | + get IsDefault(): boolean { |
| 107 | + return this.isDefault; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Initializes a new instance of the **DocumentSharingLocation** class. |
| 112 | + */ |
| 113 | + private constructor() { |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * @internal Loads DocumentSharingLocation instance. |
| 118 | + * |
| 119 | + * @param {any} jsObject Json Object converted from XML. |
| 120 | + */ |
| 121 | + static LoadFromXmlJsObject(jsObject: any): DocumentSharingLocation { |
| 122 | + EwsLogging.Assert(false, "DocumentSharingLocation.LoadFromXmlJsObject", "Please provide feedback if this is successful or failed.", true); |
| 123 | + const location: DocumentSharingLocation = new DocumentSharingLocation(); |
| 124 | + location.serviceUrl = jsObject[XmlElementNames.ServiceUrl]; |
| 125 | + location.locationUrl = jsObject[XmlElementNames.LocationUrl]; |
| 126 | + location.displayName = jsObject[XmlElementNames.DisplayName]; |
| 127 | + location.supportedFileExtensions = []; |
| 128 | + const supportedFileExtensions = jsObject[XmlElementNames.SupportedFileExtensions]; |
| 129 | + let extensions = supportedFileExtensions[XmlElementNames.FileExtension]; |
| 130 | + if (!Array.isArray(extensions)) { |
| 131 | + extensions = [extensions] |
| 132 | + } |
| 133 | + for (let i = 0; i < extensions.length; i++) { |
| 134 | + location.supportedFileExtensions.push(extensions[i]); |
| 135 | + } |
| 136 | + jsObject[XmlElementNames.SupportedFileExtensions]; |
| 137 | + location.externalAccessAllowed = Convert.toBool(jsObject[XmlElementNames.ExternalAccessAllowed]); |
| 138 | + location.anonymousAccessAllowed = Convert.toBool(jsObject[XmlElementNames.AnonymousAccessAllowed]); |
| 139 | + location.canModifyPermissions = Convert.toBool(jsObject[XmlElementNames.CanModifyPermissions]); |
| 140 | + location.isDefault = Convert.toBool(jsObject[XmlElementNames.IsDefault]); |
| 141 | + return location; |
| 142 | + } |
23 | 143 | } |
0 commit comments