mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Add documentation
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
package sonia.scm.update;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GroupV1PropertyReader implements V1PropertyReader {
|
||||||
|
@Override
|
||||||
|
public String getStoreName() {
|
||||||
|
return "group-properties-v1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instance createInstance(Map<String, V1Properties> all) {
|
||||||
|
return new MapBasedPropertyReaderInstance(all);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package sonia.scm.update;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class UserV1PropertyReader implements V1PropertyReader {
|
||||||
|
@Override
|
||||||
|
public String getStoreName() {
|
||||||
|
return "user-properties-v1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instance createInstance(Map<String, V1Properties> all) {
|
||||||
|
return new MapBasedPropertyReaderInstance(all);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,14 @@
|
|||||||
package sonia.scm.update;
|
package sonia.scm.update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to access old properties from an instance of SCM-Manager v1.
|
||||||
|
*/
|
||||||
public interface V1PropertyDAO {
|
public interface V1PropertyDAO {
|
||||||
|
/**
|
||||||
|
* Creates an instance of a property reader to process old properties.
|
||||||
|
* @param reader The reader for the origin of the properties (for example
|
||||||
|
* {@link V1PropertyReader#REPOSITORY_PROPERTY_READER} for properties of repositories).
|
||||||
|
* @return The reader instance.
|
||||||
|
*/
|
||||||
V1PropertyReader.Instance getProperties(V1PropertyReader reader);
|
V1PropertyReader.Instance getProperties(V1PropertyReader reader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,31 @@ import java.util.function.BiConsumer;
|
|||||||
|
|
||||||
public interface V1PropertyReader {
|
public interface V1PropertyReader {
|
||||||
|
|
||||||
|
V1PropertyReader REPOSITORY_PROPERTY_READER = new RepositoryV1PropertyReader();
|
||||||
|
V1PropertyReader USER_PROPERTY_READER = new RepositoryV1PropertyReader();
|
||||||
|
V1PropertyReader GROUP_PROPERTY_READER = new RepositoryV1PropertyReader();
|
||||||
|
|
||||||
String getStoreName();
|
String getStoreName();
|
||||||
|
|
||||||
Instance createInstance(Map<String, V1Properties> all);
|
Instance createInstance(Map<String, V1Properties> all);
|
||||||
|
|
||||||
interface Instance {
|
interface Instance {
|
||||||
|
/**
|
||||||
|
* Will call the given consumer for each id of the corresponding entity with its list of
|
||||||
|
* properties converted from v1.
|
||||||
|
* For example for repositories this will call the consumer with the id of each repository
|
||||||
|
* that had properties attached in v1.
|
||||||
|
*/
|
||||||
void forEachEntry(BiConsumer<String, V1Properties> propertiesForNameConsumer);
|
void forEachEntry(BiConsumer<String, V1Properties> propertiesForNameConsumer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters for entities only having at least one property with a given key name.
|
||||||
|
*/
|
||||||
Instance havingAnyOf(String... keys);
|
Instance havingAnyOf(String... keys);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters for entities only having properties for all given key name.
|
||||||
|
*/
|
||||||
Instance havingAllOf(String... keys);
|
Instance havingAllOf(String... keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static java.util.Optional.empty;
|
import static java.util.Optional.empty;
|
||||||
import static java.util.Optional.of;
|
import static java.util.Optional.of;
|
||||||
|
import static sonia.scm.update.V1PropertyReader.GROUP_PROPERTY_READER;
|
||||||
import static sonia.scm.version.Version.parse;
|
import static sonia.scm.version.Version.parse;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@@ -51,7 +52,7 @@ public class XmlGroupV1UpdateStep implements UpdateStep {
|
|||||||
this.groupDAO = groupDAO;
|
this.groupDAO = groupDAO;
|
||||||
this.propertyStore = configurationEntryStoreFactory
|
this.propertyStore = configurationEntryStoreFactory
|
||||||
.withType(V1Properties.class)
|
.withType(V1Properties.class)
|
||||||
.withName("group-properties-v1")
|
.withName(GROUP_PROPERTY_READER.getStoreName())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sonia.scm.SCMContextProvider;
|
import sonia.scm.SCMContextProvider;
|
||||||
import sonia.scm.migration.UpdateException;
|
import sonia.scm.migration.UpdateException;
|
||||||
import sonia.scm.migration.UpdateStep;
|
|
||||||
import sonia.scm.plugin.Extension;
|
import sonia.scm.plugin.Extension;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
import sonia.scm.repository.RepositoryPermission;
|
import sonia.scm.repository.RepositoryPermission;
|
||||||
@@ -15,7 +14,6 @@ import sonia.scm.store.ConfigurationEntryStoreFactory;
|
|||||||
import sonia.scm.store.StoreConstants;
|
import sonia.scm.store.StoreConstants;
|
||||||
import sonia.scm.update.CoreUpdateStep;
|
import sonia.scm.update.CoreUpdateStep;
|
||||||
import sonia.scm.update.V1Properties;
|
import sonia.scm.update.V1Properties;
|
||||||
import sonia.scm.update.RepositoryV1PropertyReader;
|
|
||||||
import sonia.scm.version.Version;
|
import sonia.scm.version.Version;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -38,6 +36,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.Optional.empty;
|
import static java.util.Optional.empty;
|
||||||
import static java.util.Optional.of;
|
import static java.util.Optional.of;
|
||||||
|
import static sonia.scm.update.V1PropertyReader.REPOSITORY_PROPERTY_READER;
|
||||||
import static sonia.scm.version.Version.parse;
|
import static sonia.scm.version.Version.parse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +81,7 @@ public class XmlRepositoryV1UpdateStep implements CoreUpdateStep {
|
|||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.propertyStore = configurationEntryStoreFactory
|
this.propertyStore = configurationEntryStoreFactory
|
||||||
.withType(V1Properties.class)
|
.withType(V1Properties.class)
|
||||||
.withName(new RepositoryV1PropertyReader().getStoreName())
|
.withName(REPOSITORY_PROPERTY_READER.getStoreName())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static java.util.Optional.empty;
|
import static java.util.Optional.empty;
|
||||||
import static java.util.Optional.of;
|
import static java.util.Optional.of;
|
||||||
|
import static sonia.scm.update.V1PropertyReader.USER_PROPERTY_READER;
|
||||||
import static sonia.scm.version.Version.parse;
|
import static sonia.scm.version.Version.parse;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@@ -50,7 +51,7 @@ public class XmlUserV1UpdateStep implements UpdateStep {
|
|||||||
this.configurationEntryStoreFactory = configurationEntryStoreFactory;
|
this.configurationEntryStoreFactory = configurationEntryStoreFactory;
|
||||||
this.propertyStore = configurationEntryStoreFactory
|
this.propertyStore = configurationEntryStoreFactory
|
||||||
.withType(V1Properties.class)
|
.withType(V1Properties.class)
|
||||||
.withName("user-properties-v1")
|
.withName(USER_PROPERTY_READER.getStoreName())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user