File tempDir = new File(pathManager.getPathEntry(TEMP_DIR).resolvePath(), deploymentName); tempDir.mkdirs(); warMetaData.setTempDir(tempDir);
private boolean hasReadableFile(final String fileName) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); if (logDir != null) { final Path dir = Paths.get(logDir); final Collection<String> validFileNames = findValidFileNames(getFileHandlersModel()); for (String name : validFileNames) { // Check if the file name is a valid file name or a possibly rotated valid file name if ((fileName.equals(name) || fileName.startsWith(name))) { final Path file = dir.resolve(fileName); return Files.exists(file) && Files.isReadable(file); } } } return false; }
private boolean hasReadableFile(final String fileName) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); if (logDir != null) { final Path dir = Paths.get(logDir); final Collection<String> validFileNames = findValidFileNames(getFileHandlersModel()); for (String name : validFileNames) { // Check if the file name is a valid file name or a possibly rotated valid file name if ((fileName.equals(name) || fileName.startsWith(name))) { final Path file = dir.resolve(fileName); return Files.exists(file) && Files.isReadable(file); } } } return false; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); try { String uuid = context.attachResultStream("text/plain", Files.newInputStream(path)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); try { String uuid = context.attachResultStream("text/plain", Files.newInputStream(path)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } } };
@Override protected void validateUpdatedModel(final OperationContext context, final Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode relativeTo = DeploymentScannerDefinition.RELATIVE_TO.resolveModelAttribute(context, model); if (relativeTo.isDefined()) { try { pathManager.getPathEntry(relativeTo.asString()); } catch (IllegalArgumentException e) { throw DeploymentScannerLogger.ROOT_LOGGER.pathEntryNotFound(relativeTo.asString()); } } } }
@Override protected void validateUpdatedModel(final OperationContext context, final Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode relativeTo = DeploymentScannerDefinition.RELATIVE_TO.resolveModelAttribute(context, model); if (relativeTo.isDefined()) { try { pathManager.getPathEntry(relativeTo.asString()); } catch (IllegalArgumentException e) { throw DeploymentScannerLogger.ROOT_LOGGER.pathEntryNotFound(relativeTo.asString()); } } } }
@Override public Set<String> getChildrenNames(final String childType) { if (LogFileResourceDefinition.NAME.equals(childType)) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); try { final Set<Path> validPaths = findFiles(logDir, getFileHandlersModel(), true); final Set<String> result = new LinkedHashSet<>(); for (Path p : validPaths) { result.add(p.toString()); } return result; } catch (IOException e) { LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } } return delegate.getChildrenNames(childType); }
@Override public Set<String> getChildrenNames(final String childType) { if (LogFileResourceDefinition.NAME.equals(childType)) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); try { final Set<Path> validPaths = findFiles(logDir, getFileHandlersModel(), true); final Set<String> result = new LinkedHashSet<>(); for (Path p : validPaths) { result.add(p.toString()); } return result; } catch (IOException e) { LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } } return delegate.getChildrenNames(childType); }
@Override public void execute(final OperationContext context, final ModelNode operation) { final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); List<File> logFiles; try { logFiles = findFiles(logDir, model); } catch (IOException e) { logFiles = Collections.emptyList(); LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } final SimpleDateFormat dateFormat = new SimpleDateFormat(LogFileResourceDefinition.ISO_8601_FORMAT); final ModelNode result = context.getResult().setEmptyList(); for (File logFile : logFiles) { final ModelNode fileInfo = new ModelNode(); fileInfo.get(FILE_NAME.getName()).set(logFile.getName()); fileInfo.get(FILE_SIZE.getName()).set(logFile.length()); fileInfo.get(LAST_MODIFIED_DATE.getName()).set(dateFormat.format(new Date(logFile.lastModified()))); result.add(fileInfo); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); } }
@Override public void execute(final OperationContext context, final ModelNode operation) { final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); List<File> logFiles; try { logFiles = findFiles(logDir, model); } catch (IOException e) { logFiles = Collections.emptyList(); LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir); } final SimpleDateFormat dateFormat = new SimpleDateFormat(LogFileResourceDefinition.ISO_8601_FORMAT); final ModelNode result = context.getResult().setEmptyList(); for (File logFile : logFiles) { final ModelNode fileInfo = new ModelNode(); fileInfo.get(FILE_NAME.getName()).set(logFile.getName()); fileInfo.get(FILE_SIZE.getName()).set(logFile.length()); fileInfo.get(LAST_MODIFIED_DATE.getName()).set(dateFormat.format(new Date(logFile.lastModified()))); result.add(fileInfo); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.getResult(); final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); if (Files.notExists(path)) { throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir); } try { updateModel(path, model); } catch (IOException e) { throw new RuntimeException(e); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.getResult(); final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); if (Files.notExists(path)) { throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir); } try { updateModel(path, model); } catch (IOException e) { throw new RuntimeException(e); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); }
result = pathManager.resolveRelativePathEntry(path.asString(), relativeTo.asString()); } else { result = pathManager.getPathEntry(relativeTo.asString()).resolvePath();
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { // Get the resource final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode model = resource.getModel(); // Validate the operation final ModelNode relativeToOnly = RELATIVE_TO_ONLY.validateOperation(operation); final boolean resolveRelativeToOnly = relativeToOnly.asBoolean(false); // Resolve the model values final ModelNode file = (parentAttribute != null ? parentAttribute.resolveModelAttribute(context, model) : model); final ModelNode relativeTo = relativeToAttribute.resolveModelAttribute(context, file); final ModelNode path = pathAttribute.resolveModelAttribute(context, file); // Resolve paths final String result; if (relativeTo.isDefined()) { // If resolving the full path and a path is defined if (!resolveRelativeToOnly && path.isDefined()) { result = pathManager.resolveRelativePathEntry(path.asString(), relativeTo.asString()); } else { result = pathManager.getPathEntry(relativeTo.asString()).resolvePath(); } } else if (path.isDefined()) { result = pathManager.resolveRelativePathEntry(path.asString(), null); } else { throw ControllerMessages.MESSAGES.noPathToResolve(relativeToAttribute.getName(), pathAttribute.getName(), model); } context.getResult().set(new ModelNode(result)); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { // Get the resource final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode model = resource.getModel(); // Validate the operation final ModelNode relativeToOnly = RELATIVE_TO_ONLY.validateOperation(operation); final boolean resolveRelativeToOnly = relativeToOnly.asBoolean(false); // Resolve the model values final ModelNode file = (parentAttribute != null ? parentAttribute.resolveModelAttribute(context, model) : model); final ModelNode relativeTo = relativeToAttribute.resolveModelAttribute(context, file); final ModelNode path = pathAttribute.resolveModelAttribute(context, file); // Resolve paths final String result; if (relativeTo.isDefined()) { // If resolving the full path and a path is defined if (!resolveRelativeToOnly && path.isDefined()) { result = pathManager.resolveRelativePathEntry(path.asString(), relativeTo.asString()); } else { result = pathManager.getPathEntry(relativeTo.asString()).resolvePath(); } } else if (path.isDefined()) { result = pathManager.resolveRelativePathEntry(path.asString(), null); } else { throw ControllerMessages.MESSAGES.noPathToResolve(relativeToAttribute.getName(), pathAttribute.getName(), model); } context.getResult().set(new ModelNode(result)); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }
result = pathManager.resolveRelativePathEntry(path.asString(), relativeTo.asString()); } else { result = pathManager.getPathEntry(relativeTo.asString()).resolvePath();
final List<File> logFiles; try { logFiles = findFiles(pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(), model); } catch (IOException e) { throw LoggingLogger.ROOT_LOGGER.failedToReadLogFile(e, fileName);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final String fileName = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, fileName);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final String fileName = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, fileName);