InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HTTPAssetLinkResourceStateUpdater.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Sanyam Jain
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // ADOBE CONFIDENTIAL
16 //
17 // Copyright 2016 Adobe
18 // All Rights Reserved.
19 //
20 // NOTICE: Adobe permits you to use, modify, and distribute this file in
21 // accordance with the terms of the Adobe license agreement accompanying
22 // it. If you have received this file from a source other than Adobe,
23 // then your use, modification, or distribution of it requires the prior
24 // written permission of Adobe.
25 //
26 //========================================================================================
27 
28 #ifndef __HTTPAssetLinkResourceStateUpdater__
29 #define __HTTPAssetLinkResourceStateUpdater__
30 
31 #include "CPMUnknown.h"
32 
33 #include "IBoolData.h"
34 #include "ILinkResource.h"
35 #include "ILinkResourceStateUpdater.h"
36 #include "IHTTPLinkResourceServerAPIWrapper.h"
37 
38 #include "HTTPLinkSubsystemTypes.h"
39 
43 class HTTPAssetLinkResourceStateUpdater : public CPMUnknown<ILinkResourceStateUpdater>
44 {
45 public:
47 
49 
50  /*
51  @param resourceRef [IN] UIDRef of the Link Resource.
52  @param bNotify [IN] true for notify on Update.
53  @return kSuccess on succes else kFailure.
54  */
55  ErrorCode UpdateResourceStateSync(const UIDRef& resourceRef, bool bNotify);
56 
57  /*
58  @param resourceRef [IN] UIDRef of the Link Resource.
59  @return kSuccess on succes else kFailure.
60  */
61  ErrorCode UpdateResourceStateAsync(const UIDRef& resourceRef);
62 
63  /*
64  @param resourceRef [IN] UIDRef of the Link Resource.
65  @ return Nothing. It just cancel the update if can.
66  */
67  void CancelUpdateResourceState(const UIDRef& resourceRef){}
68 
69  /*
70  @param resourceRef [IN] UIDRef of the Link Resource.
71  @ return Nothing. It just wait for the completion for resurce state update.
72  */
73  void WaitForUpdateResourceStateCompletion(const UIDRef& resourceRef) {}
74 
75  /*
76  @param resourceRef [IN] UIDRef of the Link Resource.
77  @param relativeURI [IN] uri of the resource.
78  @param bIgnoreStamp [IN] true if we want to ignore the stamp else false.
79  @ return kSuccess on success else false.
80  */
81  ErrorCode ResolveResource(const UIDRef& resourceRef, const URI& relativeURI, bool bIgnoreStamp);
82  // Callback for fetching asset metadata
83 
84  /*
85  @param resourceUID [IN] UID of the res.
86  @param updateLinkResourceStateData [IN] state data for res.
87  @param assetStatusWithMetadataPtr [OUT] status metadata pointer filled after fetching the asset.
88  */
89  static void HandleFetchingAssetMetadata(UID resourceUID, HTTPLinkSubsystemTypes::UpdateLinkResourceStateClientData updateLinkResourceStateData, IHTTPLinkResourceServerAPIWrapper::AssetStatusWithMetadataPtr assetStatusWithMetadataPtr);
90 
91 protected:
92 
93  /*
94  @param resourceRef [IN] UIDRef of the Link Resource.
95  @param bNotify [IN] true for notify on Update.
96  @param async [IN] true async update.
97  @return kSuccess on success else false.
98  */
99  virtual ErrorCode UpdateLinkResourceState(const UIDRef& resourceRef, bool bNotify, bool async);
100 
101  /*
102  @param uri [IN] uri of the Link
103  @param assetMetaData[IN] assetmetadata values of given link resource
104  @return resource stamp to identify the state of resource
105  */
106  static WideString CreateResourceStamp(const URI& uri, const IHTTPLinkResourceServerAPIWrapper::AssetStatusWithMetadataPtr& assetMetaData);
107 private:
108 
109  // Prevent copy construction and assignment.
112 
113  // Invalidates cache if its stale
114  static void InvalidateCacheIfStale(URI uri, IHTTPLinkResourceServerAPIWrapper::AssetMetadataPtr assetMetadata);
115 
116  // Extracts uri from linkresource and invalidate it if its stale
117  static void CheckAndInvalidateCache(InterfacePtr<ILinkResource> iLinkResource, IHTTPLinkResourceServerAPIWrapper::AssetStatusWithMetadataPtr assetStatusWithMetadataPtr, bool renditionUri = true);
118 
119 #ifdef UPDATELINKS_ASYNC
120 public:
126  virtual bool16 DoesSupportUpdateResourceStateThroughAsyncWorkManager(const UIDRef& resourceRef)
127  {
128  return kFalse;
129  }
137  virtual ErrorCode UpdateResourceStateAsyncWithPacketID(const UIDRef& resourceRef, bool16 bCheckOutstandingPackets, AsyncWorkPacketID& packetID)
138  {
139  ASSERT_FAIL("Doesn't support UpdateResourceStateAsyncWithPacketID");
140  return kFailure;
141  }
154  virtual ErrorCode ResolveResourceAsync(const UIDRef& resourceRef, const URI& relativeURI, bool bIgnoreStamp, bool16* statusBoolPtr, bool16 bCheckOutstandingPackets, AsyncWorkPacketID& packetID)
155  {
156  return kSuccess;
157  }
158 #endif
159 
160 };
161 
162 #endif // __HTTPAssetLinkResourceStateUpdater__