Fix : Search APIs don't return exception despite the content in DB doesn't match... 07/12707/2
authorSeokpil Park <seokpil.park@samsung.com>
Wed, 4 Sep 2013 06:29:10 +0000 (15:29 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Fri, 22 Nov 2013 08:08:18 +0000 (17:08 +0900)
Change-Id: I3120c073dd95bfdc23eae2f2224883dfb9217bb2
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
CMakeLists.txt
src/FCntAudioContentInfo.cpp
src/FCntImageContentInfo.cpp
src/FCntOtherContentInfo.cpp
src/FCntVideoContentInfo.cpp
src/FCnt_ContentDirectoryImpl.cpp
src/FCnt_ContentInfoImpl.cpp
src/FCnt_ContentSearchImpl.cpp
src/FCnt_PlayListImpl.cpp
src/inc/FCnt_ContentInfoImpl.h

index 151f0db..db54ead 100755 (executable)
@@ -90,7 +90,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -
 
 TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
 TARGET_LINK_LIBRARIES(${this_target} "-losp-locations")
-TARGET_LINK_LIBRARIES(${this_target} "-lexif" )
+TARGET_LINK_LIBRARIES(${this_target} "-lexif")
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-web-url-download")
 TARGET_LINK_LIBRARIES(${this_target} "-lpthread")
 
index da9483c..0221df5 100644 (file)
@@ -48,7 +48,7 @@ AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pAudioContentInfoImpl == null,
+       SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl();
@@ -59,8 +59,18 @@ AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 
        _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl);
 
+       delete __pAudioContentInfoImpl;
        __pAudioContentInfoImpl = pAudioContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pAudioContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pAudioContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
@@ -74,19 +84,29 @@ AudioContentInfo::Construct(const String* pContentPath)
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pAudioContentInfoImpl == null,
+       SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl();
        SysTryReturnResult(NID_CNT, pAudioContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
 
        r = pAudioContentInfoImpl->Construct(pContentPath);
-       SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
 
        _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl);
 
+       delete __pAudioContentInfoImpl;
        __pAudioContentInfoImpl = pAudioContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pAudioContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pAudioContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
