Skip to content

Commit ee6f63b

Browse files
committed
added:get bucket list information for http restful
1 parent b4ea4e5 commit ee6f63b

File tree

7 files changed

+109
-2
lines changed

7 files changed

+109
-2
lines changed

XEngine_Source/StorageModule_Protocol/Protocol_Packet/Protocol_StoragePacket.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,70 @@ bool CProtocol_StoragePacket::Protocol_StoragePacket_Action(XCHAR* ptszMsgBuffer
521521
return true;
522522
}
523523
/********************************************************************
524+
函数名称:Protocol_StoragePacket_Bucket
525+
函数功能:获取bucket信息
526+
参数.一:ptszMsgBuffer
527+
In/Out:Out
528+
类型:字符指针
529+
可空:N
530+
意思:输出组好包的请求缓冲区
531+
参数.二:pInt_MsgLen
532+
In/Out:Out
533+
类型:整数型指针
534+
可空:N
535+
意思:输出缓冲区大小
536+
参数.三:pStl_ListBucket
537+
In/Out:In
538+
类型:STL容器指针
539+
可空:N
540+
意思:输入要打包的信息
541+
返回值
542+
类型:逻辑型
543+
意思:是否成功
544+
备注:
545+
*********************************************************************/
546+
bool CProtocol_StoragePacket::Protocol_StoragePacket_Bucket(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket)
547+
{
548+
Protocol_IsErrorOccur = false;
549+
550+
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
551+
{
552+
Protocol_IsErrorOccur = true;
553+
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
554+
return false;
555+
}
556+
Json::Value st_JsonRoot;
557+
Json::Value st_JsonArray;
558+
559+
auto stl_ListIterator = pStl_ListBucket->begin();
560+
for (int i = 0; stl_ListIterator != pStl_ListBucket->end(); stl_ListIterator++)
561+
{
562+
Json::Value st_JsonObject;
563+
Json::Value st_JsonSub;
564+
565+
st_JsonObject["bEnable"] = stl_ListIterator->bEnable;
566+
st_JsonObject["nLevel"] = stl_ListIterator->nLevel;
567+
st_JsonObject["tszBuckSize"] = stl_ListIterator->tszBuckSize;
568+
st_JsonObject["tszBuckKey"] = stl_ListIterator->tszBuckKey;
569+
st_JsonObject["tszFilePath"] = stl_ListIterator->tszFilePath;
570+
571+
st_JsonSub["bCreateDir"] = stl_ListIterator->st_PermissionFlags.bCreateDir;
572+
st_JsonSub["bRewrite"] = stl_ListIterator->st_PermissionFlags.bRewrite;
573+
st_JsonSub["bUPLimit"] = stl_ListIterator->st_PermissionFlags.bUPLimit;
574+
st_JsonSub["bUPReady"] = stl_ListIterator->st_PermissionFlags.bUPReady;
575+
st_JsonObject["st_PermissionFlags"] = st_JsonSub;
576+
st_JsonArray.append(st_JsonObject);
577+
}
578+
st_JsonRoot["code"] = 0;
579+
st_JsonRoot["msg"] = "success";
580+
st_JsonRoot["size"] = st_JsonArray.size();
581+
st_JsonRoot["array"] = st_JsonArray;
582+
//打包输出信息
583+
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
584+
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
585+
return true;
586+
}
587+
/********************************************************************
524588
函数名称:Protocol_StoragePacket_WDPropfind
525589
函数功能:propfind协议打包处理函数
526590
参数.一:ptszMsgBuffer

XEngine_Source/StorageModule_Protocol/Protocol_Packet/Protocol_StoragePacket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CProtocol_StoragePacket
2424
bool Protocol_StoragePacket_UPDown(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszBuckKey, LPCXSTR lpszFileName, LPCXSTR lpszClientAddr, __int64x nFileSize, bool bDown, LPCXSTR lpszFileHash = NULL);
2525
bool Protocol_StoragePacket_REQFile(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCXSTR lpszFileName = NULL, LPCXSTR lpszFileHash = NULL, XNETHANDLE xhToken = 0);
2626
bool Protocol_StoragePacket_Action(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, XENGINE_ACTIONINFO* pSt_ActionInfo);
27+
bool Protocol_StoragePacket_Bucket(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket);
2728
public:
2829
bool Protocol_StoragePacket_WDPropfind(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** ppptszListFile, int nFileCount, LPCXSTR lpszBucketPath, LPCXSTR lpszBucketKey);
2930
bool Protocol_StoragePacket_WDLock(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_WEBDAVLOCK* pSt_WDLock);

XEngine_Source/StorageModule_Protocol/Protocol_Parse/Protocol_StorageParse.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ bool CProtocol_StorageParse::Protocol_StorageParse_DirOperator(LPCXSTR lpszMsgBu
289289
delete pSt_JsonReader;
290290
pSt_JsonReader = NULL;
291291

292-
*pInt_Operator = st_JsonRoot["nOPerator"].asInt();
293-
_tcsxcpy(ptszBuckKey, st_JsonRoot["lpszBuckKey"].asCString());
292+
if (!st_JsonRoot["nOPerator"].isNull())
293+
{
294+
*pInt_Operator = st_JsonRoot["nOPerator"].asInt();
295+
}
296+
if (!st_JsonRoot["lpszBuckKey"].isNull())
297+
{
298+
_tcsxcpy(ptszBuckKey, st_JsonRoot["lpszBuckKey"].asCString());
299+
}
294300
if (!st_JsonRoot["lpszUserDir"].isNull())
295301
{
296302
_tcsxcpy(ptszUserDir, st_JsonRoot["lpszUserDir"].asCString());

XEngine_Source/StorageModule_Protocol/StorageModule_Protocol.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ EXPORTS
2121
Protocol_StoragePacket_DirOperator
2222
Protocol_StoragePacket_REQFile
2323
Protocol_StoragePacket_Action
24+
Protocol_StoragePacket_Bucket
2425
Protocol_StoragePacket_WDPropfind
2526
Protocol_StoragePacket_WDLock
2627
Protocol_StoragePacket_WDPropPatch

XEngine_Source/StorageModule_Protocol/StorageProtocol_Define.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,30 @@ extern "C" bool Protocol_StoragePacket_REQFile(XCHAR * ptszMsgBuffer, int* pInt_
565565
*********************************************************************/
566566
extern "C" bool Protocol_StoragePacket_Action(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, XENGINE_ACTIONINFO* pSt_ActionInfo);
567567
/********************************************************************
568+
函数名称:Protocol_StoragePacket_Bucket
569+
函数功能:获取bucket信息
570+
参数.一:ptszMsgBuffer
571+
In/Out:Out
572+
类型:字符指针
573+
可空:N
574+
意思:输出组好包的请求缓冲区
575+
参数.二:pInt_MsgLen
576+
In/Out:Out
577+
类型:整数型指针
578+
可空:N
579+
意思:输出缓冲区大小
580+
参数.三:pStl_ListBucket
581+
In/Out:In
582+
类型:STL容器指针
583+
可空:N
584+
意思:输入要打包的信息
585+
返回值
586+
类型:逻辑型
587+
意思:是否成功
588+
备注:
589+
*********************************************************************/
590+
extern "C" bool Protocol_StoragePacket_Bucket(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket);
591+
/********************************************************************
568592
函数名称:Protocol_StoragePacket_WDPropfind
569593
函数功能:propfind协议打包处理函数
570594
参数.一:ptszMsgBuffer

XEngine_Source/StorageModule_Protocol/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ extern "C" bool Protocol_StoragePacket_Action(XCHAR * ptszMsgBuffer, int* pInt_M
9696
{
9797
return m_StoragePacket.Protocol_StoragePacket_Action(ptszMsgBuffer, pInt_MsgLen, xhToken, pSt_ActionInfo);
9898
}
99+
extern "C" bool Protocol_StoragePacket_Bucket(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket)
100+
{
101+
return m_StoragePacket.Protocol_StoragePacket_Bucket(ptszMsgBuffer, pInt_MsgLen, pStl_ListBucket);
102+
}
99103
extern "C" bool Protocol_StoragePacket_WDPropfind(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** ppptszListFile, int nFileCount, LPCXSTR lpszBucketPath, LPCXSTR lpszBucketKey)
100104
{
101105
return m_StoragePacket.Protocol_StoragePacket_WDPropfind(ptszMsgBuffer, pInt_MsgLen, ppptszListFile, nFileCount, lpszBucketPath, lpszBucketKey);

XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ bool XEngine_Task_Manage(LPCXSTR lpszAPIName, LPCXSTR lpszClientAddr, LPCXSTR lp
352352
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("业务客户端:%s,请求删除文件夹:%s,成功"), lpszClientAddr, tszRealDir);
353353
}
354354
}
355+
else if (0 == _tcsxnicmp(lpszAPIBucket, lpszAPIName, _tcsxlen(lpszAPIBucket)))
356+
{
357+
Protocol_StoragePacket_Bucket(tszRVBuffer, &nRVLen, st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket);
358+
HttpProtocol_Server_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, tszRVBuffer, nRVLen);
359+
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
360+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("业务客户端:%s,请求获取BUCKET信息成功"), lpszClientAddr);
361+
}
355362
else if (0 == _tcsxnicmp(lpszAPITask, lpszAPIName, _tcsxlen(lpszAPITask)))
356363
{
357364
int nDLCount = 0;

0 commit comments

Comments
 (0)