SocialMiner Forums

« Back to Technical Discussion

Automatic reply: New Message from Rusheel Jain in Cisco SocialMiner - Techn

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hello,
We were working with groovy script in social miner and were trying to access a database for tagging. For this we were importing "groovy.sql.Sql". The script works fine when tested with Eclipse. But after deploying the script in SocialMiner we got an exception -
java.lang.SecurityException: Importing [groovy.sql.Sql] is not allowed.

So is importing this file not allowed ? Any alternatives regarding the same would be helpful.
Thanks !

Hi,
This is a valid security restriction for scripts run in SocialMiner.  SocialMIner imposes some security restrictions on script code to ensure the security and integrity the system and the data. There are imports that cannot be used or objects of some types that cannot be created when script is executed in SocialMIner. In Developers Guide there is the whole section “Script Security” that describes in great details the same topic. Please refer to it for the list of allowed imports.
I am not completely sure what the script is trying to do, but there are script bindings available , that is basically objects that can be passed to  SocialMiner script engine to access and modify  (described in Script bindings chapter if the doc mentioned above).
Access to SM configuration db is not allowed but if you are trying to access some external db, it may be possible to use rest calls instead to obtain the same data from the application layer. RestClient is  the object allowed to use in SM scripts.
Thank you ,
Tanya

RE: Groovy Script
Answer
10/4/12 7:27 AM as a reply to Tetyana Shmukler.
 


Hi,
 
Thanks for your reply! Our script right now is just fetching some data from sql server 2008. The code is like this- 
 
import groovy.sql.Sql
 
sql = Sql.newInstance(
                           "jdbc:sqlserver://192.168.1.xx;databaseName=abcd;user=username;password=pass",       
                                    “username",
                                    “password"
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)
 
  sql.eachRow('Select * from tablename') 
  {
   var = it.fieldname
   i = i+1
  }
 
I went through the SocialMiner API, which says that certain SQL commands were not allowed. So are such queries allowed ?
because it seems a very basic SQL query where i am fetching data from some table and nothing else.
 
Thanks


 

I am out office with limited access to email Oct 2 to 4. During this time my responses will be deplayed. Thanks

Rusheel Jain:


 
Hi,
As Tetyana had mentioned you, In groovy script you can use the rest object to either invoke an external webservice or a web application where to do whatever you want.
Here is what we do to invoke an URL passing parameters. I hope this would help you.
Regards.

import groovyx.net.http.HttpResponseDecorator

HttpResponseDecorator resp = restClient.get(
        uri: "http://172.17.56.130:8090/web_get_groovy/Process",
        query : [
            title :             socialContact.getProperties().get("title") != null ? socialContact.getProperties().get("title").toString() : "null",
            link :                socialContact.getProperties().get("link") != null ? socialContact.getProperties().get("link").toString() : "null",
            author :            socialContact.getProperties().get("author") != null ? socialContact.getProperties().get("author").toString() : "null", 
            publishedDate :        socialContact.getProperties().get("publishedDate") != null ? socialContact.getProperties().get("publishedDate").toString() : "null", 
            categories :        socialContact.getProperties().get("categories") != null ? socialContact.getProperties().get("categories").toString() : "null",
            tags :                socialContact.getProperties().get("tags") != null ? socialContact.getProperties().get("tags").toString() : "null",
            description :        socialContact.getProperties().get("description") != null ? socialContact.getProperties().get("description").toString() : "null",
            sourceLink :        socialContact.getProperties().get("sourceLink") != null ? socialContact.getProperties().get("sourceLink").toString() : "null",
            ID_PUBLICACION:     "2.1"
        ]);
if (resp.isSuccess()) {
    log "ResponseFromPSO:" + resp.dump()
} else {
    log "NO_ResponseFromPSO" + resp.dump()
}
 
Hi,
 
Thanks for your reply! Our script right now is just fetching some data from sql server 2008. The code is like this- 
 
import groovy.sql.Sql
 
sql = Sql.newInstance(
                           "jdbc:sqlserver://192.168.1.xx;databaseName=abcd;user=username;password=pass",       
                                    “username",
                                    “password"
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)
 
  sql.eachRow('Select * from tablename') 
  {
   var = it.fieldname
   i = i+1
  }
 
I went through the SocialMiner API, which says that certain SQL commands were not allowed. So are such queries allowed ?
because it seems a very basic SQL query where i am fetching data from some table and nothing else.
 
Thanks

 

