...
The explanation above only describes how to create a Monitoring Dashboard plugin but does not cover how to develop your own indicator set(s). That is done entirely in Java. See the wmaxmfindicators
bundle for an example of how to create your own custom indicators. As a starting point you should implement an XMFIndicatorProvider
that enables the registration of your custom indicators. See the file DefaultIndicatorsServiceImpl.java
in wmaxmfindicators
. Refer to the Javadoc for wmaxmfapi
in the wm-addon-monitoring
package for the interfaces offered by the framework.
Back to top
...
...
Custom Content and the Is Used in Widget
Anchor |
---|
| custom_media_items_and_the_is_used_in_widget |
---|
| custom_media_items_and_the_is_used_in_widget |
---|
|
Panel |
---|
borderColor | #0081C0 |
---|
titleColor | #0081C0 |
---|
|
The following applies to XperienCentral versions R28 10.22.0 and higher. |
Beginning in XperienCentral R28, it is possible to define your own bulk actions for content items. You can, for example, add the possibility to publish multiple content items at once, change the publication or expiration date for a set of articles in one go, and so forth. The example custom bulk action implementation described below is added in a new XperienCentral plugin. It is also possible to add a custom bulk action to an existing plugin.
The bulk actions available in XperienCentral by default are delete and export. The delete bulk action is available out-of-the-box and the export bulk action is added when you install the Connector API add-on. Bulk actions are accessible in the Actions menu in Advanced Search:
[screengrab]
Bulk Action Factory Implementation
Each bulk action is identified by an action type. This is a unique ID string such as "exportToExcel". Every instance of a bulk action type is created by a custom bulk action factory. The implementation of this custom bulk action factory is also responsible for registering the custom bulk action in XperienCentral. Every custom bulk action factory must extend the class BulkActionFactory
. For example:
Code Block |
---|
|
import nl.gx.webmanager.services.jaxrs.search.bulkactions.api.BulkActionFactory;
public interface ExportToExcelFactory extends BulkActionFactory {
} |
The registering and unregistering of a bulk action is performed using the onStart
and onStop
methods of the factory implementation via the bulk action service injected by OSGi:
The Is Used In widget shows an overview of content items that are using the currently selected content item. In XperienCentral versions 10.22.0 and earlier, the usage of content items referring to a custom content type was not detected for content items from a custom content type, The widget would only show a count of 0 used content items. The API of several content items in XperienCentral has been extended with a method for implementing this used-in relationship for custom content types. This functionality is available via the new abstract method:
Code Block |
---|
|
ContentItem<?>[] getReferencedContentItems(); |
For all custom content items that implement or extend one of the following interfaces and classes:
Element
ElementImpl
MediaItemVersion
MediaItemVersionImpl
TemporaryRichTextInlineElement
The result of this method is the list of used content items (as defined by the projects requirements). The following is a code snippet from a custom content type (extending MediaItemVersion
) which implements the method getReferencedContentItems()
.
Code Block |
---|
|
@Override
@Property
public String getReferencedContentIds() {
return JcrUtil.getString(getPrivateNode(), WCBConstants.NAMESPACE_PREFIX + ":referencedcontentids");
}
|
Code Block |
---|
|
public class ExportToExcelBulkActionFactoryImpl extends SimpleServiceComponent implements ExportToExcelFactory {
private static final String ACTION_TYPE = "exportToExcel";
// Injected by OSGI
private ExcelService myExcelService;
private BulkActionService myBulkActionService;
@Override
public void onStartsetReferencedContentIds(String contentids) {
super.onStartJcrUtil.setString(getPrivateNode();
myBulkActionService.addBulkActionFactory(ACTION_TYPE, this, WCBConstants.NAMESPACE_PREFIX + ":referencedcontentids", contentids);
}
@Override
public void onStopContentItem<?>[] getReferencedContentItems() {
List<ContentItem<?>> result = super.onStopnew ArrayList<ContentItem<?>>();
myBulkActionService.removeBulkActionFactory(ACTION_TYPE);
} |
The Actions drop-down menu in Advanced Search is populated with labels provided by all bulk action factories registered to the bulk action service. The method getActionLabel
must be overridden in your factory:
Code Block |
---|
|
@Override
public String getActionLabel(String localeif (getReferencedContentIds() != null && !"".equals(getReferencedContentIds())) {
StringSession namesession = myNameDescriptionsgetSessionManager().getgetActiveSession(locale);
if (namesession =!= null) {
for (String contentid name = myNameDescriptions.get(LOCALE_EN);: getReferencedContentIds().split(",")) {
}try {
return name;
} |
Instantiating a bulk action is accomplished by calling the createBulkActionInstance
method. You should override this method in your custom factory to return the correct bulk action type:
Code Block |
---|
|
@Override
public BulkAction createBulkActionInstance(String actionIdentifier, List<String> items,FrameworkDependencies frameworkDependencies, String locale) {
return new ExportToExcelBulkAction(actionIdentifier, items, frameworkDependencies, locale, myExcelService);
} |
A method call to createBulkActionInstance
will trigger the creation of a new bulk action of type custom with possibly its own parameters such as an Excel service like that shown in the example above. This method call will usually come from the bulk action handling mechanism in XperienCentral.
Bulk Action Implementation
To implement the bulk action itself, your bulk action class must extend AbstractBulkAction
and define the members and methods it needs for its custom functionality:
Code Block |
---|
|
public class ExportToExcelBulkAction extends AbstractBulkAction {
private ExcelService myExcelService;
private ConfigurationManagement myConfigurationManagement; |
The constructor of your class should look like this:
Code Block |
---|
|
public ExportToExcelBulkAction(String actionIdentifier, List<String> items, FrameworkDependencies frameworkDependencies, String locale, ExcelService excelService) {
super(actionIdentifier, items, frameworkDependencies, locale);
myConfigurationManagement = frameworkDependencies.getConfigurationManagement();
myExcelService = excelService; |
The actionIdentifier
parameter is the actionType
identifier string. The items
parameter is a list of item identifiers like "articleversion-14" that were selected for the bulk action. The frameWorkDependencies
parameter is a collection of services in the framework that are made available for use in your bulk action by the bulk action service. The locale
parameter is the locale of the content editor. All these parameters are always passed on by the bulk action service when creating a bulk action. The last parameter, excelService
, is a custom parameter used in this example. The call to the super constructor ensures that the bulk action is initialized properly and that the bulk action framework can handle the action.
...
Code Block |
---|
|
@Override
public ProgressResponseBean.MsgType checkPermissions(BulkContentItemVersion item) {
return item.checkEditPermissions();
} |
...
result.add((MediaItem) session.getWrapper(new Integer(contentid).intValue(), MediaItem.class));
} catch (NumberFormatException e) {}
}
}
}
return result.toArray(new ContentItem[result.size()]);
} |
Use in Page Metadata
It is also possible to define this method for custom page metadata. The method must be added to the page metadata class. Additionally, an adapter must be implemented that supplies the result of the method to the indexer service. The following are examples of implementations of both the method definition and the adapter:
Method Implementation
Code Block |
---|
|
/**
* Returns the content items that this element refers to.
*
* @return List of referred content items, or <code>null</code> if no content item is referenced.
*/
@ReferField(stored = false, indexed = true, adapter = ContentReferenceFieldAdapter.class) ContentItem<?>[] getReferencedContentItems(); |
Adapter Implementation
Code Block |
---|
|
package com.gxwebmanager.helloworld.helloworldpagemetadata.pagemetadata;
import java.util.Collections;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.gx.webmanager.cms.core.RelatedDownloadLink;
import nl.gx.webmanager.cms.core.RelatedInternalLink;
import nl.gx.webmanager.cms.core.RelatedLink;
import nl.gx.webmanager.cms.core.RelatedMediaItemLink;
import nl.gx.webmanager.cms.core.RelatedResourceLink;
import nl.gx.webmanager.cms.mediarepository.MediaItemDownloadVersion;
import nl.gx.webmanager.services.contentdomain.api.ContentDomainException;
import nl.gx.webmanager.services.contentdomain.api.ContentDomainResolver;
import nl.gx.webmanager.services.contentindex.adapter.FieldAdapter;
import nl.gx.webmanager.services.framework.spi.FrameworkException;
import nl.gx.webmanager.services.framework.spi.FrameworkFactory;
/**
* Adapter that takes a content item, and returns a String-reference to it, e.g. page-32423. Logs
* a warning and returns null if the given item could not be resolved.
*
* @see ContentDomainResolver
*/
public class ContentReferenceFieldAdapter implements FieldAdapter<Object> {
private static final Logger LOG = Logger.getLogger(ContentReferenceFieldAdapter.class.getName());
@Override
public boolean isLanguageSpecific() {
return false;
}
@Override
public Object adapt(Object item, Locale forLocale) {
if (item == null) {
return null;
}
if (item instanceof RelatedLink) {
return adaptLinkReference(item, forLocale);
}
return getItemId(item);
}
private String getItemId(Object item) {
try {
ContentDomainResolver resolver = (ContentDomainResolver) FrameworkFactory.getInstance().getFramework().getService(ContentDomainResolver.class.getName());
return resolver.entityToId(item);
} catch (FrameworkException | ContentDomainException e) {
LOG.log(Level.WARNING, "Failed to retrieve content reference for " + item, e);
}
return null;
}
private Object adaptLinkReference(Object link, Locale forLocale) {
if (link instanceof RelatedInternalLink) {
return adapt(((RelatedInternalLink) link).getPage(), forLocale);
} else if (link instanceof RelatedMediaItemLink) {
return adapt(((RelatedMediaItemLink) link).getMediaItem(), forLocale);
} else if (link instanceof RelatedDownloadLink) {
MediaItemDownloadVersion downloadVersion = ((RelatedDownloadLink) link).getInContextDownloadMediaItemDownloadVersion();
if (downloadVersion != null) {
String itemId = getItemId(downloadVersion.getContentItem());
if (itemId != null) {
return Collections.singletonMap("download", itemId);
}
}
} else if (link instanceof RelatedResourceLink) {
return adapt(((RelatedResourceLink) link).getResourceInstance(), forLocale);
}
return null;
}
} |
Back to top
...
Developing Custom Bulk Actions
Panel |
---|
borderColor | #0081C0 |
---|
titleColor | #0081C0 |
---|
|
The following applies to XperienCentral versions R28 and higher. |
Beginning in XperienCentral R28, it is possible to define your own bulk actions for content items. You can, for example, add the possibility to publish multiple content items at once, change the publication or expiration date for a set of articles in one go, and so forth. The example custom bulk action implementation described below is added in a new XperienCentral plugin. It is also possible to add a custom bulk action to an existing plugin.
The bulk actions available in XperienCentral by default are delete and export. The delete bulk action is available out-of-the-box and the export bulk action is added when you install the Connector API add-on. Bulk actions are accessible in the Actions menu in Advanced Search:
[screengrab]
Bulk Action Factory Implementation
Each bulk action is identified by an action type. This is a unique ID string such as "exportToExcel". Every instance of a bulk action type is created by a custom bulk action factory. The implementation of this custom bulk action factory is also responsible for registering the custom bulk action in XperienCentral. Every custom bulk action factory must extend the class BulkActionFactory
. For example:
Code Block |
---|
|
import nl.gx.webmanager.services.jaxrs.search.bulkactions.api.BulkActionFactory;
public interface ExportToExcelFactory extends BulkActionFactory {
} |
The registering and unregistering of a bulk action is performed using the onStart
and onStop
methods of the factory implementation via the bulk action service injected by OSGi:
Code Block |
---|
|
public class ExportToExcelBulkActionFactoryImpl extends SimpleServiceComponent implements ExportToExcelFactory {
private static final String ACTION_TYPE = "exportToExcel";
// Injected by OSGI
private ExcelService myExcelService;
private BulkActionService myBulkActionService;
@Override
public void onStart() {
super.onStart();
myBulkActionService.addBulkActionFactory(ACTION_TYPE, this);
}
@Override
public void onStop() {
super.onStop();
myBulkActionService.removeBulkActionFactory(ACTION_TYPE);
} |
The Actions drop-down menu in Advanced Search is populated with labels provided by all bulk action factories registered to the bulk action service. The method getActionLabel
must be overridden in your factory:
Code Block |
---|
|
@Override
public String getActionLabel(String locale) {
String name = myNameDescriptions.get(locale);
if (name == null) {
name = myNameDescriptions.get(LOCALE_EN);
}
return name;
} |
Instantiating a bulk action is accomplished by calling the createBulkActionInstance
method. You should override this method in your custom factory to return the correct bulk action type:
Code Block |
---|
|
@Override
public BulkAction createBulkActionInstance(String actionIdentifier, List<String> items,FrameworkDependencies frameworkDependencies, String locale) {
return new ExportToExcelBulkAction(actionIdentifier, items, frameworkDependencies, locale, myExcelService);
} |
A method call to createBulkActionInstance
will trigger the creation of a new bulk action of type custom with possibly its own parameters such as an Excel service like that shown in the example above. This method call will usually come from the bulk action handling mechanism in XperienCentral.
...
Bulk Action Implementation
To implement the bulk action itself, your bulk action class must extend AbstractBulkAction
and define the members and methods it needs for its custom functionality:
Code Block |
---|
|
public class ExportToExcelBulkAction extends AbstractBulkAction {
private ExcelService myExcelService;
private ConfigurationManagement myConfigurationManagement; |
The constructor of your class should look like this:
Code Block |
---|
|
public ExportToExcelBulkAction(String actionIdentifier, List<String> items, FrameworkDependencies frameworkDependencies, String locale, ExcelService excelService) {
super(actionIdentifier, items, frameworkDependencies, locale);
myConfigurationManagement = frameworkDependencies.getConfigurationManagement();
myExcelService = excelService; |
The actionIdentifier
parameter is the actionType
identifier string. The items
parameter is a list of item identifiers like "articleversion-14" that were selected for the bulk action. The frameWorkDependencies
parameter is a collection of services in the framework that are made available for use in your bulk action by the bulk action service. The locale
parameter is the locale of the content editor. All these parameters are always passed on by the bulk action service when creating a bulk action. The last parameter, excelService
, is a custom parameter used in this example. The call to the super constructor ensures that the bulk action is initialized properly and that the bulk action framework can handle the action.
Next, the actual validation code and business logic for the bulk action needs to be implemented. This is done using the methods checkPermissions
, preProcess
, treat
and postProcess
. The method checkPermissions
is called after the bulk action selection is made in order to check whether the bulk action can be executed on the selected items. The method is called for every item in the selection. To only allow the action to be executed on items with sufficient edit permissions, you could implement the method like this:
Code Block |
---|
|
@Override
public ProgressResponseBean.MsgType checkPermissions(BulkContentItemVersion item) {
return item.checkEditPermissions();
} |
The method treat
is called in order to execute the actual action on one content item in the bulk action. The bulk action framework will iterate over the selection of items and call this method for every item. An implementation of a bulk action performing a state change on every content item of the selection, for example to publish an entire content set at once, could be implemented as follows:
Code Block |
---|
|
@Override
public void treat(BulkContentItemVersion bulkContentItemVersion) throws OperationFailedException {
LOG.log(Level.FINE, "Changing status of item {0} to {1}", new Object[] { bulkContentItemVersion.getTitle(), myWorkflowType.getWorkflowName()});
ContentItemVersion<?> contentItemVersion = getContentItemVersion(bulkContentItemVersion);
List<WorkflowModelState> targetWorkflowModelStates = getWorkflowModelStates(contentItemVersion);
if (targetWorkflowModelStates.size() == 1) {
try {
WorkflowUtils.bringToState(contentItemVersion, targetWorkflowModelStates.get(0), myWorkflowService);
} catch (UnExecutableWorkflowActionException e) {
throw new OperationFailedException("Failed to change state of " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
}
} else if (targetWorkflowModelStates.size() > 1) {
throw new OperationFailedException("Multiple target WorkflowModelStates found for " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
} else {
throw new OperationFailedException("No target WorkflowModelState found for mediaitemversion " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
}
} |
The method preProcess
can be overridden in order to prepare and initialize the bulk action. The method postProcess
can be overridden in order to perform additional work after all content items are processed. These two methods together with the treat
method can be used to export data to Excel, for example:
Code Block |
---|
|
@Override
public void preProcess() {
pages = new ArrayList<>();
2contentItems = new ArrayList<>();
}
@Override
public void treat(BulkContentItemVersion item) {
LOG.log(Level.FINE, "Exporting data of item {0}", new Object[] { item.getTitle() });
if (item instanceof BulkContentItemPageVersion) {
pages.add(item.getId());
} else if (item instanceof BulkContentItemMediaItemVersion) {
contentItems.add(item.getId());
}
}
@Override
public void postProcess(ProgressResponseBean bean) {
String finishMessage = "";
File excelFile = null;
if (checkExportDirectory()) {
excelFile = myExcelService.createExcel(pages, contentItems, myFilePath);
}
if (excelFile != null && excelFile.isFile()) {
finishMessage = "<br /><a href=\"" + myExportDownloadUrl + "\" download>Download het export Excel bestand</a>.";
} else {
finishMessage = "Error";
}
bean.finishMessage = finishMessage;
} |
Defining the Bulk Action Factory Component
The bulk action factory is a service bundle and must be defined as such in the Activator class of your plugin. Its definition will look something like this:
Code Block |
---|
|
private ServiceComponentDefinitionImpl getExportToExcelFactoryComponent() {
ServiceComponentDefinitionImpl definition = new ServiceComponentDefinitionImpl(false);
definition.setId(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_ID);
definition.setName(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_NAME);
definition.setDescription(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_DESCRIPTION);
definition.setTypeId(ServiceComponentType.class.getName());
definition.setProperties(new Hashtable<>());
definition.setImplementationClassName(ExportToExcelBulkActionFactoryImpl.class.getName());
definition.setInterfaceClassNames(new String[]{ExportToExcelFactory.class.getName()});
setRequiredDependencies(definition, ExcelService.class, BulkActionService.class);
return definition;
|
Code Block |
---|
|
@Override
public void treat(BulkContentItemVersion bulkContentItemVersion) throws OperationFailedException {
LOG.log(Level.FINE, "Changing status of item {0} to {1}", new Object[] { bulkContentItemVersion.getTitle(), myWorkflowType.getWorkflowName()});
ContentItemVersion<?> contentItemVersion = getContentItemVersion(bulkContentItemVersion);
List<WorkflowModelState> targetWorkflowModelStates = getWorkflowModelStates(contentItemVersion);
if (targetWorkflowModelStates.size() == 1) {
try {
WorkflowUtils.bringToState(contentItemVersion, targetWorkflowModelStates.get(0), myWorkflowService);
} catch (UnExecutableWorkflowActionException e) {
throw new OperationFailedException("Failed to change state of " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
}
} else if (targetWorkflowModelStates.size() > 1) {
throw new OperationFailedException("Multiple target WorkflowModelStates found for " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
} else {
throw new OperationFailedException("No target WorkflowModelState found for mediaitemversion " + bulkContentItemVersion.getType() + WITH_ID + bulkContentItemVersion.getId());
}
} |
The method preProcess
can be overridden in order to prepare and initialize the bulk action. The method postProcess
can be overridden in order to perform additional work after all content items are processed. These two methods together with the treat
method can be used to export data to Excel, for example:
Code Block |
---|
|
@Override
public void preProcess() {
pages = new ArrayList<>();
2contentItems = new ArrayList<>();
}
@Override
public void treat(BulkContentItemVersion item) {
LOG.log(Level.FINE, "Exporting data of item {0}", new Object[] { item.getTitle() });
if (item instanceof BulkContentItemPageVersion) {
pages.add(item.getId());
} else if (item instanceof BulkContentItemMediaItemVersion) {
contentItems.add(item.getId());
}
}
@Override
public void postProcess(ProgressResponseBean bean) {
String finishMessage = "";
File excelFile = null;
if (checkExportDirectory()) {
excelFile = myExcelService.createExcel(pages, contentItems, myFilePath);
}
if (excelFile != null && excelFile.isFile()) {
finishMessage = "<br /><a href=\"" + myExportDownloadUrl + "\" download>Download het export Excel bestand</a>.";
} else {
finishMessage = "Error";
}
bean.finishMessage = finishMessage;
} |
Defining the Bulk Action Factory Component
The bulk action factory is a service bundle and must be defined as such in the Activator class of your plugin. Its definition will look something like this:
Code Block |
---|
|
private ServiceComponentDefinitionImpl getExportToExcelFactoryComponent() {
ServiceComponentDefinitionImpl definition = new ServiceComponentDefinitionImpl(false);
definition.setId(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_ID);
definition.setName(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_NAME);
definition.setDescription(WCBConstants.EXPORT_TO_EXCEL_FACTORY_COMPONENT_DESCRIPTION);
definition.setTypeId(ServiceComponentType.class.getName());
definition.setProperties(new Hashtable<>());
definition.setImplementationClassName(ExportToExcelBulkActionFactoryImpl.class.getName());
definition.setInterfaceClassNames(new String[]{ExportToExcelFactory.class.getName()});
setRequiredDependencies(definition, ExcelService.class, BulkActionService.class);
return definition;
} |
Back to top
...
Panel |
---|
borderColor | #0081C0 |
---|
titleColor | #0081C0 |
---|
|
The following applies to XperienCentral versions R29 and higher. |
Panel |
---|
borderColor | #0081C0 |
---|
titleColor | #0081C0 |
---|
|
The following applies to XperienCentral versions 10.22.0 and higher. |
The Is Used In widget shows an overview of content items that are using the currently selected content item. Before XperienCentral 10.22.0, the usage of content items referring to a custom content type was not detected for content items from a custom content type, The widget would only show a count of 0 used content items. The API of several content items in XperienCentral has been extended with a method for implementing this used-in relationship for custom content types. This functionality is available via the new abstract method:
Code Block |
---|
|
ContentItem<?>[] getReferencedContentItems(); |
For all custom content items that implement or extend one of the following interfaces and classes:
Element
ElementImpl
MediaItemVersion
MediaItemVersionImpl
TemporaryRichTextInlineElement
The result of this method is the list of used content items (as defined by the projects requirements). The following is a code snippet from a custom content type (extending MediaItemVersion
) which implements the method getReferencedContentItems()
.
Code Block |
---|
|
@Override
@Property
public String getReferencedContentIds() {
return JcrUtil.getString(getPrivateNode(), WCBConstants.NAMESPACE_PREFIX + ":referencedcontentids");
}
@Override
public void setReferencedContentIds(String contentids) {
JcrUtil.setString(getPrivateNode(), WCBConstants.NAMESPACE_PREFIX + ":referencedcontentids", contentids);
}
public ContentItem<?>[] getReferencedContentItems() { List<ContentItem<?>> result = new ArrayList<ContentItem<?>>();
if (getReferencedContentIds() != null && !"".equals(getReferencedContentIds())) {
Session session = getSessionManager().getActiveSession();
if (session != null) {
for (String contentid : getReferencedContentIds().split(",")) {
try {
result.add((MediaItem) session.getWrapper(new Integer(contentid).intValue(), MediaItem.class));
} catch (NumberFormatException e) {}
}
}
}
return result.toArray(new ContentItem[result.size()]);
} |
Use in Page Metadata
It is also possible to define this method for custom page metadata. The method must be added to the page metadata class. Additionally, an adapter must be implemented that supplies the result of the method to the indexer service. The following are examples of implementations of both the method definition and the adapter:
Method Implementation
Code Block |
---|
|
/**
* Returns the content items that this element refers to.
*
* @return List of referred content items, or <code>null</code> if no content item is referenced.
*/
@ReferField(stored = false, indexed = true, adapter = ContentReferenceFieldAdapter.class) ContentItem<?>[] getReferencedContentItems(); |
Adapter Implementation
Code Block |
---|
|
package com.gxwebmanager.helloworld.helloworldpagemetadata.pagemetadata;
import java.util.Collections;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.gx.webmanager.cms.core.RelatedDownloadLink;
import nl.gx.webmanager.cms.core.RelatedInternalLink;
import nl.gx.webmanager.cms.core.RelatedLink;
import nl.gx.webmanager.cms.core.RelatedMediaItemLink;
import nl.gx.webmanager.cms.core.RelatedResourceLink;
import nl.gx.webmanager.cms.mediarepository.MediaItemDownloadVersion;
import nl.gx.webmanager.services.contentdomain.api.ContentDomainException;
import nl.gx.webmanager.services.contentdomain.api.ContentDomainResolver;
import nl.gx.webmanager.services.contentindex.adapter.FieldAdapter;
import nl.gx.webmanager.services.framework.spi.FrameworkException;
import nl.gx.webmanager.services.framework.spi.FrameworkFactory;
/**
* Adapter that takes a content item, and returns a String-reference to it, e.g. page-32423. Logs
* a warning and returns null if the given item could not be resolved.
*
* @see ContentDomainResolver
*/
public class ContentReferenceFieldAdapter implements FieldAdapter<Object> {
private static final Logger LOG = Logger.getLogger(ContentReferenceFieldAdapter.class.getName());
@Override
public boolean isLanguageSpecific() {
return false;
}
@Override
public Object adapt(Object item, Locale forLocale) {
if (item == null) {
return null;
}
if (item instanceof RelatedLink) {
return adaptLinkReference(item, forLocale);
}
return getItemId(item);
}
private String getItemId(Object item) {
try {
ContentDomainResolver resolver = (ContentDomainResolver) FrameworkFactory.getInstance().getFramework().getService(ContentDomainResolver.class.getName());
return resolver.entityToId(item);
} catch (FrameworkException | ContentDomainException e) {
LOG.log(Level.WARNING, "Failed to retrieve content reference for " + item, e);
}
return null;
}
private Object adaptLinkReference(Object link, Locale forLocale) {
if (link instanceof RelatedInternalLink) {
return adapt(((RelatedInternalLink) link).getPage(), forLocale);
} else if (link instanceof RelatedMediaItemLink) {
return adapt(((RelatedMediaItemLink) link).getMediaItem(), forLocale);
} else if (link instanceof RelatedDownloadLink) {
MediaItemDownloadVersion downloadVersion = ((RelatedDownloadLink) link).getInContextDownloadMediaItemDownloadVersion();
if (downloadVersion != null) {
String itemId = getItemId(downloadVersion.getContentItem());
if (itemId != null) {
return Collections.singletonMap("download", itemId);
}
}
} else if (link instanceof RelatedResourceLink) {
return adapt(((RelatedResourceLink) link).getResourceInstance(), forLocale);
}
return null;
}
} |
Back to top
...
Credentials Service Provider
...
In a standard installation, XperienCentral users are managed in the Authorization component. Along with the Authorization component, there are two types of credentials sets that are not targeted at the editorial tasks but are infrastructure-related. By default these credential sets are managed by the following properties in the XperienCentral Setup Tool (General (R30 and older) tab):
These credentials sets are for:
...
This can be accomplished via your own integration component by creating a plugin that implements the Credentials Service Provider. When there is no plugin active that implements the credentials services, a look-up is done on the settings internal_http_use_authentication
or internal_http_use_form_authentication
in the "application_settings" section in the General (R30 and older) tab of the Setup Tool. If a plugin is active that implements the XperienCentral credentials service, the username/password combination from the plugin is used to authorize the user.
...
To incorporate the commons HTTPp HTTP client jar files into a plugin, modify the pom.xml
file in order to define a dependency with the commons HTTPclient
artifact. For example, define the following dependency:
...