public Product createProduct(Product entity) throws InvalidEntityException, EntityAlreadyExistsException { if (Strings.isNullOrEmpty(entity.getSlug())) { entity.setSlug(this.slugifier.slugify(entity.getTitle())); } productStore.get().create(entity); return this.findProductBySlug(entity.getSlug()); }
@Override public Collection createCollection(Collection entity) throws InvalidEntityException, EntityAlreadyExistsException { if (Strings.isNullOrEmpty(entity.getSlug())) { entity.setSlug(this.slugifier.slugify(entity.getTitle())); } this.collectionStore.get().create(entity); return this.findCollectionBySlug(entity.getSlug()); }
LoadedAttachment attachment = new LoadedAttachment(); attachment.setExtension(extension); fileName = StringUtils.removeEnd(originalFilename, "." + extension); } else { String slug = this.slugifier.slugify(fileName); if (Strings.isNullOrEmpty(slug)) { throw new WebApplicationException( attachment.setSlug(slug); attachment.setData(new AttachmentData(data)); attachment.setTitle(title); attachment.setDescription(description); attachment.setParentId(parent.get()); return this.addAttachment(attachment, 0);
private void registerEntityMetaRegistryAsComponent() { Map<String, EntityMeta> entities = Maps.newHashMap(); for (Module module : modules.values()) { for (EntityMeta meta : module.getEntities()) { if (entities.containsKey(meta.getEntityName())) { LOGGER.error( "Entity with name [" + meta.getEntityName() + "] already registered. Refusing to start."); System.exit(1); } entities.put(meta.getEntityName(), meta); } } EntityMetaRegistry registry = new DefaultEntityMetaRegistry(new ArrayList(entities.values())); DefaultComponentDescriptor<EntityMetaRegistry> cd = new DefaultComponentDescriptor<EntityMetaRegistry>(); cd.setRoleType(EntityMetaRegistry.class); componentManager.registerComponent(cd, registry); }