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
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponent
|
||||
@@ -94,6 +95,13 @@ public class FilePlanComponent
|
||||
@JsonProperty (required = true)
|
||||
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)
|
||||
{
|
||||
this.name = name;
|
||||
@@ -101,14 +109,27 @@ public class FilePlanComponent
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
this.name = name;
|
||||
|
@@ -38,12 +38,21 @@ public class ReviewPeriod
|
||||
private String periodType;
|
||||
private String expression;
|
||||
|
||||
/**
|
||||
* Helper constructor with
|
||||
*
|
||||
* @param periodType
|
||||
* @param expression
|
||||
*/
|
||||
public ReviewPeriod(String periodType, String expression)
|
||||
{
|
||||
this.periodType = periodType;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor
|
||||
*/
|
||||
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 com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
|
||||
@@ -44,6 +43,13 @@ public class RMSite extends RestSiteModel
|
||||
@JsonProperty (value = COMPLIANCE,required = true)
|
||||
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)
|
||||
{
|
||||
this.title=title;
|
||||
@@ -51,8 +57,16 @@ public class RMSite extends RestSiteModel
|
||||
this.compliance=compliance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor for creating the RM Site
|
||||
*/
|
||||
public RMSite() { }
|
||||
|
||||
/**
|
||||
* Helper constructor to create RM Site object using
|
||||
*
|
||||
* @param compliance RM Site Compliance
|
||||
*/
|
||||
public RMSite(RMSiteCompliance compliance)
|
||||
{
|
||||
super();
|
||||
|
@@ -42,16 +42,22 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*/
|
||||
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();
|
||||
//include only values that differ from default settings to be included
|
||||
mapper.setSerializationInclusion(Include.NON_DEFAULT);
|
||||
try
|
||||
{
|
||||
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rmModel);
|
||||
System.out.println("Json object generated is :" + json);
|
||||
return json;
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
|
||||
} catch (JsonGenerationException e)
|
||||
{
|
||||
return e.toString();
|
||||
|
@@ -45,10 +45,18 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.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
|
||||
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
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build the file plan root properties
|
||||
// Build object for updating the filePlan
|
||||
FilePlanComponent filePlanComponent= new FilePlanComponent();
|
||||
FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION);
|
||||
filePlanComponent.setProperties(filePlanComponentProperties);
|
||||
@@ -295,9 +295,9 @@ public class FilePlanTests extends BaseRestTest
|
||||
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the RM site ID
|
||||
String rmSiteId = rmSiteAPI.getSite().getGuid();
|
||||
|
||||
String name = filePlanAlias + getRandomAlphanumeric();
|
||||
|
||||
// Build the file plan root properties
|
||||
@@ -305,6 +305,7 @@ public class FilePlanTests extends BaseRestTest
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the special containers into RM site - parent folder
|
||||
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
|
@@ -340,14 +340,17 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||
{
|
||||
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
|
||||
// Authenticate with admin user
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Create the category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
|
||||
|
||||
//Build node properties
|
||||
FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType,
|
||||
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
|
||||
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
|
||||
|
||||
//create the invalid node type
|
||||
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
|
@@ -197,7 +197,10 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
//Create a record category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
|
||||
//Create a record folder
|
||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
|
||||
// Create record category first
|
||||
@@ -206,13 +209,13 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String folderTitle = "Update title " + 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.setVitalRecord(true);
|
||||
filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1"));
|
||||
filePlanComponentProperties.setLocation(location);
|
||||
FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties);
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
|
||||
|
||||
@@ -246,8 +249,12 @@ public class RecordFolderTests extends BaseRestTest
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
// Create the record category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
|
||||
// Delete the Record folder
|
||||
filePlanComponentAPI.deleteFilePlanComponent(folder.getId());
|
||||
// Check the Response Status Code
|
||||
|
@@ -206,7 +206,8 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
|
||||
assertEquals(childFolder.getName(), childFolderName);
|
||||
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());
|
||||
|
||||
|
Reference in New Issue
Block a user