LinksServiceImpl implements LinksService { @Override public LinkInfo createLink(String siteShortName, String title, String description, String url, boolean internal) { NodeRef container = getSiteLinksContainer(siteShortName, true); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(LinksModel.PROP_TITLE, title); props.put(LinksModel.PROP_DESCRIPTION, description); props.put(LinksModel.PROP_URL, url); if (internal) { props.put(LinksModel.PROP_IS_INTERNAL, "true"); } String name = "link-" + (new Date()).getTime() + "-" + Math.round(Math.random()*10000); props.put(ContentModel.PROP_NAME, name); NodeRef nodeRef = nodeService.createNode( container, ContentModel.ASSOC_CONTAINS, QName.createQName(name), LinksModel.TYPE_LINK, props ).getChildRef(); ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); writer.putContent(url); return buildLink(nodeRef, container, name); }  void setNodeDAO(NodeDAO nodeDAO); void setNodeService(NodeService nodeService); void setSiteService(SiteService siteService); void setSearchService(SearchService searchService); void setContentService(ContentService contentService); void setTaggingService(TaggingService taggingService); void setNamespaceService(NamespaceService namespaceService); void setDictionaryService(DictionaryService dictionaryService); void setTransactionService(TransactionService transactionService); void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry); @Override LinkInfo getLink(String siteShortName, String linkName); @Override LinkInfo createLink(String siteShortName, String title,
          String description, String url, boolean internal); @Override LinkInfo updateLink(LinkInfo link); @Override void deleteLink(LinkInfo link); @Override PagingResults<LinkInfo> listLinks(String siteShortName, PagingRequest paging); @Override PagingResults<LinkInfo> listLinks(String siteShortName, String user,
          PagingRequest paging); @Override PagingResults<LinkInfo> listLinks(String siteShortName, Date from,
          Date to, PagingRequest paging); @Override PagingResults<LinkInfo> findLinks(String siteShortName, String user,
          Date from, Date to, String tag, PagingRequest paging); static final String LINKS_COMPONENT; }
@Test public void newContainerSetup() throws Exception { final String TEST_SITE_NAME = "LinksTestNewTestSite"; TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { if (SITE_SERVICE.getSite(TEST_SITE_NAME) != null) { SITE_SERVICE.deleteSite(TEST_SITE_NAME); } SITE_SERVICE.createSite( TEST_SITE_PREFIX, TEST_SITE_NAME, "Test", "Test", SiteVisibility.PUBLIC); assertFalse(SITE_SERVICE.hasContainer(TEST_SITE_NAME, LinksServiceImpl.LINKS_COMPONENT)); LINKS_SERVICE.createLink( TEST_SITE_NAME, "Title", "Description", "http: assertTrue(SITE_SERVICE.hasContainer(TEST_SITE_NAME, LinksServiceImpl.LINKS_COMPONENT)); NodeRef container = SITE_SERVICE.getContainer(TEST_SITE_NAME, LinksServiceImpl.LINKS_COMPONENT); assertTrue(TAGGING_SERVICE.isTagScope(container)); SITE_SERVICE.deleteSite(TEST_SITE_NAME); return null; } }); }