Merge master into RM-5859_AnyMarksStaging.

This commit is contained in:
Tom Page
2018-06-29 11:30:14 +01:00
92 changed files with 2024 additions and 1407 deletions

View File

@@ -237,7 +237,7 @@ public class ApiNodesModelFactory
}
if (includeParam.contains(RMNode.PARAM_PATH))
{
rmNode.setPath(apiUtils.lookupPathInfo(info.getNodeRef()));
rmNode.setPath(nodes.lookupPathInfo(info.getNodeRef(), null));
}
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_ASPECT_NAMES))
{

View File

@@ -39,12 +39,14 @@ import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import net.sf.acegisecurity.vote.AccessDecisionVoter;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
@@ -108,9 +110,6 @@ import org.alfresco.util.ParameterCheck;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.social.InternalServerErrorException;
import net.sf.acegisecurity.vote.AccessDecisionVoter;
/**
* Utility class that handles common api endpoint tasks
@@ -611,7 +610,7 @@ public class FilePlanComponentsApiUtils
else
{
// Throw internal error as this method should not be called for other types
throw new InternalServerErrorException("Creating relative path of type '" + nodesType + "' not suported for this endpoint");
throw new InvalidArgumentException("Creating relative path of type '" + nodesType + "' not suported for this endpoint");
}
return lastNodeRef;
@@ -949,56 +948,6 @@ public class FilePlanComponentsApiUtils
return allowableOperations;
}
protected PathInfo lookupPathInfo(NodeRef nodeRefIn)
{
List<ElementInfo> pathElements = new ArrayList<>();
Boolean isComplete = Boolean.TRUE;
final Path nodePath = nodeService.getPath(nodeRefIn);;
final int pathIndex = 2;
for (int i = nodePath.size() - pathIndex; i >= 0; i--)
{
Element element = nodePath.get(i);
if (element instanceof Path.ChildAssocElement)
{
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
if (elementRef.getParentRef() != null)
{
NodeRef childNodeRef = elementRef.getChildRef();
if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED)
{
Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString()));
}
else
{
// Just return the pathInfo up to the location where the user has access
isComplete = Boolean.FALSE;
break;
}
}
}
}
String pathStr = null;
if (!pathElements.isEmpty())
{
StringBuilder sb = new StringBuilder(120);
for (PathInfo.ElementInfo e : pathElements)
{
sb.append("/").append(e.getName());
}
pathStr = sb.toString();
}
else
{
// There is no path element, so set it to null in order to be
// ignored by Jackson during serialisation
isComplete = null;
}
return new PathInfo(pathStr, isComplete, pathElements);
}
/**
* Helper method to obtain file plan type or null if the rm site does not exist.
*

View File

@@ -31,6 +31,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.api.model.Assoc;
import org.alfresco.rest.api.model.PathInfo;
import org.alfresco.rest.api.model.UserInfo;
@@ -103,6 +105,7 @@ public abstract class RMNode
}
@JsonProperty ("id")
@UniqueId
public NodeRef getNodeRef()
{

View File

@@ -31,6 +31,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.framework.resource.UniqueId;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -67,6 +69,7 @@ public class Transfer
{
}
@JsonProperty ("id")
@UniqueId
public NodeRef getNodeRef()
{

View File

@@ -31,6 +31,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.framework.resource.UniqueId;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -60,6 +62,7 @@ public class TransferContainer
{
}
@JsonProperty ("id")
@UniqueId
public NodeRef getNodeRef()
{

View File

@@ -28,6 +28,7 @@
package org.alfresco.rm.rest.api.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Abstract class carrying information for an unfiled container or unfiled record folder child
@@ -43,6 +44,7 @@ public abstract class UnfiledChild extends RMNode
protected Boolean isUnfiledRecordFolder;
protected Boolean isRecord;
@JsonProperty (PARAM_IS_UNFILED_RECORD_FOLDER)
public Boolean getIsUnfiledRecordFolder()
{
return isUnfiledRecordFolder;
@@ -54,6 +56,7 @@ public abstract class UnfiledChild extends RMNode
this.isUnfiledRecordFolder = isUnfiledRecordFolder;
}
@JsonProperty (PARAM_IS_RECORD)
public Boolean getIsRecord()
{
return isRecord;

View File

@@ -0,0 +1,73 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2018 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.rm.rest.api.util;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
/**
* Custom Date Time serializer for formatting org.joda.time.DateTime
*
* @author Rodica Sutu
* @since 3.0
*/
public class CustomDateTimeSerializer extends StdSerializer<DateTime>
{
/** Date time format */
private final static DateTimeFormatter DATE_TIME_FORMAT = ISODateTimeFormat.dateTime();
public CustomDateTimeSerializer()
{
super(DateTime.class);
}
protected CustomDateTimeSerializer(Class<DateTime> t)
{
super(t);
}
/**
* Custom serialize method to convert the org.joda.time.DateTime into string value using the DATE_TIME_FORMAT
*
* @param value datetime value
* @param jgen
* @param provider
* @throws IOException
*/
@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException
{
jgen.writeString(DATE_TIME_FORMAT.print(value));
}
}

View File

@@ -0,0 +1,74 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2018 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.rm.rest.api.util;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
/**
* Custom Local Date deserializer converting a string to org.joda.time.LocalDate when the time is optional;
*
* @author Rodica Sutu
* @since 3.0
*/
public class CustomLocalDateDeserializer extends StdDeserializer<LocalDate>
{
/** Date time format with time optional */
private final static DateTimeFormatter LOCAL_DATE_OPTIONAL_TIME_PARSER = ISODateTimeFormat.localDateOptionalTimeParser();
public CustomLocalDateDeserializer()
{
super(LocalDate.class);
}
/**
* Custom deserialize method to convert string to the org.joda.time.LocalDate type with LOCAL_DATE_OPTIONAL_TIME_PARSER
*
* @param jp local date value
* @param ctxt
* @throws IOException
*/
@Override
public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException
{
String str = jp.getText().trim();
if (str.length() == 0)
{
return null;
}
return LOCAL_DATE_OPTIONAL_TIME_PARSER.parseLocalDate(str);
}
}

View File

@@ -0,0 +1,73 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2018 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.rm.rest.api.util;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
/**
* Custom Local Date serializer for formatting org.joda.time.LocalDate
*
* @author Rodica Sutu
* @since 3.0
*/
public class CustomLocalDateSerializer extends StdSerializer<LocalDate>
{
/** Local date format yyyy-MM-dd*/
private final static DateTimeFormatter DATE_FORMAT = ISODateTimeFormat.date();
public CustomLocalDateSerializer()
{
super(LocalDate.class);
}
protected CustomLocalDateSerializer(Class<LocalDate> t)
{
super(t);
}
/**
* Custom serialize method to convert the org.joda.time.LocalDate into string value using the DATE_FORMAT
*
* @param value local date value
* @param jgen
* @param provider
* @throws IOException
*/
@Override
public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException
{
jgen.writeString(DATE_FORMAT.print(value));
}
}