index 489abd6..5d6994f 100644 (file)
@@ -47,7 +47,7 @@ ImageContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pImageContentInfoImpl == null,
+       SysAssertf(__pImageContentInfoImpl == null || __pImageContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _ImageContentInfoImpl* pImageContentInfoImpl = new (std::nothrow) _ImageContentInfoImpl();
@@ -58,8 +58,18 @@ ImageContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 
        _ContentInfoHelper::SetContentInfoImpl(this, pImageContentInfoImpl);
 
+       delete __pImageContentInfoImpl;
        __pImageContentInfoImpl = pImageContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pImageContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pImageContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
@@ -73,19 +83,29 @@ ImageContentInfo::Construct(const String* pContentPath)
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pImageContentInfoImpl == null,
+       SysAssertf(__pImageContentInfoImpl == null || __pImageContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _ImageContentInfoImpl* pImageContentInfoImpl = new (std::nothrow) _ImageContentInfoImpl();
        SysTryReturnResult(NID_CNT, pImageContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
 
        r = pImageContentInfoImpl->Construct(pContentPath);
-       SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
 
        _ContentInfoHelper::SetContentInfoImpl(this, pImageContentInfoImpl);
 
+       delete __pImageContentInfoImpl;
        __pImageContentInfoImpl = pImageContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pImageContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pImageContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
index 41da4d4..9bbc74c 100644 (file)
@@ -47,7 +47,7 @@ OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pOtherContentInfoImpl == null,
+       SysAssertf(__pOtherContentInfoImpl == null || __pOtherContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl();
@@ -58,8 +58,18 @@ OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 
        _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl);
 
+       delete __pOtherContentInfoImpl;
        __pOtherContentInfoImpl = pOtherContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pOtherContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pOtherContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
@@ -73,19 +83,29 @@ OtherContentInfo::Construct(const String* pContentPath)
 {
        result r = E_SUCCESS;
 
-       SysAssertf(__pOtherContentInfoImpl == null,
+       SysAssertf(__pOtherContentInfoImpl == null || __pOtherContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl();
        SysTryReturnResult(NID_CNT, pOtherContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
 
        r = pOtherContentInfoImpl->Construct(pContentPath);
-       SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
 
        _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl);
 
+       delete __pOtherContentInfoImpl;
        __pOtherContentInfoImpl = pOtherContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pOtherContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pOtherContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
index 6d8079b..2223cb8 100644 (file)
@@ -46,7 +46,7 @@ VideoContentInfo::~VideoContentInfo(void)
 result
 VideoContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
 {
-       SysAssertf(__pVideoContentInfoImpl == null,
+       SysAssertf(__pVideoContentInfoImpl == null || __pVideoContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        result r = E_SUCCESS;
@@ -59,8 +59,18 @@ VideoContentInfo::Construct(const String& contentPath, const String& thumbnailPa
 
        _ContentInfoHelper::SetContentInfoImpl(this, pVideoContentInfoImpl);
 
+       delete __pVideoContentInfoImpl;
        __pVideoContentInfoImpl = pVideoContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pVideoContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pVideoContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
@@ -72,7 +82,7 @@ CATCH:
 result
 VideoContentInfo::Construct(const String* pContentPath)
 {
-       SysAssertf(__pVideoContentInfoImpl == null,
+       SysAssertf(__pVideoContentInfoImpl == null || __pVideoContentInfoImpl->IsReconstructable(),
                        "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
 
        result r = E_SUCCESS;
@@ -81,12 +91,22 @@ VideoContentInfo::Construct(const String* pContentPath)
        SysTryReturnResult(NID_CNT, pVideoContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
 
        r = pVideoContentInfoImpl->Construct(pContentPath);
-       SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
 
        _ContentInfoHelper::SetContentInfoImpl(this, pVideoContentInfoImpl);
 
+       delete __pVideoContentInfoImpl;
        __pVideoContentInfoImpl = pVideoContentInfoImpl;
 
+       if (r == E_FILE_NOT_FOUND)
+       {
+               __pVideoContentInfoImpl->SetReconstructable(true);
+       }
+       else
+       {
+               __pVideoContentInfoImpl->SetReconstructable(false);
+       }
+
        return r;
 
 CATCH:
index 3b3889d..05b7c7f 100644 (file)
@@ -908,8 +908,11 @@ _ContentDirectoryImpl::ConvertErrorToResult(result res) const
 
        switch (res)
        {
+       // It is processed by normal case when the content exist in DB but the actual file doesn't exist.
        case E_FILE_NOT_FOUND:
-               // Fall through
+               r = E_SUCCESS;
+               break;
+
        case E_IO:
                r = E_SYSTEM;
                break;
index f9c19a6..b80b880 100644 (file)
@@ -67,6 +67,7 @@ _ContentInfoImpl::_ContentInfoImpl(void)
        , __provider(L"")
        , __rating(L"")
        , __mediaFormat(L"")
+       , __isConstructed(false)
 {
 
 }
@@ -462,4 +463,16 @@ _ContentInfoImpl::GetCompatContentPath(const String& contentPath, String& change
        return r;
 }
 
+bool
+_ContentInfoImpl::IsReconstructable(void) const
+{
+       return __isConstructed;
+}
+
+void
+_ContentInfoImpl::SetReconstructable(bool isConstructed)
+{
+       __isConstructed = isConstructed;
+}
+
 }}
index a32f1ba..03714c8 100644 (file)
@@ -1592,7 +1592,10 @@ _ContentSearchImpl::ConvertErrorToResult(result res) const
        switch (res)
        {
        case E_FILE_NOT_FOUND:
-               // Fall through
+               // It is processed by normal case when the content exist in DB but the actual file doesn't exist.
+               r = E_SUCCESS;
+               break;
+
        case E_IO:
                r = E_SYSTEM;
                break;
index 666c4e7..ec682e2 100644 (file)
@@ -816,9 +816,12 @@ _PlayListImpl::ConvertErrorToResult(result res) const
 
        switch (res)
        {
-       case E_INVALID_ARG:
-               // Fall through
+       // It is processed by normal case when the content exist in DB but the actual file doesn't exist.
        case E_FILE_NOT_FOUND:
+               r = E_SUCCESS;
+               break;
+
+       case E_INVALID_ARG:
                // Fall through
        case E_IO:
                r = E_SYSTEM;
index b594e50..95842a8 100644 (file)
@@ -145,6 +145,10 @@ public:
 
        result GetCompatContentPath(const Tizen::Base::String& contentPath, Tizen::Base::String& changedPath) const;
 
+       bool IsReconstructable(void) const;
+
+       void SetReconstructable(bool isConstructed);
+
        static _ContentInfoImpl* GetInstance(ContentInfo& contentInfo);
 
        static const _ContentInfoImpl* GetInstance(const ContentInfo& contentInfo);
@@ -178,6 +182,7 @@ private:
        Tizen::Base::String __rating;
        Tizen::Base::String __mediaFormat;
        Tizen::Locations::Coordinates __coordinates;
+       bool __isConstructed;
 
 };  // _ContentInfoImpl