CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 948
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 2155
							+ containerMap.getESBContainerSettings());

			final ArrayList<IContainerSetting> mfConfig = configs[1];
			for (final Iterator<IContainerSetting> iterator = mfConfig
					.iterator(); iterator.hasNext();) {
				final IContainerSetting container = iterator.next();

				// Remove and re-add the element to make sure the newer setting
				// (from ContainerProperties.xml) overrides any settings in
				// pom.xml
				containerMap.getMFContainerSettings().remove(container);
				containerMap.getMFContainerSettings().add(container);
			}
			getLog().debug(
					"MF container mapping: "
							+ containerMap.getMFContainerSettings());

			getLog().debug("Adding External ESB Configuration - Done");

			final HashMap<String, IESBContainer> esbContainerMap = new HashMap<String, IESBContainer>();

			getLog().info("---------------------------------------------");
			getLog().debug("Building Container settings for SDM model...");

			final List<Xpp3Dom> serviceInstances = Xpp3Utils.collectElements(
					getDependencyDirectory(), "**/*.instances.snippet");
			for (final Xpp3Dom serviceInstance : serviceInstances) {

				final String containerHint = serviceInstance
						.getAttribute(SnippetsProcessor.HINT_ATTRIBUTE);

				getLog().debug(
						"Matching service instance "
								+ serviceInstance.getAttribute("name") + "/"
								+ serviceInstance.getAttribute("process")
								+ "\r\n\t(containerHint: " + containerHint
								+ ")");

				if (containerMap == null) {
					throw new Exception(
							"containerMap not specified in plugin configuration");
				}

				final Map<String, Properties> matches = containerMap
						.matchESBContainerSettings(containerHint);
				if (matches.size() == 0
						&& containerMap.isUseESBDefaultIncludes()) {
					getLog().warn(
							"No matching ESBContainer setting found...will use default...");
					matches.put(containerMap.getDefaultESBContainerSetting()
							.getName(), new Properties());
				}

				for (final Iterator<String> it = matches.keySet().iterator(); it
						.hasNext();) {
					final String matchedName = it.next();
File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 505
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 2501
		final SortedSet<String> propNames = new TreeSet<String>();
		for (final Enumeration<Object> en = props.keys(); en.hasMoreElements();) {
			propNames.add((String) en.nextElement());
		}

		final Xpp3Dom topology = new Xpp3Dom("Environment");
		final Xpp3Dom id = new Xpp3Dom("Id");
		final Xpp3Dom machines = new Xpp3Dom("Machines");
		final Xpp3Dom machine = new Xpp3Dom("Machine");
		final Xpp3Dom parameters = new Xpp3Dom("Parameters");

		id.setValue("GeneratedTopology");
		topology.addChild(id);

		machines.addChild(machine);

		Xpp3Dom element = null;
		Xpp3Dom child = null;
		Xpp3Dom paramId = null;
		Xpp3Dom defaultValue = null;
		Xpp3Dom parameter = null;

		element = new Xpp3Dom("Id");
		element.setValue("Generated_Machine");
		machine.addChild(element);

		element = new Xpp3Dom("AlternateId");
		element.setValue("Generated_Alternate");
		machine.addChild(element);

		element = new Xpp3Dom("LogicalHosts");
		machine.addChild(element);

		child = new Xpp3Dom("LogicalHost");
		child.setValue("GeneratedHost");
		element.addChild(child);

		element = new Xpp3Dom("Settings");

		topology.addChild(machines);
		topology.addChild(element);
		topology.addChild(parameters);

		for (final String key : propNames) {
			// bos.write((key + "=" + props.get(key) + "\n").getBytes());
			parameter = new Xpp3Dom("Parameter");
			paramId = new Xpp3Dom("Id");
			paramId.setValue(key);

			defaultValue = new Xpp3Dom("Value");
File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 648
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 768
																										.getName()) }),
														MojoExecutor.element(
																"filtering",
																"false"))) }),
						MojoExecutor.executionEnvironment(project, session,
								pluginManager));

		getLog().info("Filtering the following resources: " + "Model.xml");
		MojoExecutor.executeMojo(MojoExecutor.plugin(
				MojoExecutor.groupId("org.apache.maven.plugins"),
				MojoExecutor.artifactId("maven-resources-plugin"),
				MojoExecutor.version("2.4.3")), MojoExecutor
				.goal("copy-resources"), MojoExecutor
				.configuration(new MojoExecutor.Element[] {
						MojoExecutor.element(
								MojoExecutor.name("outputDirectory"),
								getTargetSDMDir().getAbsolutePath()),
						MojoExecutor.element(MojoExecutor.name("overwrite"),
								"true"),
						MojoExecutor.element("escapeString", "\\"),
						MojoExecutor.element("resources", MojoExecutor.element(
								"resource", MojoExecutor.element("directory",
										getSonicEsbSourceDirectory()
												.getAbsolutePath()),
								MojoExecutor.element(
										"includes",
										new MojoExecutor.Element[] {
												MojoExecutor.element("include",
														"Model.xml"),
												MojoExecutor.element("include",
														"*.properties"),
												MojoExecutor.element("include",
														"*Deletes.xml"),
												MojoExecutor.element("include",
														"*Rollback.xml") }),
								MojoExecutor.element("filtering", "true"))) }),
				MojoExecutor.executionEnvironment(project, session,
						pluginManager));
