2

I need to extend GetList() and GetListXml() methods to return items that are not in certain folder. Extending GetList() methods is not that hard since it already returns objects that i can manipulate, but extending GetListXml() method will be expensive (getting all objects and parsing their owning folders).

Is there an easy ("magic") way to achieve this?

  • Are you missing any particular information in the XML version of the list? It's not clear from your question. – Peter Kjaer Feb 27 '17 at 12:35
  • My ideal situation would be to add additional info to these 2 methods (for example path), where I can easily filter result using linq based on that property. – Marko Milic Feb 27 '17 at 12:47
  • Well, seeing as one is dealing with XML and the other objects, it seems unlikely that you'll be able to do it all with the same code. – Peter Kjaer Feb 28 '17 at 11:00
  • Yes, but I need to extend both, of course in separate extension methods. – Marko Milic Feb 28 '17 at 11:10
3

I guess it depends on your use case, but have you looked at Data Extenders? Here's an example of adding a column to a list.

0

Examples Getting lists of items (.NET)

The Core Service has methods for retrieving lists of Content Manager items.

GetList(id, filter)

Gets a list of objects. This method is for items that are containers, or are contained in a container, such as Publications, Components, Pages, Folders, Keywords, Target Groups, Schemas, and so on. id is the ID of the container in which to search for items.

GetListXml(id, filter)

Gets a list of items in the form of an XML document. This method is for items that are containers, or are contained in a container, such as Publications, Components, Pages, Folders, Keywords, Target Groups, Schemas, and so on. id is the ID of the container in which to search for items.

GetSystemWideList(filter)

Gets a list of objects for system-wide item types, that is, item types not contained in a container. Examples of system-wide item types are Users, Target Types, and Workflow Processes.

GetSystemWideListXml(filter) The same as GetSystemWideList, but gets a list of items in the form of an XML document.

The filter in all of these methods specifies exactly which items to retrieve. For GetListXml, this is a subclass of SubjectRelatedListFilterData, and in GetSystemWideList and GetSystemWideList, the filter is a subclass of SystemWideFilterData. Explore the Core Service API documentation (available online) to learn of specific filters.

Here are some examples of these methods being used to retrieve specific sets of items:

Getting all root Categories in a Publication

CategoriesFilterData filterData = new CategoriesFilterData();
filterData.IsRoot = true;
XElement resultXml = client.GetListXml(publicationId, filterData);

Getting all Components and Schemas in a Publication

RepositoryItemsFilterData filterData = new RepositoryItemsFilterData();
filterData.ItemTypes = new[]
    {
        ItemType.Component,
        ItemType.Schema
    };
filterData.Recursive = true;
XElement resultXml = client.GetListXml(publicationId, filterData);

Getting all Multimedia Components not based on one specific Schema

OrganizationalItemItemsFilterData filterData = new OrganizationalItemItemsFilterData();
filterData.ItemTypes = new[]
    {
        ItemType.Component
    };
filterData.ComponentTypes = new[]
    { 
        ComponentType.Multimedia
    };
filterData.NotBasedOnSchema = new LinkToSchemaData()
    {
        IdRef = schemaId
    };
XElement resultXml = client.GetListXml(folderId, filterData);

Getting all users in Content Manager, both as data objects and as XML

UsersFilterData filterData = new UsersFilterData();
IdentifiableObjectData[] resultData = client.GetSystemWideList(filterData);
XElement resultXml = client.GetSystemWideListXml(filterData);

Getting all active Workflow Processes being performed by one specific user, both as data objects and as XML

ProcessesFilterData filterData = new ProcessesFilterData();
filterData.ForPerformer = new LinkToUserData()
    {
        IdRef = userId
    };
filterData.ProcessType = ProcessType.Active;
IdentifiableObjectData[] resultData = client.GetSystemWideList(filterData);
XElement resultXml = client.GetSystemWideListXml(filterData);

Getting all failed publish transactions that originate from one specific Publication, both as data objects and as XML

PublishTransactionsFilterData filterData = new PublishTransactionsFilterData();
filterData.ForRepository = new LinkToRepositoryData()
    {
        IdRef = publicationId
    };
filterData.PublishTransactionState = PublishTransactionState.Failed;
IdentifiableObjectData[] resultData = client.GetSystemWideList(filterData);
XElement resultXml = client.GetSystemWideListXml(filterData);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.