-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EPMRPP-89198 routing refactor #1926
Changes from 6 commits
72877af
4d9259a
df8ef0b
b21c0ba
e94e598
e56c48f
5f28b45
ed48f97
9150c65
ba306d2
8797e13
78e61dd
2703326
780319f
0585275
1565099
5189a33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,15 @@ private Permissions() { | |
|
||
public static final String ADMIN_ONLY = "hasRole('ADMINISTRATOR')"; | ||
|
||
public static final String ALLOWED_TO_EDIT_USER = | ||
"(#login.toLowerCase() == authentication.name)" + "||" + ADMIN_ONLY; | ||
public static final String ALLOWED_TO_EDIT_USER = "(#login.toLowerCase() == authentication.name)" + "||" + ADMIN_ONLY; | ||
|
||
public static final String ALLOWED_TO_REPORT = | ||
"hasPermission(#projectName.toLowerCase(), 'reporterPermission')" + "||" + ADMIN_ONLY; | ||
public static final String ALLOWED_TO_REPORT = "hasPermission(#projectKey.toLowerCase(), 'reporterPermission')" + "||" + ADMIN_ONLY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public static final String ASSIGNED_TO_PROJECT = "hasPermission(#projectName.toLowerCase(), 'isAssignedToProject')"; | ||
public static final String ASSIGNED_TO_PROJECT = "hasPermission(#projectKey.toLowerCase(), 'isAssignedToProject')"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public static final String PROJECT_MANAGER = | ||
"hasPermission(#projectName.toLowerCase(), 'projectManagerPermission')" + "||" + ADMIN_ONLY; | ||
public static final String PROJECT_MANAGER = "hasPermission(#projectKey.toLowerCase(), 'projectManagerPermission')" + "||" + ADMIN_ONLY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public static final String NOT_CUSTOMER = | ||
"hasPermission(#projectName.toLowerCase(), 'notCustomerPermission')" + "||" + ADMIN_ONLY; | ||
public static final String NOT_CUSTOMER = "hasPermission(#projectKey.toLowerCase(), 'notCustomerPermission')" + "||" + ADMIN_ONLY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public static final String PROJECT_MANAGER_OR_ADMIN = | ||
"hasPermission(#projectName.toLowerCase(), 'projectManagerPermission')" + "||" + ADMIN_ONLY; | ||
} | ||
public static final String PROJECT_MANAGER_OR_ADMIN = "hasPermission(#projectKey.toLowerCase(), 'projectManagerPermission')" + "||" + ADMIN_ONLY; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,10 @@ | |
|
||
package com.epam.ta.reportportal.core.integration.impl; | ||
|
||
import static com.epam.ta.reportportal.ws.converter.converters.IntegrationConverter.TO_ACTIVITY_RESOURCE; | ||
import static com.epam.ta.reportportal.ws.model.ErrorType.INTEGRATION_NOT_FOUND; | ||
import static com.epam.ta.reportportal.ws.model.ErrorType.PROJECT_NOT_FOUND; | ||
|
||
import com.epam.ta.reportportal.commons.ReportPortalUser; | ||
import com.epam.ta.reportportal.commons.validation.Suppliers; | ||
import com.epam.ta.reportportal.core.events.activity.IntegrationDeletedEvent; | ||
|
@@ -29,17 +33,12 @@ | |
import com.epam.ta.reportportal.exception.ReportPortalException; | ||
import com.epam.ta.reportportal.ws.model.ErrorType; | ||
import com.epam.ta.reportportal.ws.model.OperationCompletionRS; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static com.epam.ta.reportportal.ws.converter.converters.IntegrationConverter.TO_ACTIVITY_RESOURCE; | ||
import static com.epam.ta.reportportal.ws.model.ErrorType.INTEGRATION_NOT_FOUND; | ||
import static com.epam.ta.reportportal.ws.model.ErrorType.PROJECT_NOT_FOUND; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Andrei Varabyeu</a> | ||
*/ | ||
|
@@ -96,10 +95,10 @@ public OperationCompletionRS deleteGlobalIntegrationsByType(String type, ReportP | |
} | ||
|
||
@Override | ||
public OperationCompletionRS deleteProjectIntegration(Long integrationId, String projectName, | ||
public OperationCompletionRS deleteProjectIntegration(Long integrationId, String projectKey, | ||
ReportPortalUser user) { | ||
Project project = projectRepository.findByName(projectName) | ||
.orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName)); | ||
Project project = projectRepository.findByKey(projectKey) | ||
.orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectKey)); | ||
Integration integration = integrationRepository.findByIdAndProjectId(integrationId, | ||
project.getId()) | ||
.orElseThrow(() -> new ReportPortalException(INTEGRATION_NOT_FOUND, integrationId)); | ||
|
@@ -115,10 +114,10 @@ public OperationCompletionRS deleteProjectIntegration(Long integrationId, String | |
} | ||
|
||
@Override | ||
public OperationCompletionRS deleteProjectIntegrationsByType(String type, String projectName, | ||
public OperationCompletionRS deleteProjectIntegrationsByType(String type, String projectKey, | ||
ReportPortalUser user) { | ||
Project project = projectRepository.findByName(projectName) | ||
.orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName)); | ||
Project project = projectRepository.findByKey(projectKey) | ||
.orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectKey)); | ||
IntegrationType integrationType = integrationTypeRepository.findByName(type) | ||
.orElseThrow(() -> new ReportPortalException(ErrorType.INTEGRATION_NOT_FOUND, type)); | ||
List<Integration> integrations = integrationRepository.findAllByProjectIdAndInIntegrationTypeIds( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.epam.ta.reportportal.core.organization; | ||
|
||
import com.epam.ta.reportportal.commons.ReportPortalUser; | ||
import com.epam.ta.reportportal.model.OrganizationResource; | ||
import java.util.List; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* @author Andrei Piankouski | ||
*/ | ||
public interface GetOrganizationHandler { | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* Get Organization resource information | ||
* | ||
* @param organizationId Organization id | ||
* @param user User | ||
* @return {@link OrganizationResource} | ||
*/ | ||
OrganizationResource getResource(Long organizationId, ReportPortalUser user); | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* Get List of all Organizations | ||
* | ||
* @return The {@link List} of the {@link OrganizationResource} | ||
*/ | ||
List<OrganizationResource> getAllOrganization(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.epam.ta.reportportal.core.organization.impl; | ||
|
||
import com.epam.ta.reportportal.commons.ReportPortalUser; | ||
import com.epam.ta.reportportal.core.organization.GetOrganizationHandler; | ||
import com.epam.ta.reportportal.dao.organization.OrganizationRepository; | ||
import com.epam.ta.reportportal.entity.organization.Organization; | ||
import com.epam.ta.reportportal.exception.ReportPortalException; | ||
import com.epam.ta.reportportal.model.OrganizationResource; | ||
import com.epam.ta.reportportal.ws.converter.converters.OrganizationConverter; | ||
import com.epam.ta.reportportal.ws.model.ErrorType; | ||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* @author Andrei Piankouski | ||
*/ | ||
@Service | ||
public class GetOrganizationHandlerImpl implements GetOrganizationHandler { | ||
|
||
private final OrganizationRepository organizationRepository; | ||
|
||
@Autowired | ||
public GetOrganizationHandlerImpl(OrganizationRepository organizationRepository) { | ||
this.organizationRepository = organizationRepository; | ||
} | ||
|
||
@Override | ||
public OrganizationResource getResource(Long organizationId, ReportPortalUser user) { | ||
Organization organization = organizationRepository.findById(organizationId) | ||
.orElseThrow( | ||
() -> new ReportPortalException(ErrorType.ORGANIZATION_NOT_FOUND, organizationId)); | ||
return OrganizationConverter.TO_ORGANIZATION_RESOURCE.apply(organization); | ||
} | ||
|
||
@Override | ||
public List<OrganizationResource> getAllOrganization() { | ||
List<Organization> organizations = organizationRepository.findAll(); | ||
return organizations.stream().map(OrganizationConverter.TO_ORGANIZATION_RESOURCE).toList(); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than 100 characters (found 120).