Skip to content

Commit ff4aacf

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main' into merge_2502_into_main_0417
# Conflicts: # server/odc-core/src/main/resources/i18n/ErrorMessages.properties # server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/export/ScheduleExportService.java # server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/export/ScheduleTaskExporter.java # server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/export/ScheduleTaskImporter.java # server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/model/Schedule.java
2 parents 99bd0d5 + d0f1a96 commit ff4aacf

63 files changed

Lines changed: 739 additions & 235 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libs/db-browser/src/main/java/com/oceanbase/tools/dbbrowser/schema/oracle/OBOracleSchemaAccessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,17 @@ public DBProcedure getProcedure(String schemaName, String procedureName) {
561561
procedure.setProName(procedureName);
562562
jdbcOperations.query(sb.toString(), (rs) -> {
563563
procedure.setDefiner(rs.getString("OWNER"));
564-
procedure.setDdl(String.format("create or replace %s;", rs.getClob("TEXT").toString()));
564+
procedure.setDdl(String.format("create or replace %s", rs.getClob("TEXT").toString()));
565565
procedure.setStatus(rs.getString("STATUS"));
566566
procedure.setCreateTime(rs.getTimestamp("CREATED"));
567567
procedure.setModifyTime(rs.getTimestamp("LAST_DDL_TIME"));
568568
});
569569

570+
String ddl = procedure.getDdl();
571+
if (ddl != null && !ddl.endsWith(";")) {
572+
procedure.setDdl(ddl + ";");
573+
}
574+
570575
if (StringUtils.containsIgnoreCase(procedure.getStatus(), PLConstants.PL_OBJECT_STATUS_INVALID)) {
571576
procedure.setErrorMessage(PLObjectErrMsgUtils.getOraclePLObjErrMsg(jdbcOperations,
572577
procedure.getDefiner(), DBObjectType.PROCEDURE.name(), procedure.getProName()));

server/integration-test/src/test/java/com/oceanbase/odc/AuthorityTestEnv.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import com.oceanbase.odc.metadb.iam.RolePermissionRepository;
4040
import com.oceanbase.odc.metadb.iam.RoleRepository;
4141
import com.oceanbase.odc.metadb.iam.UserEntity;
42+
import com.oceanbase.odc.metadb.iam.UserOrganizationEntity;
43+
import com.oceanbase.odc.metadb.iam.UserOrganizationRepository;
4244
import com.oceanbase.odc.metadb.iam.UserPermissionRepository;
4345
import com.oceanbase.odc.metadb.iam.UserRepository;
4446
import com.oceanbase.odc.metadb.iam.UserRoleEntity;
@@ -52,6 +54,8 @@ public abstract class AuthorityTestEnv extends ServiceTestEnv {
5254

5355
@Autowired
5456
protected UserRepository userRepository;
57+
@Autowired
58+
protected UserOrganizationRepository userOrganizationRepository;
5559

5660
@Autowired
5761
protected RoleRepository roleRepository;
@@ -108,7 +112,13 @@ protected UserEntity createUser(String username, String accountName) {
108112
entity.setActive(true);
109113
entity.setEnabled(true);
110114
entity.setDescription("internal for unit test");
111-
return userRepository.saveAndFlush(entity);
115+
116+
UserEntity user = userRepository.saveAndFlush(entity);
117+
UserOrganizationEntity userOrganizationEntity = new UserOrganizationEntity();
118+
userOrganizationEntity.setOrganizationId(user.getOrganizationId());
119+
userOrganizationEntity.setUserId(user.getId());
120+
userOrganizationRepository.saveAndFlush(userOrganizationEntity);
121+
return user;
112122
}
113123

114124
protected RoleEntity createRole() {

server/integration-test/src/test/java/com/oceanbase/odc/authority/OrganizationIsolatedValueProviderTest.java renamed to server/integration-test/src/test/java/com/oceanbase/odc/authority/SingleOrganizationResourceValueProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @date 2021-08-04 14:31
3939
* @since ODC-release_3.2.0
4040
*/
41-
public class OrganizationIsolatedValueProviderTest {
41+
public class SingleOrganizationResourceValueProviderTest {
4242

4343
@Test
4444
public void testListReturnValueOrganizationIsolated_success() {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2023 OceanBase.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.oceanbase.odc.service.iam;
17+
18+
import java.util.Arrays;
19+
import java.util.List;
20+
21+
import org.junit.Assert;
22+
import org.junit.Test;
23+
import org.springframework.beans.factory.annotation.Autowired;
24+
25+
import com.oceanbase.odc.AuthorityTestEnv;
26+
import com.oceanbase.odc.core.authority.permission.Permission;
27+
import com.oceanbase.odc.metadb.iam.resourcerole.UserResourceRoleEntity;
28+
29+
/**
30+
* @Author: Lebie
31+
* @Date: 2025/3/27 15:28
32+
* @Description: []
33+
*/
34+
public class ResourceRoleBasedPermissionExtractorTest extends AuthorityTestEnv {
35+
@Autowired
36+
private ResourceRoleBasedPermissionExtractor extractor;
37+
38+
@Test
39+
public void testGetResourcePermissions_MultiResourceIds_Success() {
40+
UserResourceRoleEntity entity1 = new UserResourceRoleEntity();
41+
entity1.setId(1L);
42+
entity1.setResourceId(1L);
43+
entity1.setResourceRoleId(1L);
44+
45+
UserResourceRoleEntity entity2 = new UserResourceRoleEntity();
46+
entity2.setId(2L);
47+
entity2.setResourceId(2L);
48+
entity2.setResourceRoleId(2L);
49+
50+
List<Permission> actual = extractor.getResourcePermissions(Arrays.asList(entity1, entity2));
51+
Assert.assertEquals(2, actual.size());
52+
}
53+
54+
@Test
55+
public void testGetResourcePermissions_OneResourceIdMultiRoles_Success() {
56+
UserResourceRoleEntity entity1 = new UserResourceRoleEntity();
57+
entity1.setId(1L);
58+
entity1.setResourceId(1L);
59+
entity1.setResourceRoleId(1L);
60+
61+
UserResourceRoleEntity entity2 = new UserResourceRoleEntity();
62+
entity2.setId(2L);
63+
entity2.setResourceId(1L);
64+
entity2.setResourceRoleId(2L);
65+
66+
List<Permission> actual = extractor.getResourcePermissions(Arrays.asList(entity1, entity2));
67+
Assert.assertEquals(1, actual.size());
68+
}
69+
70+
@Test
71+
public void testGetResourcePermissions_SameResourceIdMultiTypes_Success() {
72+
UserResourceRoleEntity entity1 = new UserResourceRoleEntity();
73+
entity1.setId(1L);
74+
entity1.setResourceId(1L);
75+
entity1.setResourceRoleId(1L);
76+
77+
UserResourceRoleEntity entity2 = new UserResourceRoleEntity();
78+
entity2.setId(2L);
79+
entity2.setResourceId(1L);
80+
entity2.setResourceRoleId(6L);
81+
82+
List<Permission> result = extractor.getResourcePermissions(Arrays.asList(entity1, entity2));
83+
Assert.assertEquals(2, result.size());
84+
}
85+
86+
}

server/odc-core/src/main/java/com/oceanbase/odc/core/authority/BaseValueFilterSecurityManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.oceanbase.odc.core.authority.auth.SecurityContext;
2727
import com.oceanbase.odc.core.authority.exception.AccessDeniedException;
2828
import com.oceanbase.odc.core.authority.model.SecurityResource;
29-
import com.oceanbase.odc.core.shared.OrganizationIsolated;
29+
import com.oceanbase.odc.core.shared.OrganizationResource;
3030

3131
import lombok.Getter;
3232
import lombok.NonNull;
@@ -67,7 +67,7 @@ public BaseValueFilterSecurityManager(AuthenticatorManager authenticatorManager,
6767
public Object decide(Subject subject, Object returnValue, SecurityContext context)
6868
throws AccessDeniedException {
6969
if (returnValue instanceof SecurityResource || returnValue instanceof Iterable
70-
|| returnValue instanceof Map || returnValue instanceof OrganizationIsolated) {
70+
|| returnValue instanceof Map || returnValue instanceof OrganizationResource) {
7171
return this.returnValueProvider.decide(subject, returnValue, context);
7272
}
7373
return returnValue;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2023 OceanBase.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.oceanbase.odc.core.shared;
17+
18+
import java.util.Set;
19+
20+
/**
21+
* Organization resource bind to multi organizations.
22+
*/
23+
public interface MultiOrganizationResource extends OrganizationResource {
24+
Set<Long> organizationIds();
25+
}

server/odc-core/src/main/java/com/oceanbase/odc/core/shared/OrganizationIsolated.java renamed to server/odc-core/src/main/java/com/oceanbase/odc/core/shared/OrganizationResource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616
package com.oceanbase.odc.core.shared;
1717

18-
public interface OrganizationIsolated {
19-
18+
/**
19+
* @author jingtian
20+
* @date 2025/1/14
21+
*/
22+
public interface OrganizationResource {
2023
String resourceType();
2124

22-
Long organizationId();
23-
2425
Long id();
25-
2626
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2023 OceanBase.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.oceanbase.odc.core.shared;
17+
18+
/**
19+
* Organization resource bind to single organization.
20+
*/
21+
public interface SingleOrganizationResource extends OrganizationResource {
22+
Long organizationId();
23+
24+
}

server/odc-core/src/main/resources/i18n/ErrorMessages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,4 @@ com.oceanbase.odc.ErrorCodes.UpdateNotAllowed=Editing is not allowed in the curr
212212
com.oceanbase.odc.ErrorCodes.PauseNotAllowed=Disabling is not allowed in the current state, please check if there are any records in execution.
213213
com.oceanbase.odc.ErrorCodes.DeleteNotAllowed=Deletion is not allowed in the current state.
214214
com.oceanbase.odc.ErrorCodes.ExtractFileFailed=Failed to extract the file. Please check whether the file is correct. Details: {0}
215-
com.oceanbase.odc.ErrorCodes.InvalidSignature=The file fails to be checked, do not modify the exported file or the wrong key was provided
215+
com.oceanbase.odc.ErrorCodes.InvalidSignature=File verification failed. Do not modify exported files or check if the correct key was used.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 OceanBase.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
CREATE TABLE IF NOT EXISTS import_file_row_history (
18+
id bigint(20) NOT NULL AUTO_INCREMENT,
19+
file_signature varchar(255) NOT NULL,
20+
row_id varchar(255) NOT NULL,
21+
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
22+
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
23+
PRIMARY KEY (id)
24+
);

0 commit comments

Comments
 (0)