Esempio n. 1
0
 /**
  * Validates the tag type create request. This method also trims the request parameters.
  *
  * @param request the tag type create request
  */
 private void validateTagTypeCreateRequest(TagTypeCreateRequest request) {
   Assert.notNull(request, "A tag type create request must be specified.");
   tagTypeHelper.validateTagTypeKey(request.getTagTypeKey());
   request.setDisplayName(
       alternateKeyHelper.validateStringParameter("display name", request.getDisplayName()));
   Assert.notNull(request.getTagTypeOrder(), "A tag type order must be specified.");
 }
Esempio n. 2
0
  @Override
  public TagType createTagType(TagTypeCreateRequest request) {
    // Validate and trim the request parameters.
    validateTagTypeCreateRequest(request);

    // Validate the tag type does not already exist in the database.
    TagTypeEntity tagTypeEntity = tagTypeDao.getTagTypeByKey(request.getTagTypeKey());
    if (tagTypeEntity != null) {
      throw new AlreadyExistsException(
          String.format(
              "Unable to create tag type with code \"%s\" because it already exists.",
              request.getTagTypeKey().getTagTypeCode()));
    }

    // Validate the display name does not already exist in the database
    tagTypeDaoHelper.assertTagTypeDisplayNameDoesNotExist(request.getDisplayName());

    // Create and persist a new tag type entity from the request information.
    tagTypeEntity =
        createTagTypeEntity(
            request.getTagTypeKey().getTagTypeCode(),
            request.getDisplayName(),
            request.getTagTypeOrder());

    // Create and return the tag type object from the persisted entity.
    return createTagTypeFromEntity(tagTypeEntity);
  }