/// <summary> /// Retrieves an array of PSItem objects representing the content items /// specified in the idList argument. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="id">The ID of the Content Item to be loaded.</param> /// <returns>An array of PSItem objects, listed in the same order as the /// entries in idList. Never null or empty.</returns> /// <remarks>The returned items are not editable.</remarks> public static PSItem[] LoadItems(contentSOAP contentSvc, long[] idList) { LoadItemsRequest req = new LoadItemsRequest(); PSItem[] items; try { if (idList.Length > 0) { req.Id = idList; req.IncludeFolderPath = true; req.IncludeChildren = true; items = contentSvc.LoadItems(req); } else { items = new PSItem[] { }; } } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in LoadItem.", ex); } return(items); }
public static PSFolder[] LoadFolders(contentSOAP contentSvc, string folderPath) { PSFolder[] returnItems; // Loading a non-existant folder results in a SoapException, // so we have to do some extra work to handle that possiblity. try { LoadFoldersRequest req = new LoadFoldersRequest(); req.Path = new string[] { folderPath }; returnItems = contentSvc.LoadFolders(req); } catch (SoapException ex) { if (ConfirmFolderNotFoundError(ex.Detail)) { returnItems = null; } else { // OK, that wasn't the error we expected. throw; } } return(returnItems); }
public static bool VerifyItemsExist(contentSOAP contentSvc, long[] idList) { bool found; try { // If the item has revisions, it exists. If it throws an exception, it doesn't. PSRevisions[] revisions = contentSvc.FindRevisions(idList); found = true; } catch (SoapException ex) { // Check that this is a Percussion error instead of connectivity. if (ex.Code.Name == "Server.userException" && ex.Message.StartsWith("java.rmi.RemoteException:")) { found = false; } else { // This is some other type of error, don't handle it. throw; } } return(found); }
/// <summary> /// The public constructor. /// </summary> /// <param name="contentService">Reference to the Percussion content Service.</param> internal FolderManager(contentSOAP contentService, systemSOAP systemService) { _contentService = contentService; _systemService = systemService; PercussionConfig percussionConfig = (PercussionConfig)System.Configuration.ConfigurationManager.GetSection("PercussionConfig"); NavonPublicTransitionName = percussionConfig.NavonPublicTransition.Value; }
/// <summary> /// Creates and intialize a proxy of the Percussion service used for manipulating /// content items and relationships. /// </summary> /// <param name="protocol">Communications protocol to use when connecting to /// the Percussion server. Should be either HTTP or HTTPS.</param> /// <param name="host">Host name or IP address of the Percussion server.</param> /// <param name="port">Port number to use when connecting to the Percussion server.</param> /// <param name="cookie">The cookie container for maintaining the session for all /// webservice requests.</param> /// <param name="authHeader">The authentication header for maintaining the Rhythmyx session /// for all webservice requests.</param> /// <returns>An initialized proxy for the Percussion content service.</returns> public static contentSOAP GetContentService(string protocol, string host, string port, CookieContainer cookie, PSAuthenticationHeader authHeader) { contentSOAP contentSvc = new contentSOAP(); contentSvc.Url = RewriteServiceUrl(contentSvc.Url, protocol, host, port); contentSvc.CookieContainer = cookie; contentSvc.PSAuthenticationHeaderValue = authHeader; return(contentSvc); }
public static void DeleteActiveAssemblyRelationships(contentSOAP contentSvc, long[] relationshipIDList) { try { contentSvc.DeleteContentRelations(relationshipIDList); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in DeleteActiveAssemblyRelationships().", ex); } }
/// <summary> /// Prepares the specified Content Item for Edit. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="idList">Array ofContent Item IDs to be prepared for editing.</param> /// <returns>An array of PSItemStatus objects reflecting the checkout state of each /// item in idList. The list is in the same order as the values in idList.</returns> public static PSItemStatus[] PrepareForEdit(contentSOAP contentSvc, long[] idList) { try { return(contentSvc.PrepareForEdit(idList)); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in PrepareForEdit.", ex); } }
public static bool FolderExists(contentSOAP contentSvc, string folderPath) { bool found = false; PSFolder[] folders = PSWSUtils.LoadFolders(contentSvc, folderPath); if (folders != null && folders.Length > 0) { found = true; } return(found); }
/// <summary> /// Release the specified Content Item from Edit /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="status">Collection of status objects for the Content Items to be released for edit.</param> public static void ReleaseFromEdit(contentSOAP contentSvc, PSItemStatus[] status) { try { ReleaseFromEditRequest req = new ReleaseFromEditRequest(); req.PSItemStatus = status; contentSvc.ReleaseFromEdit(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in ReleaseFromEdit.", ex); } }
/// <summary> /// Deletes a collection of folders. Requires admin permissions in order to purge /// folder contents. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="idList">List of folder IDs to delete</param> /// <param name="purgeItems">If true, folder contents are purged instead of being removed. /// (Requires admin permssion.)</param> public static void DeleteFolders(contentSOAP contentSvc, long[] idList, bool purgeItems) { try { DeleteFoldersRequest req = new DeleteFoldersRequest(); req.Id = idList; req.PurgItems = purgeItems; contentSvc.DeleteFolders(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in DeleteFolders.", ex); } }
/// <summary> /// Deletes a list of content items. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="itemsToDelete">array of content item ids to be deleted.</param> public static void DeleteItem(contentSOAP contentSvc, long[] itemsToDelete) { try { if (itemsToDelete.Length > 0) { contentSvc.DeleteItems(itemsToDelete); } } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in DeleteItem.", ex); } }
/// <summary> /// Retrieves relationships via the Percussion Content service. /// By default, all defined active asesmbly relationships are returned. The list /// may be filtered by assigning values to the various properties /// of the PSAaRelationshipFilter object. /// </summary> /// <param name="contentSvc">Instance of the Percussion content service.</param> /// <param name="filter">An instance of PSAaRelationshipFilter specifying /// criteria to use when filtering the list of relationsships.</param> /// <returns>An array of active asesmbly relationship objects. Never null, /// but may be empty.</returns> public static PSAaRelationship[] FindRelationships(contentSOAP contentSvc, PSAaRelationshipFilter filter) { try { LoadContentRelationsRequest req = new LoadContentRelationsRequest(); req.loadReferenceInfo = true; req.PSAaRelationshipFilter = filter; return(contentSvc.LoadContentRelations(req)); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in FindRelationships.", ex); } }
public static void CheckInItemList(contentSOAP contentSvc, long[] idList) { CheckinItemsRequest req = new CheckinItemsRequest(); try { req.Id = idList; contentSvc.CheckinItems(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in CheckinItem.", ex); } }
public static PSContentTypeSummary[] LoadContentTypes(contentSOAP contentSvc) { PSContentTypeSummary[] contentData; try { LoadContentTypesRequest req = new LoadContentTypesRequest(); req.Name = null; contentData = contentSvc.LoadContentTypes(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in PSContentTypeSummary", ex); } return(contentData); }
/// <summary> /// Saves a collection of Content Items to the repository. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="item">An array of Content Items to be saved.</param> /// <returns></returns> public static long[] SaveItem(contentSOAP contentSvc, PSItem[] item) { SaveItemsResponse response; try { SaveItemsRequest req = new SaveItemsRequest(); req.PSItem = item; response = contentSvc.SaveItems(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in SaveItem.", ex); } return(response.Ids); }
/// <summary> /// Associates the specified Content Items with the specified Folder. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="folderPath">The folder path.</param> /// <param name="childIds">The IDs of the objects to be associated with the Folder specified</param> public static void AddFolderChildren(contentSOAP contentSvc, string folderPath, long[] childIds) { AddFolderChildrenRequest req = new AddFolderChildrenRequest(); try { req.ChildIds = childIds; req.Parent = new FolderRef(); req.Parent.Path = folderPath; contentSvc.AddFolderChildren(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in AddFolderChildren.", ex); } }
public static void SaveChildEntries(contentSOAP contentSvc, long parentID, string fieldSetName, PSChildEntry[] childEntries) { try { SaveChildEntriesRequest req = new SaveChildEntriesRequest(); req.Id = parentID; req.Name = fieldSetName; req.PSChildEntry = childEntries; contentSvc.SaveChildEntries(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in SaveChildEntries", ex); } }
internal ContentTypeManager(contentSOAP contentService) { _contentService = contentService; if (_contentTypeMap == null) { // Lock the container for possible updating. lock (lockObject) { // Was the map loaded while we waited for the lock? if (_contentTypeMap == null) { LoadTemplateIDMap(); } } } }
/// <summary> /// Finds the content items residing in a folder. /// </summary> /// <param name="contentSvc">proxy of the content service</param> /// <param name="folderID">ID fo the folder to check.</param> /// <returns></returns> public static PSItemSummary[] FindFolderChildren(contentSOAP contentSvc, int folderID) { PSItemSummary[] folderResults; try { FindFolderChildrenRequest req = new FindFolderChildrenRequest(); req.Folder = new FolderRef(); req.Folder.Id = folderID; folderResults = contentSvc.FindFolderChildren(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in FindFolderChildren.", ex); } return(folderResults); }
/// <summary> /// Creates a Content Item of the specified Content Type. /// </summary> /// <param name="contentSvc">proxy of the content service</param> /// <param name="contentType">Type of the content item(druginfosummary,pdqsummary,...).</param> /// <returns>An empty content item with fields defined according to contentType.</returns> public static PSItem CreateItem(contentSOAP contentSvc, string contentType) { CreateItemsRequest request = new CreateItemsRequest(); PSItem[] items; try { request.ContentType = contentType; request.Count = 1; items = contentSvc.CreateItems(request); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in CreateItem.", ex); } return(items[0]); }
public static PSChildEntry[] CreateChildEntries(contentSOAP contentSvc, long parentItemID, string fieldSetName, int count) { PSChildEntry[] entrylist; try { CreateChildEntriesRequest req = new CreateChildEntriesRequest(); req.Id = parentItemID; req.Name = fieldSetName; req.Count = count; entrylist = contentSvc.CreateChildEntries(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in CreateChildEntries", ex); } return(entrylist); }
/// <summary> /// Moves a collection of content items from one folder to another. /// </summary> /// <param name="contentSvc">The proxy of the content service.</param> /// <param name="targetPath">The target folder path.</param> /// <param name="sourcePath">The source folder path.</param> /// <param name="id">The content item ids to be moved</param> /// <remarks>All items being moved must have the same source and target paths.</remarks> public static void MoveFolderChildren(contentSOAP contentSvc, string targetPath, string sourcePath, long[] id) { MoveFolderChildrenRequest moveFolder = new MoveFolderChildrenRequest(); FolderRef folderRefSource = new FolderRef(); FolderRef folderRefTarget = new FolderRef(); try { folderRefSource.Path = sourcePath; folderRefTarget.Path = targetPath; moveFolder.Source = folderRefSource; moveFolder.Target = folderRefTarget; moveFolder.ChildId = id; contentSvc.MoveFolderChildren(moveFolder); } catch (SoapException ex) { throw new CMSSoapException("Percussion Error in MoveFolderChildren.", ex); } }
/// <summary> /// Creates relationships between a parent object and a collection of child objects using a named /// slot and snippet template. /// </summary> /// <param name="contentSvc">Instance of the Percussion content service.</param> /// <param name="parentItemID">ID of the parent content item.</param> /// <param name="childItemIDList">Array of child item IDs.</param> /// <param name="slotName">Name of the slot which will contain the child items.</param> /// <param name="snippetTemplateName">Name of the snippet template to use when rendering /// the child items.</param> /// <returns>An array of PSAaRelationship objects representing the created relationships. /// The array is never null or empty</returns> /// <remarks>Before relationships may be created, the parent content item must be placed in an /// editable condition by calling PrepareForEdit.</remarks> public static PSAaRelationship[] CreateActiveAssemblyRelationships(contentSOAP contentSvc, long parentItemID, long[] childItemIDList, string slotName, string snippetTemplateName) { PSAaRelationship[] results = null; try { AddContentRelationsRequest req = new AddContentRelationsRequest(); req.Id = parentItemID; req.RelatedId = childItemIDList; req.Slot = slotName; req.Template = snippetTemplateName; results = contentSvc.AddContentRelations(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in CreateActiveAssemblyRelationships().", ex); } return(results); }
public static long SaveItem(contentSOAP contentSvc, PSItem item) { //TODO: Refactor SaveItem() and its callers to receive an array of PSItem objects. PSItem[] itemArray = new PSItem[] { item }; return(SaveItem(contentSvc, itemArray)[0]); }
public static PSSearchResults[] FindItemByFieldValues(contentSOAP contentSvc, string contentType, string searchPath, bool searchSubFolders, Dictionary <string, string> fieldCriteria) { PSSearchResults[] results; // The contentSvc.FindItems() method will throw a low-level error if the folder doesn't exist. // For our purposes, if caller specifies that the item must exist in a non-existant // path, then the item doesn't exist. // Before doing the other work, require either searchPath is empty, or else it contains // a valid path. (If searchPath is null/empty, the second test won't be performed.) if (string.IsNullOrEmpty(searchPath) || FolderExists(contentSvc, searchPath)) { FindItemsRequest req = new FindItemsRequest(); // Basic set up. req.PSSearch = new PSSearch(); req.PSSearch.useExternalSearchEngine = false; req.PSSearch.useDbCaseSensitivity = false; req.PSSearch.PSSearchParams = new PSSearchParams(); // Search for specific content types. if (!string.IsNullOrEmpty(contentType)) { req.PSSearch.PSSearchParams.ContentType = contentType; } // Search in path if (!string.IsNullOrEmpty(searchPath)) { req.PSSearch.PSSearchParams.FolderFilter = new PSSearchParamsFolderFilter(); req.PSSearch.PSSearchParams.FolderFilter.includeSubFolders = searchSubFolders; req.PSSearch.PSSearchParams.FolderFilter.Value = searchPath; } // Search for fields if (fieldCriteria != null && fieldCriteria.Count > 0) { req.PSSearch.PSSearchParams.Parameter = new PSSearchField[fieldCriteria.Count]; int offset = 0; foreach (KeyValuePair <string, string> pair in fieldCriteria) { req.PSSearch.PSSearchParams.Parameter[offset] = new PSSearchField(); req.PSSearch.PSSearchParams.Parameter[offset].name = pair.Key; req.PSSearch.PSSearchParams.Parameter[offset].Value = pair.Value; req.PSSearch.PSSearchParams.Parameter[offset].Operator = operatorTypes.equal; } } try { results = contentSvc.FindItems(req); } catch (SoapException ex) { throw new CMSSoapException("Percussion error in FindItemByFieldValues.", ex); } } else { results = new PSSearchResults[] { }; } return(results); }
public static PSSearchResults[] FindItemByFieldValues(contentSOAP contentSvc, string contentType, bool searchSubFolders, Dictionary <string, string> fieldCriteria) { return(FindItemByFieldValues(contentSvc, contentType, null, searchSubFolders, fieldCriteria)); }
/// <summary> /// Checkin the specified Content Item. /// </summary> /// <param name="contentSvc">The proxy of the content service</param> /// <param name="id">The ID of the Content Item to be checked in.</param> public static void CheckinItem(contentSOAP contentSvc, long id) { CheckInItemList(contentSvc, new long[] { id }); }