Skip to content

Commit

Permalink
Merge branch 'master' of github.com:proycon/clam
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Apr 5, 2018
2 parents 7c534b1 + 76b7e3c commit d03b17c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 34 deletions.
4 changes: 4 additions & 0 deletions clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,8 @@ def xml(self, indent = ""):
xml +=" filename=\""+clam.common.util.xmlescape(self.filename)+"\""
if self.extension:
xml +=" extension=\""+clam.common.util.xmlescape(self.extension)+"\""
if self.parent:
xml +=" parent=\""+clam.common.util.xmlescape(self.parent)+"\""
if self.unique:
xml +=" unique=\"yes\""
else:
Expand Down Expand Up @@ -1821,6 +1823,8 @@ def fromxml(node):
kwargs['extension'] = node.attrib['extension']
if 'unique' in node.attrib:
kwargs['unique'] = node.attrib['unique'].lower() == 'yes' or node.attrib['unique'].lower() == 'true' or node.attrib['unique'].lower() == '1'
if 'parent' in node.attrib:
kwargs['parent'] = node.attrib['parent']

#find formatclass
formatcls = None
Expand Down
85 changes: 51 additions & 34 deletions clam/static/info.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@
</li>
<li><strong>Upload one or more files</strong> - Issue a <tt>HTTP POST</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/input/<em>{filename}</em></tt>. The POST request takes the following parameters:
<ul>
<li><tt>inputtemplate</tt> - The input template for this upload, determines the type of file that is expected. The <em><xsl:value-of select="@name"/></em> webservice defines the following Input Templates:
<ul>
<xsl:for-each select="//InputTemplate">
<li><tt>inputtemplate=<xsl:value-of select="@id" /></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). If you use this input template you can specify the following extra parameters:
<ul>
<xsl:apply-templates />
</ul>
</li>
</xsl:for-each>
</ul>
<li><tt>inputtemplate</tt> - The input template for this upload, determines the type of file that is expected. The <em><xsl:value-of select="@name"/></em> webservice defines the following Input Templates (grouped per profile):
<ol>
<xsl:for-each select="//profile">
<li>Profile #<xsl:value-of select="position()" /><ul>
<xsl:for-each select=".//InputTemplate">
<li><tt>inputtemplate=<span style="color: blue"><xsl:value-of select="@id" /></span></tt> - <strong><xsl:value-of select="@label" /> (<em><xsl:value-of select="@format" /></em>)</strong>. <xsl:if test=".//*/@id">If you use this input template you can specify the following extra parameters:
<ul>
<xsl:apply-templates />
</ul>
</xsl:if></li>
</xsl:for-each>
</ul></li>
</xsl:for-each>
</ol>
</li>
<li><tt>file</tt> - HTTP file data.</li>
<li><tt>contents</tt> - full string contents of the file (can be used as an alternative to of file)</li>
Expand All @@ -71,10 +75,13 @@
Curl example: <tt>curl <xsl:call-template name="curlauth" /> -v -F "inputtemplate=<em>$inputtemplate</em>" -F "file=@<em>/path/to/file</em>" <xsl:value-of select="@baseurl"/>/<em>$yourprojectname</em>/input/<em>$filename</em></tt> (further parameters are passed similarly with -F)
</li>

