_FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs
get: function () { return XmlElementNames_1.XmlElementNames.Folder; },
enumerable: true,
configurable: true
});
Folder.Bind = function (service, idOrName, propertySet) {
if (propertySet === void 0) { propertySet = PropertySet_1.PropertySet.FirstClassProperties; }
if (idOrName instanceof FolderId_1.FolderId) {
return service.BindToFolder(idOrName, propertySet);
}
else if (typeof idOrName === 'number') {
return service.BindToFolder(new FolderId_1.FolderId(idOrName), propertySet);
}
EwsLogging_1.EwsLogging.Assert(false, "Folder.Bind", "unknown paramete type");
throw new Error("unknow parameter type. this should not be reached");
};
Folder.prototype.Copy = function (destinationFolderIdOrName) {
this.ThrowIfThisIsNew();
//EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");
if (typeof destinationFolderIdOrName === 'undefined') {
EwsLogging_1.EwsLogging.Assert(false, "Folder.Copy", "unknown paramete type");
throw new Error("unknow parameter type. this should not be reached");
}
var folderId = destinationFolderIdOrName;
if (typeof destinationFolderIdOrName === 'number')
folderId = new FolderId_1.FolderId(destinationFolderIdOrName);
return this.Service.CopyFolder(this.Id, folderId);
};
Folder.prototype.Delete = function (deleteMode) { return this.InternalDelete(deleteMode, null, null); };
Folder.prototype.Empty = function (deleteMode, deleteSubFolders) {
this.ThrowIfThisIsNew();
return this.Service.EmptyFolder(this.Id, deleteMode, deleteSubFolders);
};
Folder.prototype.FindFolders = function (viewOrSearchFilter, view) {
this.ThrowIfThisIsNew();
//todo: better argument check with ewsutilities
var argsLength = arguments.length;
if (argsLength < 1 && argsLength > 2) {
throw new Error("invalid arguments, check documentation and try again.");
}
if (viewOrSearchFilter instanceof FolderView_1.FolderView) {
return this.Service.FindFolders(this.Id, view);
}
else if (viewOrSearchFilter instanceof SearchFilter_1.SearchFilter) {
if (typeof view === 'undefined' || !(view instanceof FolderView_1.FolderView)) {
throw new Error("Folder.ts - FindFolders - incorrect uses of parameters at 2nd position, must be FolderView");
}
return this.Service.FindFolders(this.Id, viewOrSearchFilter, view);
}
else {
throw new Error("Folder.ts - FindFolders - incorrect uses of parameters at 1st position, must be FolderView or SearchFilter");
}
};
Folder.prototype.FindItems = function (viewQueryStringOrSearchFilter, viewOrGroupBy, groupBy) {
var argsLength = arguments.length;
if (argsLength < 1 && argsLength > 3) {
throw new Error("invalid arguments, check documentation and try again.");
}
//todo: better argument check with ewsutilities
//EwsUtilities.ValidateParam(groupBy, "groupBy");
//EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter");
//EwsUtilities.ValidateParamAllowNull(queryString, "queryString");
//position 1 - viewQueryStringOrSearchFilter
var queryString = null;
var searchFilter = null;
var view = null;
if (typeof viewQueryStringOrSearchFilter === 'string') {
queryString = viewQueryStringOrSearchFilter;
}
else if (viewQueryStringOrSearchFilter instanceof SearchFilter_1.SearchFilter) {
searchFilter = viewQueryStringOrSearchFilter;
}
else if (viewQueryStringOrSearchFilter instanceof ViewBase_1.ViewBase) {
view = viewQueryStringOrSearchFilter;
}
else {
throw new Error("Folder.ts - FindItems - incorrect uses of parameters at 1st position, must be string, Itemview or SearchFilter");
}
var groupResultBy = null;
var isGroupped = false; // to resturn GroupedFindItemsResults<Item>
//position 2 - viewOrGroupBy
if (argsLength >= 3) {
if (viewOrGroupBy instanceof Grouping_1.Grouping) {
if (!(viewQueryStringOrSearchFilter instanceof ItemView_1.ItemView)) {
throw new Error("Folder.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 1nd position, it must be Itemview when using Grouping at 2nd place");
}
groupResultBy = viewOrGroupBy;
isGroupped = true;
}
else if (viewOrGroupBy instanceof ItemView_1.ItemView) {
view = viewOrGroupBy;
}
else {
throw new Error("ExchangeService.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 2nd position, must be Itemsview or Grouping");
}
}
//position 3 - groupBy
if (argsLength === 3) {
if (!(viewOrGroupBy instanceof ItemView_1.ItemView)) {
throw new Error("Folder.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 1nd position, it must be Itemview when using Grouping at 3rd place");
}
groupResultBy = groupBy;
isGroupped = true;
}
return this.InternalFindItems(searchFilter || queryString, view, groupResultBy
groupBy
.then(function (res) {
if (isGroupped) {
return res.__thisIndexer(0).GroupedFindResults;
}
return res.__thisIndexer(0).Results;
});
};
Folder.prototype.GetXmlElementName = function () { return XmlElementNames_1.XmlElementNames.Folder; };
Folder.prototype.GetChangeXmlElementName = function () { return XmlElementNames_1.XmlElementNames.FolderChange; };
Folder.prototype.GetDeleteFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.DeleteFolderField; };
Folder.prototype.GetExtendedProperties = function () { return this.ExtendedProperties; };
Folder.prototype.GetIdPropertyDefinition = function () { return FolderSchema_1.FolderSchema.Id; };
Folder.prototype.GetMinimumRequiredServerVersion = function () { return ExchangeVersion_1.ExchangeVersion.Exchange2007_SP1; };
Folder.prototype.GetSchema = function () { return FolderSchema_1.FolderSchema.Instance; };
Folder.prototype.GetSetFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.SetFolderField; };
Folder.prototype.InternalDelete = function (deleteMode, sendCancellationsMode, affectedTaskOccurrences) {
this.ThrowIfThisIsNew();
return this.Service.DeleteFolder(this.Id, deleteMode);
};
Folder.prototype.InternalFindItems = function (searchFilterOrQueryString, view, groupBy) {
this.ThrowIfThisIsNew();
var searchFilter = null;
var queryString = null;
if (searchFilterOrQueryString instanceof SearchFilter_1.SearchFilter) {
searchFilter = searchFilterOrQueryString;
}
else if (typeof searchFilterOrQueryString === 'string') {
queryString = searchFilterOrQueryString;
}
//debug: //todo: //ref: verify if querystring is null
return this.Service.FindItems([this.Id], searchFilter, queryString, view, groupBy, ServiceErrorHandling_1.ServiceErrorHandling.ThrowOnError);
};
Folder.prototype.InternalLoad = function (propertySet) {
this.ThrowIfThisIsNew();
return this.Service.LoadPropertiesForFolder(this, propertySet);
};
Folder.prototype.MarkAllItemsAsRead = function (suppressReadReceipts) {
this.ThrowIfThisIsNew();
return this.Service.MarkAllItemsAsRead(this.Id, true, suppressReadReceipts);
};
Folder.prototype.MarkAllItemsAsUnread = function (suppressReadReceipts) {
this.ThrowIfThisIsNew();
return this.Service.MarkAllItemsAsRead(this.Id, false, suppressReadReceipts);
};
Folder.prototype.Move = function (destinationFolderIdOrName) {
this.ThrowIfThisIsNew();
if (typeof destinationFolderIdOrName === 'undefined') {
EwsLogging_1.EwsLogging.Assert(false, "Folder.Move", "unknown paramete type");
throw new Error("unknow parameter type. this should not be reached");
}
//EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");
var folderId = destinationFolderIdOrName;
if (typeof destinationFolderIdOrName === 'number')
folderId = new FolderId_1.FolderId(destinationFolderIdOrName);
return this.Service.MoveFolder(this.Id, folderId);
};
Folder.prototype.RemoveExtendedProperty = function (extendedPropertyDefinition) { return this.ExtendedProperties.RemoveExtendedProperty(extendedPropertyDefinition); };
Folder.prototype.Save = function (parentFolderIdOrname) {
this.ThrowIfThisIsNotNew();
if (typeof parentFolderIdOrname === 'undefined') {
EwsLogging_1.EwsLogging.Assert(false, "Folder.Save", "unknown paramete type");
throw new Error("unknow parameter type. this should not be reached");
}
//EwsUtilities.ValidateParam(parentFolderId, "parentFolderId");
var folderId = parentFolderIdOrname;
if (typeof parentFolderIdOrname === 'number')
folderId = new FolderId_1.FolderId(parentFolderIdOrname);
if (this.IsDirty) {
return this.Service.CreateFolder(this, folderId);
}
else
return null;
};
Folder.prototype.SetExtendedProperty = function (extendedPropertyDefinition, value) { this.ExtendedProperties.SetExtendedProperty(extendedPropertyDefinition, value); };
Folder.prototype.Update = function () {
if (this.IsDirty) {
if (this.PropertyBag.GetIsUpdateCallNecessary()) {
return this.Service.UpdateFolder(this);
}
}
return undefined;
};
Folder.prototype.Validate = function () {
_super.prototype.Validate.call(this);
// Validate folder permissions
if (this.PropertyBag.Contains(FolderSchema_1.FolderSchema.Permissions)) {
this.Permissions.Validate();
}
};
Object.defineProperty(Folder.prototype, "InstanceType", {
//created this to help find serviceobject type, ServiceObjectInstance instanceof Folder fails by creating circular dependency in javascript/typescript
get: function () { return XmlElementNames_1.XmlElementNames.Folder; },
enumerable: true,
configurable: true
});
return Folder;
})(ServiceObject_1.ServiceObject);
exports.Folder = Folder;