File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 359
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 2652
			}

			parameter.addChild(paramId);
			parameter.addChild(defaultValue);

			parameters.addChild(parameter);
		}

		topology.addChild(parameters);

		for (final String toCompare : FileUtilities.getFileList(
				getTargetSDMDir().getAbsolutePath(), "*.Topology.xml",
				"generated.Topology.xml")) {
			includeDom = new Xpp3Dom("xi:include");
			includeDom.setAttribute("href", toCompare);
			topology.addChild(includeDom);
		}

		final Xpp3Dom environment = new Xpp3Dom("Environment");

		final Xpp3Dom envId = new Xpp3Dom("Id");
		envId.setValue("default");
		environment.addChild(envId);

		final Xpp3Dom machines = new Xpp3Dom("Machines");

		final Xpp3Dom machine = new Xpp3Dom("Machine");

		final Xpp3Dom machineId = new Xpp3Dom("Id");
		machineId.setValue("localhost");
		machine.addChild(machineId);

		final Xpp3Dom altId = new Xpp3Dom("AlternateId");
		altId.setValue("127.0.0.1");
		machine.addChild(altId);

		final Xpp3Dom altId2 = new Xpp3Dom("AlternateId");
		altId2.setValue("::1");
		machine.addChild(altId2);

		machines.addChild(machine);
		environment.addChild(machines);

		topology.addChild(environment);

		FileUtilities.writeFile(topology.toString().getBytes(),
				getMasterTopologyFile());

	}

	private void getModelProperties(final String _modelFile,
File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 655
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 687
		getLog().info("Filtering the following resources: " + "Tuning.xml");
		MojoExecutor
				.executeMojo(
						MojoExecutor.plugin(MojoExecutor
								.groupId("org.apache.maven.plugins"),
								MojoExecutor
										.artifactId("maven-resources-plugin"),
								MojoExecutor.version("2.4.3")),
						MojoExecutor.goal("copy-resources"),
						MojoExecutor.configuration(new MojoExecutor.Element[] {
								MojoExecutor.element(
										MojoExecutor.name("outputDirectory"),
										getTargetSDMDir().getAbsolutePath()),
								MojoExecutor.element(
										MojoExecutor.name("overwrite"), "true"),
								MojoExecutor.element("escapeString", "\\"),
								MojoExecutor.element(
										"resources",
										MojoExecutor
												.element(
														"resource",
														MojoExecutor
																.element(
																		"directory",
																		getSonicEsbSourceDirectory()
																				.getAbsolutePath()),
														MojoExecutor
																.element(
																		"includes",
																		new MojoExecutor.Element[] { MojoExecutor
																				.element(
																						"include",
File Line
com/aurea/maven/plugins/sonic/utils/ProcessDependencyFinder.java 105
com/aurea/maven/plugins/sonic/utils/ProcessDependencyFinder.java 128
      for (String process : _depitems[1]) {
        System.out.println("Adding Process: " + process);
        IProcessConfigAPI proconf = eapi.getProcessConfigAPI();
        IProcessConfig pro = proconf.getProcess(process);
        if (pro.getEntryEndpointConfig() == null) {
          System.out.println("No Endpoint Config found ... skipping the add to the container");
          continue;
        } else {
          if (pro.getEntryEndpointConfig().getName() == null || pro.getEntryEndpointConfig().getName().equals("")) {
            System.out.println("No Endpoint Name Found ... skipping the add to the container");
            continue;
          }
        }
        try {
          pro.addToContainer(esbContainer, 1);
          eapi.getContainerConfigAPI().saveESBContainer(esbContainer);
        } catch (Exception e) {
          System.out.println("MSG: " + e.getMessage());
        }
        
      }
File Line
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 2440
com/aurea/maven/plugins/sonic/sdm/SdmGenerateModelMojo.java 2607
		}

		// Get the variable resolution from the dependencies
		for (final Xpp3Dom variable : Xpp3Utils.collectElements(
				getDependencyDirectory(), "**/*.variables.snippet")) {
			final String name = variable.getAttribute("name");
			final String value = variable.getValue();
			getLog().debug("Setting variable: [" + name + "] = [" + value + "]");
			props.put(name, value != null ? value : "");
		}

		final SortedSet<String> propNames = new TreeSet<String>();
		for (final Enumeration<Object> en = props.keys(); en.hasMoreElements();) {
			propNames.add((String) en.nextElement());
		}
File Line
com/aurea/maven/plugins/sonic/topology/utils/Environment.java 17
com/aurea/maven/plugins/sonic/topology/utils/MachineConfig.java 69
	}

	public String getContainerDir() {
		return containerDir;
	}

	public void setContainerDir(String containerDir) {
		this.containerDir = containerDir;
	}

	public String getRegisterAsService() {
		return registerAsService;
	}

	public void setRegisterAsService(String registerAsService) {
		this.registerAsService = registerAsService;
	}

	public String getEncryptPWD() {
		return encryptPWD;
	}

	public void setEncryptPWD(String encryptPWD) {
		this.encryptPWD = encryptPWD;
	}

	public String getServiceStartupTime() {
		return serviceStartupTime;
	}

	public void setServiceStartupTime(String serviceStartupTime) {
		this.serviceStartupTime = serviceStartupTime;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("Machine Configuration\n");
File Line
com/aurea/maven/plugins/sonic/SonicUnpackDependenciesMojo.java 90
com/aurea/maven/plugins/sonic/esb/AbstractESBConnectMojo.java 124
	protected MFUtils mfUtils = null;

	/**
	 * @return MFUtils
	 * @throws MojoExecutionException
	 *             if something goes wrong
	 */
	protected MFUtils getMFUtils() throws MojoExecutionException {

		if (mfUtils == null) {
			getLog().info("Connecting to Sonic Domain ...");
			getLog().debug("Domain: " + getDomainName());
			getLog().debug("ManagementURL: " + getManagementUrl());
			getLog().debug("User: " + getAdminUser());
			getLog().debug("Password: " + getAdminPassword());
			mfUtils = new MFUtils(getDomainName(), getManagementUrl(), getAdminUser(), getAdminPassword());
		}
		return mfUtils;
	}