Skip to content

Commit

Permalink
Most of the followup nr 3 to https://sbforge.org/fisheye/cru/CR-NAS-372
Browse files Browse the repository at this point in the history
  • Loading branch information
Asger Askov Blekinge committed Apr 10, 2019
1 parent 8d4ebfd commit b3cd9fc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ public class JMSBitmagArcRepositoryClient extends Synchronizer implements ArcRep
*
*/
private JMSBitmagArcRepositoryClient() {
//TODO this should only ever be called from the getInstance method. Verify that SettingsFactory actually does
// and not uses the constructor. If the constructor is used, then the "instance" variable will not have been initialised
// If the constructor is not used, set it to private to prevent users from using it
synchronized (JMSBitmagArcRepositoryClient.class){
if (instance != null){
throw new RuntimeException("Attempting to start an additional "+JMSBitmagArcRepositoryClient.class+" instance");
} else {
instance = this;
}
}

timeoutGetOpsMillis = Settings.getLong(ARCREPOSITORY_GET_TIMEOUT);

Expand Down Expand Up @@ -446,15 +450,15 @@ public BatchStatus batch(FileBatchJob job, String replicaId, String batchId, Str
@Override
public void updateAdminData(String fileName, String replicaId, ReplicaStoreState newval) throws ArgumentNotValid,
IOFailure {
throw new NotImplementedException("updateAdminData is relegated to the bitrepository software");
throw new NotImplementedException("updateAdminData is delegated to the bitrepository software");
}

/**
* Not implemented. This functionality is delegated to bitrepository software.
*/
@Override
public void updateAdminChecksum(String filename, String checksum) {
throw new NotImplementedException("updateAdminChecksum is relegated to the bitrepository software");
throw new NotImplementedException("updateAdminChecksum is delegated to the bitrepository software");
}

/**
Expand All @@ -464,7 +468,7 @@ public void updateAdminChecksum(String filename, String checksum) {
@Deprecated
public File removeAndGetFile(String fileName, String bitarchiveId, String checksum, String credentials)
throws IOFailure, ArgumentNotValid {
throw new NotImplementedException("removeAndGetFile is relegated to the bitrepository software");
throw new NotImplementedException("removeAndGetFile is delegated to the bitrepository software");
}

/**
Expand All @@ -473,7 +477,7 @@ public File removeAndGetFile(String fileName, String bitarchiveId, String checks
@Override
@Deprecated
public File getAllChecksums(String replicaId) throws IOFailure, ArgumentNotValid {
throw new NotImplementedException("getAllChecksums is relegated to the bitrepository software");
throw new NotImplementedException("getAllChecksums is delegated to the bitrepository software");
}

/**
Expand All @@ -482,7 +486,7 @@ public File getAllChecksums(String replicaId) throws IOFailure, ArgumentNotValid
@Override
@Deprecated
public File getAllFilenames(String replicaId) throws ArgumentNotValid, IOFailure {
throw new NotImplementedException("getAllFilenames is relegated to the bitrepository software");
throw new NotImplementedException("getAllFilenames is delegated to the bitrepository software");
}

/**
Expand All @@ -501,7 +505,7 @@ public String getChecksum(String replicaId, String filename) throws ArgumentNotV
@Deprecated
public File correct(String replicaId, String checksum, File file, String credentials) throws IOFailure,
ArgumentNotValid {
throw new NotImplementedException("Correct is relegated to the bitrepository software");
throw new NotImplementedException("Correct is delegated to the bitrepository software");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,9 @@ public class Bitrepository implements AutoCloseable {
/** Logging mechanism. */
private static final Logger logger = LoggerFactory.getLogger(Bitrepository.class);

/** The archive settings directory needed to upload to
* a bitmag style repository */
private File settingsDir = null;

/** National bitrepository settings. */
private final Settings bitmagSettings;

/** The bitrepository component id. */
private final String componentId;

/** The bitmag security manager.*/
private final SecurityManager bitMagSecurityManager;

/** The client for performing the PutFile operation.*/
private final PutFileClient bitMagPutClient;

Expand Down Expand Up @@ -139,14 +129,13 @@ public class Bitrepository implements AutoCloseable {
public Bitrepository(File configDir, String bitmagKeyFilename, int maxStoreFailures, String usepillar) {
logger.debug("Initialising bitrepository");
ArgumentNotValid.checkExistsDirectory(configDir, "File configDir");
componentId = BitrepositoryUtils.generateComponentID();
logger.info("componentId: {}", componentId);

maxNumberOfFailingPillars = maxStoreFailures;
this.usepillar = usepillar;
this.settingsDir = configDir;
/* The archive settings directory needed to upload to a bitmag style repository */
logger.info("Reading bitrepository settings from {}", configDir.getAbsolutePath());

/** The authentication key used by the putfileClient. */
/* The authentication key used by the putfileClient. */
File privateKeyFile;
if (bitmagKeyFilename == null){
privateKeyFile = new File(configDir, UUID.randomUUID().toString()); // This file should never exist
Expand All @@ -156,10 +145,16 @@ public Bitrepository(File configDir, String bitmagKeyFilename, int maxStoreFailu
logger.info("keyfile: {}", privateKeyFile.getAbsolutePath());

logger.info("Initialising bitrepository settings.");


/* The bitrepository component id. */
String componentId = BitrepositoryUtils.generateComponentID();
logger.info("componentId: {}", componentId);

SettingsProvider settingsLoader =
new SettingsProvider(
new XMLFileSettingsLoader(
settingsDir.getAbsolutePath()),
configDir.getAbsolutePath()),
componentId);
bitmagSettings = settingsLoader.getSettings();
SettingsUtils.initialize(bitmagSettings);
Expand All @@ -170,7 +165,8 @@ public Bitrepository(File configDir, String bitmagKeyFilename, int maxStoreFailu
MessageAuthenticator authenticator = new BasicMessageAuthenticator(permissionStore);
MessageSigner signer = new BasicMessageSigner();
OperationAuthorizor authorizer = new BasicOperationAuthorizor(permissionStore);
bitMagSecurityManager = new BasicSecurityManager(bitmagSettings.getRepositorySettings(),
/* The bitmag security manager.*/
SecurityManager bitMagSecurityManager = new BasicSecurityManager(bitmagSettings.getRepositorySettings(),
privateKeyFile.getAbsolutePath(),
authenticator, signer, authorizer, permissionStore,
bitmagSettings.getComponentID());
Expand All @@ -185,7 +181,6 @@ public Bitrepository(File configDir, String bitmagKeyFilename, int maxStoreFailu
AccessComponentFactory acf = AccessComponentFactory.getInstance();
bitMagGetClient = acf.createGetFileClient(bitmagSettings, bitMagSecurityManager, componentId);
bitMagGetFileIDsClient = acf.createGetFileIDsClient(bitmagSettings, bitMagSecurityManager, componentId);

bitMagGetChecksumsClient = acf.createGetChecksumsClient(bitmagSettings, bitMagSecurityManager, componentId);
}

Expand Down

0 comments on commit b3cd9fc

Please sign in to comment.