import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.stream.Collectors;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
public List<ExportRuleDto> selectRulesByProfile(DbSession dbSession, QProfileDto profile) {
List<ExportRuleDto> exportRules = mapper(dbSession).selectByProfileUuid(profile.getKee());
- Set<Integer> activeRuleIds = exportRules.stream().map(ExportRuleDto::getActiveRuleId).collect(Collectors.toSet());
+ Map<Integer, ExportRuleDto> exportRulesById = exportRules.stream().collect(Collectors.toMap(ExportRuleDto::getActiveRuleId, x -> x));
+ Map<Integer, List<ExportRuleParamDto>> rulesParams = selectParamsByActiveRuleIds(dbSession, exportRulesById.keySet());
- Map<Integer, List<ExportRuleParamDto>> activeRulesParam = selectParamsByActiveRuleIds(dbSession, activeRuleIds);
-
- exportRules.forEach(exportRuleDto ->
- exportRuleDto.setParams(activeRulesParam.get(exportRuleDto.getActiveRuleId()))
- );
+ rulesParams.forEach((id, rules) -> exportRulesById.get(id).setParams(rules));
return exportRules;
}
checkQualityGateDoesNotAlreadyExist(dbSession, organizationDto, name);
}
- public void setDefault(DbSession dbSession, OrganizationDto organizationDto, QualityGateDto qualityGateDto) {
- organizationDto.setDefaultQualityGateUuid(qualityGateDto.getUuid());
- dbClient.qualityGateDao().update(qualityGateDto, dbSession);
- }
-
private void checkQualityGateDoesNotAlreadyExist(DbSession dbSession, OrganizationDto organizationDto, String name) {
QualityGateDto existingQgate = dbClient.qualityGateDao().selectByOrganizationAndName(dbSession, organizationDto, name);
checkArgument(existingQgate == null, IS_ALREADY_USED_MESSAGE, "Name");
* Restore backup on an existing profile.
*/
QProfileRestoreSummary restore(DbSession dbSession, Reader backup, QProfileDto profile);
+
+ QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to);
}
import java.io.Reader;
import java.io.Writer;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.sonar.db.DbSession;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.ExportRuleDto;
+import org.sonar.db.qualityprofile.ExportRuleParamDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.rule.NewCustomRule;
qProfileParser.writeXml(writer, profile, rulesToExport.iterator());
}
+ @Override
+ public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
+ List<ExportRuleDto> rulesToExport = db.qualityProfileExportDao().selectRulesByProfile(dbSession, from);
+ rulesToExport.sort(BackupActiveRuleComparator.INSTANCE);
+
+ ImportedQProfile qProfile = toImportedQProfile(rulesToExport, to.getName(), to.getLanguage());
+ return restore(dbSession, qProfile, name -> to);
+ }
+
+ private static ImportedQProfile toImportedQProfile(List<ExportRuleDto> exportRules, String profileName, String profileLang) {
+ List<ImportedRule> importedRules = new ArrayList<>(exportRules.size());
+
+ for (ExportRuleDto exportRuleDto : exportRules) {
+ ImportedRule importedRule = new ImportedRule();
+ importedRule.setName(exportRuleDto.getName());
+ importedRule.setDescription(exportRuleDto.getDescription());
+ importedRule.setRuleKey(exportRuleDto.getRuleKey());
+ importedRule.setSeverity(exportRuleDto.getSeverityString());
+ if (importedRule.isCustomRule()) {
+ importedRule.setTemplateKey(exportRuleDto.getTemplateRuleKey());
+ }
+ importedRule.setType(exportRuleDto.getRuleType().name());
+ importedRule.setParameters(exportRuleDto.getParams().stream().collect(Collectors.toMap(ExportRuleParamDto::getKey, ExportRuleParamDto::getValue)));
+ importedRules.add(importedRule);
+ }
+
+ return new ImportedQProfile(profileName, profileLang, importedRules);
+ }
+
@Override
public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, OrganizationDto organization, @Nullable String overriddenProfileName) {
return restore(dbSession, backup, nameInBackup -> {
private QProfileRestoreSummary restore(DbSession dbSession, Reader backup, Function<QProfileName, QProfileDto> profileLoader) {
ImportedQProfile qProfile = qProfileParser.readXml(backup);
+ return restore(dbSession, qProfile, profileLoader);
+ }
+ private QProfileRestoreSummary restore(DbSession dbSession, ImportedQProfile qProfile, Function<QProfileName, QProfileDto> profileLoader) {
QProfileName targetName = new QProfileName(qProfile.getProfileLang(), qProfile.getProfileName());
QProfileDto targetProfile = profileLoader.apply(targetName);
@Override
public int compare(ExportRuleDto o1, ExportRuleDto o2) {
+ RuleKey rk1 = o1.getRuleKey();
+ RuleKey rk2 = o2.getRuleKey();
return new CompareToBuilder()
- .append(o1.getRuleKey().repository(), o2.getRuleKey().repository())
- .append(o1.getRuleKey().rule(), o2.getRuleKey().rule())
+ .append(rk1.repository(), rk2.repository())
+ .append(rk1.rule(), rk2.rule())
.toComparison();
}
}
*/
package org.sonar.server.qualityprofile;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import org.apache.commons.io.FileUtils;
import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.TempFolder;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
@ServerSide
public class QProfileCopier {
-
private final DbClient db;
private final QProfileFactory factory;
private final QProfileBackuper backuper;
- private final TempFolder temp;
- public QProfileCopier(DbClient db, QProfileFactory factory, QProfileBackuper backuper, TempFolder temp) {
+ public QProfileCopier(DbClient db, QProfileFactory factory, QProfileBackuper backuper) {
this.db = db;
this.factory = factory;
this.backuper = backuper;
- this.temp = temp;
}
public QProfileDto copyToName(DbSession dbSession, QProfileDto sourceProfile, String toName) {
OrganizationDto organization = db.organizationDao().selectByUuid(dbSession, sourceProfile.getOrganizationUuid())
.orElseThrow(() -> new IllegalStateException("Organization with UUID [" + sourceProfile.getOrganizationUuid() + "] does not exist"));
QProfileDto to = prepareTarget(dbSession, organization, sourceProfile, toName);
- File backupFile = temp.newFile();
- try {
- backup(dbSession, sourceProfile, backupFile);
- restore(dbSession, backupFile, to);
- return to;
- } finally {
- org.sonar.core.util.FileUtils.deleteQuietly(backupFile);
- }
+ backuper.copy(dbSession, sourceProfile, to);
+ return to;
}
private QProfileDto prepareTarget(DbSession dbSession, OrganizationDto organization, QProfileDto sourceProfile, String toName) {
+ verify(sourceProfile.getName(), toName);
QProfileName toProfileName = new QProfileName(sourceProfile.getLanguage(), toName);
- verify(sourceProfile, toProfileName);
QProfileDto toProfile = db.qualityProfileDao().selectByNameAndLanguage(dbSession, organization, toProfileName.getName(), toProfileName.getLanguage());
if (toProfile == null) {
- toProfile = factory.checkAndCreateCustom(dbSession, organization, toProfileName);
- toProfile.setParentKee(sourceProfile.getParentKee());
- db.qualityProfileDao().update(dbSession, toProfile);
+ toProfile = factory.createCustom(dbSession, organization, toProfileName, sourceProfile.getParentKee());
dbSession.commit();
}
return toProfile;
}
- private void verify(QProfileDto fromProfile, QProfileName toProfileName) {
- if (fromProfile.getName().equals(toProfileName.getName())) {
- throw new IllegalArgumentException(String.format("Source and target profiles are equal: %s",
- fromProfile.getName()));
- }
- }
-
- private void backup(DbSession dbSession, QProfileDto profile, File backupFile) {
- try (Writer writer = new OutputStreamWriter(FileUtils.openOutputStream(backupFile), UTF_8)) {
- backuper.backup(dbSession, profile, writer);
- } catch (IOException e) {
- throw new IllegalStateException("Fail to open temporary backup file: " + backupFile, e);
- }
- }
-
- private void restore(DbSession dbSession, File backupFile, QProfileDto profile) {
- try (Reader reader = new InputStreamReader(FileUtils.openInputStream(backupFile), UTF_8)) {
- backuper.restore(dbSession, reader, profile);
- } catch (IOException e) {
- throw new IllegalStateException("Fail to create temporary backup file: " + backupFile, e);
+ private static void verify(String fromProfileName, String toProfileName) {
+ if (fromProfileName.equals(toProfileName)) {
+ throw new IllegalArgumentException(String.format("Source and target profiles are equal: %s", toProfileName));
}
}
}
package org.sonar.server.qualityprofile;
import java.util.Collection;
+import javax.annotation.Nullable;
import org.sonar.db.DbSession;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
*/
QProfileDto checkAndCreateCustom(DbSession dbSession, OrganizationDto organization, QProfileName name);
+ QProfileDto createCustom(DbSession dbSession, OrganizationDto organization, QProfileName name, @Nullable String parentKey);
+
/**
* Deletes the specified profiles from database and Elasticsearch.
* All information related to custom profiles are deleted. Only association
requireNonNull(organization);
QProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage(dbSession, organization, name.getName(), name.getLanguage());
if (profile == null) {
- profile = doCreate(dbSession, organization, name, false, false);
+ profile = doCreate(dbSession, organization, name, null, false, false);
} else {
checkArgument(!profile.isBuiltIn(), "Operation forbidden for built-in Quality Profile '%s' with language '%s'", profile.getName(), profile.getLanguage());
}
requireNonNull(organization);
QProfileDto dto = db.qualityProfileDao().selectByNameAndLanguage(dbSession, organization, name.getName(), name.getLanguage());
checkRequest(dto == null, "Quality profile already exists: %s", name);
- return doCreate(dbSession, organization, name, false, false);
+ return doCreate(dbSession, organization, name, null,false, false);
}
- private QProfileDto doCreate(DbSession dbSession, OrganizationDto organization, QProfileName name, boolean isDefault, boolean isBuiltIn) {
+ @Override
+ public QProfileDto createCustom(DbSession dbSession, OrganizationDto organization, QProfileName name, @Nullable String parentKey) {
+ requireNonNull(organization);
+ return doCreate(dbSession, organization, name, parentKey,false, false);
+ }
+
+ private QProfileDto doCreate(DbSession dbSession, OrganizationDto organization, QProfileName name, @Nullable String parentKey, boolean isDefault, boolean isBuiltIn) {
if (StringUtils.isEmpty(name.getName())) {
throw BadRequestException.create("quality_profiles.profile_name_cant_be_blank");
}
.setOrganizationUuid(organization.getUuid())
.setLanguage(name.getLanguage())
.setIsBuiltIn(isBuiltIn)
+ .setParentKee(parentKey)
.setRulesUpdatedAtAsDate(now);
db.qualityProfileDao().insert(dbSession, dto);
if (isDefault) {
*/
package org.sonar.server.qualityprofile;
-import com.google.common.collect.Lists;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
}
public ImportedQProfile readXml(Reader reader) {
- List<ImportedRule> rules = Lists.newArrayList();
+ List<ImportedRule> rules = new ArrayList<>();
String profileName = null;
String profileLang = null;
try {
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
+import org.sonar.db.qualityprofile.RulesProfileDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.rule.RuleMetadataDto;
import org.sonar.db.rule.RuleParamDto;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class QProfileBackuperImplTest {
@Test
public void backup_generates_xml_file() {
RuleDefinitionDto rule = createRule();
- QProfileDto profile = createProfile(rule);
+ QProfileDto profile = createProfile(rule.getLanguage());
ActiveRuleDto activeRule = activate(profile, rule);
StringWriter writer = new StringWriter();
public void backup_rules_having_parameters() {
RuleDefinitionDto rule = createRule();
RuleParamDto param = db.rules().insertRuleParam(rule);
- QProfileDto profile = createProfile(rule);
+ QProfileDto profile = createProfile(rule.getLanguage());
ActiveRuleDto activeRule = activate(profile, rule, param);
StringWriter writer = new StringWriter();
@Test
public void backup_empty_profile() {
RuleDefinitionDto rule = createRule();
- QProfileDto profile = createProfile(rule);
+ QProfileDto profile = createProfile(rule.getLanguage());
StringWriter writer = new StringWriter();
underTest.backup(db.getSession(), profile, writer);
.setStatus(RuleStatus.READY)
.setTemplateId(templateRule.getId()));
RuleParamDto param = db.rules().insertRuleParam(rule);
- QProfileDto profile = createProfile(rule);
+ QProfileDto profile = createProfile(rule.getLanguage());
ActiveRuleDto activeRule = activate(profile, rule, param);
StringWriter writer = new StringWriter();
assertThat(activation.getParameter("bar")).isEqualTo("baz");
}
+ @Test
+ public void copy_profile() {
+ RuleDefinitionDto rule = createRule();
+ RuleParamDto param = db.rules().insertRuleParam(rule);
+ QProfileDto from = createProfile(rule.getLanguage());
+ ActiveRuleDto activeRule = activate(from, rule, param);
+
+ QProfileDto to = createProfile(rule.getLanguage());
+ QProfileRestoreSummary summary = underTest.copy(db.getSession(), from, to);
+
+ assertThat(reset.calledActivations).extracting(RuleActivation::getRuleId).containsOnly(activeRule.getRuleId());
+ assertThat(reset.calledActivations.get(0).getParameter(param.getName())).isEqualTo("20");
+ assertThat(reset.calledProfile).isEqualTo(to);
+ }
+
@Test
public void fail_to_restore_if_bad_xml_format() {
OrganizationDto organization = db.organizations().insert();
return db.rules().insertOrUpdateMetadata(metadataDto);
}
- private QProfileDto createProfile(RuleDefinitionDto rule) {
- return db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(rule.getLanguage()));
+ private QProfileDto createProfile(String language) {
+ return db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(language));
}
private ActiveRuleDto activate(QProfileDto profile, RuleDefinitionDto rule) {
throw new UnsupportedOperationException();
}
+ @Override public QProfileDto createCustom(DbSession dbSession, OrganizationDto organization, QProfileName name, @Nullable String parentKey) {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public void delete(DbSession dbSession, Collection<QProfileDto> profiles) {
throw new UnsupportedOperationException();
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
public class QProfileCopierTest {
public JUnitTempFolder temp = new JUnitTempFolder();
private DummyProfileFactory profileFactory = new DummyProfileFactory();
- private DummyBackuper backuper = new DummyBackuper();
- private QProfileCopier underTest = new QProfileCopier(db.getDbClient(), profileFactory, backuper, temp);
+ private QProfileBackuper backuper = mock(QProfileBackuper.class);
+ private QProfileCopier underTest = new QProfileCopier(db.getDbClient(), profileFactory, backuper);
@Test
public void create_target_profile_and_copy_rules() {
assertThat(target.getLanguage()).isEqualTo(source.getLanguage());
assertThat(target.getName()).isEqualTo("foo");
assertThat(target.getParentKee()).isNull();
- assertThat(backuper.backuped).isSameAs(source);
- assertThat(backuper.restored.getName()).isEqualTo("foo");
- assertThat(backuper.restoredBackup).isEqualTo(BACKUP);
+
+ verify(backuper).copy(db.getSession(), source, target);
}
@Test
assertThat(target.getLanguage()).isEqualTo(source.getLanguage());
assertThat(target.getName()).isEqualTo("foo");
assertThat(target.getParentKee()).isEqualTo(parent.getKee());
+
+ verify(backuper).copy(db.getSession(), source, target);
}
@Test
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Source and target profiles are equal: " + source.getName());
- assertThat(backuper.backuped).isNull();
- assertThat(backuper.restored).isNull();
+ verifyZeroInteractions(backuper);
}
}
assertThat(profileFactory.createdProfile).isNull();
assertThat(target.getLanguage()).isEqualTo(profile2.getLanguage());
assertThat(target.getName()).isEqualTo(profile2.getName());
- assertThat(backuper.backuped).isSameAs(profile1);
- assertThat(backuper.restored.getName()).isEqualTo(profile2.getName());
- assertThat(backuper.restoredBackup).isEqualTo(BACKUP);
+
+ verify(backuper).copy(eq(db.getSession()), eq(profile1), argThat(a -> a.getKee().equals(profile2.getKee())));
}
private static class DummyProfileFactory implements QProfileFactory {
@Override
public QProfileDto checkAndCreateCustom(DbSession dbSession, OrganizationDto organization, QProfileName key) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override public QProfileDto createCustom(DbSession dbSession, OrganizationDto organization, QProfileName key, @Nullable String parentKey) {
createdProfile = QualityProfileTesting.newQualityProfileDto()
.setOrganizationUuid(organization.getUuid())
.setLanguage(key.getLanguage())
+ .setParentKee(parentKey)
.setName(key.getName());
return createdProfile;
}
throw new UnsupportedOperationException();
}
}
-
- private static class DummyBackuper implements QProfileBackuper {
- private QProfileDto backuped;
- private String restoredBackup;
- private QProfileDto restored;
-
- @Override
- public void backup(DbSession dbSession, QProfileDto profile, Writer backupWriter) {
- this.backuped = profile;
- try {
- backupWriter.write(BACKUP);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, OrganizationDto organization, @Nullable String overriddenProfileName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, QProfileDto profile) {
- try {
- this.restoredBackup = IOUtils.toString(backup);
- this.restored = profile;
- return null;
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- }
}
private ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class);
private QProfileFactory profileFactory = new QProfileFactoryImpl(db.getDbClient(), new SequenceUuidFactory(), System2.INSTANCE, activeRuleIndexer);
private TestBackuper backuper = new TestBackuper();
- private QProfileCopier profileCopier = new QProfileCopier(db.getDbClient(), profileFactory, backuper, tempDir);
+ private QProfileCopier profileCopier = new QProfileCopier(db.getDbClient(), profileFactory, backuper);
private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private Languages languages = LanguageTesting.newLanguages(A_LANGUAGE);
private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, defaultOrganizationProvider);
assertThat(loadedProfile.getKee()).isEqualTo(generatedUuid);
assertThat(loadedProfile.getParentKee()).isNull();
- assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee());
- assertThat(backuper.restoredProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid());
- assertThat(backuper.restoredProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage());
- assertThat(backuper.restoredProfile.getName()).isEqualTo("target-name");
- assertThat(backuper.restoredProfile.getKee()).isEqualTo(generatedUuid);
- assertThat(backuper.restoredProfile.getParentKee()).isNull();
+ assertThat(backuper.copiedProfile.getKee()).isEqualTo(sourceProfile.getKee());
+ assertThat(backuper.toProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid());
+ assertThat(backuper.toProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage());
+ assertThat(backuper.toProfile.getName()).isEqualTo("target-name");
+ assertThat(backuper.toProfile.getKee()).isEqualTo(generatedUuid);
+ assertThat(backuper.toProfile.getParentKee()).isNull();
}
@Test
QProfileDto loadedProfile = db.getDbClient().qualityProfileDao().selectByUuid(db.getSession(), targetProfile.getKee());
assertThat(loadedProfile).isNotNull();
- assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee());
- assertThat(backuper.restoredProfile.getKee()).isEqualTo(targetProfile.getKee());
+ assertThat(backuper.copiedProfile.getKee()).isEqualTo(sourceProfile.getKee());
+ assertThat(backuper.toProfile.getKee()).isEqualTo(targetProfile.getKee());
}
@Test
assertThat(loadedProfile.getKee()).isEqualTo(generatedUuid);
assertThat(loadedProfile.getParentKee()).isEqualTo(parentProfile.getKee());
- assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee());
- assertThat(backuper.restoredProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid());
- assertThat(backuper.restoredProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage());
- assertThat(backuper.restoredProfile.getName()).isEqualTo("target-name");
- assertThat(backuper.restoredProfile.getKee()).isEqualTo(generatedUuid);
- assertThat(backuper.restoredProfile.getParentKee()).isEqualTo(parentProfile.getKee());
+ assertThat(backuper.copiedProfile.getKee()).isEqualTo(sourceProfile.getKee());
+ assertThat(backuper.toProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid());
+ assertThat(backuper.toProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage());
+ assertThat(backuper.toProfile.getName()).isEqualTo("target-name");
+ assertThat(backuper.toProfile.getKee()).isEqualTo(generatedUuid);
+ assertThat(backuper.toProfile.getParentKee()).isEqualTo(parentProfile.getKee());
}
@Test
private static class TestBackuper implements QProfileBackuper {
- private QProfileDto backupedProfile;
- private QProfileDto restoredProfile;
+ private QProfileDto copiedProfile;
+ private QProfileDto toProfile;
@Override
public void backup(DbSession dbSession, QProfileDto profile, Writer backupWriter) {
- if (this.backupedProfile != null) {
- throw new IllegalStateException("Already backup-ed/backed-up");
- }
- this.backupedProfile = profile;
+ throw new UnsupportedOperationException();
}
@Override
@Override
public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, QProfileDto profile) {
- if (this.restoredProfile != null) {
- throw new IllegalStateException("Already restored");
- }
- this.restoredProfile = profile;
- return new QProfileRestoreSummary(profile, new BulkChangeResult());
+ throw new UnsupportedOperationException();
+ }
+
+ @Override public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
+ this.copiedProfile = from;
+ this.toProfile = to;
+ return null;
}
}
}
public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, QProfileDto profile) {
throw new UnsupportedOperationException();
}
+
+ @Override public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
+ throw new UnsupportedOperationException();
+ }
}
}
public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, QProfileDto profile) {
throw new UnsupportedOperationException();
}
+
+ @Override public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
+ throw new UnsupportedOperationException();
+ }
}
}