Hi,
unfortunately script security will not let to query even 3d party database from inside the SocialMiner script. The script filter is to allow users to create custom scripts within acceptable boundaries defined by Cisco , SocialMiner.
It is not that the particular query is not allowed. What is not allowed is to use groovy sql package in general.
Thank you,
Tanya
<!--[if gte mso 9]><xml>
<w:WordDocument>
<wemoticoniew>Normal</wemoticoniew>
<w:Zoom>0</w:Zoom>
<w:TrackMoves />
<w:TrackFormatting />
<wemoticonunctuationKerning />
<wemoticonalidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<wemoticonoNotPromoteQF />
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables />
<w:SnapToGridInCell />
<w:WrapTextWithPunct />
<w:UseAsianBreakRules />
<wemoticonontGrowAutofit />
<w:SplitPgBreakAndParaMark />
<wemoticonontVertAlignCellWithSp />
<wemoticonontBreakConstrainedForcedTables />
<wemoticonontVertAlignInTxbx />
<w:Word11KerningPairs />
<w:CachedColBalance />
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math" />
<m:brkBin m:val="before" />
<m:brkBinSub m:val="&#45;-" />
<m:smallFrac m:val="off" />
<m:dispDef />
<m:lMargin m:val="0" />
<m:rMargin m:val="0" />
<m:defJc m:val="centerGroup" />
<m:wrapIndent m:val="1440" />
<m:intLim m:val="subSup" />
<m:naryLim m:val="undOvr" />
</m:mathPr></w:WordDocument>
</xml><!-->
<!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal" />
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" />
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" />
<w:LsdException Locked="false" Priority="39" Name="toc 1" />
<w:LsdException Locked="false" Priority="39" Name="toc 2" />
<w:LsdException Locked="false" Priority="39" Name="toc 3" />
<w:LsdException Locked="false" Priority="39" Name="toc 4" />
<w:LsdException Locked="false" Priority="39" Name="toc 5" />
<w:LsdException Locked="false" Priority="39" Name="toc 6" />
<w:LsdException Locked="false" Priority="39" Name="toc 7" />
<w:LsdException Locked="false" Priority="39" Name="toc 8" />
<w:LsdException Locked="false" Priority="39" Name="toc 9" />
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" />
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title" />
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" />
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle" />
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong" />
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis" />
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid" />
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" />
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1" />
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" />
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" />
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote" />
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5" />
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6" />
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6" />
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6" />
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" />
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" />
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6" />
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6" />
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" />
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" />
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" />
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6" />
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6" />
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6" />
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" />
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" />
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" />
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" />
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title" />
<w:LsdException Locked="false" Priority="37" Name="Bibliography" />
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" />
</w:LatentStyles>
</xml><!--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style>
<!-->The script filter is to allow users to create
custom scripts within acceptable boundaries defined by Cisco
Rusheel Jain:
 


Hi,
 
Thanks for your reply! Our script right now is just fetching some data from sql server 2008. The code is like this- 
 
import groovy.sql.Sql
 
sql = Sql.newInstance(
                           "jdbc:sqlserver://192.168.1.xx;databaseName=abcd;user=username;password=pass",       
                                    “username",
                                    “password"
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)
 
  sql.eachRow('Select * from tablename') 
  {
   var = it.fieldname
   i = i+1
  }
 
I went through the SocialMiner API, which says that certain SQL commands were not allowed. So are such queries allowed ?
because it seems a very basic SQL query where i am fetching data from some table and nothing else.
 
Thanks


 

RE: Groovy Script
Answer
10/5/12 12:50 PM as a reply to Tetyana Shmukler.
Hi
 
Thanks for the reply. Since the Sql package is not allowed, we were looking for alternatives. We were thinking of creating a Webservice using c# and then accessing the data using SOAP client in the groovy script. Any idea if that would be allowed or would we face similar restrictions again ?
 
Thanks

Hi,
Unfortunately SOAP client in groovy will not work either, because the corresponding import is not on a white list. You can find the complete list of imports that allowed in SocialMinder documentation that pointed earlier.
If you develop REST web services instead of SOAP, then you can use it. SocialMiner script even provides built-in rest client for it and script examples on how to use it.
Hope this helps.

Thanks,
Tanya

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, October 05, 2012 8:50 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Rusheel Jain in Cisco SocialMiner - Technical Discussion: RE: Groovy Script

Rusheel Jain has created a new message in the forum "Technical Discussion": -------------------------------------------------------------- Hi

Thanks for the reply. Since the Sql package is not allowed, we were looking for alternatives. We were thinking of creating a Webservice using c# and then accessing the data using SOAP client in the groovy script. Any idea if that would be allowed or would we face similar restrictions again ?

Thanks
--
To respond to this post, please click the following link: http://developer.cisco.com/web/socialminer/forums/-/message_boards/view_message/7370197 or simply reply to this email.

RE: Groovy Script
Answer
10/9/12 12:32 PM as a reply to Tetyana Shmukler.
Hi !
As you suggested we had built REST based web service for extracting data from the database and a groovy script for accessing the web service and reading the data. The script seems fine but due to these imports
 
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
 
 we got an "Invalid Input" error. I've read the Social Miner API, it says that RESTClient is allowed. So any idea about the error and why exactly are these import causing the problem.

 
