@Override public File getFile(String relativePath, byte repoId, HostFileRepository localFileRepository) { return localFileRepository.getFile(relativePath); } });
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } else { final File file = localFileRepository.getFile(relativePath); // using --cached-dc and the DC is unavailable, make sure the content exists locally. if (localHostInfo.isUsingCachedDc()) { if (! file.exists()) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(new RuntimeException("Content hash " + relativePath + " not found.")); } } return file; } } };
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } else { final File file = localFileRepository.getFile(relativePath); // using --cached-dc and the DC is unavailable, make sure the content exists locally. if (localHostInfo.isUsingCachedDc()) { if (! file.exists()) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(new RuntimeException("Content hash " + relativePath + " not found.")); } } return file; } } };
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw MESSAGES.failedToGetFileFromRemoteRepository(e); } } else { return localFileRepository.getFile(relativePath); } } };
public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(hash); } default: { throw MESSAGES.invalidRootId(rootId); } } } };
public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } default: { throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId); } } } };
public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } default: { throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId); } } } };
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(hash); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw MESSAGES.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw MESSAGES.didNotReadEntireFile(e.getMissing()); } } }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw HostControllerLogger.ROOT_LOGGER.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw HostControllerLogger.ROOT_LOGGER.didNotReadEntireFile(e.getMissing()); } } }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw HostControllerLogger.ROOT_LOGGER.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw HostControllerLogger.ROOT_LOGGER.didNotReadEntireFile(e.getMissing()); } } }