private boolean validateUsernameAndTenantId()

in custos-services/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/validator/UserProfileInputValidator.java [126:165]


    private boolean validateUsernameAndTenantId(Object obj, String method) {
        if (method.equals("getUserProfile")) {
            UserProfileRequest profileRequest = (UserProfileRequest) obj;
            if (profileRequest.getTenantId() == 0) {
                throw new MissingParameterException("tenantId should be valid ", null);
            }
            if (profileRequest.getProfile() == null) {
                throw new MissingParameterException("Profile should be valid ", null);
            }
            if (profileRequest.getProfile().getUsername() == null || profileRequest.getProfile().getUsername().equals("")) {
                throw new MissingParameterException("username should not be null", null);
            }
        } else if (method.equals("deleteUserProfile")) {

            UserProfileRequest profileRequest = (UserProfileRequest) obj;
            if (profileRequest.getTenantId() == 0) {
                throw new MissingParameterException("tenantId should be valid ", null);
            }
            if (profileRequest.getProfile() == null) {
                throw new MissingParameterException("Profile should be valid ", null);
            }
            if (profileRequest.getProfile().getUsername() == null || profileRequest.getProfile().getUsername().equals("")) {
                throw new MissingParameterException("username should not be null", null);
            }

        } else if (method.equals("getUserProfileAuditTrails")) {

            GetUpdateAuditTrailRequest profileRequest = (GetUpdateAuditTrailRequest) obj;
            if (profileRequest.getTenantId() == 0) {
                throw new MissingParameterException("tenantId should be valid ", null);
            }
            if (profileRequest.getUsername() == null || profileRequest.getUsername().equals("")) {
                throw new MissingParameterException("username should not be null", null);
            }

        }

        return true;

    }