Thanks

Thank you for your email. I am currently out of the office on PTO with limited access to e-mail and voicemail. I will respond when I return on Tuesday, June 9th.

I am on PTO from 10/8/2012 to 10/11/2012. For Contact Contact Center opportunities in GET please contact Joe Cusack. And for service related issues please contact Cisco TAC at 1-800-553-2447.

Hi,
SocialMiner groovy script engine already provides an embedded restClient object that you can just use in your script without any additional imports.
Please refer to the example below -- no imports needed in order to use restCLient to call REST GET on it.
Thanks,
Tanya
================================================
def KLOUT_KEY = "w34xzr2vqbsg5aye7wj5w2fu";

log "New version - 2, klout key is ${KLOUT_KEY}"

restClient.setProxy("161.44.248.59", 80, null);

String user = socialContact.getAuthor();
int space = user.indexOf(' ');
if (space != -1)
user = user.substring(0, space);

log "user = " + user;

def resp = restClient.get( uri: "http://api.klout.com/1/klout.xml", query : [key: KLOUT_KEY, users: user]);
if (!resp.isSuccess()) {
log ("Request Failed");
}
else {
log "Influence: " + resp.data.user.kscore;
boolean influential = (Double.parseDouble(resp.data.user.kscore as String) > 20.0);
log "User is influential" + influential;
if (influential){
def tags = socialContact.getSocialContactTags();
tags += "influential" as String;
log "New tags: " + tags;
socialContact.setSocialContactTags(tags as SortedSet, null);
datastore.update(socialContact);
}
return influential?100:0;
}

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Tuesday, October 09, 2012 8:32 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Rusheel Jain in Cisco SocialMiner - Technical Discussion: RE: Groovy Script

Rusheel Jain has created a new message in the forum "Technical Discussion": -------------------------------------------------------------- Hi !
As you suggested we had built REST based web service for extracting data from the database and a groovy script for accessing the web service and reading the data. The script seems fine but due to these imports

import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient

we got an "Invalid Input" error. I've read the Social Miner API, it says that RESTClient is allowed. So any idea about the error and why exactly are these import causing the problem.


Thanks
--
To respond to this post, please click the following link: http://developer.cisco.com/web/socialminer/forums/-/message_boards/view_message/7446413 or simply reply to this email.

RE: Groovy Script
Answer
10/10/12 12:22 PM as a reply to Tetyana Shmukler.
We followed the example and built a simple program using RESTClient as u said but i'm still having this error
 
"The following fields are invalid:
Script Source: Invalid input"
 
i removed both the imports and it seems that as soon as the statment below is added, the above mentioned error comes up
 
def http = new RESTClient('http://.... URL for Webservice....')
 
On removing this line of code, the script works fine. We have tested the script outside socialminer and it works fine. According to troubleshooting documents the error is generally caused by the file being saved in Rich text format but we are sure that it is not the case here as we have written the script in Eclipse IDE. So any idea about what is causing this error ?
 
Thanks !

Hi,
As you can see from the script example provided before, there is no need to create a new RestClient “normal way”, but instead you need to use SocialMiner “embedded” restClient. No imports need to be added to use it. Think about it as already initialized object that always exists in any SM script and you can just use it.
Usage example:
def resp = restClient.get( uri: "http://api.klout.com/1/klout.xml", query : [key: KLOUT_KEY, users: user]);
It is also true that you would not be able to run the script with restClient as is outside SocialMiner. While testing it, you can use restClient the way you did /showed earlier, but it should be replaced with the “embedded” one and all the corresponding imports removed, before importing the script into SocialMiner.

Thanks,
Tanya

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Wednesday, October 10, 2012 8:22 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Rusheel Jain in Cisco SocialMiner - Technical Discussion: RE: Groovy Script

Rusheel Jain has created a new message in the forum "Technical Discussion": -------------------------------------------------------------- We followed the example and built a simple program using RESTClient as u said but i'm still having this error

"The following fields are invalid:
Script Source: Invalid input"

i removed both the imports and it seems that as soon as the statment below is added, the above mentioned error comes up

def http = new RESTClient('http://.... URL for Webservice....')

On removing this line of code, the script works fine. We have tested the script outside socialminer and it works fine. According to troubleshooting documents the error is generally caused by the file being saved in Rich text format but we are sure that it is not the case here as we have written the script in Eclipse IDE. So any idea about what is causing this error ?

Thanks !
--
To respond to this post, please click the following link: http://developer.cisco.com/web/socialminer/forums/-/message_boards/view_message/7489304 or simply reply to this email.

RE: Groovy Script
Answer
10/11/12 1:00 PM as a reply to Tetyana Shmukler.
Thanks a lot emoticon
It worked !!!
thanks

Search CDN

 Go

By API/SDK: