Browse Source

Fix gh-#2071 DFS exception when View Data File

When ldap is turned on and a user trys to view a data file,
the DFS exception '3 Lookup access denied for scope' shows.
The exception is thrown by the ViewFileWeb object when it
does a file look-up. Since the data file has been resolved
by WsDFU service, WsDFU service should pass the solved file
point to ViewFileWeb object and the ViewFileWeb may use the
point without doing the file loop-up. This fix adds a
method to the ViewFileWeb class. The method allows the
solved file point being given to the ViewFileWeb.

I also revise the code in WsDFU service for better
functionalities.

Signed-off-by: Kevin Wang <kevin.wang@lexisnexis.com>
Kevin Wang 13 years ago
parent
commit
741ba5fa06

+ 14 - 0
common/fileview2/fvrelate.cpp

@@ -361,6 +361,20 @@ void ViewFileWeb::gatherWeb(const char * rootFilename, const ViewGatherOptions &
 }
 
 
+void ViewFileWeb::gatherWeb(const char * rootFilename, IDistributedFile * alreadyResolved, const ViewGatherOptions & options)
+{
+    ViewWalkOptions localOptions(options);
+    if (!localOptions.kind)
+        localOptions.kind = S_LINK_RELATIONSHIP_KIND;
+    localOptions.isExplicitFile = true;
+
+    if (!walkFile(rootFilename, alreadyResolved, localOptions))
+        throwError1(FVERR_CouldNotResolveX, rootFilename);
+
+    //MORE: Should possibly percolate relations between superfiles down to files they contain.
+}
+
+
 void ViewFileWeb::gatherWebFromPattern(const char * filenamePattern, const ViewGatherOptions & options)
 {
     ViewWalkOptions localOptions(options);

+ 1 - 0
common/fileview2/fvrelate.hpp

@@ -102,6 +102,7 @@ interface IViewFileWeb : public IInterface
 {
 public:
     virtual void gatherWeb(const char * rootFilename, const ViewGatherOptions & options) = 0;
+    virtual void gatherWeb(const char * rootFilename, IDistributedFile * alreadyResolved, const ViewGatherOptions & options) = 0;
     virtual void gatherWebFromPattern(const char * pattern, const ViewGatherOptions & options) = 0;
     virtual IViewRelatedFile * queryFile(unsigned i) = 0;
     virtual IViewRelatedFileIterator * getFileIterator() = 0;

+ 1 - 0
common/fileview2/fvrelate.ipp

@@ -197,6 +197,7 @@ public:
     IMPLEMENT_IINTERFACE
 
     virtual void gatherWeb(const char * rootFilename, const ViewGatherOptions & options);
+    virtual void gatherWeb(const char * rootFilename, IDistributedFile * alreadyResolved, const ViewGatherOptions & options);
     virtual void gatherWebFromPattern(const char * filenamePattern, const ViewGatherOptions & options);
     virtual IViewRelatedFileIterator * getFileIterator();
     virtual IViewRelatedFile * queryFile(unsigned i);

+ 31 - 33
esp/services/ws_dfu/ws_dfuService.cpp

@@ -5084,48 +5084,46 @@ int CWsDfuEx::GetIndexData(IEspContext &context, bool bSchemaOnly, const char* i
     StringBuffer cluster;
     Owned<IUserDescriptor> userdesc;
     bool disableUppercaseTranslation = false;
+    Owned<IDistributedFile> df;
     try
     {
         userdesc.setown(createUserDescriptor());
         userdesc->set(username.str(), passwd);
-        Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(indexName, userdesc);
-        if(df)
-        {
-            //Check disableUppercaseTranslation
-            bool bFound = false;
-            StringBuffer mapping;
-            df->getColumnMapping(mapping);
-            if (mapping.length() > 37 && strstr(mapping.str(), "word{set(stringlib.StringToLowerCase)}")) 
-            {
-                bFound = true;
-                disableUppercaseTranslation = true;
-            }
-
-            //if no index flag, use the flag inside esp config
-            if (!bFound)
-            {
-                disableUppercaseTranslation = m_disableUppercaseTranslation;
-                if (webDisableUppercaseTranslation)
-                {
-                    disableUppercaseTranslation = webDisableUppercaseTranslation;
-                }
-            }
+        df.setown(queryDistributedFileDirectory().lookup(indexName, userdesc));
+        if(!df)
+            throw MakeStringException(ECLWATCH_FILE_NOT_EXIST,"Could not find file %s.", indexName);
+
+        //Check disableUppercaseTranslation
+        StringBuffer mapping;
+        df->getColumnMapping(mapping);
+        if (mapping.length() > 37 && strstr(mapping.str(), "word{set(stringlib.StringToLowerCase)}"))
+            disableUppercaseTranslation = true;
+        else if (webDisableUppercaseTranslation)
+            disableUppercaseTranslation = webDisableUppercaseTranslation;
+        else
+            disableUppercaseTranslation = m_disableUppercaseTranslation;
 
-            const char* wuid = df->queryAttributes().queryProp("@workunit");
-            if (wuid && *wuid)
+        const char* wuid = df->queryAttributes().queryProp("@workunit");
+        if (wuid && *wuid)
+        {
+            CWUWrapper wu(wuid, context);
+            if (wu)
             {
-                CWUWrapper wu(wuid, context);
-                if (wu)
-                {   
-                    SCMStringBuffer cluster0;
-                    cluster.append(wu->getClusterName(cluster0).str());
-                }
+                SCMStringBuffer cluster0;
+                cluster.append(wu->getClusterName(cluster0).str());
             }
         }
     }
+    catch (IException *e)
+    {
+        DBGLOG(e);
+        e->Release();
+    }
     catch(...)
     {
-        ;
+        StringBuffer msg;
+        msg.appendf("Unknown Exception - view data file: %s", indexName);
+        DBGLOG(msg.str());
     }
 
     Owned<IResultSetFactory> resultSetFactory;
@@ -5158,7 +5156,7 @@ int CWsDfuEx::GetIndexData(IEspContext &context, bool bSchemaOnly, const char* i
     Owned<IFileTreeBrowser> browser;
     try
     {
-        web->gatherWeb(indexName0, options);
+        web->gatherWeb(indexName0, df, options);
         browser.setown(web->createBrowseTree(indexName0));
     }   
     catch(IException* e)
@@ -5172,7 +5170,7 @@ int CWsDfuEx::GetIndexData(IEspContext &context, bool bSchemaOnly, const char* i
             e->Release();
 
             indexName0 = (char *) (indexName+1);
-            web->gatherWeb(indexName0, options);
+            web->gatherWeb(indexName0, df, options);
             browser.setown(web->createBrowseTree(indexName0));
         }
     }