mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-4362: Fix returned HTTP error status for invalid note type (#1691)
* ACS-4362: Create categories and tags - fix returned HTTP error status for invalid note type
This commit is contained in:
committed by
GitHub
parent
ee7a5370f8
commit
37ec795358
@@ -47,7 +47,7 @@ import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidNodeTypeException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.ListPage;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
@@ -74,7 +74,7 @@ public class CategoriesImpl implements Categories
|
||||
static final String NO_PERMISSION_TO_READ_CONTENT = "Current user does not have read permission to content";
|
||||
static final String NO_PERMISSION_TO_CHANGE_CONTENT = "Current user does not have change permission to content";
|
||||
static final String NOT_NULL_OR_EMPTY = "Category name must not be null or empty";
|
||||
static final String INVALID_NODE_TYPE = "Cannot categorize this node type";
|
||||
static final String INVALID_NODE_TYPE = "Cannot categorize this type of node";
|
||||
|
||||
private final AuthorityService authorityService;
|
||||
private final CategoryService categoryService;
|
||||
@@ -264,7 +264,7 @@ public class CategoriesImpl implements Categories
|
||||
{
|
||||
if (!typeConstraint.matches(nodeRef))
|
||||
{
|
||||
throw new UnsupportedResourceOperationException(INVALID_NODE_TYPE);
|
||||
throw new InvalidNodeTypeException(INVALID_NODE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.framework.core.exceptions;
|
||||
|
||||
/**
|
||||
* Type of provided node is invalid.
|
||||
*/
|
||||
public class InvalidNodeTypeException extends ApiException
|
||||
{
|
||||
private static final long serialVersionUID = -672100019820298939L;
|
||||
|
||||
public static String DEFAULT_MESSAGE_ID = "framework.exception.InvalidNodeType";
|
||||
|
||||
public InvalidNodeTypeException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
}
|
||||
|
||||
public InvalidNodeTypeException(Object[] msgParams)
|
||||
{
|
||||
super(DEFAULT_MESSAGE_ID, msgParams);
|
||||
}
|
||||
|
||||
public InvalidNodeTypeException(String msgId, Object[] msgParams)
|
||||
{
|
||||
super(msgId, msgParams);
|
||||
}
|
||||
}
|
@@ -15,5 +15,6 @@ framework.exception.DeletedResource=In this version of the REST API resource {0}
|
||||
framework.exception.RequestEntityTooLarge=The file can't be uploaded because it's larger than the maximum upload size
|
||||
framework.exception.InsufficientStorage=The file upload exceeds the content storage allowance
|
||||
framework.exception.JsonpCallbackNotAllowed=For security reasons the callback parameter is not allowed
|
||||
framework.exception.InvalidNodeType=Type of provided node with id: {0} is invalid
|
||||
framework.no.stacktrace=For security reasons the stack trace is no longer displayed, but the property is kept for previous versions
|
||||
|
||||
|
@@ -177,6 +177,7 @@
|
||||
<entry key="org.alfresco.service.cmr.dictionary.InvalidTypeException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.ArchivedContentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_PRECONDITION_FAILED}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.RestoreInProgressException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InvalidNodeTypeException" value="#{T(org.apache.http.HttpStatus).SC_UNPROCESSABLE_ENTITY}" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -62,8 +62,8 @@ import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidNodeTypeException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -961,7 +961,7 @@ public class CategoriesImplTest
|
||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
assertThat(actualException)
|
||||
.isInstanceOf(UnsupportedResourceOperationException.class)
|
||||
.isInstanceOf(InvalidNodeTypeException.class)
|
||||
.hasMessageContaining(INVALID_NODE_TYPE);
|
||||
}
|
||||
|
||||
@@ -1125,7 +1125,7 @@ public class CategoriesImplTest
|
||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
assertThat(actualException)
|
||||
.isInstanceOf(UnsupportedResourceOperationException.class)
|
||||
.isInstanceOf(InvalidNodeTypeException.class)
|
||||
.hasMessageContaining(INVALID_NODE_TYPE);
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,7 @@
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InsufficientStorageException" value="507" />
|
||||
<entry key="org.alfresco.repo.node.integrity.IntegrityException" value="422" />
|
||||
<entry key="org.alfresco.repo.site.SiteServiceException" value="422" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InvalidNodeTypeException" value="#{T(org.apache.http.HttpStatus).SC_UNPROCESSABLE_ENTITY}" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
Reference in New Issue
Block a user