mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
tidy up code, add java docs
This commit is contained in:
@@ -38,6 +38,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
* POJO for file plan component
|
* POJO for file plan component
|
||||||
*
|
*
|
||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
|
* @author Rodica Sutu
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
public class FilePlanComponent
|
public class FilePlanComponent
|
||||||
@@ -94,6 +95,13 @@ public class FilePlanComponent
|
|||||||
@JsonProperty (required = true)
|
@JsonProperty (required = true)
|
||||||
private FilePlanComponentUserInfo modifiedByUser;
|
private FilePlanComponentUserInfo modifiedByUser;
|
||||||
|
|
||||||
|
|
||||||
|
/**Helper constructor for creating the file plan component using
|
||||||
|
*
|
||||||
|
* @param name File Plan Component name
|
||||||
|
* @param nodeType File Plan Component node type
|
||||||
|
* @param properties File Plan Component properties
|
||||||
|
*/
|
||||||
public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties)
|
public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -101,14 +109,27 @@ public class FilePlanComponent
|
|||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilePlanComponent()
|
/**
|
||||||
{
|
* Helper constructor to create empty file plan component
|
||||||
}
|
*/
|
||||||
|
public FilePlanComponent() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor for creating the file plan component using
|
||||||
|
*
|
||||||
|
* @param name File Plan Component name
|
||||||
|
*/
|
||||||
public FilePlanComponent(String name)
|
public FilePlanComponent(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor for creating the file plan component using
|
||||||
|
*
|
||||||
|
* @param name File Plan Component name
|
||||||
|
* @param properties File Plan Component properties
|
||||||
|
*/
|
||||||
public FilePlanComponent(String name, FilePlanComponentProperties properties)
|
public FilePlanComponent(String name, FilePlanComponentProperties properties)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@@ -38,12 +38,21 @@ public class ReviewPeriod
|
|||||||
private String periodType;
|
private String periodType;
|
||||||
private String expression;
|
private String expression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor with
|
||||||
|
*
|
||||||
|
* @param periodType
|
||||||
|
* @param expression
|
||||||
|
*/
|
||||||
public ReviewPeriod(String periodType, String expression)
|
public ReviewPeriod(String periodType, String expression)
|
||||||
{
|
{
|
||||||
this.periodType = periodType;
|
this.periodType = periodType;
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor
|
||||||
|
*/
|
||||||
public ReviewPeriod()
|
public ReviewPeriod()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@ package org.alfresco.rest.rm.community.model.site;
|
|||||||
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
|
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import org.alfresco.rest.model.RestSiteModel;
|
import org.alfresco.rest.model.RestSiteModel;
|
||||||
|
|
||||||
@@ -44,6 +43,13 @@ public class RMSite extends RestSiteModel
|
|||||||
@JsonProperty (value = COMPLIANCE,required = true)
|
@JsonProperty (value = COMPLIANCE,required = true)
|
||||||
private RMSiteCompliance compliance;
|
private RMSiteCompliance compliance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor to create RM Site object using
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
* @param description
|
||||||
|
* @param compliance
|
||||||
|
*/
|
||||||
public RMSite(String title, String description, RMSiteCompliance compliance)
|
public RMSite(String title, String description, RMSiteCompliance compliance)
|
||||||
{
|
{
|
||||||
this.title=title;
|
this.title=title;
|
||||||
@@ -51,8 +57,16 @@ public class RMSite extends RestSiteModel
|
|||||||
this.compliance=compliance;
|
this.compliance=compliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor for creating the RM Site
|
||||||
|
*/
|
||||||
public RMSite() { }
|
public RMSite() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor to create RM Site object using
|
||||||
|
*
|
||||||
|
* @param compliance RM Site Compliance
|
||||||
|
*/
|
||||||
public RMSite(RMSiteCompliance compliance)
|
public RMSite(RMSiteCompliance compliance)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@@ -42,16 +42,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
*/
|
*/
|
||||||
public class PojoUtility
|
public class PojoUtility
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
public static String toJson(Object rmModel) throws JsonProcessingException
|
* Converting object to JSON string
|
||||||
|
*
|
||||||
|
* @param model The java object model to convert
|
||||||
|
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
|
||||||
|
*/
|
||||||
|
public static String toJson(Object model) throws JsonProcessingException
|
||||||
{
|
{
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
//include only values that differ from default settings to be included
|
||||||
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rmModel);
|
//return the json object
|
||||||
System.out.println("Json object generated is :" + json);
|
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||||
return json;
|
|
||||||
} catch (JsonGenerationException e)
|
} catch (JsonGenerationException e)
|
||||||
{
|
{
|
||||||
return e.toString();
|
return e.toString();
|
||||||
|
@@ -45,10 +45,18 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
|
|||||||
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value The Review Period value that is being serialized.
|
||||||
|
* @param gen Jackson utility is responsible for writing JSON
|
||||||
|
* @param serializers Provider for getting access to other serializers and configurations registered with the ObjectMapper.
|
||||||
|
* @throws IOException
|
||||||
|
* @throws JsonProcessingException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
|
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
|
||||||
{
|
{
|
||||||
gen.writeString(String.valueOf(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression())));
|
//create the custom string value for the Review Period type
|
||||||
|
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -198,7 +198,7 @@ public class FilePlanTests extends BaseRestTest
|
|||||||
// Authenticate with admin user
|
// Authenticate with admin user
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
// Build the file plan root properties
|
// Build object for updating the filePlan
|
||||||
FilePlanComponent filePlanComponent= new FilePlanComponent();
|
FilePlanComponent filePlanComponent= new FilePlanComponent();
|
||||||
FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION);
|
FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION);
|
||||||
filePlanComponent.setProperties(filePlanComponentProperties);
|
filePlanComponent.setProperties(filePlanComponentProperties);
|
||||||
@@ -295,9 +295,9 @@ public class FilePlanTests extends BaseRestTest
|
|||||||
|
|
||||||
// Authenticate with admin user
|
// Authenticate with admin user
|
||||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
// Get the RM site ID
|
// Get the RM site ID
|
||||||
String rmSiteId = rmSiteAPI.getSite().getGuid();
|
String rmSiteId = rmSiteAPI.getSite().getGuid();
|
||||||
|
|
||||||
String name = filePlanAlias + getRandomAlphanumeric();
|
String name = filePlanAlias + getRandomAlphanumeric();
|
||||||
|
|
||||||
// Build the file plan root properties
|
// Build the file plan root properties
|
||||||
@@ -305,6 +305,7 @@ public class FilePlanTests extends BaseRestTest
|
|||||||
|
|
||||||
// Authenticate with admin user
|
// Authenticate with admin user
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
// Create the special containers into RM site - parent folder
|
// Create the special containers into RM site - parent folder
|
||||||
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
|
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||||
|
@@ -340,14 +340,17 @@ public class RecordCategoryTest extends BaseRestTest
|
|||||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||||
{
|
{
|
||||||
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
|
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
|
||||||
// Authenticate with admin user
|
|
||||||
|
|
||||||
|
// Authenticate with admin user
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
//Create the category
|
||||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
|
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
|
||||||
|
|
||||||
//Build node properties
|
//Build node properties
|
||||||
FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType,
|
FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType,
|
||||||
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
|
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
|
||||||
|
|
||||||
//create the invalid node type
|
//create the invalid node type
|
||||||
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
|
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||||
|
@@ -197,7 +197,10 @@ public class RecordFolderTests extends BaseRestTest
|
|||||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||||
// Authenticate with admin user
|
// Authenticate with admin user
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
//Create a record category
|
||||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||||
|
|
||||||
|
//Create a record folder
|
||||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||||
|
|
||||||
// Create record category first
|
// Create record category first
|
||||||
@@ -206,13 +209,13 @@ public class RecordFolderTests extends BaseRestTest
|
|||||||
String folderTitle = "Update title " + getRandomAlphanumeric();
|
String folderTitle = "Update title " + getRandomAlphanumeric();
|
||||||
String location="Location"+getRandomAlphanumeric();
|
String location="Location"+getRandomAlphanumeric();
|
||||||
|
|
||||||
String review_period="month|1";
|
//Create the file plan component properties to update
|
||||||
|
|
||||||
FilePlanComponentProperties filePlanComponentProperties= new FilePlanComponentProperties(folderTitle, folderDescription);
|
FilePlanComponentProperties filePlanComponentProperties= new FilePlanComponentProperties(folderTitle, folderDescription);
|
||||||
filePlanComponentProperties.setVitalRecord(true);
|
filePlanComponentProperties.setVitalRecord(true);
|
||||||
filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1"));
|
filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1"));
|
||||||
filePlanComponentProperties.setLocation(location);
|
filePlanComponentProperties.setLocation(location);
|
||||||
FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties);
|
FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties);
|
||||||
|
|
||||||
// Update the record category
|
// Update the record category
|
||||||
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
|
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
|
||||||
|
|
||||||
@@ -246,8 +249,12 @@ public class RecordFolderTests extends BaseRestTest
|
|||||||
|
|
||||||
// Authenticate with admin user
|
// Authenticate with admin user
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
// Create the record category
|
||||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||||
|
|
||||||
|
// Create the record folder
|
||||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||||
|
|
||||||
// Delete the Record folder
|
// Delete the Record folder
|
||||||
filePlanComponentAPI.deleteFilePlanComponent(folder.getId());
|
filePlanComponentAPI.deleteFilePlanComponent(folder.getId());
|
||||||
// Check the Response Status Code
|
// Check the Response Status Code
|
||||||
|
@@ -206,7 +206,8 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
|||||||
|
|
||||||
assertEquals(childFolder.getName(), childFolderName);
|
assertEquals(childFolder.getName(), childFolderName);
|
||||||
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
||||||
// assertFalse(childFolder.isHasRetentionSchedule());
|
// FIXME: TO DO investigate. Has Retention schedule is not returned!!
|
||||||
|
//assertFalse(childFolder.isHasRetentionSchedule());
|
||||||
|
|
||||||
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user