mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
MNT-24637 Pre-commit formatting.
This commit is contained in:
@@ -2,6 +2,11 @@ package org.alfresco.rest.favorites;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.rest.RestTest;
|
||||||
import org.alfresco.rest.model.RestErrorModel;
|
import org.alfresco.rest.model.RestErrorModel;
|
||||||
@@ -20,10 +25,6 @@ import org.alfresco.utility.model.TestGroup;
|
|||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.alfresco.utility.testrail.ExecutionType;
|
import org.alfresco.utility.testrail.ExecutionType;
|
||||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
public class GetFavoritesTests extends RestTest
|
public class GetFavoritesTests extends RestTest
|
||||||
{
|
{
|
||||||
@@ -56,7 +57,7 @@ public class GetFavoritesTests extends RestTest
|
|||||||
firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||||
UserRole.SiteContributor);
|
UserRole.SiteContributor);
|
||||||
secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||||
UserRole.SiteContributor);
|
UserRole.SiteContributor);
|
||||||
|
|
||||||
restClient.authenticateUser(userModel);
|
restClient.authenticateUser(userModel);
|
||||||
restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel);
|
restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel);
|
||||||
@@ -64,9 +65,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel);
|
restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.SANITY,
|
||||||
description = "Verify Manager user gets favorites with Rest API and status code is 200")
|
description = "Verify Manager user gets favorites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY})
|
||||||
public void managerIsAbleToRetrieveFavorites()
|
public void managerIsAbleToRetrieveFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
||||||
@@ -79,10 +80,10 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
.assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.SANITY,
|
||||||
description = "Verify user gets status code 401 if authentication call fails")
|
description = "Verify user gets status code 401 if authentication call fails")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY})
|
||||||
// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
||||||
public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails()
|
public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails()
|
||||||
{
|
{
|
||||||
UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager);
|
UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager);
|
||||||
@@ -91,44 +92,44 @@ public class GetFavoritesTests extends RestTest
|
|||||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Admin user gets favorites sites with Rest API and status code is 200")
|
description = "Verify Admin user gets favorites sites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void adminIsAbleToRetrieveFavoritesSites()
|
public void adminIsAbleToRetrieveFavoritesSites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel);
|
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel);
|
||||||
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel);
|
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI()
|
userFavorites = restClient.withCoreAPI()
|
||||||
.usingAuthUser().where().targetSiteExist().getFavorites();
|
.usingAuthUser().where().targetSiteExist().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
||||||
.and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
.and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Admin user gets favorites folders with Rest API and status code is 200")
|
description = "Verify Admin user gets favorites folders with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void adminIsAbleToRetrieveFavoritesFolders()
|
public void adminIsAbleToRetrieveFavoritesFolders()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel);
|
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel);
|
||||||
restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel);
|
restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI()
|
userFavorites = restClient.withCoreAPI()
|
||||||
.usingAuthUser().where().targetFolderExist().getFavorites();
|
.usingAuthUser().where().targetFolderExist().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef())
|
userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef())
|
||||||
.and().entriesListContains("targetGuid", secondFolderModel.getNodeRef());
|
.and().entriesListContains("targetGuid", secondFolderModel.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Admin user gets favorites files with Rest API and status code is 200")
|
description = "Verify Admin user gets favorites files with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void adminIsAbleToRetrieveFavoritesFiles()
|
public void adminIsAbleToRetrieveFavoritesFiles()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel);
|
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel);
|
||||||
restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel);
|
restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI()
|
userFavorites = restClient.withCoreAPI()
|
||||||
.usingAuthUser().where().targetFileExist().getFavorites();
|
.usingAuthUser().where().targetFileExist().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
@@ -136,87 +137,87 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion());
|
.and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Collaborator user gets favorites with Rest API and status code is 200")
|
description = "Verify Collaborator user gets favorites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void collaboratorIsAbleToRetrieveFavorites()
|
public void collaboratorIsAbleToRetrieveFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator))
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||||
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
||||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
||||||
.and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
.and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Contributor user gets favorites with Rest API and status code is 200")
|
description = "Verify Contributor user gets favorites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void contributorIsAbleToRetrieveFavorites()
|
public void contributorIsAbleToRetrieveFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor))
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor))
|
||||||
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
||||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and()
|
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and()
|
||||||
.entriesListContains("targetGuid", secondSiteModel.getGuid());
|
.entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify Consumer user gets favorites with Rest API and status code is 200")
|
description = "Verify Consumer user gets favorites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void consumerIsAbleToRetrieveFavorites()
|
public void consumerIsAbleToRetrieveFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer))
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer))
|
||||||
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel);
|
||||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel);
|
||||||
|
|
||||||
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid())
|
||||||
.assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
.assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404")
|
description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsNotAbleToRetrieveFavoritesOfAnotherUser()
|
public void userIsNotAbleToRetrieveFavoritesOfAnotherUser()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer))
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer))
|
||||||
.withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites();
|
.withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()));
|
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200")
|
description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsNotAbleToRetrieveFavoritesOfAdminUser()
|
public void userIsNotAbleToRetrieveFavoritesOfAdminUser()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI()
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI()
|
||||||
.usingUser(adminUserModel).getFavorites();
|
.usingUser(adminUserModel).getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername()));
|
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200")
|
description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser()
|
public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator))
|
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||||
.getFavorites();
|
.getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()));
|
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites sites with Rest API and status code is 200")
|
description = "Verify User gets only favorites sites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveOnlyFavoritesSites()
|
public void userIsAbleToRetrieveOnlyFavoritesSites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
||||||
@@ -232,9 +233,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites files with Rest API and status code is 200")
|
description = "Verify User gets only favorites files with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveOnlyFavoritesFiles()
|
public void userIsAbleToRetrieveOnlyFavoritesFiles()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||||
@@ -250,9 +251,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites folders with Rest API and status code is 200")
|
description = "Verify User gets only favorites folders with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveOnlyFavoritesFolders()
|
public void userIsAbleToRetrieveOnlyFavoritesFolders()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||||
@@ -268,9 +269,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion());
|
.and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites files or folders with Rest API and status code is 200")
|
description = "Verify User gets only favorites files or folders with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveFavoritesFilesOrFolders()
|
public void userIsAbleToRetrieveFavoritesFilesOrFolders()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer));
|
||||||
@@ -289,9 +290,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid());
|
.and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites files or sites with Rest API and status code is 200")
|
description = "Verify User gets only favorites files or sites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveFavoritesFilesOrSites()
|
public void userIsAbleToRetrieveFavoritesFilesOrSites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
||||||
@@ -310,9 +311,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
.and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets only favorites folders or sites with Rest API and status code is 200")
|
description = "Verify User gets only favorites folders or sites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveFavoritesFoldersOrSites()
|
public void userIsAbleToRetrieveFavoritesFoldersOrSites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
||||||
@@ -331,9 +332,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion());
|
.and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets all favorites with Rest API and status code is 200")
|
description = "Verify User gets all favorites with Rest API and status code is 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToRetrieveAllFavorites()
|
public void userIsAbleToRetrieveAllFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||||
@@ -362,9 +363,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion());
|
.and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify request for a user with no favorites returns status 200")
|
description = "Verify request for a user with no favorites returns status 200")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userHasNoFavorites()
|
public void userHasNoFavorites()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor));
|
restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor));
|
||||||
@@ -374,9 +375,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0");
|
userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify request using invalid where parameter returns status 400")
|
description = "Verify request using invalid where parameter returns status 400")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void getFavoritesUsingInvalidWhereParameter()
|
public void getFavoritesUsingInvalidWhereParameter()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer));
|
||||||
@@ -390,9 +391,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify User gets correct favorites after deleting a favorite")
|
description = "Verify User gets correct favorites after deleting a favorite")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void checkFavoriteFolderIsRemoved()
|
public void checkFavoriteFolderIsRemoved()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager));
|
||||||
@@ -408,9 +409,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().paginationField("totalItems").is("2");
|
.and().paginationField("totalItems").is("2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites specifying -me- string in place of <personid> for request")
|
description = "Verify get favorites specifying -me- string in place of <personid> for request")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesWhenUsingMeAsUsername()
|
public void userIsAbleToGetFavoritesWhenUsingMeAsUsername()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites();
|
||||||
@@ -418,9 +419,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites using empty for where parameter for request")
|
description = "Verify get favorites using empty for where parameter for request")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter()
|
public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites();
|
userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites();
|
||||||
@@ -428,27 +429,27 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify that for invalid maxItems parameter status code returned is 400.")
|
description = "Verify that for invalid maxItems parameter status code returned is 400.")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void checkInvalidMaxItemsStatusCode()
|
public void checkInvalidMaxItemsStatusCode()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites();
|
restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter");
|
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify that for invalid skipCount parameter status code returned is 400.")
|
description = "Verify that for invalid skipCount parameter status code returned is 400.")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void checkInvalidSkipCountStatusCode()
|
public void checkInvalidSkipCountStatusCode()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites();
|
restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter");
|
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites when using invalid network id for non-tenant user")
|
description = "Verify get favorites when using invalid network id for non-tenant user")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void getFavoritesWhenNetworkIdIsInvalid()
|
public void getFavoritesWhenNetworkIdIsInvalid()
|
||||||
{
|
{
|
||||||
UserModel networkUserModel = dataUser.createRandomTestUser();
|
UserModel networkUserModel = dataUser.createRandomTestUser();
|
||||||
@@ -457,9 +458,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername()));
|
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites using AND instead of OR in where parameter for request")
|
description = "Verify get favorites using AND instead of OR in where parameter for request")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter()
|
public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites();
|
userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites();
|
||||||
@@ -467,9 +468,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request")
|
description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter()
|
public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites();
|
userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites();
|
||||||
@@ -477,9 +478,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites except the first one for request")
|
description = "Verify get favorites except the first one for request")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesExceptTheFirstOne()
|
public void userIsAbleToGetFavoritesExceptTheFirstOne()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites();
|
||||||
@@ -490,9 +491,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid());
|
.and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get first two favorites sites")
|
description = "Verify get first two favorites sites")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFirstTwoFavorites()
|
public void userIsAbleToGetFirstTwoFavorites()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites();
|
||||||
@@ -506,9 +507,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
.and().field("count").is("2");
|
.and().field("count").is("2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify get favorites sites when using empty values for skipCount and maxItems")
|
description = "Verify get favorites sites when using empty values for skipCount and maxItems")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty()
|
public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty()
|
||||||
{
|
{
|
||||||
restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites();
|
restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites();
|
||||||
@@ -518,9 +519,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " "));
|
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify the get favorites request for a high value for skipCount parameter")
|
description = "Verify the get favorites request for a high value for skipCount parameter")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesWithHighSkipCount()
|
public void userIsAbleToGetFavoritesWithHighSkipCount()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites();
|
||||||
@@ -529,9 +530,9 @@ public class GetFavoritesTests extends RestTest
|
|||||||
userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999");
|
userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify the get favorites request with properties parameter applied")
|
description = "Verify the get favorites request with properties parameter applied")
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void userIsAbleToGetFavoritesWithPropertiesParamApplied()
|
public void userIsAbleToGetFavoritesWithPropertiesParamApplied()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites();
|
||||||
@@ -541,8 +542,8 @@ public class GetFavoritesTests extends RestTest
|
|||||||
restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull();
|
restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION })
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API")
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API")
|
||||||
public void checkResponseSchemaForGetFavorites()
|
public void checkResponseSchemaForGetFavorites()
|
||||||
{
|
{
|
||||||
userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites();
|
userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites();
|
||||||
@@ -564,8 +565,7 @@ public class GetFavoritesTests extends RestTest
|
|||||||
description = "Verify if get favorites response returns allowableOperations object when requested")
|
description = "Verify if get favorites response returns allowableOperations object when requested")
|
||||||
public void checkResponsesForGetFavoritesWithAllowableOperations()
|
public void checkResponsesForGetFavoritesWithAllowableOperations()
|
||||||
{
|
{
|
||||||
final RestPersonFavoritesModelsCollection adminFavorites =
|
final RestPersonFavoritesModelsCollection adminFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().include(ALLOWABLE_OPERATIONS).getFavorites();
|
||||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().include(ALLOWABLE_OPERATIONS).getFavorites();
|
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
|
||||||
adminFavorites.getEntries().stream()
|
adminFavorites.getEntries().stream()
|
||||||
@@ -576,18 +576,17 @@ public class GetFavoritesTests extends RestTest
|
|||||||
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
@TestRail(section = {TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION,
|
||||||
description = "Verify the get favorites request with properties parameter applied")
|
description = "Verify the get favorites request with properties parameter applied")
|
||||||
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
@Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION})
|
||||||
public void checkSearchResponseContainsIsFavoriteWhenRequested() throws InterruptedException {
|
public void checkSearchResponseContainsIsFavoriteWhenRequested() throws InterruptedException
|
||||||
|
{
|
||||||
final SearchRequest query = new SearchRequest();
|
final SearchRequest query = new SearchRequest();
|
||||||
final RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
final RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||||
queryReq.setQuery(firstFileModel.getName());
|
queryReq.setQuery(firstFileModel.getName());
|
||||||
query.setQuery(queryReq);
|
query.setQuery(queryReq);
|
||||||
query.setInclude(List.of("isFavorite"));
|
query.setInclude(List.of("isFavorite"));
|
||||||
|
|
||||||
Utility.sleep(500, 60000, () ->
|
Utility.sleep(500, 60000, () -> {
|
||||||
{
|
restClient.authenticateUser(adminUserModel).withSearchAPI().search(query);
|
||||||
restClient.authenticateUser(adminUserModel).withSearchAPI().search(query);
|
restClient.onResponse().assertThat().body("list.entries.entry[0].isFavorite", Matchers.notNullValue());
|
||||||
restClient.onResponse().assertThat().body("list.entries.entry[0].isFavorite", Matchers.notNullValue());
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,460 +1,459 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.impl;
|
package org.alfresco.rest.api.impl;
|
||||||
|
|
||||||
import static org.alfresco.rest.api.Nodes.PARAM_INCLUDE_ALLOWABLEOPERATIONS;
|
import static org.alfresco.rest.api.Nodes.PARAM_INCLUDE_ALLOWABLEOPERATIONS;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.apache.commons.logging.Log;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.alfresco.repo.favourites.PersonFavourite;
|
|
||||||
import org.alfresco.repo.site.SiteDoesNotExistException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.rest.api.Favourites;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.repo.favourites.PersonFavourite;
|
||||||
import org.alfresco.rest.api.People;
|
import org.alfresco.repo.site.SiteDoesNotExistException;
|
||||||
import org.alfresco.rest.api.Sites;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.rest.api.model.Document;
|
import org.alfresco.rest.api.Favourites;
|
||||||
import org.alfresco.rest.api.model.DocumentTarget;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.Favourite;
|
import org.alfresco.rest.api.People;
|
||||||
import org.alfresco.rest.api.model.Folder;
|
import org.alfresco.rest.api.Sites;
|
||||||
import org.alfresco.rest.api.model.FolderTarget;
|
import org.alfresco.rest.api.model.Document;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.DocumentTarget;
|
||||||
import org.alfresco.rest.api.model.PathInfo;
|
import org.alfresco.rest.api.model.Favourite;
|
||||||
import org.alfresco.rest.api.model.Site;
|
import org.alfresco.rest.api.model.Folder;
|
||||||
import org.alfresco.rest.api.model.SiteTarget;
|
import org.alfresco.rest.api.model.FolderTarget;
|
||||||
import org.alfresco.rest.api.model.Target;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
import org.alfresco.rest.api.model.PathInfo;
|
||||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
import org.alfresco.rest.api.model.Site;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.api.model.SiteTarget;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
import org.alfresco.rest.api.model.Target;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper.WalkerCallbackAdapter;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.service.cmr.favourites.FavouritesService;
|
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||||
import org.alfresco.service.cmr.favourites.FavouritesService.SortFields;
|
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
||||||
import org.alfresco.service.cmr.favourites.FavouritesService.Type;
|
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper.WalkerCallbackAdapter;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.favourites.FavouritesService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.favourites.FavouritesService.SortFields;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.favourites.FavouritesService.Type;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
/**
|
|
||||||
* Public REST API: Centralises access to favourites functionality and maps between representations repository and api representations.
|
/**
|
||||||
*
|
* Public REST API: Centralises access to favourites functionality and maps between representations repository and api representations.
|
||||||
* @author steveglover
|
*
|
||||||
* @since publicapi1.0
|
* @author steveglover
|
||||||
*/
|
* @since publicapi1.0
|
||||||
public class FavouritesImpl implements Favourites
|
*/
|
||||||
{
|
public class FavouritesImpl implements Favourites
|
||||||
private static final Log logger = LogFactory.getLog(FavouritesImpl.class);
|
{
|
||||||
|
private static final Log logger = LogFactory.getLog(FavouritesImpl.class);
|
||||||
private static final List<String> ALLOWED_INCLUDES = List.of(PARAM_INCLUDE_PROPERTIES, PARAM_INCLUDE_ALLOWABLEOPERATIONS);
|
|
||||||
|
private static final List<String> ALLOWED_INCLUDES = List.of(PARAM_INCLUDE_PROPERTIES, PARAM_INCLUDE_ALLOWABLEOPERATIONS);
|
||||||
private People people;
|
|
||||||
private Sites sites;
|
private People people;
|
||||||
private Nodes nodes;
|
private Sites sites;
|
||||||
private FavouritesService favouritesService;
|
private Nodes nodes;
|
||||||
private SiteService siteService;
|
private FavouritesService favouritesService;
|
||||||
private NamespaceService namespaceService;
|
private SiteService siteService;
|
||||||
|
private NamespaceService namespaceService;
|
||||||
// additional exclude properties for favourites as these can be already top-level properties
|
|
||||||
private static final List<QName> EXCLUDED_PROPS = Arrays.asList(
|
// additional exclude properties for favourites as these can be already top-level properties
|
||||||
ContentModel.PROP_TITLE,
|
private static final List<QName> EXCLUDED_PROPS = Arrays.asList(
|
||||||
ContentModel.PROP_DESCRIPTION,
|
ContentModel.PROP_TITLE,
|
||||||
SiteModel.PROP_SITE_VISIBILITY,
|
ContentModel.PROP_DESCRIPTION,
|
||||||
SiteModel.PROP_SITE_PRESET
|
SiteModel.PROP_SITE_VISIBILITY,
|
||||||
);
|
SiteModel.PROP_SITE_PRESET);
|
||||||
|
|
||||||
public void setPeople(People people)
|
public void setPeople(People people)
|
||||||
{
|
{
|
||||||
this.people = people;
|
this.people = people;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSites(Sites sites)
|
public void setSites(Sites sites)
|
||||||
{
|
{
|
||||||
this.sites = sites;
|
this.sites = sites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodes(Nodes nodes)
|
public void setNodes(Nodes nodes)
|
||||||
{
|
{
|
||||||
this.nodes = nodes;
|
this.nodes = nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFavouritesService(FavouritesService favouritesService)
|
public void setFavouritesService(FavouritesService favouritesService)
|
||||||
{
|
{
|
||||||
this.favouritesService = favouritesService;
|
this.favouritesService = favouritesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSiteService(SiteService siteService)
|
public void setSiteService(SiteService siteService)
|
||||||
{
|
{
|
||||||
this.siteService = siteService;
|
this.siteService = siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
public void setNamespaceService(NamespaceService namespaceService)
|
||||||
{
|
{
|
||||||
this.namespaceService = namespaceService;
|
this.namespaceService = namespaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Target getTarget(PersonFavourite personFavourite, Parameters parameters)
|
private Target getTarget(PersonFavourite personFavourite, Parameters parameters)
|
||||||
{
|
{
|
||||||
Target target = null;
|
Target target = null;
|
||||||
NodeRef nodeRef = personFavourite.getNodeRef();
|
NodeRef nodeRef = personFavourite.getNodeRef();
|
||||||
Type type = personFavourite.getType();
|
Type type = personFavourite.getType();
|
||||||
if(type.equals(Type.FILE))
|
if (type.equals(Type.FILE))
|
||||||
{
|
{
|
||||||
Document document = nodes.getDocument(nodeRef);
|
Document document = nodes.getDocument(nodeRef);
|
||||||
setPathInfo(document, parameters.getInclude());
|
setPathInfo(document, parameters.getInclude());
|
||||||
target = new DocumentTarget(document);
|
target = new DocumentTarget(document);
|
||||||
}
|
}
|
||||||
else if(type.equals(Type.FOLDER))
|
else if (type.equals(Type.FOLDER))
|
||||||
{
|
{
|
||||||
Folder folder = nodes.getFolder(nodeRef);
|
Folder folder = nodes.getFolder(nodeRef);
|
||||||
setPathInfo(folder, parameters.getInclude());
|
setPathInfo(folder, parameters.getInclude());
|
||||||
target = new FolderTarget(folder);
|
target = new FolderTarget(folder);
|
||||||
}
|
}
|
||||||
else if(type.equals(Type.SITE))
|
else if (type.equals(Type.SITE))
|
||||||
{
|
{
|
||||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||||
String role = sites.getSiteRole(siteInfo.getShortName());
|
String role = sites.getSiteRole(siteInfo.getShortName());
|
||||||
Site site = new Site(siteInfo, role);
|
Site site = new Site(siteInfo, role);
|
||||||
target = new SiteTarget(site);
|
target = new SiteTarget(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unexpected favourite target type: " + type);
|
throw new AlfrescoRuntimeException("Unexpected favourite target type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Favourite getFavourite(PersonFavourite personFavourite, Parameters parameters)
|
private Favourite getFavourite(PersonFavourite personFavourite, Parameters parameters)
|
||||||
{
|
{
|
||||||
Favourite fav = new Favourite();
|
Favourite fav = new Favourite();
|
||||||
fav.setTargetGuid(personFavourite.getNodeRef().getId());
|
fav.setTargetGuid(personFavourite.getNodeRef().getId());
|
||||||
fav.setCreatedAt(personFavourite.getCreatedAt());
|
fav.setCreatedAt(personFavourite.getCreatedAt());
|
||||||
Target target = getTarget(personFavourite, parameters);
|
Target target = getTarget(personFavourite, parameters);
|
||||||
fav.setTarget(target);
|
fav.setTarget(target);
|
||||||
|
|
||||||
// REPO-1147 allow retrieving additional properties
|
// REPO-1147 allow retrieving additional properties
|
||||||
final List<String> paramsInclude = parameters.getInclude();
|
final List<String> paramsInclude = parameters.getInclude();
|
||||||
if (!Collections.disjoint(paramsInclude, ALLOWED_INCLUDES))
|
if (!Collections.disjoint(paramsInclude, ALLOWED_INCLUDES))
|
||||||
{
|
{
|
||||||
final List<String> includes = ALLOWED_INCLUDES.stream().filter(a -> paramsInclude.contains(a)).collect(Collectors.toList());
|
final List<String> includes = ALLOWED_INCLUDES.stream().filter(a -> paramsInclude.contains(a)).collect(Collectors.toList());
|
||||||
// get node representation with only properties included
|
// get node representation with only properties included
|
||||||
Node node = nodes.getFolderOrDocument(personFavourite.getNodeRef(), null, null, includes, null);
|
Node node = nodes.getFolderOrDocument(personFavourite.getNodeRef(), null, null, includes, null);
|
||||||
// Create a map from node properties excluding properties already in this Favorite
|
// Create a map from node properties excluding properties already in this Favorite
|
||||||
Map<String, Object> filteredNodeProperties = filterProps(node.getProperties(), EXCLUDED_PROPS);
|
Map<String, Object> filteredNodeProperties = filterProps(node.getProperties(), EXCLUDED_PROPS);
|
||||||
if(filteredNodeProperties.size() > 0 && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES))
|
if (filteredNodeProperties.size() > 0 && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES))
|
||||||
{
|
{
|
||||||
fav.setProperties(filteredNodeProperties);
|
fav.setProperties(filteredNodeProperties);
|
||||||
}
|
}
|
||||||
final List<String> allowableOperations = node.getAllowableOperations();
|
final List<String> allowableOperations = node.getAllowableOperations();
|
||||||
if (CollectionUtils.isNotEmpty(allowableOperations) && paramsInclude.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
|
if (CollectionUtils.isNotEmpty(allowableOperations) && paramsInclude.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
|
||||||
{
|
{
|
||||||
fav.setAllowableOperations(allowableOperations);
|
fav.setAllowableOperations(allowableOperations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fav;
|
return fav;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> filterProps(Map<String, Object> properties, List<QName> toRemove)
|
private Map<String, Object> filterProps(Map<String, Object> properties, List<QName> toRemove)
|
||||||
{
|
{
|
||||||
Map<String, Object> filteredProps = properties == null ? new HashMap<>() : new HashMap<>(properties);
|
Map<String, Object> filteredProps = properties == null ? new HashMap<>() : new HashMap<>(properties);
|
||||||
List<String> propsToRemove = toRemove.stream().map(e -> e.toPrefixString(namespaceService)).collect(Collectors.toList());
|
List<String> propsToRemove = toRemove.stream().map(e -> e.toPrefixString(namespaceService)).collect(Collectors.toList());
|
||||||
filteredProps.keySet().removeAll(propsToRemove);
|
filteredProps.keySet().removeAll(propsToRemove);
|
||||||
return filteredProps;
|
return filteredProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectionWithPagingInfo<Favourite> wrap(Paging paging, PagingResults<PersonFavourite> personFavourites, Parameters parameters)
|
private CollectionWithPagingInfo<Favourite> wrap(Paging paging, PagingResults<PersonFavourite> personFavourites, Parameters parameters)
|
||||||
{
|
{
|
||||||
final List<PersonFavourite> page = personFavourites.getPage();
|
final List<PersonFavourite> page = personFavourites.getPage();
|
||||||
final List<Favourite> list = new AbstractList<Favourite>()
|
final List<Favourite> list = new AbstractList<Favourite>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public Favourite get(int index)
|
||||||
public Favourite get(int index)
|
{
|
||||||
{
|
PersonFavourite personFavourite = page.get(index);
|
||||||
PersonFavourite personFavourite = page.get(index);
|
Favourite fav = getFavourite(personFavourite, parameters);
|
||||||
Favourite fav = getFavourite(personFavourite, parameters);
|
return fav;
|
||||||
return fav;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int size()
|
||||||
public int size()
|
{
|
||||||
{
|
return page.size();
|
||||||
return page.size();
|
}
|
||||||
}
|
};
|
||||||
};
|
Pair<Integer, Integer> pair = personFavourites.getTotalResultCount();
|
||||||
Pair<Integer, Integer> pair = personFavourites.getTotalResultCount();
|
Integer total = null;
|
||||||
Integer total = null;
|
if (pair.getFirst().equals(pair.getSecond()))
|
||||||
if(pair.getFirst().equals(pair.getSecond()))
|
{
|
||||||
{
|
total = pair.getFirst();
|
||||||
total = pair.getFirst();
|
}
|
||||||
}
|
return CollectionWithPagingInfo.asPaged(paging, list, personFavourites.hasMoreItems(), total);
|
||||||
return CollectionWithPagingInfo.asPaged(paging, list, personFavourites.hasMoreItems(), total);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public Favourite addFavourite(String personId, Favourite favourite)
|
||||||
public Favourite addFavourite(String personId, Favourite favourite)
|
{
|
||||||
{
|
Parameters parameters = getDefaultParameters(personId, null);
|
||||||
Parameters parameters = getDefaultParameters(personId, null);
|
return addFavourite(personId, favourite, parameters);
|
||||||
return addFavourite(personId, favourite, parameters);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public Favourite addFavourite(String personId, Favourite favourite, Parameters parameters)
|
||||||
public Favourite addFavourite(String personId, Favourite favourite, Parameters parameters)
|
{
|
||||||
{
|
Favourite ret = null;
|
||||||
Favourite ret = null;
|
|
||||||
|
personId = people.validatePerson(personId, true);
|
||||||
personId = people.validatePerson(personId, true);
|
Target target = favourite.getTarget();
|
||||||
Target target = favourite.getTarget();
|
if (target == null)
|
||||||
if(target == null)
|
{
|
||||||
{
|
throw new InvalidArgumentException("target is missing");
|
||||||
throw new InvalidArgumentException("target is missing");
|
}
|
||||||
}
|
else if (target instanceof SiteTarget)
|
||||||
else if(target instanceof SiteTarget)
|
{
|
||||||
{
|
SiteTarget siteTarget = (SiteTarget) target;
|
||||||
SiteTarget siteTarget = (SiteTarget)target;
|
String guid = siteTarget.getSite().getGuid();
|
||||||
String guid = siteTarget.getSite().getGuid();
|
SiteInfo siteInfo = sites.validateSite(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, guid));
|
||||||
SiteInfo siteInfo = sites.validateSite(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, guid));
|
NodeRef siteNodeRef = siteInfo.getNodeRef();
|
||||||
NodeRef siteNodeRef = siteInfo.getNodeRef();
|
String siteId = siteInfo.getShortName();
|
||||||
String siteId = siteInfo.getShortName();
|
|
||||||
|
try
|
||||||
try
|
{
|
||||||
{
|
PersonFavourite personFavourite = favouritesService.addFavourite(personId, siteNodeRef);
|
||||||
PersonFavourite personFavourite = favouritesService.addFavourite(personId, siteNodeRef);
|
ret = getFavourite(personFavourite, parameters);
|
||||||
ret = getFavourite(personFavourite, parameters);
|
}
|
||||||
}
|
catch (SiteDoesNotExistException e)
|
||||||
catch(SiteDoesNotExistException e)
|
{
|
||||||
{
|
throw new RelationshipResourceNotFoundException(personId, siteId);
|
||||||
throw new RelationshipResourceNotFoundException(personId, siteId);
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (target instanceof DocumentTarget)
|
||||||
else if(target instanceof DocumentTarget)
|
{
|
||||||
{
|
DocumentTarget documentTarget = (DocumentTarget) target;
|
||||||
DocumentTarget documentTarget = (DocumentTarget)target;
|
NodeRef nodeRef = documentTarget.getFile().getGuid();
|
||||||
NodeRef nodeRef = documentTarget.getFile().getGuid();
|
if (!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null))
|
||||||
if(!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null))
|
{
|
||||||
{
|
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
|
||||||
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
|
}
|
||||||
}
|
|
||||||
|
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
|
||||||
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
|
ret = getFavourite(personFavourite, parameters);
|
||||||
ret = getFavourite(personFavourite, parameters);
|
}
|
||||||
}
|
else if (target instanceof FolderTarget)
|
||||||
else if(target instanceof FolderTarget)
|
{
|
||||||
{
|
FolderTarget folderTarget = (FolderTarget) target;
|
||||||
FolderTarget folderTarget = (FolderTarget)target;
|
NodeRef nodeRef = folderTarget.getFolder().getGuid();
|
||||||
NodeRef nodeRef = folderTarget.getFolder().getGuid();
|
if (!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_FOLDER), Collections.singleton(SiteModel.TYPE_SITE)))
|
||||||
if(!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_FOLDER), Collections.singleton(SiteModel.TYPE_SITE)))
|
{
|
||||||
{
|
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
|
||||||
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
|
}
|
||||||
}
|
|
||||||
|
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
|
||||||
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
|
ret = getFavourite(personFavourite, parameters);
|
||||||
ret = getFavourite(personFavourite, parameters);
|
}
|
||||||
}
|
|
||||||
|
return ret;
|
||||||
return ret;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void removeFavourite(String personId, String id)
|
||||||
public void removeFavourite(String personId, String id)
|
{
|
||||||
{
|
personId = people.validatePerson(personId, true);
|
||||||
personId = people.validatePerson(personId, true);
|
NodeRef nodeRef = nodes.validateNode(id);
|
||||||
NodeRef nodeRef = nodes.validateNode(id);
|
boolean exists = false;
|
||||||
boolean exists = false;
|
|
||||||
|
Type type = favouritesService.getType(nodeRef);
|
||||||
Type type = favouritesService.getType(nodeRef);
|
if (type.equals(Type.SITE))
|
||||||
if(type.equals(Type.SITE))
|
{
|
||||||
{
|
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
if (siteInfo == null)
|
||||||
if(siteInfo == null)
|
{
|
||||||
{
|
// shouldn't happen because the type implies it's a site
|
||||||
// shouldn't happen because the type implies it's a site
|
throw new AlfrescoRuntimeException("Unable to find site with nodeRef " + nodeRef);
|
||||||
throw new AlfrescoRuntimeException("Unable to find site with nodeRef " + nodeRef);
|
}
|
||||||
}
|
exists = favouritesService.removeFavourite(personId, siteInfo.getNodeRef());
|
||||||
exists = favouritesService.removeFavourite(personId, siteInfo.getNodeRef());
|
}
|
||||||
}
|
else if (type.equals(Type.FILE))
|
||||||
else if(type.equals(Type.FILE))
|
{
|
||||||
{
|
exists = favouritesService.removeFavourite(personId, nodeRef);
|
||||||
exists = favouritesService.removeFavourite(personId, nodeRef);
|
}
|
||||||
}
|
else if (type.equals(Type.FOLDER))
|
||||||
else if(type.equals(Type.FOLDER))
|
{
|
||||||
{
|
exists = favouritesService.removeFavourite(personId, nodeRef);
|
||||||
exists = favouritesService.removeFavourite(personId, nodeRef);
|
}
|
||||||
}
|
if (!exists)
|
||||||
if(!exists)
|
{
|
||||||
{
|
throw new RelationshipResourceNotFoundException(personId, id);
|
||||||
throw new RelationshipResourceNotFoundException(personId, id);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public Favourite getFavourite(String personId, String favouriteId)
|
||||||
public Favourite getFavourite(String personId, String favouriteId)
|
{
|
||||||
{
|
Parameters parameters = getDefaultParameters(personId, favouriteId);
|
||||||
Parameters parameters = getDefaultParameters(personId, favouriteId);
|
return getFavourite(personId, favouriteId, parameters);
|
||||||
return getFavourite(personId, favouriteId, parameters);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public Favourite getFavourite(String personId, String favouriteId, Parameters parameters)
|
||||||
public Favourite getFavourite(String personId, String favouriteId, Parameters parameters)
|
{
|
||||||
{
|
NodeRef nodeRef = nodes.validateNode(favouriteId);
|
||||||
NodeRef nodeRef = nodes.validateNode(favouriteId);
|
personId = people.validatePerson(personId, true);
|
||||||
personId = people.validatePerson(personId, true);
|
|
||||||
|
PersonFavourite personFavourite = favouritesService.getFavourite(personId, nodeRef);
|
||||||
PersonFavourite personFavourite = favouritesService.getFavourite(personId, nodeRef);
|
if (personFavourite != null)
|
||||||
if(personFavourite != null)
|
{
|
||||||
{
|
Favourite favourite = getFavourite(personFavourite, parameters);
|
||||||
Favourite favourite = getFavourite(personFavourite, parameters);
|
return favourite;
|
||||||
return favourite;
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
throw new RelationshipResourceNotFoundException(personId, favouriteId);
|
||||||
throw new RelationshipResourceNotFoundException(personId, favouriteId);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public CollectionWithPagingInfo<Favourite> getFavourites(String personId, final Parameters parameters)
|
||||||
public CollectionWithPagingInfo<Favourite> getFavourites(String personId, final Parameters parameters)
|
{
|
||||||
{
|
personId = people.validatePerson(personId, true);
|
||||||
personId = people.validatePerson(personId, true);
|
|
||||||
|
Paging paging = parameters.getPaging();
|
||||||
Paging paging = parameters.getPaging();
|
|
||||||
|
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = getSortProps(parameters);
|
||||||
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = getSortProps(parameters);
|
|
||||||
|
final Set<Type> filteredByClientQuery = new HashSet<Type>();
|
||||||
final Set<Type> filteredByClientQuery = new HashSet<Type>();
|
Set<Type> filterTypes = FavouritesService.Type.ALL_FILTER_TYPES; // Default all
|
||||||
Set<Type> filterTypes = FavouritesService.Type.ALL_FILTER_TYPES; //Default all
|
|
||||||
|
// filterType is of the form 'target.<site|file|folder>'
|
||||||
// filterType is of the form 'target.<site|file|folder>'
|
QueryHelper.walk(parameters.getQuery(), new WalkerCallbackAdapter() {
|
||||||
QueryHelper.walk(parameters.getQuery(), new WalkerCallbackAdapter()
|
@Override
|
||||||
{
|
public void or()
|
||||||
@Override
|
{
|
||||||
public void or() {
|
// OR is supported but exists() will be called for each EXISTS so we don't
|
||||||
//OR is supported but exists() will be called for each EXISTS so we don't
|
// need to do anything here. If we don't override it then it will be assumed
|
||||||
//need to do anything here. If we don't override it then it will be assumed
|
// that OR in the grammar is not supported.
|
||||||
//that OR in the grammar is not supported.
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void exists(String filteredByClient, boolean negated)
|
||||||
public void exists(String filteredByClient, boolean negated) {
|
{
|
||||||
if(filteredByClient != null)
|
if (filteredByClient != null)
|
||||||
{
|
{
|
||||||
int idx = filteredByClient.lastIndexOf("/");
|
int idx = filteredByClient.lastIndexOf("/");
|
||||||
if(idx == -1 || idx == filteredByClient.length())
|
if (idx == -1 || idx == filteredByClient.length())
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException();
|
throw new InvalidArgumentException();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String filtertype = filteredByClient.substring(idx + 1).toUpperCase();
|
String filtertype = filteredByClient.substring(idx + 1).toUpperCase();
|
||||||
filteredByClientQuery.add(Type.valueOf(filtertype));
|
filteredByClientQuery.add(Type.valueOf(filtertype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filteredByClientQuery.size() > 0)
|
if (filteredByClientQuery.size() > 0)
|
||||||
{
|
{
|
||||||
filterTypes = filteredByClientQuery;
|
filterTypes = filteredByClientQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PagingResults<PersonFavourite> favourites = favouritesService.getPagedFavourites(personId, filterTypes, sortProps, Util.getPagingRequest(paging));
|
final PagingResults<PersonFavourite> favourites = favouritesService.getPagedFavourites(personId, filterTypes, sortProps, Util.getPagingRequest(paging));
|
||||||
|
|
||||||
return wrap(paging, favourites, parameters);
|
return wrap(paging, favourites, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPathInfo(Node node, List<String> includeParam)
|
private void setPathInfo(Node node, List<String> includeParam)
|
||||||
{
|
{
|
||||||
if (includeParam.contains(PARAM_INCLUDE_PATH))
|
if (includeParam.contains(PARAM_INCLUDE_PATH))
|
||||||
{
|
{
|
||||||
PathInfo pathInfo = nodes.lookupPathInfo(node.getNodeRef(), null);
|
PathInfo pathInfo = nodes.lookupPathInfo(node.getNodeRef(), null);
|
||||||
node.setPath(pathInfo);
|
node.setPath(pathInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code {@link Parameters} object where almost all of its values are null.
|
* Returns a {@code {@link Parameters} object where almost all of its values are null. the non-null value is the {@literal include} and whatever value is passed for {@code personId} and {@code favouriteId}
|
||||||
* the non-null value is the {@literal include} and whatever value is passed for {@code personId} and {@code favouriteId}
|
*/
|
||||||
*/
|
private Parameters getDefaultParameters(String personId, String favouriteId)
|
||||||
private Parameters getDefaultParameters(String personId, String favouriteId)
|
{
|
||||||
{
|
Params.RecognizedParams recognizedParams = new Params.RecognizedParams(null, null, null, null, Collections.emptyList(), null, null, null,
|
||||||
Params.RecognizedParams recognizedParams = new Params.RecognizedParams(null, null, null, null, Collections.emptyList(), null, null, null,
|
false);
|
||||||
false);
|
Parameters parameters = Params.valueOf(recognizedParams, personId, favouriteId, null);
|
||||||
Parameters parameters = Params.valueOf(recognizedParams, personId, favouriteId, null);
|
return parameters;
|
||||||
return parameters;
|
}
|
||||||
}
|
|
||||||
|
private List<Pair<FavouritesService.SortFields, Boolean>> getSortProps(Parameters parameters)
|
||||||
private List<Pair<FavouritesService.SortFields, Boolean>> getSortProps(Parameters parameters)
|
{
|
||||||
{
|
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = new ArrayList<>();
|
||||||
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = new ArrayList<>();
|
List<SortColumn> sortCols = parameters.getSorting();
|
||||||
List<SortColumn> sortCols = parameters.getSorting();
|
if ((sortCols != null) && (sortCols.size() > 0))
|
||||||
if ((sortCols != null) && (sortCols.size() > 0))
|
{
|
||||||
{
|
for (SortColumn sortCol : sortCols)
|
||||||
for (SortColumn sortCol : sortCols)
|
{
|
||||||
{
|
SortFields sortField;
|
||||||
SortFields sortField;
|
try
|
||||||
try
|
{
|
||||||
{
|
sortField = SortFields.valueOf(sortCol.column);
|
||||||
sortField = SortFields.valueOf(sortCol.column);
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
|
||||||
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
|
}
|
||||||
}
|
sortProps.add(new Pair<>(sortField, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE)));
|
||||||
sortProps.add(new Pair<>(sortField, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE)));
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
// default sort order
|
||||||
// default sort order
|
sortProps = FavouritesService.DEFAULT_SORT_PROPS;
|
||||||
sortProps = FavouritesService.DEFAULT_SORT_PROPS;
|
}
|
||||||
}
|
return sortProps;
|
||||||
return sortProps;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@@ -23,43 +23,43 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.model;
|
package org.alfresco.rest.api.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A document target favourite.
|
* A document target favourite.
|
||||||
*
|
*
|
||||||
* @author steveglover
|
* @author steveglover
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DocumentTarget extends Target
|
public class DocumentTarget extends Target
|
||||||
{
|
{
|
||||||
private Document file;
|
private Document file;
|
||||||
|
|
||||||
public DocumentTarget()
|
public DocumentTarget()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DocumentTarget(Document file)
|
public DocumentTarget(Document file)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDocument(Document file)
|
public void setDocument(Document file)
|
||||||
{
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Document getFile()
|
public Document getFile()
|
||||||
{
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "DocumentTarget [file=" + file + "]";
|
return "DocumentTarget [file=" + file + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,103 +1,105 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.model;
|
package org.alfresco.rest.api.model;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.rest.framework.resource.UniqueId;
|
import org.alfresco.rest.framework.resource.UniqueId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a favourite (document, folder, site, ...).
|
* Representation of a favourite (document, folder, site, ...).
|
||||||
*
|
*
|
||||||
* @author steveglover
|
* @author steveglover
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Favourite
|
public class Favourite
|
||||||
{
|
{
|
||||||
private String targetGuid;
|
private String targetGuid;
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private Target target;
|
private Target target;
|
||||||
private Map<String, Object> properties;
|
private Map<String, Object> properties;
|
||||||
private List<String> allowableOperations;
|
private List<String> allowableOperations;
|
||||||
|
|
||||||
public Date getCreatedAt()
|
public Date getCreatedAt()
|
||||||
{
|
{
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedAt(Date createdAt)
|
public void setCreatedAt(Date createdAt)
|
||||||
{
|
{
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UniqueId(name="targetGuid")
|
@UniqueId(name = "targetGuid")
|
||||||
public String getTargetGuid()
|
public String getTargetGuid()
|
||||||
{
|
{
|
||||||
return targetGuid;
|
return targetGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetGuid(String targetGuid)
|
public void setTargetGuid(String targetGuid)
|
||||||
{
|
{
|
||||||
this.targetGuid = targetGuid;
|
this.targetGuid = targetGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target getTarget()
|
public Target getTarget()
|
||||||
{
|
{
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(Target target)
|
public void setTarget(Target target)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getProperties()
|
public Map<String, Object> getProperties()
|
||||||
{
|
{
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(Map<String, Object> properties)
|
public void setProperties(Map<String, Object> properties)
|
||||||
{
|
{
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAllowableOperations() {
|
public List<String> getAllowableOperations()
|
||||||
return allowableOperations;
|
{
|
||||||
}
|
return allowableOperations;
|
||||||
|
}
|
||||||
public void setAllowableOperations(List<String> allowableOperations) {
|
|
||||||
this.allowableOperations = allowableOperations;
|
public void setAllowableOperations(List<String> allowableOperations)
|
||||||
}
|
{
|
||||||
|
this.allowableOperations = allowableOperations;
|
||||||
@Override
|
}
|
||||||
public String toString()
|
|
||||||
{
|
@Override
|
||||||
return "Favourite [targetGuid=" + targetGuid
|
public String toString()
|
||||||
+ ", createdAt=" + createdAt + ", target=" + target + ", properties=" + properties + "]";
|
{
|
||||||
}
|
return "Favourite [targetGuid=" + targetGuid
|
||||||
}
|
+ ", createdAt=" + createdAt + ", target=" + target + ", properties=" + properties + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -25,59 +25,60 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco;
|
package org.alfresco;
|
||||||
|
|
||||||
import org.alfresco.repo.web.scripts.TestWebScriptRepoServer;
|
|
||||||
import org.alfresco.util.testing.category.DBTests;
|
|
||||||
import org.alfresco.util.testing.category.NonBuildTests;
|
|
||||||
import org.junit.experimental.categories.Categories;
|
import org.junit.experimental.categories.Categories;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
|
import org.alfresco.repo.web.scripts.TestWebScriptRepoServer;
|
||||||
|
import org.alfresco.util.testing.category.DBTests;
|
||||||
|
import org.alfresco.util.testing.category.NonBuildTests;
|
||||||
|
|
||||||
@RunWith(Categories.class)
|
@RunWith(Categories.class)
|
||||||
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({
|
||||||
// [classpath:alfresco/application-context.xml, classpath:alfresco/web-scripts-application-context-test.xml,
|
// [classpath:alfresco/application-context.xml, classpath:alfresco/web-scripts-application-context-test.xml,
|
||||||
// classpath:alfresco/web-scripts-application-context.xml]
|
// classpath:alfresco/web-scripts-application-context.xml]
|
||||||
org.alfresco.repo.web.scripts.quickshare.QuickShareRestApiTest.class,
|
org.alfresco.repo.web.scripts.quickshare.QuickShareRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.admin.AdminWebScriptTest.class,
|
org.alfresco.repo.web.scripts.admin.AdminWebScriptTest.class,
|
||||||
org.alfresco.repo.web.scripts.audit.AuditWebScriptTest.class,
|
org.alfresco.repo.web.scripts.audit.AuditWebScriptTest.class,
|
||||||
org.alfresco.repo.web.scripts.blogs.BlogServiceTest.class,
|
org.alfresco.repo.web.scripts.blogs.BlogServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.dictionary.DictionaryRestApiTest.class,
|
org.alfresco.repo.web.scripts.dictionary.DictionaryRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.discussion.DiscussionRestApiTest.class,
|
org.alfresco.repo.web.scripts.discussion.DiscussionRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.activities.feed.control.FeedControlTest.class,
|
org.alfresco.repo.web.scripts.activities.feed.control.FeedControlTest.class,
|
||||||
org.alfresco.repo.web.scripts.forms.FormRestApiGet_Test.class,
|
org.alfresco.repo.web.scripts.forms.FormRestApiGet_Test.class,
|
||||||
org.alfresco.repo.web.scripts.forms.FormRestApiJsonPost_Test.class,
|
org.alfresco.repo.web.scripts.forms.FormRestApiJsonPost_Test.class,
|
||||||
org.alfresco.repo.web.scripts.groups.GroupsTest.class,
|
org.alfresco.repo.web.scripts.groups.GroupsTest.class,
|
||||||
org.alfresco.repo.web.scripts.invitation.InvitationWebScriptTest.class,
|
org.alfresco.repo.web.scripts.invitation.InvitationWebScriptTest.class,
|
||||||
org.alfresco.repo.web.scripts.invite.InviteServiceTest.class,
|
org.alfresco.repo.web.scripts.invite.InviteServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.LoginTest.class,
|
org.alfresco.repo.web.scripts.LoginTest.class,
|
||||||
org.alfresco.repo.web.scripts.search.PersonSearchTest.class,
|
org.alfresco.repo.web.scripts.search.PersonSearchTest.class,
|
||||||
org.alfresco.repo.web.scripts.person.PersonServiceTest.class,
|
org.alfresco.repo.web.scripts.person.PersonServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.preference.PreferenceServiceTest.class,
|
org.alfresco.repo.web.scripts.preference.PreferenceServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.rating.RatingRestApiTest.class,
|
org.alfresco.repo.web.scripts.rating.RatingRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.replication.ReplicationRestApiTest.class,
|
org.alfresco.repo.web.scripts.replication.ReplicationRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.RepositoryContainerTest.class,
|
org.alfresco.repo.web.scripts.RepositoryContainerTest.class,
|
||||||
org.alfresco.repo.web.scripts.rule.RuleServiceTest.class,
|
org.alfresco.repo.web.scripts.rule.RuleServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.action.RunningActionRestApiTest.class,
|
org.alfresco.repo.web.scripts.action.RunningActionRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.site.SiteServiceTest.class,
|
org.alfresco.repo.web.scripts.site.SiteServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.tagging.TaggingServiceTest.class,
|
org.alfresco.repo.web.scripts.tagging.TaggingServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.thumbnail.ThumbnailServiceTest.class,
|
org.alfresco.repo.web.scripts.thumbnail.ThumbnailServiceTest.class,
|
||||||
org.alfresco.repo.web.scripts.transfer.TransferWebScriptTest.class,
|
org.alfresco.repo.web.scripts.transfer.TransferWebScriptTest.class,
|
||||||
org.alfresco.repo.web.scripts.workflow.ActivitiWorkflowRestApiTest.class,
|
org.alfresco.repo.web.scripts.workflow.ActivitiWorkflowRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.solr.SOLRWebScriptTest.class,
|
org.alfresco.repo.web.scripts.solr.SOLRWebScriptTest.class,
|
||||||
org.alfresco.repo.web.scripts.subscriptions.SubscriptionServiceRestApiTest.class,
|
org.alfresco.repo.web.scripts.subscriptions.SubscriptionServiceRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.facet.FacetRestApiTest.class,
|
org.alfresco.repo.web.scripts.facet.FacetRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.comment.CommentsApiTest.class,
|
org.alfresco.repo.web.scripts.comment.CommentsApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.content.ContentGetTest.class,
|
org.alfresco.repo.web.scripts.content.ContentGetTest.class,
|
||||||
org.alfresco.repo.web.scripts.XssVulnerabilityTest.class,
|
org.alfresco.repo.web.scripts.XssVulnerabilityTest.class,
|
||||||
org.alfresco.repo.web.scripts.links.LinksRestApiTest.class,
|
org.alfresco.repo.web.scripts.links.LinksRestApiTest.class,
|
||||||
org.alfresco.repo.model.filefolder.RemoteFileFolderLoaderTest.class,
|
org.alfresco.repo.model.filefolder.RemoteFileFolderLoaderTest.class,
|
||||||
org.alfresco.repo.web.scripts.ReadOnlyTransactionInGetRestApiTest.class,
|
org.alfresco.repo.web.scripts.ReadOnlyTransactionInGetRestApiTest.class,
|
||||||
org.alfresco.repo.web.scripts.custommodel.CustomModelImportTest.class,
|
org.alfresco.repo.web.scripts.custommodel.CustomModelImportTest.class,
|
||||||
org.alfresco.repo.web.scripts.site.SurfConfigTest.class,
|
org.alfresco.repo.web.scripts.site.SurfConfigTest.class,
|
||||||
org.alfresco.repo.web.scripts.node.NodeWebScripTest.class,
|
org.alfresco.repo.web.scripts.node.NodeWebScripTest.class,
|
||||||
org.alfresco.rest.api.impl.CommentsImplUnitTest.class,
|
org.alfresco.rest.api.impl.CommentsImplUnitTest.class,
|
||||||
org.alfresco.rest.api.impl.DownloadsImplCheckArchiveStatusUnitTest.class,
|
org.alfresco.rest.api.impl.DownloadsImplCheckArchiveStatusUnitTest.class,
|
||||||
org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class
|
org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class
|
||||||
})
|
})
|
||||||
public class AppContext04TestSuite
|
public class AppContext04TestSuite
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user