<li><strong>Start project execution with specified parameters</strong> - Issue a <tt>HTTP POST</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/</tt>. The POST request takes the following parameters:
<li><strong>Start project execution with specified parameters</strong> - Issue a <tt>HTTP POST</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/</tt>. <xsl:if test=".//parametergroup/*/@id">The POST request takes the following parameters:
<ul>
<xsl:apply-templates />
<xsl:for-each select="//parametergroup">
<xsl:apply-templates />
</xsl:for-each>
</ul>
</xsl:if>
<br /><em>Responses:</em>
<ul>
<li>Will respond with <tt>HTTP 202 Accepted</tt> if successful, and returns the CLAM XML for the project's current state.</li>
Expand All @@ -98,12 +105,16 @@
</ul><br/>
Curl example (getting project state only, no intepretation): <tt>curl <xsl:call-template name="curlauth" /> -v -X GET <xsl:value-of select="@baseurl"/>/<em>$yourprojectname</em></tt>
</li>
<li><strong>Retrieve the desired output file(s)</strong> - Issue a <tt>HTTP GET</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/output/<em>{outputfilename}</em></tt>. A list of available output files can be obtained by querying the project's state (HTTP GET on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/</tt>) and iterating over <tt>/CLAM/output/file/name</tt> (XPath). A <tt>template</tt> attribute will be available on these nodes indicating what output template was responsible for generating this file. The following output templates are defined for this webservice:
<ul>
<xsl:for-each select="//OutputTemplate">
<li><tt><xsl:value-of select="@id" /></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). </li>
</xsl:for-each>
</ul>
<li><strong>Retrieve the desired output file(s)</strong> - Issue a <tt>HTTP GET</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/output/<em>{outputfilename}</em></tt>. A list of available output files can be obtained by querying the project's state (HTTP GET on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/</tt>) and iterating over <tt>/CLAM/output/file/name</tt> (XPath). A <tt>template</tt> attribute will be available on these nodes indicating what output template was responsible for generating this file. The following output templates are defined for this webservice (grouped per profile):
<ol>
<xsl:for-each select="//profile">
<li>Profile #<xsl:value-of select="position()" /><ul>
<xsl:for-each select=".//OutputTemplate">
<li><tt><xsl:value-of select="@id" /></tt> - <strong><xsl:value-of select="@label" /> (<em><xsl:value-of select="@format" /></em>)</strong>. <xsl:if test="@parent">[from input template <tt><xsl:value-of select="@parent" /></tt>]</xsl:if></li>
</xsl:for-each>
</ul></li>
</xsl:for-each>
</ol>
<br /><em>Responses:</em>
<ul>
<li>Will respond with <tt>HTTP 200 OK</tt> if successful, and returns the content of the file (along with the correct mime-type for it)</li>
Expand Down Expand Up @@ -136,23 +147,29 @@
<li><tt>project</tt> -- The name of the project, it will be created if it does not exist yet. Set the value to <em>new</em> if you want CLAM to create a random project name for you.</li>
</ul>

<p>The shortcut allows for the adding of files, use the following parameters:</p>

<ul>
<xsl:for-each select="//InputTemplate">
<li><strong><xsl:value-of select="@label" /></strong><xsl:text> </xsl:text><em>(<xsl:value-of select="@format" />)</em>:
<ul>
<li><tt><xsl:value-of select="@id" /></tt> -- The contents of a file for this input template (corresponds to <tt>contents</tt> in the non-shortcut method).</li>
<li><tt><xsl:value-of select="@id" />_url</tt> -- A URL from which to download the file for this input template (corresponds to <tt>url</tt> in the non-shortcut method).</li>
<li><tt><xsl:value-of select="@id" />_filename</tt> -- The desired filename for the added file (corresponds to (<tt>filename</tt> in the non-shortcut method). Will be automatically generated when not provided and if possible.</li>
<li>You can use any of the following parameters, but <strong>prepended with </strong> <tt><xsl:value-of select="@id" />_</tt>
<ul>
<xsl:apply-templates />
</ul>
</li>
</ul></li>
<p>The shortcut allows for the adding of files, use the following parameters (grouped per profile):</p>

<ol>
<xsl:for-each select="//profile">
<li>Profile #<xsl:value-of select="position()" />
<ul>
<xsl:for-each select=".//InputTemplate">
<li><strong><xsl:value-of select="@label" /></strong><xsl:text> </xsl:text><em>(<xsl:value-of select="@format" />)</em>:
<ul>
<li><tt><xsl:value-of select="@id" /></tt> -- The contents of a file for this input template (corresponds to <tt>contents</tt> in the non-shortcut method).</li>
<li><tt><xsl:value-of select="@id" />_url</tt> -- A URL from which to download the file for this input template (corresponds to <tt>url</tt> in the non-shortcut method).</li>
<li><tt><xsl:value-of select="@id" />_filename</tt> -- The desired filename for the added file (corresponds to (<tt>filename</tt> in the non-shortcut method). Will be automatically generated when not provided and if possible.</li>
<li>You can use any of the following parameters, but <strong>prepended with </strong> <tt><xsl:value-of select="@id" />_</tt>
<ul>
<xsl:apply-templates />
</ul>
</li>
</ul></li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each>
</ul>
</ol>

<p>To automatically start the system, pass the parameter <tt>start</tt> with value 1. By default, the system will not be started yet. You can pass any global parameters by ID.</p>

Expand Down
5 changes: 5 additions & 0 deletions docs/clam.rng
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ RelaxNG schema for CLAM XML
<attribute name="unique">
<a:documentation>Boolean value set to "true" or "false", determining whether this output template is unique and produces only one file, or whether multiple files can be produces using this input template</a:documentation>
</attribute>
</optional>
<optional>
<attribute name="parent">
<a:documentation>The ID of the inputtemplate that acts as the parent for this output template</a:documentation>
</attribute>
</optional>
<zeroOrMore>
<choice>
Expand Down

0 comments on commit d03b17c

Please sign in to comment.