SeriesServiceImpl extends AbstractIndexProducer implements SeriesService { @Override public DublinCoreCatalog updateSeries(DublinCoreCatalog dc) throws SeriesException, UnauthorizedException { try { for (DublinCoreCatalog dublinCore : isNew(notNull(dc, "dc"))) { final String id = dublinCore.getFirst(DublinCore.PROPERTY_IDENTIFIER); if (!dublinCore.hasValue(DublinCore.PROPERTY_CREATED)) { DublinCoreValue date = EncodingSchemeUtils.encodeDate(new Date(), Precision.Minute); dublinCore.set(DublinCore.PROPERTY_CREATED, date); logger.debug("Setting series creation date to '{}'", date.getValue()); } if (dublinCore.hasValue(DublinCore.PROPERTY_TITLE)) { if (dublinCore.getFirst(DublinCore.PROPERTY_TITLE).length() > 255) { dublinCore.set(DublinCore.PROPERTY_TITLE, dublinCore.getFirst(DublinCore.PROPERTY_TITLE).substring(0, 255)); logger.warn("Title was longer than 255 characters. Cutting excess off."); } } logger.debug("Updating series {}", id); index.updateIndex(dublinCore); try { final AccessControlList acl = persistence.getAccessControlList(id); if (acl != null) { index.updateSecurityPolicy(id, acl); } } catch (NotFoundException ignore) { } DublinCoreCatalog updated = persistence.storeSeries(dublinCore); messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateCatalog(dublinCore)); return (updated == null) ? null : dublinCore; } return dc; } catch (Exception e) { throw new SeriesException(e); } }  @Reference(name = "series-index") void setIndex(SeriesServiceIndex index); @Reference(name = "series-persistence") void setPersistence(SeriesServiceDatabase persistence); @Reference(name = "security-service") void setSecurityService(SecurityService securityService); @Reference(name = "orgDirectory") void setOrgDirectory(OrganizationDirectoryService orgDirectory); @Reference(name = "message-broker-sender") void setMessageSender(MessageSender messageSender); @Reference(name = "message-broker-receiver") void setMessageReceiver(MessageReceiver messageReceiver); @Activate void activate(ComponentContext cc); @Deactivate void deactivate(); @Override DublinCoreCatalog updateSeries(DublinCoreCatalog dc); @Override boolean updateAccessControl(final String seriesId, final AccessControlList accessControl); @Override boolean updateAccessControl(final String seriesId, final AccessControlList accessControl,
          boolean overrideEpisodeAcl); @Override void deleteSeries(final String seriesID); @Override DublinCoreCatalogList getSeries(SeriesQuery query); @Override Map<String, String> getIdTitleMapOfAllSeries(); @Override DublinCoreCatalog getSeries(String seriesID); @Override AccessControlList getSeriesAccessControl(String seriesID); @Override int getSeriesCount(); @Override Map<String, String> getSeriesProperties(String seriesID); @Override String getSeriesProperty(String seriesID, String propertyName); @Override void updateSeriesProperty(String seriesID, String propertyName, String propertyValue); @Override void deleteSeriesProperty(String seriesID, String propertyName); static boolean equals(DublinCoreCatalog a, DublinCoreCatalog b); static boolean equals(AccessControlList a, AccessControlList b); @Override Opt<Map<String, byte[]>> getSeriesElements(String seriesId); @Override Opt<byte[]> getSeriesElementData(String seriesId, String type); @Override boolean addSeriesElement(String seriesID, String type, byte[] data); @Override boolean updateSeriesElement(String seriesID, String type, byte[] data); @Override boolean deleteSeriesElement(String seriesID, String type); @Override void repopulate(final String indexName); @Override MessageReceiver getMessageReceiver(); @Override Service getService(); @Override String getClassName(); @Override MessageSender getMessageSender(); @Override SecurityService getSecurityService(); @Override String getSystemUserName();  }
@Test public void testAddingSeriesWithoutID() throws Exception { testCatalog.remove(DublinCore.PROPERTY_IDENTIFIER); DublinCoreCatalog newSeries = seriesService.updateSeries(testCatalog); Assert.assertNotNull("New series DC should be returned", newSeries); String id = newSeries.getFirst(DublinCore.PROPERTY_IDENTIFIER); Assert.assertNotNull("New series should have id set", id); }