@RequiredPermission(Permission.MANAGE_REPOSITORIES) public ContentSource simpleCreateContentSource(Subject subject, ContentSource contentSource) throws ContentSourceException { validateContentSource(contentSource); contentSource.setSyncResults(new ArrayList<ContentSourceSyncResults>()); obfuscatePasswords(contentSource); entityManager.persist(contentSource); return contentSource; }
@RequiredPermission(Permission.MANAGE_REPOSITORIES) public ContentSource createContentSource(Subject subject, ContentSource contentSource) throws ContentSourceException { validateContentSource(contentSource); log.debug("User [" + subject + "] is creating content source [" + contentSource + "]"); // now that a new content source has been added to the system, let's start its adapter now try { ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer(); pc.getAdapterManager().startAdapter(contentSource); // Schedule a job for the future pc.scheduleProviderSyncJob(contentSource); // Also sync immediately so we have the metadata pc.syncProviderNow(contentSource); } catch (InitializationException ie) { log.warn("Failed to start adapter for [" + contentSource + "]", ie); throw new ContentSourceException("Failed to start adapter for [" + contentSource + "]. Cause: " + ThrowableUtil.getAllMessages(ie)); } catch (Exception e) { log.warn("Failed to start adapter for [" + contentSource + "]", e); } obfuscatePasswords(contentSource); entityManager.persist(contentSource); // these aren't cascaded during persist, but I want to set them to null anyway, just to be sure contentSource.setSyncResults(null); log.debug("User [" + subject + "] created content source [" + contentSource + "]"); return contentSource; // now has the ID set }