!1007 12.23 告警清零

Merge pull request !1007 from maruiqazqaz/OpenHarmony-4.1-Beta1
This commit is contained in:
openharmony_ci 2023-12-25 08:58:51 +00:00 committed by Gitee
commit dd9e9aed3e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 230 additions and 214 deletions

View File

@ -54,6 +54,7 @@ napi_value AllocResourceAndShare(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<AllocResAndShareContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// allocResourceAndShare storeId, predicates, participants 3 required parameter, columns 1 Optional parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 3, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->storeId);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK,
@ -68,6 +69,7 @@ napi_value AllocResourceAndShare(napi_env env, napi_callback_info info)
Status::INVALID_ARGUMENT, "The type of participants must be Array<Participant>.");
// 'argv[3]' represents an optional std::vector<std::string> parameter
if (argc > 3 && !JSUtils::IsNull(env, argv[3])) {
// 'argv[3]' represents the columns optional parameter
status = JSUtils::Convert2Value(env, argv[3], ctxt->columns);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK,
Status::INVALID_ARGUMENT, "The type of columns must be Array<string>.");
@ -88,8 +90,8 @@ napi_value AllocResourceAndShare(napi_env env, napi_callback_info info)
auto [result, valueBuckets] = proxy->AllocResourceAndShare(
ctxt->storeId, ctxt->predicates->GetDistributedPredicates(), ctxt->columns, ctxt->participants);
ctxt->resultSet = std::make_shared<CacheResultSet>(std::move(valueBuckets));
LOG_DEBUG("AllocResourceAndShare result: %{public}d, size:%{public}zu", result, valueBuckets.size());
ctxt->resultSet = std::make_shared<CacheResultSet>(std::move(valueBuckets));
ctxt->status =
(GenerateNapiError(result, ctxt->jsCode, ctxt->error) == Status::SUCCESS) ? napi_ok : napi_generic_failure;
};
@ -118,6 +120,7 @@ napi_value Share(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<ShareContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// ShareContext have sharingRes, participants 2 required parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 2, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->sharingRes);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK && !ctxt->sharingRes.empty(),
@ -168,6 +171,7 @@ napi_value Unshare(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<UnshareContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// ShareContext have sharingRes, participants 2 required parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 2, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->sharingRes);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK && !ctxt->sharingRes.empty(),
@ -263,6 +267,7 @@ napi_value ChangePrivilege(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<ChangePrivilegeContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// ShareContext have sharingRes, participants 2 required parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 2, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->sharingRes);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK && !ctxt->sharingRes.empty(),
@ -400,6 +405,7 @@ napi_value ConfirmInvitation(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<ConfirmInvitationContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// ShareContext have sharingRes, participants 2 required parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 2, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->invitationCode);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK && !ctxt->invitationCode.empty(),
@ -451,6 +457,7 @@ napi_value ChangeConfirmation(napi_env env, napi_callback_info info)
};
auto ctxt = std::make_shared<ChangeConfirmationContext>();
ctxt->GetCbInfo(env, info, [env, ctxt](size_t argc, napi_value *argv) {
// ShareContext have sharingRes, participants 2 required parameter
ASSERT_BUSINESS_ERR(ctxt, argc >= 2, Status::INVALID_ARGUMENT, "The number of parameters is incorrect.");
int status = JSUtils::Convert2Value(env, argv[0], ctxt->sharingRes);
ASSERT_BUSINESS_ERR(ctxt, status == JSUtils::OK && !ctxt->sharingRes.empty(),

View File

@ -17,230 +17,239 @@ let rpc = requireNapi('rpc');
const TAG = "sharingCenterExtension";
export var cloudExtension;
!function(e) {
let t;
!function(e) {
e[e.ConnectShareCenter = 0] = "ConnectShareCenter"
}(t = e.CloudService_Function || (e.CloudService_Function = {}));
let r;
!function(e) {
e[e.Share = 0] = "Share";
e[e.Unshare = 1] = "Unshare";
e[e.Exit = 2] = "Exit";
e[e.ChangePrivilege = 3] = "ChangePrivilege";
e[e.QueryParticipants = 4] = "QueryParticipants";
e[e.QueryParticipantsByInvitation = 5] = "QueryParticipantsByInvitation";
e[e.ConfirmInvitation = 6] = "ConfirmInvitation";
e[e.ChangeConfirmation = 7] = "ChangeConfirmation";
}(r = e.ShareCenter_Function || (e.ShareCenter_Function = {}));
let waitTime1 = 1e3;
class n extends rpc.RemoteObject {
constructor(e, t) {
super(e);
this.cloudService = t;
console.info(`${TAG} CloudServiceProxy constructor`);
}
let waitTime2 = 1500;
async onRemoteMessageRequest(e, r, n, i) {
console.info(`${TAG}, onRemoteRequest called, code: ${e}`);
i.setWaitTime(1e3);
if (e === t.ConnectShareCenter) {
let e = r.readInt();
let t = r.readString();
let i = await this.cloudService.connectShareCenter(e, t);
if (null == i) {
console.error(`${TAG}, sharingCenter is null`);
return !1;
}
n.writeRemoteObject(i);
return !0;
}
console.error(`${TAG}, invalid request code: ${e}`);
return !1;
}
export let cloudExtension;
!function (e) {
let t;
!function (e) {
e[e.ConnectShareCenter = 0] = 'ConnectShareCenter';
}(t = e.CloudService_Function || (e.CloudService_Function = {}));
let r;
!function (e) {
e[e.Share = 0] = 'Share';
e[e.Unshare = 1] = 'Unshare';
e[e.Exit = 2] = 'Exit';
e[e.ChangePrivilege = 3] = 'ChangePrivilege';
e[e.QueryParticipants = 4] = 'QueryParticipants';
e[e.QueryParticipantsByInvitation = 5] = 'QueryParticipantsByInvitation';
e[e.ConfirmInvitation = 6] = 'ConfirmInvitation';
e[e.ChangeConfirmation = 7] = 'ChangeConfirmation';
}(r = e.ShareCenter_Function || (e.ShareCenter_Function = {}));
class N extends rpc.RemoteObject {
constructor(e, t) {
super(e);
this.cloudService = t;
console.info(`${TAG} CloudServiceProxy constructor`);
}
e.CloudServiceProxy = n;
class i extends rpc.RemoteObject {
constructor(e, t) {
super(e);
this.shareCenter = t;
console.info(`${TAG} shareCenter constructor`);
async onRemoteMessageRequest(e, r, N, i) {
console.info(`${TAG}, onRemoteRequest called, code: ${e}`);
i.setWaitTime(waitTime1);
if (e === t.ConnectShareCenter) {
let e = r.readInt();
let t = r.readString();
let i = await this.cloudService.connectShareCenter(e, t);
if (null == i) {
console.error(`${TAG}, sharingCenter is null`);
return !1;
}
N.writeRemoteObject(i);
return !0;
}
console.error(`${TAG}, invalid request code: ${e}`);
return !1;
}
}
async onRemoteMessageRequest(e, t, n, i) {
console.info(`${TAG}, shareCenter onRemoteRequest called, code: ${e}`);
if (null == this.shareCenter) {
console.info(`${TAG}, shareCenter undefined`);
return !1;
}
i.setWaitTime(1500);
switch(e) {
case r.Share:
let e = t.readInt();
let i = t.readString();
let a = t.readString();
let l = this.unMarshallingParticipants(t);
let o = await this.shareCenter.share(e, i, a, l);
this.marshallingResults(n, o);
return !0;
case r.Unshare:
let s = t.readInt();
let c = t.readString();
let h = t.readString();
let d = this.unMarshallingParticipants(t);
let u = await this.shareCenter.unshare(s, c, h, d);
this.marshallingResults(n, u);
return !0;
case r.Exit:
let g = t.readInt();
let S = t.readString();
let w = t.readString();
let C = await this.shareCenter.exit(g, S, w);
n.writeInt(C.code);
C.description ? n.writeString(C.description) : n.writeString("");
return !0;
case r.ChangePrivilege:
let v = t.readInt();
let p = t.readString();
let I = t.readString();
let f = this.unMarshallingParticipants(t);
let m = await this.shareCenter.changePrivilege(v, p, I, f);
this.marshallingResults(n, m);
return !0;
case r.QueryParticipants:
let P = t.readInt();
let y = t.readString();
let B = t.readString();
let R = await this.shareCenter.queryParticipants(P, y, B);
this.marshallingResultsArray(n, R);
return !0;
case r.QueryParticipantsByInvitation:
let x = t.readInt();
let A = t.readString();
let b = t.readString();
let T = await this.shareCenter.queryParticipantsByInvitation(x, A, b);
this.marshallingResultsArray(n, T);
return !0;
case r.ConfirmInvitation:
let $ = t.readInt();
let E = t.readString();
let G = t.readString();
let M = t.readInt();
let q = await this.shareCenter.confirmInvitation($, E, G, M);
n.writeInt(q.code);
q.description ? n.writeString(q.description) : n.writeString("");
q.value ? n.writeString(q.value) : n.writeString("");
return !0;
case r.ChangeConfirmation:
let Q = t.readInt();
let _ = t.readString();
let F = t.readString();
let j = t.readInt();
let O = await this.shareCenter.changeConfirmation(Q, _, F, j);
n.writeInt(O.code);
O.description ? n.writeString(O.description) : n.writeString("");
return !0;
default:
console.info(`${TAG}, invalid request code`);
}
return !1
}
e.CloudServiceProxy = N;
unMarshallingParticipants(e) {
let t = [];
let r = e.readInt();
console.info(`${TAG}, array length: ${r}`);
for (let n = 0; n < r; n++) t.push(this.unMarshallingParticipant(e));
return t;
}
unMarshallingParticipant(e) {
let t = e.readString();
let r;
let n = e.readInt();
let i = e.readInt();
r = {
identity: t,
role: -1 == n ? void 0 : n,
state: -1 == i ? void 0 : i,
privilege: this.unMarshallingPrivilege(e),
attachInfo: e.readString()
};
return r;
}
unMarshallingPrivilege(e) {
let t;
t = {
writable: e.readBoolean(),
readable: e.readBoolean(),
creatable: e.readBoolean(),
deletable: e.readBoolean(),
shareable: e.readBoolean()
};
return t;
}
marshallingResultsArray(e, t) {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString("");
if (t.value) {
e.writeInt(t.value.length);
t.value.forEach((t => {
this.marshallingParticipant(e, t);
}))
}
}
marshallingResults(e, t) {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString("");
if (t.value) {
e.writeInt(t.value.length);
t.value.forEach((t => {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString("");
}))
}
}
marshallingParticipant(e, t) {
e.writeString(t.identity);
void 0 !== t.role? e.writeInt(t.role) : e.writeInt(-1);
void 0 !== t.state? e.writeInt(t.state) : e.writeInt(-1);
if (t.privilege) this.marshallingPrivilege(e, t.privilege); else {
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
}
t.attachInfo ? e.writeString(t.attachInfo) : e.writeString("");
}
marshallingPrivilege(e, t) {
e.writeBoolean(t.writable);
e.writeBoolean(t.readable);
e.writeBoolean(t.creatable);
e.writeBoolean(t.deletable);
e.writeBoolean(t.shareable);
}
class I extends rpc.RemoteObject {
constructor(e, t) {
super(e);
this.shareCenter = t;
console.info(`${TAG} shareCenter constructor`);
}
e.ShareCenterProxy = i;
e.createCloudServiceStub = async function (e) {
return new n('CloudServiceProxy', e);
};
e.createShareServiceStub = async function (e) {
return new i('ShareCenterProxy', e);
async onRemoteMessageRequest(e, t, N, I) {
console.info(`${TAG}, shareCenter onRemoteRequest called, code: ${e}`);
if (null == this.shareCenter) {
console.info(`${TAG}, shareCenter undefined`);
return !1;
}
I.setWaitTime(waitTime2);
switch (e) {
case r.Share:
let e = t.readInt();
let i = t.readString();
let a = t.readString();
let l = this.unMarshallingParticipants(t);
let o = await this.shareCenter.share(e, i, a, l);
this.marshallingResults(N, o);
return !0;
case r.Unshare:
let s = t.readInt();
let c = t.readString();
let h = t.readString();
let d = this.unMarshallingParticipants(t);
let u = await this.shareCenter.unshare(s, c, h, d);
this.marshallingResults(N, u);
return !0;
case r.Exit:
let g = t.readInt();
let S = t.readString();
let w = t.readString();
let C = await this.shareCenter.exit(g, S, w);
N.writeInt(C.code);
C.description ? N.writeString(C.description) : N.writeString('');
return !0;
case r.ChangePrivilege:
let v = t.readInt();
let p = t.readString();
let I = t.readString();
let f = this.unMarshallingParticipants(t);
let m = await this.shareCenter.changePrivilege(v, p, I, f);
this.marshallingResults(N, m);
return !0;
case r.QueryParticipants:
let P = t.readInt();
let y = t.readString();
let B = t.readString();
let R = await this.shareCenter.queryParticipants(P, y, B);
this.marshallingResultsArray(N, R);
return !0;
case r.QueryParticipantsByInvitation:
let x = t.readInt();
let A = t.readString();
let b = t.readString();
let T = await this.shareCenter.queryParticipantsByInvitation(x, A, b);
this.marshallingResultsArray(N, T);
return !0;
case r.ConfirmInvitation:
let $ = t.readInt();
let E = t.readString();
let G = t.readString();
let M = t.readInt();
let q = await this.shareCenter.confirmInvitation($, E, G, M);
N.writeInt(q.code);
q.description ? N.writeString(q.description) : N.writeString('');
q.value ? N.writeString(q.value) : N.writeString('');
return !0;
case r.ChangeConfirmation:
let Q = t.readInt();
let _ = t.readString();
let F = t.readString();
let j = t.readInt();
let O = await this.shareCenter.changeConfirmation(Q, _, F, j);
N.writeInt(O.code);
O.description ? N.writeString(O.description) : N.writeString('');
return !0;
default:
console.info(`${TAG}, invalid request code`);
}
return !1;
}
unMarshallingParticipants(e) {
let t = [];
let r = e.readInt();
console.info(`${TAG}, array length: ${r}`);
for (let n = 0; n < r; n++) {
t.push(this.unMarshallingParticipant(e));
}
return t;
}
unMarshallingParticipant(e) {
let t = e.readString();
let r;
let n = e.readInt();
let i = e.readInt();
r = {
identity: t,
role: -1 === n ? void 0 : n,
state: -1 === i ? void 0 : i,
privilege: this.unMarshallingPrivilege(e),
attachInfo: e.readString()
};
return r;
}
unMarshallingPrivilege(e) {
let t;
t = {
writable: e.readBoolean(),
readable: e.readBoolean(),
creatable: e.readBoolean(),
deletable: e.readBoolean(),
shareable: e.readBoolean()
};
return t;
}
marshallingResultsArray(e, t) {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString('');
if (t.value) {
e.writeInt(t.value.length);
t.value.forEach((t => {
this.marshallingParticipant(e, t);
}));
}
}
marshallingResults(e, t) {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString('');
if (t.value) {
e.writeInt(t.value.length);
t.value.forEach((t => {
e.writeInt(t.code);
t.description ? e.writeString(t.description) : e.writeString('');
}));
}
}
marshallingParticipant(e, t) {
e.writeString(t.identity);
void 0 !== t.role ? e.writeInt(t.role) : e.writeInt(-1);
void 0 !== t.state ? e.writeInt(t.state) : e.writeInt(-1);
if (t.privilege) {
this.marshallingPrivilege(e, t.privilege);
}
else {
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
e.writeBoolean(!1);
}
t.attachInfo ? e.writeString(t.attachInfo) : e.writeString('');
}
marshallingPrivilege(e, t) {
e.writeBoolean(t.writable);
e.writeBoolean(t.readable);
e.writeBoolean(t.creatable);
e.writeBoolean(t.deletable);
e.writeBoolean(t.shareable);
}
}
e.ShareCenterProxy = I;
e.createCloudServiceStub = async function (e) {
return new N('CloudServiceProxy', e);
};
e.createShareServiceStub = async function (e) {
return new I('ShareCenterProxy', e);
};
}(cloudExtension || (cloudExtension = {}));
export default {
cloudExtension,
createCloudServiceStub: cloudExtension.createCloudServiceStub,
createShareServiceStub: cloudExtension.createShareServiceStub,
cloudExtension,
createCloudServiceStub: cloudExtension.createCloudServiceStub,
createShareServiceStub: cloudExtension.createShareServiceStub,
};