Merge master into feature/RM-4357_and_RM_4373

This commit is contained in:
Ana Bozianu
2016-11-18 14:15:53 +02:00
38 changed files with 1451 additions and 643 deletions

View File

@@ -4,16 +4,31 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import java.util.List;

View File

@@ -4,14 +4,29 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
/**
* File plan component alias enumeration

View File

@@ -0,0 +1,50 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ENTRY;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
/**
* POJO for file plan component entry
*
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
{
@JsonProperty(ENTRY)
FilePlanComponent filePlanComponent;
public FilePlanComponent getFilePlanComponent()
{
return filePlanComponent;
}
}

View File

@@ -4,12 +4,27 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
/**
* File plan component field names constants

View File

@@ -0,0 +1,71 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
/**
* POJO for id/name pair
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentIdNamePair
{
public String id;
public String name;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name)
{
this.name = name;
}
}

View File

@@ -4,12 +4,27 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
import java.util.List;

View File

@@ -4,20 +4,35 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SUPPLEMENTAL_MARKING_LIST;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_SUPPLEMENTAL_MARKING_LIST;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import java.util.List;

View File

@@ -4,14 +4,29 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
package org.alfresco.rest.rm.community.model.fileplancomponents;
import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
/**
* File plan component type enumeration
@@ -27,8 +42,11 @@ public enum FilePlanComponentType
HOLD_TYPE("rma:hold"),
UNFILED_RECORD_FOLDER_TYPE("rma:unfiledRecordFolder"),
HOLD_CONTAINER_TYPE("rma:holdContainer"),
TRANSFER_TYPE("rma:transfer"),
TRANSFER_CONTAINER_TYPE("rma:transferContainer"),
UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer");
UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"),
FOLDER_TYPE("cm:folder"),
CONTENT_TYPE("cm:content");
private String type;

View File

@@ -0,0 +1,71 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
/**
* POJO for file plan component created by object
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentUserInfo
{
private String id;
private String displayName;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the displayName
*/
public String getDisplayName()
{
return this.displayName;
}
/**
* @param displayName the displayName to set
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
}

View File

@@ -0,0 +1,40 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
import org.alfresco.rest.core.RestModels;
/**
* Handle collection of FilePlanComponents
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentsCollection extends RestModels<FilePlanComponentEntry, FilePlanComponentsCollection>
{
}

View File

@@ -0,0 +1,71 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.fileplancomponents;
/**
* POJO for the review period
*
* @author Rodica Sutu
* @since 2.6
*/
public class ReviewPeriod
{
private String periodType;
private String expression;
/**
* @return the periodType
*/
public String getPeriodType()
{
return this.periodType;
}
/**
* @param periodType the periodType to set
*/
public void setPeriodType(String periodType)
{
this.periodType = periodType;
}
/**
* @return the expression
*/
public String getExpression()
{
return this.expression;
}
/**
* @param expression the expression to set
*/
public void setExpression(String expression)
{
this.expression = expression;
}
}

View File

@@ -0,0 +1,63 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.site;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestSiteModel;
/**
* POJO for RM Site component
*
* @author Rodica Sutu
* @since 2.6
*/
public class RMSite extends RestSiteModel
{
@JsonProperty (required = true)
private RMSiteCompliance compliance;
/**
* Helper method to set RM site compliance
*
* @param compliance {@link RMSiteCompliance} the compliance to set
*/
public void setCompliance(RMSiteCompliance compliance)
{
this.compliance = compliance;
}
/**
* Helper method to get RM site compliance
*
* @return compliance the RM Site compliance to get
*/
public RMSiteCompliance getCompliance()
{
return compliance;
}
}

View File

@@ -0,0 +1,39 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.site;
/**
* RM Site compliance
*
* @author Tuna Aksoy
* @since 2.6
*/
public enum RMSiteCompliance
{
STANDARD,
DOD5015
}

View File

@@ -0,0 +1,52 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.model.site;
/**
*RM Site properties from the RM Model Schema
*"entry": {
* "id": "string",
* "guid": "string",
* "title": "string",
* "description": "string",
* "visibility": "{@link org.springframework.social.alfresco.api.entities.Site.Visibility}",
* "compliance": "{@link RMSiteCompliance}",
* "role": "{@link org.alfresco.utility.constants.UserRole}"
*}
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 2.6
*/
public class RMSiteFields
{
public static final String ID = "id";
public static final String COMPLIANCE = "compliance";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public static final String VISIBILITY ="visibility";
public static final String ROLE = "role";
}

