// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.Services;
using WebsitePanel.EnterpriseServer.Code.SharePoint;
using WebsitePanel.Providers.SharePoint;
using Microsoft.Web.Services3;
namespace WebsitePanel.EnterpriseServer
{
///
/// Summary description for esHostedSharePointServers
///
[WebService(Namespace = "http://smbsaas/websitepanel/enterpriseserver")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Policy("ServerPolicy")]
[ToolboxItem(false)]
public class esHostedSharePointServers : WebService
{
///
/// Gets site collections in raw form.
///
/// Package to which desired site collections belong.
/// Organization to which desired site collections belong.
/// Filter column name.
/// Filter value.
/// Sort column name.
/// Row index to start from.
/// Maximum number of rows to retrieve.
/// Site collections in raw format.
[WebMethod]
public SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId,
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return HostedSharePointServerController.GetSiteCollectionsPaged(packageId, organizationId, filterColumn, filterValue,
sortColumn, startRow, maximumRows);
}
///
/// Gets list of supported languages by this installation of SharePoint.
///
/// List of supported languages
[WebMethod]
public int[] GetSupportedLanguages(int packageId)
{
return HostedSharePointServerController.GetSupportedLanguages(packageId);
}
///
/// Gets list of SharePoint site collections that belong to the package.
///
/// Package that owns site collections.
/// A value which shows whether nested spaces must be searched as well.
/// List of found site collections.
[WebMethod]
public List GetSiteCollections(int packageId, bool recursive)
{
return HostedSharePointServerController.GetSiteCollections(packageId, recursive);
}
[WebMethod]
public int SetStorageSettings(int itemId, int maxStorage, int warningStorage, bool applyToSiteCollections)
{
return HostedSharePointServerController.SetStorageSettings(itemId, maxStorage, warningStorage, applyToSiteCollections );
}
///
/// Gets SharePoint site collection with given id.
///
/// Site collection id within metabase.
/// Site collection.
[WebMethod]
public SharePointSiteCollection GetSiteCollection(int itemId)
{
return HostedSharePointServerController.GetSiteCollection(itemId);
}
///
/// Gets SharePoint site collection from package under organization with given domain.
///
/// Package id.
/// Organization id.
/// Domain name.
/// SharePoint site collection or null.
[WebMethod]
public SharePointSiteCollection GetSiteCollectionByDomain(int organizationId, string domain)
{
DomainInfo domainInfo = ServerController.GetDomain(domain);
SharePointSiteCollectionListPaged existentSiteCollections = this.GetSiteCollectionsPaged(domainInfo.PackageId, organizationId, "ItemName", String.Format("%{0}", domain), String.Empty, 0, Int32.MaxValue);
foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections)
{
Uri existentSiteCollectionUri = new Uri(existentSiteCollection.Name);
if (existentSiteCollection.Name == String.Format("{0}://{1}", existentSiteCollectionUri.Scheme, domain))
{
return existentSiteCollection;
}
}
return null;
}
///
/// Adds SharePoint site collection.
///
/// Site collection description.
/// Created site collection id within metabase.
[WebMethod]
public int AddSiteCollection(SharePointSiteCollection item)
{
return HostedSharePointServerController.AddSiteCollection(item);
}
///
/// Deletes SharePoint site collection with given id.
///
/// Site collection id within metabase.
/// ?
[WebMethod]
public int DeleteSiteCollection(int itemId)
{
return HostedSharePointServerController.DeleteSiteCollection(itemId);
}
///
/// Deletes SharePoint site collections which belong to organization.
///
/// Site collection id within metabase.
/// ?
[WebMethod]
public int DeleteSiteCollections(int organizationId)
{
HostedSharePointServerController.DeleteSiteCollections(organizationId);
return 0;
}
///
/// Backups SharePoint site collection.
///
/// Site collection id within metabase.
/// Backed up site collection file name.
/// A value which shows whether back up must be archived.
/// A value which shows whether created back up must be downloaded.
/// Local folder to store downloaded backup.
/// Created backup file name.
[WebMethod]
public string BackupSiteCollection(int itemId, string fileName, bool zipBackup, bool download, string folderName)
{
return HostedSharePointServerController.BackupSiteCollection(itemId, fileName, zipBackup, download, folderName);
}
///
/// Restores SharePoint site collection.
///
/// Site collection id within metabase.
///
///
///
[WebMethod]
public int RestoreSiteCollection(int itemId, string uploadedFile, string packageFile)
{
return HostedSharePointServerController.RestoreSiteCollection(itemId, uploadedFile, packageFile);
}
///
/// Gets binary data chunk of specified size from specified offset.
///
/// Item id to obtain realted service id.
/// Path to file to get bunary data chunk from.
/// Offset from which to start data reading.
/// Binary data chunk length.
/// Binary data chunk read from file.
[WebMethod]
public byte[] GetBackupBinaryChunk(int itemId, string path, int offset, int length)
{
return HostedSharePointServerController.GetBackupBinaryChunk(itemId, path, offset, length);
}
///
/// Appends supplied binary data chunk to file.
///
/// Item id to obtain realted service id.
/// Non existent file name to append to.
/// Full path to existent file to append to.
/// Binary data chunk to append to.
/// Path to file that was appended with chunk.
[WebMethod]
public string AppendBackupBinaryChunk(int itemId, string fileName, string path, byte[] chunk)
{
return HostedSharePointServerController.AppendBackupBinaryChunk(itemId, fileName, path, chunk);
}
[WebMethod]
public SharePointSiteDiskSpace[] CalculateSharePointSitesDiskSpace(int itemId, out int errorCode)
{
return HostedSharePointServerController.CalculateSharePointSitesDiskSpace(itemId, out errorCode);
}
[WebMethod]
public void UpdateQuota(int itemId, int siteCollectionId, int maxSize, int warningSize)
{
HostedSharePointServerController.UpdateQuota(itemId, siteCollectionId, maxSize, warningSize);
}
}
}