mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix tag feature modifications after review
This commit is contained in:
parent
8d2fb5fa76
commit
cfa40c0d2b
@ -338,10 +338,10 @@ public interface DeviceManagementService {
|
|||||||
@QueryParam("requireDeviceInfo")
|
@QueryParam("requireDeviceInfo")
|
||||||
boolean requireDeviceInfo,
|
boolean requireDeviceInfo,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "tags",
|
name = "tag",
|
||||||
value = "Describes the tags associated with the enrolment",
|
value = "Describes the tags associated with the enrolment",
|
||||||
required = false)
|
required = false)
|
||||||
@QueryParam("tags")
|
@QueryParam("tag")
|
||||||
List<String> tags,
|
List<String> tags,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "offset",
|
name = "offset",
|
||||||
|
|||||||
@ -151,7 +151,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@QueryParam("since") String since,
|
@QueryParam("since") String since,
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||||
@QueryParam("requireDeviceInfo") boolean requireDeviceInfo,
|
@QueryParam("requireDeviceInfo") boolean requireDeviceInfo,
|
||||||
@QueryParam("tags") List<String> tags,
|
@QueryParam("tag") List<String> tags,
|
||||||
@QueryParam("offset") int offset,
|
@QueryParam("offset") int offset,
|
||||||
@QueryParam("limit") int limit) {
|
@QueryParam("limit") int limit) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -126,7 +126,7 @@ public class TagManagementServiceImpl implements TagManagementService {
|
|||||||
log.debug(msg, e);
|
log.debug(msg, e);
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse.ErrorResponseBuilder().
|
return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse.ErrorResponseBuilder().
|
||||||
setMessage(msg).build()).build();
|
setMessage(e.getMessage()).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -172,6 +172,12 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new TagNotFoundException(msg);
|
throw new TagNotFoundException(msg);
|
||||||
}
|
}
|
||||||
|
Tag tagWithName = tagDAO.getTagByName(tag.getName(), tenantId);
|
||||||
|
if (tagWithName != null && tagWithName.getId() != tag.getId()) {
|
||||||
|
String msg = "Tag with name: " + tag.getName() + " already exists.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new BadRequestException(msg);
|
||||||
|
}
|
||||||
tagDAO.updateTag(tag, tenantId);
|
tagDAO.updateTag(tag, tenantId);
|
||||||
DeviceManagementDAOFactory.commitTransaction();
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
} catch (TagManagementDAOException | TransactionManagementException e) {
|
} catch (TagManagementDAOException | TransactionManagementException e) {
|
||||||
|
|||||||
@ -41,8 +41,8 @@ public class TestDataHolder {
|
|||||||
|
|
||||||
public final static String TEST_DEVICE_TYPE = "TEST-DEVICE-TYPE";
|
public final static String TEST_DEVICE_TYPE = "TEST-DEVICE-TYPE";
|
||||||
public final static Integer SUPER_TENANT_ID = -1234;
|
public final static Integer SUPER_TENANT_ID = -1234;
|
||||||
public final static Integer ALTERNATE_TENANT_ID = -1235;
|
public final static Integer ALTERNATE_TENANT_ID = 1234;
|
||||||
public final static Integer ALTERNATE_TENANT_ID_1 = -1236;
|
public final static Integer ALTERNATE_TENANT_ID_1 = 1235;
|
||||||
public final static String SUPER_TENANT_DOMAIN = "carbon.super";
|
public final static String SUPER_TENANT_DOMAIN = "carbon.super";
|
||||||
public final static String initialDeviceIdentifier = "12345";
|
public final static String initialDeviceIdentifier = "12345";
|
||||||
public final static String initialDeviceName = "TEST-DEVICE";
|
public final static String initialDeviceName = "TEST-DEVICE";
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class TagManagementProviderServiceTest extends BaseDeviceManagementTest {
|
|||||||
tagManagementProviderService.addTags(TestUtils.createTagList2());
|
tagManagementProviderService.addTags(TestUtils.createTagList2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = {TagNotFoundException.class}, dependsOnMethods = "createTags")
|
@Test(expectedExceptions = {TagNotFoundException.class, BadRequestException.class, TagManagementException.class})
|
||||||
public void updateTagsNotFound() throws TagNotFoundException, TagManagementException, BadRequestException {
|
public void updateTagsNotFound() throws TagNotFoundException, TagManagementException, BadRequestException {
|
||||||
String updateDescString = "This tag is updated";
|
String updateDescString = "This tag is updated";
|
||||||
tagManagementProviderService.updateTag(new Tag(10,"tag10", updateDescString));
|
tagManagementProviderService.updateTag(new Tag(10,"tag10", updateDescString));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user