Skip to content

Commit

Permalink
fix order
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Jan 3, 2025
1 parent aa449bf commit 2c92828
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.bigtop.manager.server.model.vo;

import org.apache.bigtop.manager.server.enums.InstalledStatusEnum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,18 @@ public AuthPlatformVO addAuthorizedPlatform(AuthPlatformDTO authPlatformDTO) {
getStringMap(authPlatformDTO, PlatformConverter.INSTANCE.fromPO2DTO(platformPO));

authPlatformDTO.setAuthCredentials(credentialSet);

if (authPlatformDTO.getAccessLevel() == null) {
authPlatformDTO.setAccessLevel(LLMAccessLevel.READONLY.getCode());
}

AuthPlatformPO authPlatformPO = AuthPlatformConverter.INSTANCE.fromDTO2PO(authPlatformDTO);
if (authPlatformDTO.getTestPassed()) {
authPlatformPO.setStatus(AuthPlatformStatus.AVAILABLE.getCode());
} else {
authPlatformPO.setStatus(AuthPlatformStatus.UNAVAILABLE.getCode());
}

if (authPlatformDTO.getAccessLevel() == null) {
authPlatformDTO.setAccessLevel(LLMAccessLevel.READONLY.getCode());
}

authPlatformDao.save(authPlatformPO);
return AuthPlatformConverter.INSTANCE.fromPO2VO(authPlatformPO, platformPO);
}
Expand All @@ -163,8 +164,8 @@ public boolean deleteAuthorizedPlatform(Long authId) {
@Override
public boolean testAuthorizedPlatform(AuthPlatformDTO authPlatformDTO) {
if (authPlatformDTO.getId() != null) {
authPlatformDTO =
AuthPlatformConverter.INSTANCE.fromPO2DTO(authPlatformDao.findById(authPlatformDTO.getId()));
AuthPlatformPO authPlatformPO = validateAndGetAuthPlatform(authPlatformDTO.getId());
authPlatformDTO = AuthPlatformConverter.INSTANCE.fromPO2DTO(authPlatformPO);
}

PlatformPO platformPO = validateAndGetPlatform(authPlatformDTO.getPlatformId());
Expand All @@ -174,14 +175,6 @@ public boolean testAuthorizedPlatform(AuthPlatformDTO authPlatformDTO) {
throw new ApiException(ApiExceptionEnum.MODEL_NOT_SUPPORTED);
}

if (authPlatformDTO.getId() != null) {
AuthPlatformPO authPlatformPO = validateAndGetAuthPlatform(authPlatformDTO.getId());

AuthPlatformDTO existAuthPlatformDTO = AuthPlatformConverter.INSTANCE.fromPO2DTO(authPlatformPO);
authPlatformDTO.setAuthCredentials(existAuthPlatformDTO.getAuthCredentials());
authPlatformDTO.setModel(existAuthPlatformDTO.getModel());
}

Map<String, String> credentialSet =
getStringMap(authPlatformDTO, PlatformConverter.INSTANCE.fromPO2DTO(platformPO));

Expand Down Expand Up @@ -311,8 +304,6 @@ private PlatformType getPlatformType(String platformName) {
}

private Boolean testAuthorization(String platformName, String model, Map<String, String> credentials) {
Boolean result = testFuncCalling(platformName, model, credentials);
log.info("Test func calling result: {}", result);
GeneralAssistantConfig generalAssistantConfig = getAIAssistantConfig(platformName, model, credentials);
AIAssistant aiAssistant = aiAssistantFactory.createForTest(generalAssistantConfig, null);
try {
Expand Down

0 comments on commit 2c92828

Please sign in to comment.