initial public commit
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-manager
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.management.permission.manager;
|
||||
|
||||
import ru.entaxy.esb.system.management.permission.manager.dto.PermissionDto;
|
||||
|
||||
public interface PermissionManager {
|
||||
|
||||
PermissionDto createPermission(PermissionDto permissionDto);
|
||||
|
||||
void removePermission(PermissionDto permissionDto);
|
||||
|
||||
void removeAllPermission(long id);
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-manager
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.management.permission.manager;
|
||||
|
||||
import ru.entaxy.esb.system.core.permission.jpa.PermissionService;
|
||||
import ru.entaxy.esb.system.core.permission.jpa.entity.Permission;
|
||||
import ru.entaxy.esb.system.jpa.SystemService;
|
||||
import ru.entaxy.esb.system.jpa.entity.System;
|
||||
import ru.entaxy.esb.system.management.permission.manager.dto.PermissionDto;
|
||||
import ru.entaxy.esb.system.management.permission.manager.mapper.PermissionMapper;
|
||||
|
||||
import static ru.entaxy.esb.system.core.permission.common.PermissionConstants.TYPE_SYSTEM;
|
||||
|
||||
public class PermissionManagerImpl implements PermissionManager {
|
||||
|
||||
private PermissionService permissionService;
|
||||
private SystemService systemService;
|
||||
private PermissionMapper permissionMapper;
|
||||
|
||||
@Override
|
||||
public PermissionDto createPermission(PermissionDto permissionDto) {
|
||||
System object = systemService.getByUuid(permissionDto.getObjectId());
|
||||
System subject = systemService.getByUuid(permissionDto.getSubjectId());
|
||||
|
||||
Permission permission = permissionService.addIfNotExist(object.getId(),
|
||||
TYPE_SYSTEM, String.valueOf(subject.getId()), TYPE_SYSTEM, null);
|
||||
return permissionMapper.toPermissionDto(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(PermissionDto permissionDto) {
|
||||
System object = systemService.getByUuid(permissionDto.getObjectId());
|
||||
System subject = systemService.getByUuid(permissionDto.getSubjectId());
|
||||
|
||||
permissionService.remove(object.getId(), TYPE_SYSTEM, String.valueOf(subject.getId()),
|
||||
TYPE_SYSTEM, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllPermission(long id) {
|
||||
permissionService.removeAll(id, TYPE_SYSTEM);
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService) {
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setPermissionMapper(PermissionMapper permissionMapper) {
|
||||
this.permissionMapper = permissionMapper;
|
||||
}
|
||||
|
||||
public void setSystemService(SystemService systemService) {
|
||||
this.systemService = systemService;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-manager
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.management.permission.manager.dto;
|
||||
|
||||
public class PermissionDto {
|
||||
|
||||
private String objectId;
|
||||
private String subjectId;
|
||||
|
||||
public PermissionDto() {
|
||||
}
|
||||
|
||||
public PermissionDto(String objectId, String subjectId) {
|
||||
this.objectId = objectId;
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public String getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(String objectId) {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
public String getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(String subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-manager
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.management.permission.manager.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import ru.entaxy.esb.system.core.permission.jpa.entity.Permission;
|
||||
import ru.entaxy.esb.system.management.permission.manager.dto.PermissionDto;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface PermissionMapper {
|
||||
|
||||
Permission toPermission(PermissionDto permissionDto);
|
||||
|
||||
PermissionDto toPermissionDto(Permission permission);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
permission-manager
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
|
||||
|
||||
<bean id="permissionManager" class="ru.entaxy.esb.system.management.permission.manager.PermissionManagerImpl">
|
||||
<property name="permissionService" ref="permissionService"/>
|
||||
<property name="permissionMapper" ref="permissionMapper"/>
|
||||
<property name="systemService" ref="systemService"/>
|
||||
</bean>
|
||||
|
||||
<service ref="permissionManager" interface="ru.entaxy.esb.system.management.permission.manager.PermissionManager"/>
|
||||
|
||||
<reference id="permissionService"
|
||||
interface="ru.entaxy.esb.system.core.permission.jpa.PermissionService"
|
||||
timeout="30000"
|
||||
availability="mandatory"/>
|
||||
|
||||
<reference id="systemService"
|
||||
interface="ru.entaxy.esb.system.jpa.SystemService"
|
||||
timeout="30000"
|
||||
availability="mandatory"/>
|
||||
|
||||
<bean id="permissionMapper" class="ru.entaxy.esb.system.management.permission.manager.mapper.PermissionMapperImpl"/>
|
||||
</blueprint>
|
Reference in New Issue
Block a user