InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HTTPAssetLinkResourceStateBatchUpdater.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 __HTTPAssetLinkResourceStateBatchUpdater__
29 #define __HTTPAssetLinkResourceStateBatchUpdater__
30 
31 #include "CPMUnknown.h"
32 
33 #include "IHTTPLinkConnectionManager.h"
34 #include "IHTTPLinkManager.h"
35 #include "IHTTPLinkUtils.h"
36 #include "IHTTPServerInfo.h"
37 
38 #include "StringUtils.h"
39 #include "URICommonUtils.h"
40 
41 #include "DocHTTPBatchQueryManager.h"
42 
43 #include <boost/thread/thread_time.hpp>
44 #include <set>
45 
49 class HTTPAssetLinkResourceStateBatchUpdater : public CPMUnknown<IHTTPLinkResourceStateBatchUpdater>
50 {
51 public:
55  virtual ErrorCode QueueLinkResourceUpdateRequestForBatch(const UID& resourceUID, const HTTPLinkSubsystemTypes::UpdateLinkResourceStateClientData& updateLinkResourceStateData);
56 
57 private:
58  typedef std::set<UID> UIDSet;
59  typedef UIDSet::iterator UIDSet_iter;
60  //TODO extend it to associate batch size for each type if needed
61  typedef std::map<HTTPLinkSubsystemTypes::BatchRequestObjectType, boost::system_time> BatchRequestObjectTypeInfoMap;
62  typedef BatchRequestObjectTypeInfoMap::iterator BatchRequestObjectTypeInfoMap_iter;
63 
64  int32 fIDBatchSize;
65  int32 fHTTPConfiguredBatchLimit;
66  long fTimeLimitForBatchCall; //Max time limit for successive batch calls in milliseconds
67  long fMinTimeBetweenCalls; //Min time duration between two batch calls in milliseconds
68  URI fConnectionURI;
69  BatchRequestObjectTypeInfoMap fBatchRequestObjectTypeInfo;
70 
71  static void HandleFetchingBatchAssetMetadata(const std::vector<UID> &uidVector,
73  URI connectionURI,
75  IHTTPLinkResourceServerAPIWrapper::AssetStatusWithMetadataPtrVectorPtr assetStatusWithMetadataVectorPtr);
76  bool16 PopulateBatchRequestVectors(const HTTPLinkSubsystemTypes::GUID& guid, HTTPLinkSubsystemTypes::BatchRequestObjectType objType, std::vector<IHTTPLinkResourceServerAPIWrapper::URIVector>&batchRequestURIPathVectors, std::vector<std::vector<UID> >&batchRequestUIDVectors);
77  bool InitiateBatchRequest(const int32& numOfUIDs, const HTTPLinkSubsystemTypes::BatchRequestObjectType& objType, const HTTPLinkSubsystemTypes::UpdateLinkResourceStateClientData& updateLinkResourceStateData);
78  bool RetrieveBatchLimitsConfigured(void);
79  void PopulateBatchObjectTypeInfoMap(void);
80  static void GetHttpRequestPathForBatchRequest(const URI& uri, std::string& requestPath, bool encodedPathRequested = false);
81 };
82 
83 #endif // __HTTPAssetLinkResourceStateBatchUpdater__