/** * Creates the name for the scheduled content source's sync job. Calling this * method multiple times with the same content source always produces the same name. * * @param cs the content source whose scheduled job name is to be returned * * @return the scheduled job name for the given content source */ public static String createJobName(ContentSource cs) { // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique // so encode the names' hashcodes to ensure we fix into the quartz job name column. String nameEncoded = Integer.toHexString(cs.getName().hashCode()); String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode()); String jobName = nameEncoded + SEPARATOR + typeNameEncoded; if (jobName.length() > 80) { throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: " + jobName); } return jobName; }
/** * Creates a unique name for a new content source sync job. Calling this * method multiple times with the same content source always produces a different name * which is useful if you want to schedule an new job that is separate and distinct * from any other job in the system. * * @param cs the content source * * @return a unique job name that can be used for a new job to sync a given content source */ public static String createUniqueJobName(ContentSource cs) { // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique // so encode the names' hashcodes to ensure we fix into the quartz job name column. // appendStr is used to make the job unique among others for the same content source. String nameEncoded = Integer.toHexString(cs.getName().hashCode()); String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode()); String appendStr = Long.toHexString(System.currentTimeMillis()); String jobName = nameEncoded + SEPARATOR + typeNameEncoded + SEPARATOR + appendStr; if (jobName.length() > 80) { throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: " + jobName); } return jobName; } }
@SuppressWarnings("unchecked") private void validateContentSource(ContentSource cs) throws ContentSourceException { String name = cs.getName(); ContentSourceType type = cs.getContentSourceType(); if (name == null || name.trim().equals("")) { throw new ContentSourceException("ContentSource name attribute is required"); } // If a content source with this name and type combination exists, throw an error as it's a violation // of the DB uniqueness constraints Query q = entityManager.createNamedQuery(ContentSource.QUERY_FIND_BY_NAME_AND_TYPENAME); q.setParameter("name", name); q.setParameter("typeName", type.getName()); List<ContentSource> existingMatchingContentSources = q.getResultList(); if (existingMatchingContentSources.size() > 0) { throw new ContentSourceException("Content source with name [" + name + "] and of type [" + type.getName() + "] already exists, please specify a different name."); } }
ServerPluginEnvironment env = this.pluginManager.getPluginEnvironment(contentSource.getContentSourceType()); if (env == null) { throw new RuntimeException("There is no plugin env. for content source [" + contentSource + "]");
/** * All content source sync jobs must have specified data prepared * in their job details data map. This creates that data map. You must * call this method everytime you schedule a content source sync job. * If the given details is not <code>null</code>, this will place the * created data map in the details for you. Otherwise, you must ensure * the returned data map gets associated with the job when it is created. * * @param contentSource the content source whose sync job's details is being prepared * @param details where the job's data map will be stored (may be <code>null</code>) * * @return the data map with the data necessary to execute a content sync job */ public static JobDataMap createJobDataMap(ContentSource contentSource, JobDetail details) { JobDataMap dataMap; if (details != null) { dataMap = details.getJobDataMap(); } else { dataMap = new JobDataMap(); } dataMap.put(DATAMAP_CONTENT_SOURCE_NAME, contentSource.getName()); dataMap.put(DATAMAP_CONTENT_SOURCE_TYPE_NAME, contentSource.getContentSourceType().getName()); return dataMap; }
+ contentSource.getContentSourceType() + "]");
private void obfuscatePasswords(ContentSource contentSource) { ConfigurationDefinition configurationDefinition = contentSource.getContentSourceType().getContentSourceConfigurationDefinition(); if (configurationDefinition == null) { ContentSourceType attachedContentSourceType = getContentSourceType(contentSource.getContentSourceType().getName()); configurationDefinition = attachedContentSourceType.getContentSourceConfigurationDefinition(); } PasswordObfuscationUtility.obfuscatePasswords(configurationDefinition, contentSource.getConfiguration()); } }
ContentSourceType type = contentSource.getContentSourceType(); apiClassName = type.getContentSourceApiClass(); pluginName = this.pluginManager.getMetadataManager().getPluginNameFromContentSourceType(type);
+ contentSource.getContentSourceType() + "]");