View File

@@ -4,17 +4,32 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.requests;
package org.alfresco.rest.rm.community.requests;
import static org.alfresco.rest.core.RestRequest.requestWithBody;
import static org.alfresco.rest.core.RestRequest.simpleRequest;
import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryObject;
import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
import static org.springframework.http.HttpMethod.DELETE;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
@@ -23,8 +38,8 @@ import static org.springframework.http.HttpMethod.PUT;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestAPI;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

View File

@@ -4,25 +4,43 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.requests;
package org.alfresco.rest.rm.community.requests;
import static org.alfresco.rest.core.RestRequest.requestWithBody;
import static org.alfresco.rest.core.RestRequest.simpleRequest;
import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryObject;
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
import static org.springframework.http.HttpMethod.DELETE;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import static org.springframework.http.HttpStatus.OK;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestAPI;
import org.alfresco.rest.rm.model.site.RMSite;
import org.alfresco.rest.rm.community.model.site.RMSite;
import org.alfresco.utility.data.DataUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -37,6 +55,9 @@ import org.springframework.stereotype.Component;
@Scope (value = "prototype")
public class RMSiteAPI extends RestAPI<RMSiteAPI>
{
@Autowired
private DataUser dataUser;
/**
* Get the RM site
*
@@ -124,4 +145,23 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
"ig-sites/rm"
));
}
/**
* Checks if the RM site exists or not
*
* @return <code>true</code> if the RM site exists, <code>false</code> otherwise
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</li>
* <li>Api Response code 409 If RM Site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public boolean existsRMSite() throws Exception
{
usingRestWrapper().authenticateUser(dataUser.getAdminUser());
getSite();
return usingRestWrapper().getStatusCode().equals(OK.toString());
}
}

View File

@@ -4,12 +4,27 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.util;
package org.alfresco.rest.rm.community.util;
import static org.apache.commons.lang3.StringUtils.isBlank;

View File

@@ -1,35 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.ENTRY;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels;
/**
* POJO for file plan component entry
*
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
{
@JsonProperty(ENTRY)
FilePlanComponent filePlanComponent;
public FilePlanComponent getFilePlanComponent()
{
return filePlanComponent;
}
}

View File

@@ -1,56 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
/**
* POJO for id/name pair
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentIdNamePair
{
public String id;
public String name;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name)
{
this.name = name;
}
}

View File

@@ -1,56 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
/**
* POJO for file plan component created by object
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentUserInfo
{
private String id;
private String displayName;
/**
* @return the id
*/
public String getId()
{
return this.id;
}
/**
* @param id the id to set
*/
public void setId(String id)
{
this.id = id;
}
/**
* @return the displayName
*/
public String getDisplayName()
{
return this.displayName;
}
/**
* @param displayName the displayName to set
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
}

View File

@@ -1,25 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.fileplancomponents;
import org.alfresco.rest.core.RestModels;
/**
* Handle collection of FilePlanComponents
*
* @author Kristijan Conkas
* @since 2.6
*/
public class FilePlanComponentsCollection extends RestModels<FilePlanComponentEntry, FilePlanComponentsCollection>
{
}

View File

@@ -1,45 +0,0 @@
package org.alfresco.rest.rm.model.fileplancomponents;
/**
* POJO for the review period
*
* @author Rodica Sutu
* @since 2.6
*/
public class ReviewPeriod
{
private String periodType;
private String expression;
/**
* @return the periodType
*/
public String getPeriodType()
{
return this.periodType;
}
/**
* @param periodType the periodType to set
*/
public void setPeriodType(String periodType)
{
this.periodType = periodType;
}
/**
* @return the expression
*/
public String getExpression()
{
return this.expression;
}
/**
* @param expression the expression to set
*/
public void setExpression(String expression)
{
this.expression = expression;
}
}

View File

@@ -1,48 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.site;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestSiteModel;
/**
* POJO for RM Site component
*
* @author Rodica Sutu
* @since 2.6
*/
public class RMSite extends RestSiteModel
{
@JsonProperty (required = true)
private RMSiteCompliance compliance;
/**
* Helper method to set RM site compliance
*
* @param compliance {@link RMSiteCompliance} the compliance to set
*/
public void setCompliance(RMSiteCompliance compliance)
{
this.compliance = compliance;
}
/**
* Helper method to get RM site compliance
*
* @return compliance the RM Site compliance to get
*/
public RMSiteCompliance getCompliance()
{
return compliance;
}
}

View File

@@ -1,24 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.site;
/**
* RM Site compliance
*
* @author Tuna Aksoy
* @since 2.6
*/
public enum RMSiteCompliance
{
STANDARD,
DOD5015
}

View File

@@ -1,37 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.model.site;
/**
*RM Site properties from the RM Model Schema
*"entry": {
* "id": "string",
* "guid": "string",
* "title": "string",
* "description": "string",
* "visibility": "{@link org.springframework.social.alfresco.api.entities.Site.Visibility}",
* "compliance": "{@link RMSiteCompliance}",
* "role": "{@link org.alfresco.utility.constants.UserRole}"
*}
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 2.6
*/
public class RMSiteFields
{
public static final String ID = "id";
public static final String COMPLIANCE = "compliance";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public static final String VISIBILITY ="visibility";
public static final String ROLE = "role";
}

View File

@@ -1,25 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.base;
/**
* List of allowable operations
*
* @author Tuna Aksoy
* @since 2.6
*/
public class AllowableOperations
{
public static final String CREATE = "create";
public static final String UPDATE = "update";
public static final String DELETE = "delete";
}

View File

@@ -1,101 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.rm.base;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import org.testng.annotations.DataProvider;
/**
* Test data used in tests
*
* @author Rodica Sutu
* @since 2.6
*/
public interface TestData
{
/**
* A user with ALFRESCO_ADMINISTRATORS role.
* <p>"GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created.
*/
public static final String ANOTHER_ADMIN = "another_admin";
/**
* The default password used when creating test users.
*/
public static final String DEFAULT_PASSWORD = "password";
/**
* The default email address used when creating test users.
*/
public static final String DEFAULT_EMAIL = "default@alfresco.com";
/**
* Data Provider with the special file plan components alias
* @return file plan component alias
*/
@DataProvider
public static Object[][] getContainers()
{
return new Object[][] {
{ FILE_PLAN_ALIAS.toString() },
{ TRANSFERS_ALIAS.toString() },
{ HOLDS_ALIAS.toString() },
{ UNFILED_RECORDS_CONTAINER_ALIAS.toString() },
};
}
/**
* Data Provider with:
* the special file plan components alias
* file plan component node type
* @return file plan component alias
*/
@DataProvider
public static Object[][] getContainersAndTypes()
{
return new Object[][] {
{ FILE_PLAN_ALIAS, FILE_PLAN_TYPE },
{ TRANSFERS_ALIAS, TRANSFER_CONTAINER_TYPE },
{ HOLDS_ALIAS, HOLD_CONTAINER_TYPE },
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
};
}
/**
* The default CATEGORY name used when creating categories
*/
public static String CATEGORY_NAME = "CATEGORY NAME"+ getRandomAlphanumeric();
/**
* The default CATEGORY title used when creating categories
*/
public static String CATEGORY_TITLE = "CATEGORY TITLE" + getRandomAlphanumeric();
/**
* The default FOLDER name used when creating categories
*/
public static String FOLDER_NAME = "FOLDER NAME" + getRandomAlphanumeric();
/**
* The default FOLDER title used when creating categories
*/
public static String FOLDER_TITLE = "FOLDER TITLE" + getRandomAlphanumeric();
}

View File

@@ -0,0 +1,40 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.base;
/**
* List of allowable operations
*
* @author Tuna Aksoy
* @since 2.6
*/
public class AllowableOperations
{
public static final String CREATE = "create";
public static final String UPDATE = "update";
public static final String DELETE = "delete";
}

View File

@@ -4,40 +4,55 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.base;
package org.alfresco.rest.rm.community.base;
import static java.lang.Integer.parseInt;
import static org.alfresco.rest.rm.base.TestData.CATEGORY_TITLE;
import static org.alfresco.rest.rm.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.model.site.RMSiteFields.TITLE;
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE;
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
import com.google.gson.JsonObject;
import com.jayway.restassured.RestAssured;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.requests.RMSiteAPI;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
import org.alfresco.utility.data.DataUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -108,7 +123,7 @@ public class BaseRestTest extends RestTest
public void createRMSiteIfNotExists() throws Exception
{
// Check RM site doesn't exist
if (!siteRMExists())
if (!rmSiteAPI.existsRMSite())
{
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
@@ -127,16 +142,6 @@ public class BaseRestTest extends RestTest
}
}
/**
* Check if the RM site exists via the GET request
*/
public boolean siteRMExists() throws Exception
{
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
rmSiteAPI.getSite();
return restWrapper.getStatusCode().equals(OK.toString());
}
/**
* Helper method to create child category
*
@@ -163,6 +168,19 @@ public class BaseRestTest extends RestTest
return createComponent(parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE);
}
/**
* Helper method to create child unfiled record folder
*
* @param parentId The id of the parent folder
* @param folderName The name of the folder
* @return The created folder
* @throws Exception on unsuccessful component creation
*/
public FilePlanComponent createUnfiledRecordsFolder(String parentId, String folderName) throws Exception
{
return createComponent(parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE);
}
/**
* Helper method to create generic child component
*

View File

@@ -0,0 +1,145 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.base;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import org.testng.annotations.DataProvider;
/**
* Test data used in tests
*
* @author Rodica Sutu
* @since 2.6
*/
public interface TestData
{
/**
* A user with ALFRESCO_ADMINISTRATORS role.
* <p>"GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created.
*/
public static final String ANOTHER_ADMIN = "another_admin";
/**
* The default password used when creating test users.
*/
public static final String DEFAULT_PASSWORD = "password";
/**
* The default email address used when creating test users.
*/
public static final String DEFAULT_EMAIL = "default@alfresco.com";
/**
* Data Provider with the special file plan components alias
* @return file plan component alias
*/
@DataProvider
public static Object[][] getContainers()
{
return new Object[][] {
{ FILE_PLAN_ALIAS.toString() },
{ TRANSFERS_ALIAS.toString() },
{ HOLDS_ALIAS.toString() },
{ UNFILED_RECORDS_CONTAINER_ALIAS.toString() },
};
}
/**
* Data Provider with:
* the special file plan components alias
* file plan component node type
* @return file plan component alias
*/
@DataProvider
public static Object[][] getContainersAndTypes()
{
return new Object[][] {
{ FILE_PLAN_ALIAS, FILE_PLAN_TYPE },
{ TRANSFERS_ALIAS, TRANSFER_CONTAINER_TYPE },
{ HOLDS_ALIAS, HOLD_CONTAINER_TYPE },
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
};
}
/**
* The default CATEGORY name used when creating categories
*/
public static String CATEGORY_NAME = "CATEGORY NAME"+ getRandomAlphanumeric();
/**
* The default CATEGORY title used when creating categories
*/
public static String CATEGORY_TITLE = "CATEGORY TITLE" + getRandomAlphanumeric();
/**
* The default FOLDER name used when creating categories
*/
public static String FOLDER_NAME = "FOLDER NAME" + getRandomAlphanumeric();
/**
* The default FOLDER title used when creating categories
*/
public static String FOLDER_TITLE = "FOLDER TITLE" + getRandomAlphanumeric();
/**
* Data Provider with:
* with the object types not allowed as children for a record category
*
* @return file plan component alias
*/
@DataProvider
public static Object[][] childrenNotAllowedForCategory()
{
return new Object[][] {
{ FILE_PLAN_TYPE.toString() },
{ TRANSFER_CONTAINER_TYPE.toString() },
{ HOLD_CONTAINER_TYPE.toString() },
{ UNFILED_CONTAINER_TYPE.toString() },
{ UNFILED_RECORD_FOLDER_TYPE.toString()},
{ HOLD_TYPE.toString()},
{ TRANSFER_TYPE.toString()},
{ FOLDER_TYPE.toString()},
{ CONTENT_TYPE.toString()}
};
}
}

View File

@@ -4,25 +4,40 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.fileplancomponents;
package org.alfresco.rest.rm.community.fileplancomponents;
import static java.util.Arrays.asList;
import static org.alfresco.rest.rm.base.AllowableOperations.CREATE;
import static org.alfresco.rest.rm.base.AllowableOperations.DELETE;
import static org.alfresco.rest.rm.base.AllowableOperations.UPDATE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.base.AllowableOperations.CREATE;
import static org.alfresco.rest.rm.community.base.AllowableOperations.DELETE;
import static org.alfresco.rest.rm.community.base.AllowableOperations.UPDATE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.FORBIDDEN;
@@ -35,13 +50,13 @@ import static org.testng.Assert.assertTrue;
import com.google.gson.JsonObject;
import org.alfresco.rest.rm.base.BaseRestTest;
import org.alfresco.rest.rm.base.TestData;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.requests.RMSiteAPI;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
@@ -80,7 +95,7 @@ public class FilePlanTests extends BaseRestTest
public void getFilePlanComponentWhenRMIsNotCreated(String filePlanAlias) throws Exception
{
// Check RM Site Exist
if (siteRMExists())
if (rmSiteAPI.existsRMSite())
{
// Delete RM Site
rmSiteAPI.deleteRMSite();

View File

@@ -4,26 +4,42 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.fileplancomponents;
package org.alfresco.rest.rm.community.fileplancomponents;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
@@ -35,14 +51,16 @@ import java.util.NoSuchElementException;
import com.google.gson.JsonObject;
import org.alfresco.rest.rm.base.BaseRestTest;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;
@@ -333,6 +351,41 @@ public class RecordCategoryTest extends BaseRestTest
});
}
/**
* Given that a record category exists
* When I ask to create a object type which is not a record category or a record folder as a child
* Then the children are not created and the 422 response code is returned
*/
@Test
(
description = "Create node types not allowed inside a category",
dataProviderClass = TestData.class,
dataProvider = "childrenNotAllowedForCategory"
)
@Bug (id="RM-4367")
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
{
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
// Authenticate with admin user
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
//Build node properties
JsonObject componentProperties = buildObject()
.add(NAME, COMPONENT_NAME)
.add(NODE_TYPE, nodeType)
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, "Title for " + COMPONENT_NAME)
.end()
.getJson();
//create the invalid node type
filePlanComponentAPI.createFilePlanComponent(componentProperties, category.getId());
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}
/**
* Helper method to create child category
*

View File

@@ -4,27 +4,42 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.fileplancomponents;
package org.alfresco.rest.rm.community.fileplancomponents;
import static org.alfresco.rest.rm.base.TestData.CATEGORY_NAME;
import static org.alfresco.rest.rm.base.TestData.FOLDER_NAME;
import static org.alfresco.rest.rm.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_NAME;
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
@@ -44,12 +59,12 @@ import java.util.NoSuchElementException;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.base.BaseRestTest;
import org.alfresco.rest.rm.base.TestData;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -0,0 +1,329 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.fileplancomponents;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.utility.data.DataUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Unfiled Records folder CRUD API tests
*
* @author Kristijan Conkas
* @since 2.6
*/
public class UnfiledRecordsFolderTests extends BaseRestTest
{
@Autowired
private FilePlanComponentAPI filePlanComponentAPI;
@Autowired
private DataUser dataUser;
/** invalid root level types, at unfiled records root level these shouldn't be possible to create */
@DataProvider(name = "invalidRootTypes")
public Object[][] createData1() {
return new Object[][] {
{ FILE_PLAN_TYPE },
{ RECORD_CATEGORY_TYPE },
{ RECORD_FOLDER_TYPE },
{ HOLD_TYPE },
{ HOLD_CONTAINER_TYPE },
{ TRANSFER_CONTAINER_TYPE },
{ UNFILED_CONTAINER_TYPE }
};
}
/**
* Given the unfiled record container root
* When I create an unfiled record folder via the ReST API
* Then a root unfiled record folder is created
*
* @throws Exception if folder couldn't be created
*/
@Test(description = "Create root unfiled records folder")
public void createRootUnfiledRecordsFolder() throws Exception
{
// Authenticate with admin user
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
String folderName = "Folder " + getRandomAlphanumeric();
String folderTitle = folderName + " Title";
String folderDescription = folderName + " Description";
// Build unfiled records folder properties
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, folderName)
.add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, folderTitle)
.add(PROPERTIES_DESCRIPTION, folderDescription)
.end()
.getJson();
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
// Verify the returned file plan component
assertFalse(filePlanComponent.isIsCategory());
assertFalse(filePlanComponent.isIsFile());
assertFalse(filePlanComponent.isIsRecordFolder()); // it is not a _normal_ record folder!
assertEquals(filePlanComponent.getName(), folderName);
assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
assertFalse(filePlanComponent.isHasRetentionSchedule());
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
// Verify the returned file plan component properties
FilePlanComponentProperties filePlanComponentProperties = filePlanComponent.getProperties();
assertEquals(filePlanComponentProperties.getTitle(), folderTitle);
assertEquals(filePlanComponentProperties.getDescription(), folderDescription);
}
/**
* Negative test to verify only unfiled record folders can be created at root level
*/
@Test
(
dataProvider = "invalidRootTypes",
description = "Only unfiled records folders can be created at unfiled records root level"
)
public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(FilePlanComponentType componentType)
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
String folderName = "Folder " + getRandomAlphanumeric();
String folderTitle = folderName + " Title";
String folderDescription = folderName + " Description";
logger.info("creating " + componentType.toString());
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, folderName)
.add(NODE_TYPE, componentType.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, folderTitle)
.add(PROPERTIES_DESCRIPTION, folderDescription)
.end()
.getJson();
try
{
filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
}
catch (Exception error)
{
}
// Verify the status code
restWrapper.assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}
/**
* Given an unfiled record folder
* When I create an unfiled record folder via the ReST API
* Then an unfiled record folder is created within the unfiled record folder
*
* @throws Exception for failed actions
*/
@Test(description = "Child unfiled records folder can be created in a parent unfiled records folder")
public void childUnfiledRecordsFolderCanBeCreated() throws Exception
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
String parentFolderName = "Parent Folder " + getRandomAlphanumeric();
String childFolderName = "Child Folder " + getRandomAlphanumeric();
String childFolderTitle = childFolderName + " Title";
String childFolderDescription = childFolderName + " Description";
// No need for fine control, create it using utility function
FilePlanComponent parentFolder = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), parentFolderName);
assertEquals(parentFolderName, parentFolder.getName());
// Build the unfiled records folder properties
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, childFolderName)
.add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, childFolderTitle)
.add(PROPERTIES_DESCRIPTION, childFolderDescription)
.end()
.getJson();
// Create it as a child of parentFolder
FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
parentFolder.getId());
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
// Verify the returned file plan component
assertFalse(childFolder.isIsCategory());
assertFalse(childFolder.isIsFile());
assertFalse(childFolder.isIsRecordFolder()); // it is not a _normal_ record folder!
assertEquals(childFolder.getName(), childFolderName);
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
assertFalse(childFolder.isHasRetentionSchedule());
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
// Verify the returned file plan component properties
FilePlanComponentProperties childProperties = childFolder.getProperties();
assertEquals(childProperties.getTitle(), childFolderTitle);
assertEquals(childProperties.getDescription(), childFolderDescription);
// Does this child point to its parent?
assertEquals(childFolder.getParentId(), parentFolder.getId());
// Does child's parent point to it?
// Perform another call as our parentFolder had been executed before childFolder existed
FilePlanComponentsCollection parentsChildren = filePlanComponentAPI.listChildComponents(parentFolder.getId());
restWrapper.assertStatusCodeIs(OK);
List<String> childIds = parentsChildren.getEntries()
.stream()
.map(c -> c.getFilePlanComponent().getId())
.collect(Collectors.toList());
// Child folder is listed in parent
assertTrue(childIds.contains(childFolder.getId()));
// There should be only one child
assertEquals(1, childIds.size());
}
/**
* Given an unfiled record folder
* When I modify the unfiled record folder details via the ReST API
* Then the details of the unfiled record folder are modified
*
* @throws Exception for failed actions
*/
@Test(description = "Unfiled record folder")
public void editUnfiledRecordsFolder() throws Exception
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
String modified = "Modified ";
String folderName = "Folder To Modify" + getRandomAlphanumeric();
// No need for fine control, create it using utility function
FilePlanComponent folderToModify = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
assertEquals(folderName, folderToModify.getName());
// Build the properties which will be updated
JsonObject updateFolderProperties = buildObject()
.add(NAME, modified + folderToModify.getName())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, modified + folderToModify.getProperties().getTitle())
.add(PROPERTIES_DESCRIPTION, modified + folderToModify.getProperties().getDescription())
.end()
.getJson();
// Update the unfiled records folder
filePlanComponentAPI.updateFilePlanComponent(updateFolderProperties, folderToModify.getId());
// Verify the status code
restWrapper.assertStatusCodeIs(OK);
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
FilePlanComponent renamedFolder = filePlanComponentAPI.getFilePlanComponent(folderToModify.getId());
// Verify the returned file plan component
assertEquals(modified + folderToModify.getName(), renamedFolder.getName());
assertEquals(modified + folderToModify.getProperties().getTitle(), renamedFolder.getProperties().getTitle());
assertEquals(modified + folderToModify.getProperties().getDescription(), renamedFolder.getProperties().getDescription());
}
/**
* Given an unfiled record folder
* When I delete the unfiled record folder via the ReST API
* Then the unfiled record folder is deleted
*
* @throws Exception for failed actions
*/
@Test(description = "Delete unfiled record folder")
public void deleteUnfiledRecordsFolder() throws Exception
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
String folderName = "Folder To Delete" + getRandomAlphanumeric();
// Create folderToDelete
FilePlanComponent folderToDelete = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
assertEquals(folderName, folderToDelete.getName());
// Delete folderToDelete
filePlanComponentAPI.deleteFilePlanComponent(folderToDelete.getId());
// Verify the status code
restWrapper.assertStatusCodeIs(NO_CONTENT);
// Deleted component should no longer be retrievable
filePlanComponentAPI.getFilePlanComponent(folderToDelete.getId());
restWrapper.assertStatusCodeIs(NOT_FOUND);
}
}

