Created
October 24, 2012 15:43
-
-
Save rileyw/3946845 to your computer and use it in GitHub Desktop.
Incrementally Published Content Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page import="com.percussion.services.sitemgr.PSSiteManagerLocator, | |
com.percussion.services.sitemgr.IPSSiteManager,com.percussion.services.sitemgr.IPSSite, | |
com.percussion.services.contentmgr.PSContentMgrLocator,com.percussion.services.contentmgr.IPSContentMgr, | |
com.percussion.services.assembly.IPSAssemblyService,com.percussion.services.assembly.IPSAssemblyTemplate, | |
com.percussion.services.assembly.IPSTemplateSlot,com.percussion.services.assembly.IPSSlotContentFinder, | |
com.percussion.services.guidmgr.IPSGuidManager,org.hibernate.Session,org.springframework.orm.hibernate3.support.HibernateDaoSupport, | |
com.percussion.services.guidmgr.PSGuidManagerLocator,com.percussion.services.publisher.IPSPublisherService, | |
com.percussion.services.publisher.PSPublisherServiceLocator,com.percussion.services.publisher.PSPublisherException, | |
com.percussion.services.publisher.impl.PSPublisherService,com.percussion.services.publisher.IPSContentList, | |
com.percussion.services.publisher.data.PSContentListItem,com.percussion.services.legacy.PSCmsObjectMgrLocator, | |
com.percussion.services.assembly.PSAssemblyServiceLocator,com.percussion.services.legacy.IPSCmsObjectMgr, | |
com.percussion.services.contentmgr.IPSNodeDefinition,com.percussion.utils.guid.IPSGuid, | |
com.percussion.services.guidmgr.data.PSGuid,com.percussion.services.guidmgr.data.PSLegacyGuid, | |
com.percussion.services.catalog.PSTypeEnum,com.percussion.services.assembly.PSAssemblyException, | |
java.io.Serializable,java.util.HashMap,java.util.List,java.util.HashSet,java.util.Iterator, | |
org.apache.commons.lang.StringUtils,java.util.Collection,java.util.Set, | |
com.percussion.services.error.PSNotFoundException"%> | |
<html> | |
<body> | |
<% | |
String siteID = (request.getParameter("siteid")!=null) ? request.getParameter("siteid") : ""; | |
%> | |
<form action="<%=request.getRequestURI()%>" method="GET"> | |
<p> | |
Site ID: <input type="text" name="siteid" id="siteid" value="<%=siteID%>"><br /> | |
<input type="submit" value="Find all incrementally published content types"> | |
</p> | |
</form> | |
<% | |
if(!StringUtils.isBlank(siteID)){ | |
/** | |
* Initial basic site manager to allow the loading of site and site specific information. | |
* @type IPSSiteManager | |
*/ | |
IPSSiteManager localIPSSiteManager = PSSiteManagerLocator.getSiteManager(); | |
/** | |
* Create globally unique ids for use when creating service objects. | |
* @type IPSGuidManager | |
*/ | |
IPSGuidManager localIPSGuidManager = PSGuidManagerLocator.getGuidMgr(); | |
/** | |
* Represents a publishing site. | |
* @type IPSSite | |
*/ | |
try { | |
IPSSite localIPSSite = localIPSSiteManager.loadUnmodifiableSite(localIPSGuidManager.makeGuid(siteID, PSTypeEnum.SITE)); | |
/** | |
* The assembler service acts as a toplevel assembler that dispatches to component | |
* assemblers on the basis of the passed template, and additionally supplies the | |
* methods to manipulate templates and slots. See the super interface descriptions | |
* for more details. | |
* @type IPSAssemblyService | |
*/ | |
IPSAssemblyService localIPSAssemblyService = PSAssemblyServiceLocator.getAssemblyService(); | |
/** | |
* The content manager allows the loading of content items by either GUID or path. | |
* @type IPSContentMgr | |
*/ | |
IPSContentMgr localIPSContentMgr = PSContentMgrLocator.getContentMgr(); | |
/** | |
* Service to do CRUD operations on content lists and run content lists. | |
* @type IPSPublisherService | |
*/ | |
IPSPublisherService localIPSPublisherService = PSPublisherServiceLocator.getPublisherService(); | |
/** | |
* Stores all content types containing a template with an auto index slot | |
* @type {HashSet} | |
*/ | |
HashSet locatedContentTypes = new HashSet(); | |
/** | |
* Temporary stores the Template slot finder name | |
* @type String | |
*/ | |
String currentSlotFinder = null; | |
%> | |
<h1>isMustIncrementallyPublish</h1> | |
<ul> | |
<% | |
/** | |
* Get the modifiable set of associated templates for this site. | |
* @type Iterator | |
*/ | |
Iterator associatedTemplates = localIPSSite.getAssociatedTemplates().iterator(); | |
/** | |
* Iterate through associated templates | |
*/ | |
while (associatedTemplates.hasNext()) { | |
/** | |
* Initialize current associated template | |
* @type IPSAssemblyTemplate | |
*/ | |
IPSAssemblyTemplate currentAssociatedTemplate = (IPSAssemblyTemplate)associatedTemplates.next(); | |
/** | |
* Get the slots related to this template | |
* @type Iterator | |
*/ | |
Iterator relatedSlots = currentAssociatedTemplate.getSlots().iterator(); | |
/** | |
* Iterate through related slots | |
*/ | |
while (relatedSlots.hasNext()) { | |
/** | |
* Initialize current related slot | |
* @type IPSTemplateSlot | |
*/ | |
IPSTemplateSlot currentRelatedSlot = (IPSTemplateSlot)relatedSlots.next(); | |
/** | |
* Try loading the finder, catching PSAssemblyException | |
*/ | |
try { | |
/** | |
* Populate currentSlotFinder with the Slot's Finder Name | |
* @type String | |
*/ | |
currentSlotFinder = currentRelatedSlot.getFinderName(); | |
/** | |
* currentSlotFinder cannot be blank | |
*/ | |
if (!StringUtils.isBlank(currentSlotFinder)) { | |
/** | |
* Load the named finder via the extensions manager. | |
* @type IPSSlotContentFinder | |
*/ | |
IPSSlotContentFinder loadedFinder = localIPSAssemblyService.loadFinder(currentSlotFinder); | |
/** | |
* Does this type require incremental publishing? If this is true then page templates | |
* that use slots that use this finder, or use snippets that display slots using this | |
* finder will always be published on incremental. In addition, parent items may be | |
* published on incremental. | |
* | |
* |true| if this slot contains data that changes from call to call and therefore always | |
* requires new publishing. | |
*/ | |
if (loadedFinder.getType().isMustIncrementallyPublish()) { | |
/** | |
* Finds zero or more node definitions that reference the supplied template guid. | |
* @type Iterator | |
*/ | |
Iterator currentTemplateNodeDefinitions = localIPSContentMgr.findNodeDefinitionsByTemplate(currentAssociatedTemplate.getGUID()).iterator(); | |
/** | |
* Iterate through template node definitions | |
*/ | |
while (currentTemplateNodeDefinitions.hasNext()) { | |
/** | |
* Initiate the current Node Definition | |
* @type IPSNodeDefinition | |
*/ | |
IPSNodeDefinition currentNodeDefinition = (IPSNodeDefinition)currentTemplateNodeDefinitions.next(); | |
/** | |
* Add node definition to locatedContentTypes | |
*/ | |
locatedContentTypes.add(currentNodeDefinition.getGUID()); | |
%> | |
<li> | |
<strong>ContentType:</strong> <%=currentNodeDefinition.getName()%> (<%=currentNodeDefinition.getGUID().getUUID()%>) | |
<ul> | |
<li><strong>Template:</strong> <%=currentAssociatedTemplate.getName()%> (<%=currentAssociatedTemplate.getGUID().getUUID()%>)</li> | |
<li><strong>Auto Slot:</strong> <%=currentRelatedSlot.getName()%> (<%=currentRelatedSlot.getGUID().getUUID()%>)</li> | |
</ul> | |
</li> | |
<% } | |
} | |
} | |
} catch (PSAssemblyException localPSAssemblyException) { | |
} | |
} | |
} | |
} catch (PSNotFoundException e){ | |
%> | |
Site ID:<%=siteID%> could not be loaded. | |
<% | |
} | |
} | |
%> | |
</ul> | |
</body> | |
</html> |
I would do a check on this page to make sure that only authorized people can view it...
IPSRequestContext reqCtx = (IPSRequestContext) request.getAttribute("RX_REQUEST_CONTEXT");
List userRoles = reqCtx.getSubjectRoles();
// make sure that the user is an Admin before proceeding with code (could be another role)
if (userRoles.contains("Admin")){
// do stuff here
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Imported libraries could be optimized.