source: cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_scope_update.acc @ 2686

Last change on this file since 2686 was 2686, checked in by mwindhouwer, 11 years ago

Fixed the throtteling:

  • all SQL request go through the ISOcat.database throttle (settings in the ISOcat config), also the indirect DBX ones
  • big (more then 100 DCs) DCS to DCIF go through the big-dcif throttle (hardcoded settings)
File size: 3.8 KB
Line 
1<accessor debug="false">
2        <name>ISOcat.access.data.dc.scope.update</name>
3        <descr>Update the scope of a DC.</descr>
4        <param mandatory="true">
5                <name>dc</name>
6                <descr>the DC key</descr>
7                <type canonical="true">string</type>
8        </param>
9        <param mandatory="true">
10                <name>scope</name>
11                <descr>the DC scope</descr>
12        </param>
13        <idoc>
14                <seq>
15                        <accessor-debug>
16                                <instr>
17                                        <type>ISOcat.access.data.dc.scope</type>
18                                        <dc>var:dc</dc>
19                                        <target>ffcpl:/trace/dc_scope_update.old.xml</target>
20                                </instr>
21                        </accessor-debug>
22                       
23                        <!-- create the SQL -->
24                        <instr>
25                                <type>xslt2</type>
26                                <operand>var:scope</operand>
27                                <operator>
28                                        <xsl:stylesheet
29                                                version="2.0"
30                                                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
31                                                >
32                                                <xsl:param name="dc"/>
33                                               
34                                                <xsl:template match="text()"/>
35                                               
36                                                <xsl:template match="/scope">
37                                                        <batch>
38                                                                <!-- delete the old scope -->
39                                                                <sql>
40                                                                        DELETE FROM
41                                                                                link_dc_access
42                                                                        WHERE
43                                                                                dc = <xsl:value-of select="$dc"/>
44                                                                        ;
45                                                                </sql>
46                                                                <!-- insert the new scope -->
47                                                                <xsl:for-each select="db/entry">
48                                                                        <sql>
49                                                                                INSERT INTO
50                                                                                        link_dc_access
51                                                                                (
52                                                                                        dc,
53                                                                                        account,
54                                                                                        rights
55                                                                                )
56                                                                                VALUES
57                                                                                (
58                                                                                        <xsl:value-of select="$dc"/>,
59                                                                                        <xsl:value-of select="@acc"/>,
60                                                                                        '<xsl:value-of select="@rights"/>'
61                                                                                )
62                                                                                ;
63                                                                        </sql>
64                                                                </xsl:for-each>
65                                                                <sql>
66                                                                        UPDATE
67                                                                                core_data_category
68                                                                        SET
69                                                                                private = <xsl:value-of select="if (public/@rights='r') then ('false') else ('true')"/>
70                                                                        WHERE
71                                                                                id = <xsl:value-of select="$dc"/>
72                                                                        ;
73                                                                </sql>
74                                                        </batch>
75                                                </xsl:template>
76                                        </xsl:stylesheet>
77                                </operator>
78                                <dc>var:dc</dc>
79                                <target>var:sql</target>
80                        </instr>
81                        <accessor-debug>
82                                <instr>
83                                        <type>copy</type>
84                                        <operand>var:sql</operand>
85                                        <target>ffcpl:/trace/dc_scope_update.sql.xml</target>
86                                </instr>
87                        </accessor-debug>
88                        <instr>
89                                <type>isocat.sqlBatch</type>
90                                <operand>var:sql</operand>
91                                <target>var:result</target>
92                        </instr>
93                        <accessor-debug>
94                                <instr>
95                                        <type>copy</type>
96                                        <operand>var:result</operand>
97                                        <target>ffcpl:/trace/dc_scope_update.result.xml</target>
98                                </instr>
99                        </accessor-debug>
100
101                        <!-- touch the updated DC -->
102                        <instr>
103                                <type>ISOcat.access.data.dc.touch</type>
104                                <dc>var:dc</dc>
105                                <target>var:void</target>
106                        </instr>
107                       
108                        <!-- return the updated DC scope -->
109                        <instr>
110                                <type>ISOcat.access.data.dc.scope</type>
111                                <dc>var:dc</dc>
112                                <target>this:response</target>
113                        </instr>
114                       
115                        <accessor-debug>
116                                <instr>
117                                        <type>ISOcat.access.data.dc.scope</type>
118                                        <dc>var:dc</dc>
119                                        <target>ffcpl:/trace/dc_scope_update.new.xml</target>
120                                </instr>
121                        </accessor-debug>
122                       
123                        <instr>
124                                <type>xslt2</type>
125                                <operand>this:response</operand>
126                                <operator>
127                                        <xsl:stylesheet
128                                                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
129                                                version="2.0"
130                                                >
131                                                <xsl:template match="/scope">
132                                                        <msg>INF: <xsl:value-of select="current-dateTime()"/>: update DC[<xsl:value-of select="@dc"/>][<xsl:value-of select="dc/@name"/> owned by <xsl:value-of select="dc/@owner"/>] scope shared[<xsl:value-of select="exists(shared/account)"/>] public[<xsl:value-of select="public/@rights='r'"/>]</msg>
133                                                </xsl:template>
134                                        </xsl:stylesheet>
135                                </operator>
136                                <target>var:msg</target>
137                        </instr>
138                        <instr>
139                                <type>sloot.log</type>
140                                <operand>var:msg</operand>
141                        </instr>
142                </seq>
143        </idoc>
144        <exception>
145                <debug/>
146                <trace>ffcpl:/trace/dc_scope_update.exception.xml</trace>
147                <throw/>
148        </exception>
149        <response>
150                <debug>ffcpl:/trace/dc_scope_update.response.xml</debug>
151                <mime>application/xml</mime>
152        </response>
153</accessor>
Note: See TracBrowser for help on using the repository browser.