View File

@@ -4,21 +4,36 @@
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.site;
package org.alfresco.rest.rm.community.site;
import static org.alfresco.rest.rm.base.TestData.ANOTHER_ADMIN;
import static org.alfresco.rest.rm.base.TestData.DEFAULT_EMAIL;
import static org.alfresco.rest.rm.base.TestData.DEFAULT_PASSWORD;
import static org.alfresco.rest.rm.model.site.RMSiteCompliance.DOD5015;
import static org.alfresco.rest.rm.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.model.site.RMSiteFields.TITLE;
import static org.alfresco.rest.rm.community.base.TestData.ANOTHER_ADMIN;
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_EMAIL;
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT;
@@ -34,10 +49,10 @@ import static org.testng.Assert.assertNotNull;
import com.google.gson.JsonObject;
import org.alfresco.dataprep.UserService;
import org.alfresco.rest.rm.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.model.site.RMSite;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.model.site.RMSite;
import org.alfresco.rest.rm.requests.RMSiteAPI;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.RandomData;
@@ -79,7 +94,7 @@ public class RMSiteTests extends BaseRestTest
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Check if the RM site exists
if (siteRMExists())
if (rmSiteAPI.existsRMSite())
{
// Delete the RM site
rmSiteAPI.deleteRMSite();
@@ -177,9 +192,8 @@ public class RMSiteTests extends BaseRestTest
// Authenticate with admin user
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Get the RM site
RMSite rmSite = rmSiteAPI.getSite();
if (!siteRMExists())
// Check if RM site exists
if (!rmSiteAPI.existsRMSite())
{
// Verify the status code when RM site doesn't exist
restWrapper.assertStatusCodeIs(NOT_FOUND);
@@ -187,6 +201,9 @@ public class RMSiteTests extends BaseRestTest
}
else
{
// Get the RM site
RMSite rmSite = rmSiteAPI.getSite();
// Verify the status code
restWrapper.assertStatusCodeIs(OK);
assertEquals(rmSite.getId(), RM_ID);
@@ -212,7 +229,7 @@ public class RMSiteTests extends BaseRestTest
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Check if the RM site exists
if (siteRMExists())
if (rmSiteAPI.existsRMSite())
{
// Delete the RM site
rmSiteAPI.deleteRMSite();

View File

@@ -1,10 +1,9 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestNG AllTestSuite" verbose="1" time-out="300000">
<test name="restapi">
<packages>
<package name="org.alfresco.rest.rm.*"/>
<package name="org.alfresco.rest.rm.community.*"/>
</packages>
</test>
</suite>