Overpopulated publishing destinations, containing thousands of content items, can seriously slow down the GN4 system and cause various malfunctioning. The default configuration of the GN4 system does not provide for an automatic purge of publishing destinations.
Therefore, you need to provide for the automatic cleanup of publishing destinations.
This may be achieved by scheduling a batch command file that exports from publishing destinations only the content you want to keep, and then reimporting it, overwriting anything else.
Important: this procedure must run on a GN4 server!
What you need to install?
You need to copy on a GN4 server two files:
ClearPubDests.cmd
ClearPubDest.xml
Copy both files in the folder of your choice, e.g. C:\TERA\GN4\BIN.
Customize the ClearPubDests.cmd as explained below. Customize the ClearPubDest.xml as explained in the paragraph ClearPubDest.xml.
Then, schedule the ClearPubDests.cmd to run every night out of the production hours.
ClearPubDests.cmd
This is the batch command file that performs the content export, unlocking of the publishing destinations and reimporting the content. The below code shows an example of such file. The parts highlighted in yellow are to be customized.
@ECHO OFF
rem ---------------------------
rem THIS IS JUST AN EXAMPLE
rem CHANGE THE PATH TO THE CLEARPUBDEST.XML AND IDS OF THE PUBLISHING DESTINATIONS TO UNLOCK FORCIBLY
rem v1.0 on 7/july/2014 (MP)
rem -------------------------
SET GN4PATH=C:\TERA\GN4\BIN
%GN4PATH%\srv4.exe export -conditions gn4:pubDest -opt %GN4PATH%\ClearPubDest.xml -out c:\temp\pubDests.xml -pars DaysToKeep:45
%GN4PATH%\srv4.exe unlock -ids 100,200,300,400
%GN4PATH%\srv4.exe import -in c:\temp\pubDests.xml
SET GN4PATH=
Notes
•GN4PATH: the path on the server where are 64-bit GN4 executables.
•C:\TEMP\PUBDESTS.XML: the path to the temporary file. If you do not have TEMP under C: root, adjust the batch file accordingly.
•DaysToKeep: this applies on systems newer that 1.6, where you can pass the value as the parameter. For the 1.6 systems, the parameter is hard-coded in the XSL part of the ClearPubDest.xml. Search for DaysToKeep to locate it.
•100,200,300... etc: these are ids of the publishing destinations to unlock during this maintenance. Replace with the ids of your publishing destinations, comma delimited.
ClearPubDest.xml
This is the export option:
<?xml version="1.0" encoding="utf-8"?> <!--
v1.0 on 7/july/2014 (MP)
Export options used by cmd4 export srv4 export ../do.ashx?cmd=feed LoadObjects workflow activity
See http://tech.teradp.com/tech/html/gn4/docs/VSdoc/frlrfTeraDPGN4CommonXmlExportOptionsClassTopic.html for technical documentation
AccessStrict 'true' to make the export fail if any of the object attributes to be exported are not readable by the current user. If 'false' (the default) such attributes would not be exported and the export would fail only if ALL the attributes are not readable by the current user.
DataAsId 'true' to export binary data only as id 'false' by default - exports binary data as a complete element with size, MIME type and either URL or inline data
DataFiles True to extract as separate files the binary data that is not inserted directly in the XML. The corresponding URLs will point to the extracted file instead than back to the server. The files will be placed in the same directory of the output XML file. It does not apply when used in a workflow or a feed command 'false' by default
DataMaxSize Maximum size in bytes of the binary data to be inserted directly in the XML. Larger data is exported as URLs pointing back to the service or as separate files (see DataFiles above). If 0 all the data is exported as URL, if -1 all the data is inserted in the XML regardless of its size. Not used if DataAsId is true. Default value 100,000 bytes
Zip 'true' to create a single ZIP containing all the files (XML+data files) being exported. It doesn't apply to LoadObjects workflow activity Default: 'false'
ZipCompressionLevel Zip compression level (0 - store only to 9 - means best compression) Used only when Zip is 'true' (see above), and it doesn't apply to LoadObjects workflow activity. Default: 9
Encoding Character encoding of the output, it can be one of the encoding names listed at http://msdn.microsoft.com/en-us/library/system.text.encoding.getencodings.aspx#Y489 or one of those special values: UTF-8-NOBOM UTF-8 without the initial byte order mark UTF-16BE Big-endian UTF-16 (high-order byte first) UTF-16LE Little-endian UTF-16 (low-order byte first) UTF-16BE-NOBOM Big-endian UTF-16 without the initial byte order mark UTF-16LE-NOBOM Little-endian UTF-16 without the initial byte order mark UTF-32BE Big-endian UTF-32 UTF-32LE Little-endian UTF-32 UTF-32BE-NOBOM Big-endian UTF-32 without the initial byte order mark UTF-32LE-NOBOM Little-endian UTF-32 without the initial byte order mark Encoding names are case-insensitive. Meaningless when used in a workflow activity: the output is an in-memory XML and not a file with an encoding. Default value 'UTF-8'.
Indent Indentation of the XML output, possible values are: No No indentation Tab Indentation using a tab TabAttr Indentation using a tab and indenting also the attributes TwoSpaces Indentation using two spaces TwoSpacesAttr Indentation using two spaces and indenting also the attributes FourSpaces Indentation using four spaces FourSpacesAttr Indentation using four spaces and indenting also the attributes Meaningless when used in a workflow activity: the output is an in-memory XML, not a string or file with indentation. Default value 'No'
NewLine New line characters to use, possible values are: CR Single CR (code 13 - Mac) CRLF CR+LF pair (Windows) - the default LF Single LF (code 10 - Unix) Meaningless when used in a workflow activity: the output is an in-memory XML, not a string or file with multiple lines. Used only when Indentation is different than 'No' Default 'CRLF'
OmitXmlDeclaration 'true' to omit the inital XML declaration in the output Meaningless when used in a workflow activity: the output is an in-memory XML, not a string or file with an XML declaration. Default: 'false'
MimeType MIME type of the produced output. Used only by the do.ashx?cmd=feed command. Useful when generating special XML formats (like RSS) that have their own MIME type No default value. If not specified do.ashx?cmd=feed uses 'application/xml'.
MaxDepth Maximum depth of the XML representation of the objects being exported. It is used when generating a feed or by the LoadObjects command, not when exporting stand-alone objects. -1 = no limits (dangerous), 0 = generate stand-alone object XML, without navigation of the referenced objects. It is ignored if the options specify an XSL transformation to apply to the XML Default value 3
NavOptions Options controlling which extra information go in the XML. It is used when generating a feed or by the LoadObjects command, not when exporting stand-alone objects. See http://tech.teradp.com/tech/html/gn4/docs/VSdoc/frlrfTeraDPGN4GNClientDataNavigatorOptionClassTopic.html for a list of the available options. Multiple options can be combined, separated by comma (',') Default value 'Default'
OutputNulls If 'true' attributes that have the special 'null' value - i.e. that are not present in the object - are still exported, either as xsi:nil elements or as empty attributes Default: 'false'
RefKeys 'true' to export in the references to other objects (i.e. the values of reference, multi-reference and category attributes) also the key attribute(s) values of the referenced object, instead than just its database numeric id. Default: 'false'
XsltUrl URL or file name of the Xsl transformation to apply to the source. Used if an XSLT is not specified directly using the Xslt element. The referenced XSLT can use the semplified XSL syntax Use the special URL 'self://localhost/do.ashx?cmd=config&name=xsl_XXXXX' to get the XSL from the globl configuration named 'xsl_XXXXX' --> <XmlExportOptions xmlns="http://www.teradp.com/schemas/GN4/1/XmlExportOptions.xsd" Encoding="UTF-8" OmitXmlDeclaration="false" DataAsId="false" DataMaxSize="0" AccessStrict="false" OutputNulls="false" RefKeys="true"> <!-- List of counters to increment for each exported object
<Counters> <Name>GlobalImpressions</Name> </Counters> --> <!-- XSL transformation to apply to the source. If specified it has precedence over XsltUrl. Supports the semplified XSL syntax
<Xslt> <object xmlns="" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" type="{local-name()}" id="{@id}"> <xsl:if test="$pars and $pars/*/add[@key='test']"> <xsl:attribute name="testPar"> <xsl:value-of select="$pars/*/add[@key='test']/@value"/> </xsl:attribute> </xsl:if> </object> </Xslt> --> <Xslt> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nav="http://www.teradp.com/schemas/GN4/1/ObjNav.xsd" xmlns:lc="http://www.teradp.com/schemas/GN4/1/LoginContext.xsd" xmlns:oc="http://www.teradp.com/schemas/GN4/1/OperationContext.xsd" xmlns:fn="http://www.teradp.com/schemas/GN4/1/Xslt" xmlns:gn4="urn:schemas-teradp-com:gn4tera" exclude-result-prefixes="nav gn4 fn lc oc xsd xsi"> <xsl:output method="xml"/> <xsl:param name="context" /> <xsl:param name="pars" />
<!-- NOTE: in 1.6, we can't pass pars to the XSL, only to the GNQuery? Therefore, we remove all references to stories that have been published more than 30 days ago, with the 30 as hard-coded value --> <xsl:variable name="DaysToKeep"> <xsl:choose> <xsl:when test="$pars and $pars/*/add[@key='DaysToKeep']"><xsl:value-of select="$pars/*/add[@key='DaysToKeep']/@value"/></xsl:when> <xsl:otherwise>30</xsl:otherwise><!-- Number of days to keep, for published objects --> </xsl:choose> </xsl:variable>
<xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template>
<xsl:template match="objs|gn4:objs"> <xsl:copy> <xsl:apply-templates select="./ref|./gn4:ref" mode="objs"/> </xsl:copy> </xsl:template>
<xsl:template match="ref|gn4:ref" mode="objs"> <xsl:if test="fn:dateRange(gn4:pubTime,$context/oc:OperationContext/@Now,'days')<=$DaysToKeep"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:if> </xsl:template>
</xsl:stylesheet> </Xslt> <!-- Optional parameters passed to the XSL transformation They are merged with the parameters passed explicitely to cmd4, srv4, do.ashx?cmd=feed or the LoadObject activity
<Pars> <exportSettings xmlns=""> <add key="test" value="test parameter value"/> </exportSettings> </Pars> --> <Pars> </Pars> </XmlExportOptions>
|