private List<ConfigPart> loadPartsFromSettings() { P4VcsRootSettings settings = getRootSettings(); return settings.getConfigParts(); }
@Override public void apply() throws ConfigurationException { Collection<ConfigProblem> problems = null; if (isModified()) { LOG.info("Updating root configuration for " + vcsRoot); // ClientConfig oldConfig = loadConfigFromSettings(); P4VcsRootSettings settings = new P4VcsRootSettingsImpl(project, vcsRoot); MultipleConfigPart parentPart = loadParentPartFromUI(); settings.setConfigParts(parentPart.getChildren()); mapping.setRootSettings(settings); if (parentPart.hasError()) { problems = parentPart.getConfigProblems(); } } else { LOG.info("Skipping root configuration update; nothing modified for " + vcsRoot); } // Send the update events regarding the root configuration updates. Do this even in the // case of an error, or if there were no updates. The no updates use case is for the situation where // events were fired in an unexpected order, then the user can rerun the apply to re-trigger everything. // It's a hack, yes. project.getMessageBus().syncPublisher(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED) .directoryMappingChanged(); if (problems != null) { LOG.warn("Configuration problems discovered; not adding: " + problems); throw new ConfigurationException(toMessage(problems), P4Bundle.getString("configuration.error.title")); } }
private void updateRoot(@NotNull P4VcsRootSettings settings, @NotNull VcsDirectoryMapping directoryMapping) { VirtualFile root = DirectoryMappingUtil.getDirectory(getProject(), directoryMapping); List<ConfigPart> parts = settings.getConfigParts(); MultipleConfigPart parentPart = new MultipleConfigPart("Project Registry", parts); if (LOG.isDebugEnabled()) { LOG.debug("Add mapping for " + root + " -> " + parentPart + " (directory mapping dir [" + directoryMapping.getDirectory() + "])"); } try { if (ServerConfig.isValidServerConfig(parentPart)) { ServerConfig serverConfig = ServerConfig.createFrom(parentPart); if (ClientConfig.isValidClientConfig(serverConfig, parentPart)) { ClientConfig clientConfig = ClientConfig.createFrom(serverConfig, parentPart); addClientConfig(clientConfig, root); return; } if (LOG.isDebugEnabled()) { LOG.debug(root + ": skipping invalid config " + parentPart); } } else if (LOG.isDebugEnabled()) { LOG.debug(root + ": skipping invalid config " + parentPart); } } catch (IllegalArgumentException e) { LOG.info("Problem with config under " + root + ": " + parentPart, e); } // Invalid config. removeClientConfigAt(root); }