diff --git a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java index fbfa610402..0ddfdfa033 100644 --- a/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java +++ b/zanata-war/src/main/java/org/zanata/rest/service/ProjectIterationService.java @@ -190,7 +190,7 @@ else if (Objects.equal(hProject.getStatus(), READONLY)) { hProject.addIteration(hProjectIteration); // pre-emptive entity permission check - // identity.checkPermission(hProject, "add-iteration"); + // identity.checkWorkspaceAction(hProject, "add-iteration"); identity.checkPermission(hProjectIteration, "insert"); response = Response.created(uri.getAbsolutePath()); diff --git a/zanata-war/src/main/java/org/zanata/service/SecurityService.java b/zanata-war/src/main/java/org/zanata/service/SecurityService.java index b0c6bb05fa..fee05b946b 100644 --- a/zanata-war/src/main/java/org/zanata/service/SecurityService.java +++ b/zanata-war/src/main/java/org/zanata/service/SecurityService.java @@ -47,8 +47,8 @@ public interface SecurityService { * , org.jboss.seam.security.NotLoggedInException * org.zanata.webtrans.shared.NoSuchWorkspaceException */ - SecurityCheckResult checkPermission(AbstractWorkspaceAction action, - TranslationAction translationAction) + SecurityCheckResult checkWorkspaceAction(AbstractWorkspaceAction action, + TranslationAction translationAction) throws NoSuchWorkspaceException; HProject checkWorkspaceStatus(WorkspaceId workspaceId); diff --git a/zanata-war/src/main/java/org/zanata/service/impl/SecurityServiceImpl.java b/zanata-war/src/main/java/org/zanata/service/impl/SecurityServiceImpl.java index e9796cd56a..b9d87befc5 100644 --- a/zanata-war/src/main/java/org/zanata/service/impl/SecurityServiceImpl.java +++ b/zanata-war/src/main/java/org/zanata/service/impl/SecurityServiceImpl.java @@ -64,8 +64,9 @@ public class SecurityServiceImpl implements SecurityService { private TranslationWorkspaceManager translationWorkspaceManager; @Override - public SecurityCheckResult checkPermission(AbstractWorkspaceAction action, - TranslationAction translationAction) + public SecurityCheckResult checkWorkspaceAction( + AbstractWorkspaceAction action, + TranslationAction translationAction) throws NoSuchWorkspaceException { WorkspaceId workspaceId = action.getWorkspaceId(); HProject project = checkWorkspaceStatus(workspaceId); diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/ReplaceTextHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/ReplaceTextHandler.java index 95ec99d5e6..19020770fd 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/ReplaceTextHandler.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/ReplaceTextHandler.java @@ -54,8 +54,8 @@ public class ReplaceTextHandler extends @Override public UpdateTransUnitResult execute(ReplaceText action, ExecutionContext context) throws ActionException { - securityServiceImpl.checkPermission(action, - SecurityService.TranslationAction.MODIFY); + securityServiceImpl.checkWorkspaceAction(action, + SecurityService.TranslationAction.MODIFY); replaceTextInUpdateRequests(action); diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandler.java index 4072230cb4..cf9ccf7ab1 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandler.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandler.java @@ -60,8 +60,8 @@ public class RevertTransUnitUpdatesHandler extends public UpdateTransUnitResult execute(RevertTransUnitUpdates action, ExecutionContext context) throws ActionException { SecurityService.SecurityCheckResult securityCheckResult = - securityServiceImpl.checkPermission(action, - SecurityService.TranslationAction.MODIFY); + securityServiceImpl.checkWorkspaceAction(action, + SecurityService.TranslationAction.MODIFY); HLocale hLocale = securityCheckResult.getLocale(); TranslationWorkspace workspace = securityCheckResult.getWorkspace(); diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandler.java index dc709ff6e0..e12844571c 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandler.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandler.java @@ -91,7 +91,7 @@ public class TransMemoryMergeHandler extends public UpdateTransUnitResult execute(TransMemoryMerge action, ExecutionContext context) throws ActionException { SecurityService.SecurityCheckResult securityCheckResult = - securityServiceImpl.checkPermission(action, MODIFY); + securityServiceImpl.checkWorkspaceAction(action, MODIFY); HLocale hLocale = securityCheckResult.getLocale(); TranslationWorkspace workspace = securityCheckResult.getWorkspace(); diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java index 415990299e..776e258a03 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java @@ -71,11 +71,11 @@ public boolean apply(TransUnitUpdateRequest input) { } }); if (hasReviewUpdate.isPresent()) { - securityServiceImpl.checkPermission(action, - SecurityService.TranslationAction.REVIEW); + securityServiceImpl.checkWorkspaceAction(action, + SecurityService.TranslationAction.REVIEW); } else { - securityServiceImpl.checkPermission(action, - SecurityService.TranslationAction.MODIFY); + securityServiceImpl.checkWorkspaceAction(action, + SecurityService.TranslationAction.MODIFY); } return doTranslation(action.getWorkspaceId().getLocaleId(), diff --git a/zanata-war/src/test/java/org/zanata/rest/service/GlossaryRestTest.java b/zanata-war/src/test/java/org/zanata/rest/service/GlossaryRestTest.java index 740144091f..57a7289242 100644 --- a/zanata-war/src/test/java/org/zanata/rest/service/GlossaryRestTest.java +++ b/zanata-war/src/test/java/org/zanata/rest/service/GlossaryRestTest.java @@ -161,7 +161,7 @@ public void putGlossary() { // TODO SeamAutowire needs to handle @Restrict. See // org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[]) - // verify(mockIdentity).checkPermission(anyString(), + // verify(mockIdentity).checkWorkspaceAction(anyString(), // eq("glossary-insert")); } @@ -178,7 +178,7 @@ public void deleteAllGlossaries() { // TODO SeamAutowire needs to handle @Restrict. See // org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[]) - // verify(mockIdentity).checkPermission(anyString(), + // verify(mockIdentity).checkWorkspaceAction(anyString(), // eq("glossary-delete")); } @@ -196,7 +196,7 @@ public void deleteGlossaryTermWithLocale() { // TODO SeamAutowire needs to handle @Restrict. See // org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[]) - // verify(mockIdentity).checkPermission(anyString(), + // verify(mockIdentity).checkWorkspaceAction(anyString(), // eq("glossary-delete")); } @@ -224,7 +224,7 @@ public void testPutGlossaries() { // TODO SeamAutowire needs to handle @Restrict. See // org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[]) - // verify(mockIdentity).checkPermission(anyString(), + // verify(mockIdentity).checkWorkspaceAction(anyString(), // eq("glossary-insert")); } } diff --git a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandlerTest.java b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandlerTest.java index 83768cecc9..c226d3e9f5 100644 --- a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandlerTest.java +++ b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/RevertTransUnitUpdatesHandlerTest.java @@ -9,8 +9,6 @@ import java.util.List; import org.hamcrest.Matchers; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.testng.annotations.BeforeMethod; @@ -30,7 +28,6 @@ import org.zanata.webtrans.shared.model.DocumentId; import org.zanata.webtrans.shared.model.TransUnitUpdateInfo; import org.zanata.webtrans.shared.rpc.RevertTransUnitUpdates; -import org.zanata.webtrans.shared.rpc.TransUnitUpdated; import org.zanata.webtrans.shared.rpc.UpdateTransUnitResult; import com.google.common.collect.Lists; @@ -78,8 +75,8 @@ public void testExecute() throws Exception { RevertTransUnitUpdates action = new RevertTransUnitUpdates(updatesToRevert); when( - securityServiceImpl.checkPermission(action, - SecurityService.TranslationAction.MODIFY)).thenReturn( + securityServiceImpl.checkWorkspaceAction(action, + SecurityService.TranslationAction.MODIFY)).thenReturn( checkResult); when(checkResult.getLocale()).thenReturn(new HLocale(LocaleId.EN_US)); when(checkResult.getWorkspace()).thenReturn(translationWorkspace); diff --git a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandlerTest.java b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandlerTest.java index c9ebbba7f1..9462f92915 100644 --- a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandlerTest.java +++ b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/TransMemoryMergeHandlerTest.java @@ -149,8 +149,8 @@ private TransMemoryMerge prepareActionAndMockSecurityService(int threshold, private void mockSecurityService(TransMemoryMerge action) throws NoSuchWorkspaceException { when( - securityService.checkPermission(action, - SecurityService.TranslationAction.MODIFY)).thenReturn( + securityService.checkWorkspaceAction(action, + SecurityService.TranslationAction.MODIFY)).thenReturn( securityResult); when(securityResult.getLocale()).thenReturn(hLocale); when(securityResult.getWorkspace()).thenReturn(workspace);