1 package com.atlassian.plugins.codegen.modules.common;
2
3 import com.atlassian.plugins.codegen.annotations.*;
4 import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
5 import com.atlassian.plugins.codegen.modules.PluginModuleLocation;
6 import com.atlassian.plugins.codegen.modules.common.component.ComponentImportModuleCreator;
7 import com.atlassian.plugins.codegen.modules.common.component.ComponentImportProperties;
8 import com.atlassian.plugins.codegen.modules.common.component.ComponentModuleCreator;
9 import com.atlassian.plugins.codegen.modules.common.component.ComponentProperties;
10
11
12
13
14 @RefAppPluginModuleCreator
15 @JiraPluginModuleCreator
16 @ConfluencePluginModuleCreator
17 @BambooPluginModuleCreator
18 @FeCruPluginModuleCreator
19 @CrowdPluginModuleCreator
20 @Dependencies({
21 @Dependency(groupId = "com.atlassian.upm", artifactId = "licensing-api", version = "2.0", scope = "provided"),
22 @Dependency(groupId = "com.atlassian.upm", artifactId = "upm-api", version = "2.0", scope = "provided"),
23 @Dependency(groupId = "com.atlassian.plugins", artifactId = "atlassian-plugins-core", version = "2.9.0", scope = "provided"),
24 @Dependency(groupId = "com.atlassian.sal", artifactId = "sal-api", version = "2.6.0", scope = "provided")
25 })
26 public class LicensingModuleCreator extends AbstractPluginModuleCreator<LicensingProperties>
27 {
28 public static final String MODULE_NAME = "Atlassian License Management";
29
30 public static final String PLUGIN_LICENSE_MANAGER_CLASS = "com.atlassian.upm.api.license.PluginLicenseManager";
31 public static final String PLUGIN_CONTROLLER_CLASS = "com.atlassian.plugin.PluginController";
32 public static final String PLUGIN_LICENSE_EVENT_REGISTRY_CLASS = "com.atlassian.upm.api.license.PluginLicenseEventRegistry";
33 public static final String LICENSE_CHECKER_DESCRIPTION = "Atlassian license management module";
34 public static final String LICENSE_CHECKER_CLASS_TEMPLATE = "templates/common/licensing/LicenseChecker.java.vtl";
35
36 @Override
37 public void createModule(PluginModuleLocation location, LicensingProperties props) throws Exception
38 {
39 addPluginInfoParamToPluginXml(location, "atlassian-licensing-enabled", "true");
40
41 ComponentImportModuleCreator importCreator = new ComponentImportModuleCreator();
42 importCreator.createModule(location, new ComponentImportProperties(PLUGIN_LICENSE_MANAGER_CLASS));
43 importCreator.createModule(location, new ComponentImportProperties(PLUGIN_CONTROLLER_CLASS));
44 importCreator.createModule(location, new ComponentImportProperties(PLUGIN_LICENSE_EVENT_REGISTRY_CLASS));
45
46 ComponentModuleCreator componentCreator = new ComponentModuleCreator();
47 ComponentProperties componentProps = new ComponentProperties(props.getFullyQualifiedClassname());
48 componentProps.setGenerateClass(false);
49 componentProps.setGenerateInterface(false);
50 componentProps.setIncludeExamples(false);
51 componentProps.setDescription(LICENSE_CHECKER_DESCRIPTION);
52 componentCreator.createModule(location, componentProps);
53
54 templateHelper.writeJavaClassFromTemplate(LICENSE_CHECKER_CLASS_TEMPLATE,
55 props.getClassname(),
56 location.getSourceDirectory(),
57 props.getPackage(),
58 props);
59 }
60
61 @Override
62 public String getModuleName()
63 {
64 return MODULE_NAME;
65 }
66 }