Merge lp:~zorba-coders/zorba/bug-948879 into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Chris Hillery
Approved revision: 10755
Merged at revision: 10758
Proposed branch: lp:~zorba-coders/zorba/bug-948879
Merge into: lp:zorba
Diff against target: 188 lines (+110/-0)
6 files modified
ChangeLog (+1/-0)
include/zorba/static_context.h (+32/-0)
include/zorba/xmldatamanager.h (+2/-0)
src/api/staticcontextimpl.cpp (+46/-0)
src/api/staticcontextimpl.h (+6/-0)
test/unit/static_context.cpp (+23/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-948879
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Matthias Brantner Approve
Review via email: mp+101874@code.launchpad.net

This proposal supersedes a proposal from 2012-04-12.

Commit message

fix for bug #948879 (--uri-path doesn't work with fetch:content())

Description of the change

fix for bug #948879 (--uri-path doesn't work with fetch:content())

Deprecated the C++ API's XmlDataManager::fetch function and replaced it with two StaticContext::fetch functions.

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job bug-948879-2012-04-12T10-16-01.483Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

To maintain ABI compatibility, new virtual functions in the public API need to be added at the end of the class definition. At least, that is what I've been led to believe. Not sure if we're caring about ABI compat yet, but we might as well get into the habit.

review: Needs Fixing
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-948879-2012-04-13T09-21-02.501Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-948879-2012-04-13T11-04-00.667Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-04-12 09:32:55 +0000
3+++ ChangeLog 2012-04-13 09:13:22 +0000
4@@ -11,6 +11,7 @@
5 * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
6 * Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
7 * Fixed bug #967864 (var substitution did not update theFreeVars property)
8+ * Fixed bug #948879 (--uri-path doesn't work with fetch:content())
9 * Fixed bug in window iterator (binding the end vars in the output tuple stream)
10 * Fixed bug #866547 (protect index-join rule from general flwor)
11 * Fixed bug #967428 (do not hoist index creation outside a try-catch)
12
13=== modified file 'include/zorba/static_context.h'
14--- include/zorba/static_context.h 2012-03-28 05:19:57 +0000
15+++ include/zorba/static_context.h 2012-04-13 09:13:22 +0000
16@@ -685,6 +685,38 @@
17 */
18 virtual void
19 getFullLibPath(std::vector<String>& aLibPath) const = 0;
20+
21+ /** \brief Fetches an resource refered to by the given URI.
22+ *
23+ * Resolution is done using the URI mappers and resolvers registered
24+ * in this static context. If no such mappers or resolvers have been
25+ * registered, the built-in ones are used.
26+ *
27+ * The default EntityKind for resources fetched by this function
28+ * is "SOME_CONTENT".
29+ *
30+ * @param aURI the name of the resource to fetch
31+ *
32+ * @return the fetched resource
33+ */
34+ virtual Item
35+ fetch(const String& aURI) const = 0;
36+
37+ /** \brief Fetches an resource refered to by the given URI.
38+ *
39+ * Resolution is done using the URI mappers and resolvers registered
40+ * in this static context. If no such mappers or resolvers have been
41+ * registered, the built-in ones are used.
42+ *
43+ * @param aURI the name of the resource to fetch
44+ *
45+ * @param aEntityKind the kind of the entity to fetch (i.e.
46+ * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
47+ *
48+ * @return the fetched resource
49+ */
50+ virtual Item
51+ fetch(const String& aURI, const String& aEntityKind) const = 0;
52 };
53
54 } /* namespace zorba */
55
56=== modified file 'include/zorba/xmldatamanager.h'
57--- include/zorba/xmldatamanager.h 2012-03-28 05:19:57 +0000
58+++ include/zorba/xmldatamanager.h 2012-04-13 09:13:22 +0000
59@@ -187,6 +187,8 @@
60 ParseOptions& aOptions) const = 0;
61
62 /** \brief Fetches an resource refered to by the given URI.
63+ *
64+ * @deprecated this function has been replaced by StaticContext::fetch.
65 */
66 virtual Item
67 fetch(const String& aURI) const = 0;
68
69=== modified file 'src/api/staticcontextimpl.cpp'
70--- src/api/staticcontextimpl.cpp 2012-03-28 05:19:57 +0000
71+++ src/api/staticcontextimpl.cpp 2012-04-13 09:13:22 +0000
72@@ -25,6 +25,7 @@
73 #include <zorba/typeident.h>
74 #include <zorba/util/path.h>
75 #include <zorba/empty_sequence.h>
76+#include <zorba/singleton_item_sequence.h>
77
78 #include "store/api/item_factory.h"
79 #include "store/api/temp_seq.h"
80@@ -1539,5 +1540,50 @@
81 ZORBA_CATCH
82 }
83
84+Item
85+StaticContextImpl::fetch(const String& aURI) const
86+{
87+ return fetch(aURI, "SOME_CONTENT");
88+}
89+
90+Item
91+StaticContextImpl::fetch(
92+ const String& aURI,
93+ const String& aEntityKind) const
94+{
95+ ZORBA_TRY
96+ {
97+ Zorba* lZorba = Zorba::getInstance(0);
98+ ItemFactory* lFactory = lZorba->getItemFactory();
99+
100+ Item lQName = lFactory->createQName(static_context::ZORBA_FETCH_FN_NS,
101+ "content");
102+
103+ // create a streamable string item
104+ std::vector<ItemSequence_t> lArgs;
105+ lArgs.push_back(new SingletonItemSequence(lFactory->createString(aURI)));
106+ lArgs.push_back(
107+ new SingletonItemSequence(lFactory->createString(aEntityKind)));
108+
109+ StaticContext_t lCtx = createChildContext();
110+
111+ Zorba_CompilerHints_t lHints;
112+ std::ostringstream lProlog;
113+ lProlog
114+ << "import module namespace d = '" << static_context::ZORBA_FETCH_FN_NS << "';";
115+
116+ lCtx->loadProlog(lProlog.str(), lHints);
117+
118+ ItemSequence_t lSeq = lCtx->invoke(lQName, lArgs);
119+ Iterator_t lIter = lSeq->getIterator();
120+ lIter->open();
121+ Item lRes;
122+ lIter->next(lRes);
123+ return lRes;
124+ }
125+ ZORBA_CATCH
126+ return 0;
127+}
128+
129 } /* namespace zorba */
130 /* vim:set et sw=2 ts=2: */
131
132=== modified file 'src/api/staticcontextimpl.h'
133--- src/api/staticcontextimpl.h 2012-03-28 05:19:57 +0000
134+++ src/api/staticcontextimpl.h 2012-04-13 09:13:22 +0000
135@@ -281,6 +281,12 @@
136 virtual void
137 getFullLibPath(std::vector<String>& aLibPath) const;
138
139+ virtual Item
140+ fetch(const String& aURI) const;
141+
142+ virtual Item
143+ fetch(const String& aURI, const String& aEntityKind) const;
144+
145 protected:
146 String
147 createInvokeQuery(const Function_t&, size_t aArity) const;
148
149=== modified file 'test/unit/static_context.cpp'
150--- test/unit/static_context.cpp 2012-01-17 19:07:24 +0000
151+++ test/unit/static_context.cpp 2012-04-13 09:13:22 +0000
152@@ -60,6 +60,26 @@
153 return lFooFound && lBindings.size() == 6;
154 }
155
156+bool
157+sctx_test_2(Zorba* const zorba)
158+{
159+ StaticContext_t lSctx = zorba->createStaticContext();
160+
161+ Zorba_CompilerHints_t lHints;
162+
163+ try
164+ {
165+ Item lFetched = lSctx->fetch("http://www.zorba-xquery.com/modules/fetch", "MODULE");
166+
167+ return !lFetched.isNull();
168+ }
169+ catch (ZorbaException& e)
170+ {
171+ std::cerr << e << std::endl;
172+ }
173+ return false;
174+}
175+
176 int static_context( int argc, char *argv[] ) {
177 void *const zstore = StoreManager::getStore();
178 Zorba *const zorba = Zorba::getInstance( zstore );
179@@ -67,6 +87,9 @@
180 if (!sctx_test_1(zorba))
181 return 1;
182
183+ if (!sctx_test_2(zorba))
184+ return 2;
185+
186 zorba->shutdown();
187 StoreManager::shutdownStore( zstore );
188 return 0;

Subscribers

People subscribed via source and target branches