List of usage examples for org.apache.commons.io FileExistsException getMessage
public String getMessage()
From source file:io.hops.hopsworks.ca.api.certs.CertSigningService.java
private CsrDTO signCSR(String hostId, String commandId, String csr, boolean rotation, CertificateType certType) throws HopsSecurityException { try {//from ww w. j a v a2s. co m // If there is a certificate already for that host, rename it to .TO_BE_REVOKED.COMMAND_ID // When AgentResource has received a successful response for the key rotation, revoke and delete it if (rotation) { File certFile = Paths.get(settings.getIntermediateCaDir(), "certs", hostId + CertificatesMgmService.CERTIFICATE_SUFFIX).toFile(); if (certFile.exists()) { File destination = Paths .get(settings.getIntermediateCaDir(), "certs", hostId + serviceCertificateRotationTimer.getToBeRevokedSuffix(commandId)) .toFile(); try { FileUtils.moveFile(certFile, destination); } catch (FileExistsException ex) { FileUtils.deleteQuietly(destination); FileUtils.moveFile(certFile, destination); } } } String agentCert = opensslOperations.signCertificateRequest(csr, certType); File caCertFile = Paths.get(settings.getIntermediateCaDir(), "certs", "ca-chain.cert.pem").toFile(); String caCert = Files.toString(caCertFile, Charset.defaultCharset()); return new CsrDTO(caCert, agentCert, settings.getHadoopVersionedDir()); } catch (IOException ex) { throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CSR_ERROR, Level.SEVERE, "host: " + hostId, ex.getMessage(), ex); } }
From source file:io.hops.hopsworks.api.certs.CertSigningService.java
private CsrDTO signCSR(String hostId, String commandId, String csr, boolean rotation, boolean isAppCertificate) throws AppException { try {/*ww w . j a v a2 s . c o m*/ // If there is a certificate already for that host, rename it to .TO_BE_REVOKED.COMMAND_ID // When AgentResource has received a successful response for the key rotation, revoke and delete it if (rotation) { File certFile = Paths.get(settings.getIntermediateCaDir(), "certs", hostId + CertificatesMgmService.CERTIFICATE_SUFFIX).toFile(); if (certFile.exists()) { File destination = Paths .get(settings.getIntermediateCaDir(), "certs", hostId + serviceCertificateRotationTimer.getToBeRevokedSuffix(commandId)) .toFile(); try { FileUtils.moveFile(certFile, destination); } catch (FileExistsException ex) { FileUtils.deleteQuietly(destination); FileUtils.moveFile(certFile, destination); } } } String agentCert = opensslOperations.signCertificateRequest(csr, true, true, isAppCertificate); File caCertFile = Paths.get(settings.getIntermediateCaDir(), "certs", "ca-chain.cert.pem").toFile(); String caCert = Files.toString(caCertFile, Charset.defaultCharset()); return new CsrDTO(caCert, agentCert, settings.getHadoopVersionedDir()); } catch (IOException ex) { String errorMsg = "Error while signing CSR for host " + hostId + " Reason: " + ex.getMessage(); logger.log(Level.SEVERE, errorMsg, ex); throw new AppException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), errorMsg); } }
From source file:com.photon.phresco.framework.rest.api.RepositoryService.java
private Response importPerforceApplication(String type, RepoDetail repodetail, String displayName) throws Exception { SCMManagerImpl scmi = new SCMManagerImpl(); ResponseInfo responseData = new ResponseInfo(); UUID uniqueKey = UUID.randomUUID(); String unique_key = uniqueKey.toString(); try {/*from www .j a v a 2s .co m*/ ProjectInfo importProject = scmi.importFromPerforce(repodetail, new File("")); if (importProject != null) { status = RESPONSE_STATUS_SUCCESS; successCode = PHR200017; ResponseInfo finalOutput = responseDataEvaluation(responseData, null, null, status, successCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } else { status = RESPONSE_STATUS_FAILURE; errorCode = PHR210022; ResponseInfo finalOutput = responseDataEvaluation(responseData, null, null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } } catch (FileExistsException e) { status = RESPONSE_STATUS_FAILURE; errorCode = PHR210027; ResponseInfo finalOutput = responseDataEvaluation(responseData, new Exception(e.getMessage()), null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } catch (PhrescoException e) { status = RESPONSE_STATUS_ERROR; errorCode = PHR210026; ResponseInfo finalOutput = responseDataEvaluation(responseData, new Exception(e.getMessage()), null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } catch (ConnectionException e) { status = RESPONSE_STATUS_FAILURE; errorCode = PHR210049; ResponseInfo finalOutput = responseDataEvaluation(responseData, new Exception(e.getMessage()), null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } catch (RequestException e) { status = RESPONSE_STATUS_FAILURE; errorCode = PHR210050; ResponseInfo finalOutput = responseDataEvaluation(responseData, new Exception(e.getMessage()), null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } catch (Exception e) { status = RESPONSE_STATUS_ERROR; errorCode = PHR210026; ResponseInfo finalOutput = responseDataEvaluation(responseData, new Exception(e.getMessage()), null, status, errorCode); return Response.status(Status.OK).entity(finalOutput).header("Access-Control-Allow-Origin", "*") .build(); } finally { try { LockUtil.removeLock(unique_key); } catch (PhrescoException e) { } } }
From source file:org.cytoscape.app.internal.manager.KarafArchiveApp.java
@Override public void uninstall(AppManager appManager) throws AppUninstallException { // Use the default uninstallation procedure consisting of moving the app file // to the uninstalled apps directory // defaultUninstall(appManager); try {/* ww w. j a va 2 s .co m*/ File uninstallDirectoryTargetFile = new File( appManager.getUninstalledAppsPath() + File.separator + getAppFile().getName()); if (uninstallDirectoryTargetFile.exists()) { uninstallDirectoryTargetFile.delete(); } try { FileUtils.moveFile(getAppFile(), uninstallDirectoryTargetFile); } catch (FileExistsException e) { } this.setAppFile(uninstallDirectoryTargetFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new AppUninstallException( "Unable to move app file to uninstalled apps directory: " + e.getMessage()); } this.getAppTemporaryInstallFile().delete(); this.setStatus(AppStatus.UNINSTALLED); }