From e47e4a28ab843e39c20c33fdf77fd55bfec273ee Mon Sep 17 00:00:00 2001
From: "HDS\\rammansoor"
+ * --export --url=http://localhost:8080/pentaho --username=admin --password=password
+ * --file-path=c:/temp/export.zip --charset=UTF-8 --path=public/pentaho-solutions/steel-wheels
+ * --logfile=c:/temp/steel-wheels.log --withManifest=true
*/
private void performExport() throws ParseException, KettleException, URISyntaxException {
String contextURL = getOptionValue( INFO_OPTION_URL_NAME, true, false );
@@ -851,20 +886,20 @@ private void performExport() throws ParseException, KettleException, URISyntaxEx
String withManifest = getOptionValue( INFO_OPTION_WITH_MANIFEST_NAME, false, true );
String effPath = RepositoryPathEncoder.encodeURIComponent( RepositoryPathEncoder.encodeRepositoryPath( path ) );
if ( effPath.lastIndexOf( ':' ) == effPath.length() - 1 // remove trailing slash
- && effPath.length() > 1 ) { // allow user to enter "--path=/"
+ && effPath.length() > 1 ) { // allow user to enter "--path=/"
effPath = effPath.substring( 0, effPath.length() - 1 );
}
String logFile = getOptionValue( INFO_OPTION_LOGFILE_NAME, false, true );
String exportURL =
- contextURL + API_REPO_FILES + effPath + "/download?withManifest=" + ( "false".equals( withManifest )
- ? "false" : "true" );
+ contextURL + API_REPO_FILES + effPath + "/download?withManifest=" + ( "false".equals( withManifest )
+ ? "false" : "true" );
// Output file is validated before executing
String outputFile = getOptionValue( INFO_OPTION_FILEPATH_NAME, true, false );
if ( !isValidExportPath( outputFile, logFile ) ) {
throw new ParseException( Messages.getInstance().getString( "CommandLineProcessor.ERROR_0005_INVALID_FILE_PATH",
- outputFile ) );
+ outputFile ) );
}
initRestService( contextURL );
@@ -917,24 +952,20 @@ private boolean isValidExportPath( String filePath, String logFile ) {
/**
* Returns the option value from the command line
*
- * @param option
- * the option whose value should be returned (NOTE: {@code null} will be returned if the option was not
- * provided)
- * @param required
- * indicates if the option is required
- * @param emptyOk
- * indicates if a blank value is acceptable
+ * @param option the option whose value should be returned (NOTE: {@code null} will be returned if the option was not
+ * provided)
+ * @param required indicates if the option is required
+ * @param emptyOk indicates if a blank value is acceptable
* @return the value provided from the command line, or {@code null} if none was provided
- * @throws ParseException
- * indicates the required or non-blank value was not provided
+ * @throws ParseException indicates the required or non-blank value was not provided
*/
protected String getOptionValue( final String option, final boolean required, final boolean emptyOk )
- throws ParseException {
+ throws ParseException {
final String value = StringUtils.trim( commandLine.getOptionValue( option ) );
if ( StringUtils.isEmpty( value ) && ( required || !emptyOk ) ) {
throw new ParseException( Messages.getInstance().getErrorString( "CommandLineProcessor.ERROR_0001_MISSING_ARG",
- option ) );
+ option ) );
}
return StringUtils.removeStart( value, "=" );
@@ -981,7 +1012,7 @@ private void writeToFile( String str, String pathName ) {
* @see #writeToFile(String, String)
*/
private static void writeToFile( InputStream inputStream, File file ) throws IOException {
- try ( FileOutputStream fos = new FileOutputStream( file ) ) {
+ try ( FileOutputStream fos = new FileOutputStream( file, true ) ) {
IOUtils.copy( inputStream, fos );
}
}
@@ -989,8 +1020,8 @@ private static void writeToFile( InputStream inputStream, File file ) throws IOE
protected static void printHelp() {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( Messages.getInstance().getString( "CommandLineProcessor.INFO_PRINTHELP_CMDLINE" ), Messages
- .getInstance().getString( "CommandLineProcessor.INFO_PRINTHELP_HEADER" ), options, Messages.getInstance()
- .getString( "CommandLineProcessor.INFO_PRINTHELP_FOOTER" ) );
+ .getInstance().getString( "CommandLineProcessor.INFO_PRINTHELP_HEADER" ), options, Messages.getInstance()
+ .getString( "CommandLineProcessor.INFO_PRINTHELP_FOOTER" ) );
}
/**
@@ -1002,12 +1033,12 @@ protected static void printHelp() {
*/
private static boolean checkUserAuthorization( String contextURL, String securityAction ) {
WebResource authResource =
- client.resource( contextURL + API_AUTHORIZATION_ACTION_IS_AUTHORIZED + "?authAction="
- + securityAction );
+ client.resource( contextURL + API_AUTHORIZATION_ACTION_IS_AUTHORIZED + "?authAction="
+ + securityAction );
boolean isAuthorized = Boolean.parseBoolean( authResource.get( String.class ) );
if ( !isAuthorized ) {
System.err.println( Messages.getInstance().getString(
- "CommandLineProcessor.ERROR_0006_NON_ADMIN_CREDENTIALS" ) );
+ "CommandLineProcessor.ERROR_0006_NON_ADMIN_CREDENTIALS" ) );
}
return isAuthorized;
}
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/DefaultExportHandler.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/DefaultExportHandler.java
index f7c67e6fb2f..4d928e557ab 100644
--- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/DefaultExportHandler.java
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/DefaultExportHandler.java
@@ -45,6 +45,7 @@
import org.pentaho.platform.api.repository2.unified.IRepositoryContentConverterHandler;
import org.pentaho.platform.api.repository2.unified.IUnifiedRepository;
import org.pentaho.platform.api.repository2.unified.RepositoryFile;
+import org.pentaho.platform.api.importexport.ExportException;
import org.pentaho.platform.engine.core.system.PentahoSystem;
import org.pentaho.platform.repository.RepositoryFilenameUtils;
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ExportHandler.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ExportHandler.java
index e18e9ea4a76..2ce13f3cc42 100644
--- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ExportHandler.java
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ExportHandler.java
@@ -34,6 +34,7 @@
*/
import org.pentaho.platform.api.repository2.unified.RepositoryFile;
+import org.pentaho.platform.api.importexport.ExportException;
import java.io.IOException;
import java.io.InputStream;
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/IRepositoryImportLogger.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/IRepositoryImportLogger.java
index edb9f15e37c..002290f3f9a 100644
--- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/IRepositoryImportLogger.java
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/IRepositoryImportLogger.java
@@ -15,6 +15,7 @@
import org.apache.commons.logging.Log;
import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.StringLayout;
import java.io.OutputStream;
@@ -22,51 +23,57 @@
* * Below is a sample of how to use this class to generate a log file. 1) You must use startJob(OutputStream,
* ImportPath) to instantiate the log and supply it with an output stream to hold the log and the root folder of the
* import.
- *
+ *
* 2) Call setCurrentFilePath() each time you start processing a new import file. The log shows the file being imported
* so it must be registered.
- *
+ *
* 3) Call endJob() when the import is done to log the finish and release resources. If the the import terminates
* abnormally this call should be in the finally block.
- *
- *
+ *
+ *
* Sample code taken from RepositoryImportLogTest
- *
+ *
* FileOutputStream fileStream = new FileOutputStream(outputFile); logger =
* PentahoSystem.get(IRepositoryImportLogger.class);
- *
+ *
* //You must call this method to start posting the log. logger.startJob(fileStream, "/import/Path");
- *
+ *
* logger.setCurrentFilePath("/path/file1path"); logger.debug("Some more detail here"); logger.info("Success");
- *
+ *
* logger.setCurrentFilePath("path/file2path");
- *
+ *
* //Simulate an exception try { throw new RuntimeException("forced exception"); } catch (Exception e) {
* logger.error(e); } //End of job logger.endJob();
- *
+ *
* @author TKafalas
- *
*/
public interface IRepositoryImportLogger extends Log {
+
+ /**
+ * Initiates an import job. Each call creates a new log associated with the current thread.
+ *
+ * @param outputStream Will receive the html content of the log
+ * @param importRootPath The root import dir receiving the import
+ * @param logLevel The log level to be logged.
+ * @param layout The layout to be use.
+ */
+ void startJob( OutputStream outputStream, String importRootPath, Level logLevel, StringLayout layout );
+
/**
* Initiates an import job. Each call creates a new log associated with the current thread.
- *
- * @param outputStream
- * Will receive the html content of the log
- * @param importRootPath
- * The root import dir receiving the import
- * @param logLevel
- * The log level to be logged.
+ *
+ * @param outputStream Will receive the html content of the log
+ * @param importRootPath The root import dir receiving the import
+ * @param logLevel The log level to be logged.
*/
void startJob( OutputStream outputStream, String importRootPath, Level logLevel );
/**
* Registers the file being worked on. Each log entry will list the path to the file being processed. Call this method
* just before processing the next file. It will automatically post a "Start File Import" entry in the log.
- *
- * @param currentFilePath
- * path to file being imported
+ *
+ * @param currentFilePath path to file being imported
*/
void setCurrentFilePath( String currentFilePath );
@@ -77,40 +84,40 @@ public interface IRepositoryImportLogger extends Log {
/**
* Log informational data. Should be called when the starting a new file and when finishing that file.
- *
- * @param s
- * The information message to be logged.
+ *
+ * @param s The information message to be logged.
*/
void info( String s );
/**
* Log an error.
- *
- * @param s
- * The Error message to be logged.
+ *
+ * @param s The Error message to be logged.
*/
void error( String s );
/**
* Log debug information
- *
- * @param s
- * The debug message to be logged
+ *
+ * @param s The debug message to be logged
*/
void debug( String s );
/**
* Log error information
- *
- * @param e
- * The exception to be logged.
+ *
+ * @param e The exception to be logged.
*/
void error( Exception e );
/**
* Allows a class to check if an ImportLogger has been instantiated for the current thread.
- *
+ *
* @return true if the logger is present.
*/
boolean hasLogger();
+
+ boolean isPerformingRestore();
+
+ void setPerformingRestore( boolean value );
}
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLog.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLog.java
new file mode 100644
index 00000000000..b04dc3e6498
--- /dev/null
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLog.java
@@ -0,0 +1,90 @@
+/*! ******************************************************************************
+ *
+ * Pentaho
+ *
+ * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
+ *
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file.
+ *
+ * Change Date: 2029-07-20
+ ******************************************************************************/
+package org.pentaho.platform.plugin.services.importexport;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.StringLayout;
+import org.pentaho.platform.api.util.LogUtil;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+
+
+public class Log4JRepositoryExportLog {
+
+ private Logger logger;
+ private OutputStream outputStream;
+ private String logName;
+ private Level logLevel;
+ private Appender appender;
+ private StringLayout layout;
+
+ /**
+ * Constructs an object that keeps track of additional fields for Log4j logging and writes/formats an html file to the
+ * output stream provided.
+ *
+ * @param outputStream
+ */
+ Log4JRepositoryExportLog( OutputStream outputStream, Level logLevel, StringLayout layout ) {
+ this.outputStream = outputStream;
+ this.logLevel = logLevel;
+ this.layout = layout;
+ init();
+ }
+
+ /**
+ * Constructs an object that keeps track of additional fields for Log4j logging and writes/formats an html file to the
+ * output stream provided.
+ *
+ * @param outputStream
+ */
+ Log4JRepositoryExportLog( OutputStream outputStream, Level logLevel ) {
+ this.outputStream = outputStream;
+ this.logLevel = logLevel;
+ RepositoryImportHTMLLayout htmlLayout = new RepositoryImportHTMLLayout( logLevel );
+ htmlLayout.setTitle( "Repository Backup Log" );
+ this.layout = htmlLayout;
+ init();
+ }
+
+ private void init() {
+ logName = "RepositoryExportLog." + getThreadName();
+ logger = LogManager.getLogger( logName );
+ LogUtil.setLevel( logger, logLevel );
+ appender =
+ LogUtil.makeAppender( logName, new OutputStreamWriter( outputStream, Charset.forName( "utf-8" ) ), this.layout );
+ LogUtil.addAppender( appender, logger, logLevel );
+ }
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+
+ protected void endJob() {
+ try {
+ outputStream.write( appender.getLayout().getFooter() );
+ } catch ( Exception e ) {
+ System.out.println( e );
+ // Don't try logging a log error.
+ }
+ LogUtil.removeAppender( appender, logger );
+ }
+
+ private String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+}
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLogger.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLogger.java
new file mode 100644
index 00000000000..3dfde711e4a
--- /dev/null
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/Log4JRepositoryExportLogger.java
@@ -0,0 +1,184 @@
+/*! ******************************************************************************
+ *
+ * Pentaho
+ *
+ * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
+ *
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file.
+ *
+ * Change Date: 2029-07-20
+ ******************************************************************************/
+
+
+package org.pentaho.platform.plugin.services.importexport;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.StringLayout;
+import org.pentaho.platform.api.util.IRepositoryExportLogger;
+
+import java.io.OutputStream;
+
+/**
+ * {@inherit}
+ *
+ * @author TKafalas
+ */
+public class Log4JRepositoryExportLogger implements IRepositoryExportLogger {
+
+ private ThreadLocal
+ * Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII
+ * characters could result in corrupted log files.
+ *
+ * @author tkafalas
+ */
+public class RepositoryTextLayout implements StringLayout {
+
+ protected static final int BUF_SIZE = 256;
+ protected static final int MAX_CAPACITY = 1024;
+ public static final String LINE_SEP = System.getProperty( "line.separator" );
+ private static final String REGEXP = Strings.LINE_SEPARATOR.equals( "\n" ) ? "\n" : Strings.LINE_SEPARATOR + "|\n";
+
+ private Level loggerLogLevel;
+
+ // output buffer appended to when format() is invoked
+ private StringBuffer sbuf = new StringBuffer( BUF_SIZE );
+
+ String title = "Log4J Log Messages";
+
+ public RepositoryTextLayout( Level loggerLogLevel ) {
+ super();
+ this.loggerLogLevel = loggerLogLevel;
+ }
+
+ /**
+ * The Title option takes a String value. This option sets the document title of the generated HTML document.
+ *
+ *
+ * Defaults to 'Log4J Log Messages'.
+ */
+ public void setTitle( String title ) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the current value of the Title option.
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Returns the content type output by this layout, i.e "text/html".
+ */
+ public String getContentType() {
+ return "text/plain";
+ }
+
+ @Override
+ public Map Example Request: Example Response: Example Request:
* Important Note: This end-point is not intended for concurrent execution by the
* same user or session. It facilitates the User Console deletion UI, and should
* not be used in a manner inconsistent with how that UI operates.
*
* @param params Comma separated list of the files to be moved to trash folder.
- *
* @return A jax-rs Response object with the appropriate status code, header, and body.
*/
@PUT
@Path( "/delete" )
- @Consumes( { MediaType.WILDCARD } )
+ @Consumes( {MediaType.WILDCARD} )
@StatusCodes( {
- @ResponseCode( code = 200, condition = "Successfully moved file to trash." ),
- @ResponseCode( code = 500, condition = "Failure move the file to the trash." ) } )
+ @ResponseCode( code = 200, condition = "Successfully moved file to trash." ),
+ @ResponseCode( code = 500, condition = "Failure move the file to the trash." )} )
public Response doDeleteFiles( String params ) {
try {
fileService.doDeleteFiles( params );
@@ -261,23 +267,22 @@ public Response doDeleteFiles( String params ) {
* Permanently deletes the selected list of files from the repository.
*
* Example Request:
* Important Note: This end-point is not intended for concurrent execution by the
* same user or session. It facilitates the User Console deletion UI, and should
* not be used in a manner inconsistent with how that UI operates.
*
* @param params Comma separated list of the files to be deleted.
- *
* @return Server Response indicating the success of the operation.
*/
@PUT
- @Path ( "/deletepermanent" )
- @Consumes ( { MediaType.WILDCARD } )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully deleted the comma seperated list of fileIds from the system." ),
- @ResponseCode ( code = 403, condition = "Failure to delete the file due to path not found." ) } )
+ @Path( "/deletepermanent" )
+ @Consumes( {MediaType.WILDCARD} )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully deleted the comma seperated list of fileIds from the system." ),
+ @ResponseCode( code = 403, condition = "Failure to delete the file due to path not found." )} )
public Response doDeleteFilesPermanent( String params ) {
try {
fileService.doDeleteFilesPermanent( params );
@@ -292,23 +297,22 @@ public Response doDeleteFilesPermanent( String params ) {
* Moves a list of files from its current location to another.
*
* Example Request: Example Request: Example Request: Example Response: Example Request: Example Request: Example Response: Example Request: Example Response: Example Request: Example Response: Example Request: Example Response: Example Request:true
.
+ */
+ public boolean ignoresThrowable() {
+ return true;
+ }
+
+ @Override
+ public Charset getCharset() {
+ return StandardCharsets.UTF_8;
+ }
+
+ @Override
+ public void encode( LogEvent source, ByteBufferDestination destination ) {
+
+ }
+}
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/SimpleExportProcessor.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/SimpleExportProcessor.java
index 9598a5951c1..8e1e46e99ad 100644
--- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/SimpleExportProcessor.java
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/SimpleExportProcessor.java
@@ -19,6 +19,7 @@
import org.apache.commons.logging.LogFactory;
import org.pentaho.platform.api.repository2.unified.IUnifiedRepository;
import org.pentaho.platform.api.repository2.unified.RepositoryFile;
+import org.pentaho.platform.api.importexport.ExportException;
import java.io.File;
import java.io.FileNotFoundException;
@@ -53,9 +54,8 @@ public SimpleExportProcessor( String path, IUnifiedRepository repository ) {
/**
* Performs the export process, returns a File object
- *
- * @throws ExportException
- * indicates an error in import processing
+ *
+ * @throws ExportException indicates an error in import processing
*/
public File performExport( RepositoryFile exportRepositoryFile ) throws ExportException, IOException {
OutputStream os;
@@ -98,18 +98,17 @@ public File performExport( RepositoryFile exportRepositoryFile ) throws ExportEx
*/
@Override
public void exportDirectory( RepositoryFile repositoryDir, OutputStream outputStream, String filePath )
- throws ExportException, IOException {
+ throws ExportException, IOException {
throw new UnsupportedOperationException();
}
/**
- *
* @param repositoryFile
* @param outputStream
*/
@Override
public void exportFile( RepositoryFile repositoryFile, OutputStream outputStream, String filePath )
- throws ExportException, IOException {
+ throws ExportException, IOException {
// iterate through handlers to perform export
for ( ExportHandler exportHandler : exportHandlerList ) {
diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java
index 0b0b5a1964a..230ff14c984 100644
--- a/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java
+++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessor.java
@@ -23,6 +23,7 @@
import org.pentaho.platform.api.repository2.unified.RepositoryFile;
import org.pentaho.platform.api.repository2.unified.RepositoryFileAcl;
import org.pentaho.platform.api.repository2.unified.RepositoryRequest;
+import org.pentaho.platform.api.importexport.ExportException;
import org.pentaho.platform.engine.core.system.PentahoSessionHolder;
import org.pentaho.platform.engine.core.system.PentahoSystem;
import org.pentaho.platform.plugin.services.importexport.exportManifest.ExportManifest;
@@ -61,6 +62,9 @@ public class ZipExportProcessor extends BaseExportProcessor {
private static final int SAFETY_TMP_FILE_SIZE = 50;
+ private Log logger;
+
+
/**
* Encapsulates the logic of registering import handlers, generating the manifest, and performing the export
*/
@@ -93,7 +97,7 @@ protected void initManifest() {
exportManifest.getManifestInformation().setExportBy( session.getName() );
exportManifest.getManifestInformation().setExportDate(
- dateFormat.format( todaysDate ) + " " + timeFormat.format( todaysDate ) );
+ dateFormat.format( todaysDate ) + " " + timeFormat.format( todaysDate ) );
exportManifest.getManifestInformation().setManifestVersion( "2" );
}
@@ -107,6 +111,7 @@ protected IPentahoSession getSession() {
* @throws ExportException indicates an error in import processing
*/
public File performExport( RepositoryFile exportRepositoryFile ) throws ExportException, IOException {
+ logger = getRepositoryExportLogger();
File exportFile = null;
// create temp file
@@ -180,13 +185,28 @@ public void exportFile( RepositoryFile repositoryFile, OutputStream outputStream
try ( InputStream is = exportHandler.doExport( repositoryFile, filePath ) ) {
// if we don't get a valid input stream back, skip it
if ( is != null ) {
+ if ( logger != null ) {
+ logger.debug( "Adding repository object [ " + repositoryFile.getName() + " ] to the manifest" );
+ }
+
addToManifest( repositoryFile );
+ if ( logger != null ) {
+ logger.debug( "Starting to add repository object [ " + repositoryFile.getName() + " ] to the bundle" );
+ }
String zipEntryName = getFixedZipEntryName( repositoryFile, filePath );
ZipEntry entry = new ZipEntry( zipEntryName );
zos.putNextEntry( entry );
IOUtils.copy( is, outputStream );
zos.closeEntry();
+
+ if ( logger != null ) {
+ logger.debug( "Successfully added repository object [ " + repositoryFile.getName() + " ] to the bundle" );
+ logger.trace( "Starting to create locale entry for repository object [ " + ( ( repositoryFile != null ) ? repositoryFile.getName() : "" ) + " ] " );
+ }
createLocales( repositoryFile, filePath, repositoryFile.isFolder(), outputStream );
+ if ( logger != null ) {
+ logger.trace( "Finished creating locale entry for repository object [ " + ( ( repositoryFile != null ) ? repositoryFile.getName() : "" ) + " ] " );
+ }
}
}
}
@@ -217,31 +237,59 @@ protected void addToManifest( RepositoryFile repositoryFile ) throws ExportExcep
@Override
public void exportDirectory( RepositoryFile repositoryDir, OutputStream outputStream, String filePath ) throws
ExportException, IOException {
+ if ( logger != null ) {
+ logger.debug( "Adding repository object [ " + repositoryDir.getName() + " ] to the manifest" );
+ }
addToManifest( repositoryDir );
List
- * GET pentaho/api/repo/files/backup
+ * GET pentaho/api/repo/files/backup
*
+ *
* Encrypted file stream
*
*/
- @GET
+ @POST
@Path( "/backup" )
+ @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
@StatusCodes( {
- @ResponseCode( code = 200, condition = "Successfully exported the existing Pentaho System" ),
- @ResponseCode( code = 403, condition = "User does not have administrative permissions" ),
- @ResponseCode( code = 500, condition = "Failure to complete the export." ) } )
- public Response systemBackup( @HeaderParam ( "user-agent" ) String userAgent ) {
+ @ResponseCode( code = 200, condition = "Successfully exported the existing Pentaho System" ),
+ @ResponseCode( code = 400, condition = "User has provided a invalid file path" ),
+ @ResponseCode( code = 403, condition = "User does not have administrative permissions" ),
+ @ResponseCode( code = 500, condition = "Failure to complete the export." )} )
+ public Response systemBackup( final MultivaluedMap
- * PUT pentaho/api/repo/files/delete
+ * PUT pentaho/api/repo/files/delete
*
- * PUT pentaho/api/repo/files/deletepermanent
+ * PUT pentaho/api/repo/files/deletepermanent
*
- * PUT pentaho/api/repo/files/{pathId}/move
+ * PUT pentaho/api/repo/files/{pathId}/move
*
- * PUT pentaho/api/repo/files/restore - restore files to original location
- * PUT pentaho/api/repo/files/restore?overwriteMode=2 - restore files to user home folder, RENAME mode
+ * PUT pentaho/api/repo/files/restore - restore files to original location
+ * PUT pentaho/api/repo/files/restore?overwriteMode=2 - restore files to user home folder, RENAME mode
*
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml
+ * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml
*
PUT data:
- *
+ *
* This PUT body does not contain data.
*
*
+ *
* This response does not contain data.
*
*/
@PUT
- @Path ( "{pathId : .+}" )
- @Consumes ( { MediaType.WILDCARD } )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully created the file." ),
- @ResponseCode ( code = 403, condition = "Failure to create the file due to permissions, file already exists, or invalid path id." ) } )
- public Response createFile( @PathParam ( "pathId" ) String pathId, InputStream fileContents ) {
+ @Path( "{pathId : .+}" )
+ @Consumes( {MediaType.WILDCARD} )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully created the file." ),
+ @ResponseCode( code = 403, condition = "Failure to create the file due to permissions, file already exists, or invalid path id." )} )
+ public Response createFile( @PathParam( "pathId" ) String pathId, InputStream fileContents ) {
try {
checkCorrectExtension( pathId );
@@ -423,24 +426,23 @@ public Response createFile( @PathParam ( "pathId" ) String pathId, InputStream f
* Copy selected list of files to a new specified location.
*
*
- * PUT pentaho/api/repo/files/{pathId}/children?mode=2
+ * PUT pentaho/api/repo/files/{pathId}/children?mode=2
*
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml
+ * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml
*
+ *
* This response does not contain data.
*
*/
@GET
- @Path ( "{pathId : .+}" )
- @Produces ( { MediaType.WILDCARD } )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully get the file or directory." ),
- @ResponseCode ( code = 404, condition = "Failed to find the file or resource." ),
- @ResponseCode ( code = 500, condition = "Failed to open content." ) } )
- public Response doGetFileOrDir( @PathParam ( "pathId" ) String pathId ) {
+ @Path( "{pathId : .+}" )
+ @Produces( {MediaType.WILDCARD} )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully get the file or directory." ),
+ @ResponseCode( code = 404, condition = "Failed to find the file or resource." ),
+ @ResponseCode( code = 500, condition = "Failed to open content." )} )
+ public Response doGetFileOrDir( @PathParam( "pathId" ) String pathId ) {
try {
FileService.RepositoryFileToStreamWrapper wrapper = fileService.doGetFileOrDir( pathId );
return buildOkResponse( wrapper );
@@ -496,7 +497,7 @@ public Response doGetFileOrDir( @PathParam ( "pathId" ) String pathId ) {
// @GET
// @Path("{pathId : .+}")
// @Produces({ APPLICATION_ZIP })
- public Response doGetDirAsZip( @PathParam ( "pathId" ) String pathId ) {
+ public Response doGetDirAsZip( @PathParam( "pathId" ) String pathId ) {
String path = fileService.idToPath( pathId );
if ( !isPathValid( path ) ) {
@@ -548,19 +549,18 @@ public Response doGetDirAsZip( RepositoryFile repositoryFile ) {
* Determines whether a selected file supports parameters or not
*
* @param pathId Colon separated path for the repository file.
- *
- * @return ("true" or "false")
+ * @return (" true " or " false ")
* @throws FileNotFoundException
*/
@GET
- @Path ( "{pathId : .+}/parameterizable" )
- @Produces ( MediaType.TEXT_PLAIN )
- @Facet ( name = "Unsupported" )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully get the file or directory." ),
- @ResponseCode ( code = 404, condition = "Failed to find the file or resource." ) } )
+ @Path( "{pathId : .+}/parameterizable" )
+ @Produces( MediaType.TEXT_PLAIN )
+ @Facet( name = "Unsupported" )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully get the file or directory." ),
+ @ResponseCode( code = 404, condition = "Failed to find the file or resource." )} )
// have to accept anything for browsers to work
- public String doIsParameterizable( @PathParam ( "pathId" ) String pathId ) throws FileNotFoundException {
+ public String doIsParameterizable( @PathParam( "pathId" ) String pathId ) throws FileNotFoundException {
boolean hasParameterUi = false;
RepositoryFile repositoryFile = getRepository().getFile( fileService.idToPath( pathId ) );
if ( repositoryFile != null ) {
@@ -594,7 +594,7 @@ public String doIsParameterizable( @PathParam ( "pathId" ) String pathId ) throw
Document document = parseText( outputStream.toString() );
// exclude all parameters that are of type "system", xactions set system params that have to be ignored.
- @SuppressWarnings ( "rawtypes" )
+ @SuppressWarnings( "rawtypes" )
List nodes = document.selectNodes( "parameters/parameter" );
for ( int i = 0; i < nodes.size() && !hasParameters; i++ ) {
Element elem = (Element) nodes.get( i );
@@ -624,7 +624,7 @@ public String doIsParameterizable( @PathParam ( "pathId" ) String pathId ) throw
* have Publish action. How the file comes down to the user and where it is saved is system and browser dependent.
*
*
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/download?locale=de
+ * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/download?locale=de
*
+ *
* Encrypted file stream
*
*/
@GET
- @Path ( "{pathId : .+}/download" )
- @Produces ( MediaType.WILDCARD )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successful download." ),
- @ResponseCode ( code = 400, condition = "Usually a bad pathId." ),
- @ResponseCode ( code = 403, condition = "pathId points at a file the user doesn't have access to." ),
- @ResponseCode ( code = 404, condition = "File not found." ),
- @ResponseCode ( code = 500, condition = "Failed to download file for another reason." ) } )
+ @Path( "{pathId : .+}/download" )
+ @Produces( MediaType.WILDCARD )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successful download." ),
+ @ResponseCode( code = 400, condition = "Usually a bad pathId." ),
+ @ResponseCode( code = 403, condition = "pathId points at a file the user doesn't have access to." ),
+ @ResponseCode( code = 404, condition = "File not found." ),
+ @ResponseCode( code = 500, condition = "Failed to download file for another reason." )} )
// have to accept anything for browsers to work
- public Response doGetFileOrDirAsDownload( @HeaderParam ( "user-agent" ) String userAgent,
- @PathParam ( "pathId" ) String pathId, @QueryParam ( "withManifest" ) String strWithManifest ) {
+ public Response doGetFileOrDirAsDownload( @HeaderParam( "user-agent" ) String userAgent,
+ @PathParam( "pathId" ) String pathId, @QueryParam( "withManifest" ) String strWithManifest ) {
FileService.DownloadFileWrapper wrapper;
try {
wrapper = fileService.doGetFileOrDirAsDownload( userAgent, pathId, strWithManifest );
@@ -680,27 +679,26 @@ public Response doGetFileOrDirAsDownload( @HeaderParam ( "user-agent" ) String u
* document.
*
*
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/inline
+ * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/inline
*
+ *
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
*
*/
@GET
- @Path ( "{pathId : .+}/inline" )
- @Produces ( MediaType.WILDCARD )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully retrieved file." ),
- @ResponseCode ( code = 403, condition = "Failed to retrieve file due to permission problem." ),
- @ResponseCode ( code = 404, condition = "Failed to retrieve file due because file was not found." ),
- @ResponseCode ( code = 500, condition = "Failed to download file because of some other error." ) } )
- public Response doGetFileAsInline( @PathParam ( "pathId" ) String pathId ) {
+ @Path( "{pathId : .+}/inline" )
+ @Produces( MediaType.WILDCARD )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully retrieved file." ),
+ @ResponseCode( code = 403, condition = "Failed to retrieve file due to permission problem." ),
+ @ResponseCode( code = 404, condition = "Failed to retrieve file due because file was not found." ),
+ @ResponseCode( code = 500, condition = "Failed to download file because of some other error." )} )
+ public Response doGetFileAsInline( @PathParam( "pathId" ) String pathId ) {
try {
FileService.RepositoryFileToStreamWrapper wrapper = fileService.doGetFileAsInline( pathId );
return buildOkResponse( wrapper );
@@ -720,32 +718,31 @@ public Response doGetFileAsInline( @PathParam ( "pathId" ) String pathId ) {
* This method is used to update and save the acls of the selected file to the repository.
*
*
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
+ * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
*
PUT data:
- *
+ *
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
*
*
+ *
* This response does not contain data.
*
*/
@PUT
- @Path ( "{pathId : .+}/acl" )
- @Consumes ( { MediaType.APPLICATION_XML } )
- @StatusCodes ( {
- @ResponseCode ( code = 200, condition = "Successfully saved file." ),
- @ResponseCode ( code = 403, condition = "Failed to save acls due to missing or incorrect properties." ),
- @ResponseCode ( code = 400, condition = "Failed to save acls due to malformed xml." ),
- @ResponseCode ( code = 500, condition = "Failed to save acls due to another error." ) } )
- public Response setFileAcls( @PathParam ( "pathId" ) String pathId, StreamSource aclXml ) {
+ @Path( "{pathId : .+}/acl" )
+ @Consumes( {MediaType.APPLICATION_XML} )
+ @StatusCodes( {
+ @ResponseCode( code = 200, condition = "Successfully saved file." ),
+ @ResponseCode( code = 403, condition = "Failed to save acls due to missing or incorrect properties." ),
+ @ResponseCode( code = 400, condition = "Failed to save acls due to malformed xml." ),
+ @ResponseCode( code = 500, condition = "Failed to save acls due to another error." )} )
+ public Response setFileAcls( @PathParam( "pathId" ) String pathId, StreamSource aclXml ) {
/*
* [BISERVER-14294] Ensuring the owner is set to a non-null, non-empty string value to prevent any issues
* that might cause problems with the repository. Then following it up with a user existence check
@@ -777,32 +774,31 @@ public Response setFileAcls( @PathParam ( "pathId" ) String pathId, StreamSource
* This method is used to update and save the acls of the selected file to the repository.
*
*
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
+ * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
*
PUT data:
- *
+ *
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
*
*
Example Response:
- *+ ** @param contentCreator Repository file that created the file at the above pathId location ** This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/acl" ) - @Consumes ( { MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully saved file." ), - @ResponseCode ( code = 403, condition = "Failed to save acls due to missing or incorrect properties." ), - @ResponseCode ( code = 400, condition = "Failed to save acls due to malformed xml." ), - @ResponseCode ( code = 500, condition = "Failed to save acls due to another error." ) } ) - public Response setFileAcls( @PathParam ( "pathId" ) String pathId, RepositoryFileAclDto acl ) { + @Path( "{pathId : .+}/acl" ) + @Consumes( {MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully saved file." ), + @ResponseCode( code = 403, condition = "Failed to save acls due to missing or incorrect properties." ), + @ResponseCode( code = 400, condition = "Failed to save acls due to malformed xml." ), + @ResponseCode( code = 500, condition = "Failed to save acls due to another error." )} ) + public Response setFileAcls( @PathParam( "pathId" ) String pathId, RepositoryFileAclDto acl ) { /* * [BISERVER-14294] Ensuring the owner is set to a non-null, non-empty string value to prevent any issues * that might cause problems with the repository. Then following it up with a user existence check @@ -853,63 +849,63 @@ protected Unmarshaller getUnmarshaller( Class> clazz ) throws JAXBException { /** * Store content creator for the given path of created content. * - * @param pathId colon separated path for the repository file that was created by the contenCreator below - *- * :path:to:file:id - *+ * @param pathId colon separated path for the repository file that was created by the contenCreator below + *+ * :path:to:file:id + ** @param contentCreatorXml Repository file that created the file at the above pathId location - *- * <repositoryFileDto> - * <createdDate>1402911997019</createdDate> - * <fileSize>3461</fileSize> - * <folder>false</folder> - * <hidden>false</hidden> - * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> - * <lastModifiedDate>1406647160536</lastModifiedDate> - * <locale>en</locale> - * <localePropertiesMapEntries> - * <localeMapDto> - * <locale>default</locale> - * <properties> - * <stringKeyStringValueDto> - * <key>file.title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>jcr:primaryType</key> - * <value>nt:unstructured</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>file.description</key> - * <value>myFile Description</value> - * </stringKeyStringValueDto> - * </properties> - * </localeMapDto> - * </localePropertiesMapEntries> - * <locked>false</locked> - * <name>myFile.prpt</name></name> - * <originalParentFolderPath>/public/admin</originalParentFolderPath> - * <ownerType>-1</ownerType> - * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> - * <title>myFile</title> - * <versionId>1.9</versionId> - * <versioned>true</versioned> - * </repositoryFileAclDto> - *+ *+ * <repositoryFileDto> + * <createdDate>1402911997019</createdDate> + * <fileSize>3461</fileSize> + * <folder>false</folder> + * <hidden>false</hidden> + * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> + * <lastModifiedDate>1406647160536</lastModifiedDate> + * <locale>en</locale> + * <localePropertiesMapEntries> + * <localeMapDto> + * <locale>default</locale> + * <properties> + * <stringKeyStringValueDto> + * <key>file.title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>jcr:primaryType</key> + * <value>nt:unstructured</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>file.description</key> + * <value>myFile Description</value> + * </stringKeyStringValueDto> + * </properties> + * </localeMapDto> + * </localePropertiesMapEntries> + * <locked>false</locked> + * <name>myFile.prpt</name></name> + * <originalParentFolderPath>/public/admin</originalParentFolderPath> + * <ownerType>-1</ownerType> + * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> + * <title>myFile</title> + * <versionId>1.9</versionId> + * <versioned>true</versioned> + * </repositoryFileAclDto> + ** @return A jax-rs Response object with the appropriate status code, header, and body. */ @PUT - @Path ( "{pathId : .+}/creator" ) - @Consumes ( { MediaType.APPLICATION_XML } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved file." ), - @ResponseCode ( code = 500, condition = "Failed to download file because of some other error." ) } ) - @Facet ( name = "Unsupported" ) - public Response doSetContentCreator( @PathParam ( "pathId" ) String pathId, StreamSource contentCreatorXml ) { + @Path( "{pathId : .+}/creator" ) + @Consumes( {MediaType.APPLICATION_XML} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved file." ), + @ResponseCode( code = 500, condition = "Failed to download file because of some other error." )} ) + @Facet( name = "Unsupported" ) + public Response doSetContentCreator( @PathParam( "pathId" ) String pathId, StreamSource contentCreatorXml ) { try { Unmarshaller unmarshaller = getUnmarshaller( RepositoryFileDto.class ); XMLStreamReader xsr = getSecureXmlStreamReader( contentCreatorXml ); @@ -930,61 +926,61 @@ public Response doSetContentCreator( @PathParam ( "pathId" ) String pathId, Stre * * @param pathId colon separated path for the repository file that was created by the contenCreator below *- * :path:to:file:id - *+ * :path:to:file:id + *
- * <repositoryFileDto> - * <createdDate>1402911997019</createdDate> - * <fileSize>3461</fileSize> - * <folder>false</folder> - * <hidden>false</hidden> - * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> - * <lastModifiedDate>1406647160536</lastModifiedDate> - * <locale>en</locale> - * <localePropertiesMapEntries> - * <localeMapDto> - * <locale>default</locale> - * <properties> - * <stringKeyStringValueDto> - * <key>file.title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>jcr:primaryType</key> - * <value>nt:unstructured</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>file.description</key> - * <value>myFile Description</value> - * </stringKeyStringValueDto> - * </properties> - * </localeMapDto> - * </localePropertiesMapEntries> - * <locked>false</locked> - * <name>myFile.prpt</name></name> - * <originalParentFolderPath>/public/admin</originalParentFolderPath> - * <ownerType>-1</ownerType> - * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> - * <title>myFile</title> - * <versionId>1.9</versionId> - * <versioned>true</versioned> - * </repositoryFileAclDto> - *+ * <repositoryFileDto> + * <createdDate>1402911997019</createdDate> + * <fileSize>3461</fileSize> + * <folder>false</folder> + * <hidden>false</hidden> + * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> + * <lastModifiedDate>1406647160536</lastModifiedDate> + * <locale>en</locale> + * <localePropertiesMapEntries> + * <localeMapDto> + * <locale>default</locale> + * <properties> + * <stringKeyStringValueDto> + * <key>file.title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>jcr:primaryType</key> + * <value>nt:unstructured</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>file.description</key> + * <value>myFile Description</value> + * </stringKeyStringValueDto> + * </properties> + * </localeMapDto> + * </localePropertiesMapEntries> + * <locked>false</locked> + * <name>myFile.prpt</name></name> + * <originalParentFolderPath>/public/admin</originalParentFolderPath> + * <ownerType>-1</ownerType> + * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> + * <title>myFile</title> + * <versionId>1.9</versionId> + * <versioned>true</versioned> + * </repositoryFileAclDto> + * * @return A jax-rs Response object with the appropriate status code, header, and body. */ @PUT - @Path ( "{pathId : .+}/creator" ) - @Consumes ( { MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved file." ), - @ResponseCode ( code = 500, condition = "Failed to download file because of some other error." ) } ) - @Facet ( name = "Unsupported" ) - public Response doSetContentCreator( @PathParam ( "pathId" ) String pathId, RepositoryFileDto contentCreator ) { + @Path( "{pathId : .+}/creator" ) + @Consumes( {MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved file." ), + @ResponseCode( code = 500, condition = "Failed to download file because of some other error." )} ) + @Facet( name = "Unsupported" ) + public Response doSetContentCreator( @PathParam( "pathId" ) String pathId, RepositoryFileDto contentCreator ) { try { fileService.doSetContentCreator( pathId, contentCreator ); return buildOkResponse(); @@ -1001,15 +997,14 @@ public Response doSetContentCreator( @PathParam ( "pathId" ) String pathId, Repo * Retrieves the list of locale maps for the selected repository file. * *
Example Request:
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/locales
+ * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/locales
*
Example Response:
- *+ ** <localePropertiesMapEntries> * <localeMapDto> * <locale>default</locale> @@ -1036,13 +1031,13 @@ public Response doSetContentCreator( @PathParam ( "pathId" ) String pathId, Repo **/ @GET - @Path ( "{pathId : .+}/locales" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved locale information." ), - @ResponseCode ( code = 404, condition = "Failed to retrieve locales because the file was not found." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve locales due to some other error." ) } ) - public ListdoGetFileLocales( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/locales" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved locale information." ), + @ResponseCode( code = 404, condition = "Failed to retrieve locales because the file was not found." ), + @ResponseCode( code = 500, condition = "Unable to retrieve locales due to some other error." )} ) + public List doGetFileLocales( @PathParam( "pathId" ) String pathId ) { List locales = new ArrayList (); try { locales = fileService.doGetFileLocales( pathId ); @@ -1058,16 +1053,15 @@ public List doGetFileLocales( @PathParam ( "pathId" ) String pathI * Retrieve the list of locale properties for a given locale. * * Example Request:
* * @param pathId Colon separated path for the repository file. * @param locale The specified locale. - * * @return A list of locale properties. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja *Example Response:
- *+ ** <stringKeyStringValueDtoes> * <stringKeyStringValueDto> * <key>file.title</key> @@ -1085,13 +1079,13 @@ public List*/ @GET - @Path ( "{pathId : .+}/localeProperties" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved locale properties." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve locale properties due to some other error." ) } ) - public ListdoGetFileLocales( @PathParam ( "pathId" ) String pathI * doGetLocaleProperties( @PathParam ( "pathId" ) String pathId, - @QueryParam ( "locale" ) String locale ) { + @Path( "{pathId : .+}/localeProperties" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved locale properties." ), + @ResponseCode( code = 500, condition = "Unable to retrieve locale properties due to some other error." )} ) + public List doGetLocaleProperties( @PathParam( "pathId" ) String pathId, + @QueryParam( "locale" ) String locale ) { return fileService.doGetLocaleProperties( pathId, locale ); } @@ -1099,9 +1093,9 @@ public List doGetLocaleProperties( @PathParam ( "pathId * Save list of locale properties for a given locale. * * Example Request:
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja + * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja *
PUT data: - *+ ** <?xml version="1.0" encoding="UTF-8" standalone="yes"?><stringKeyStringValueDtoes><stringKeyStringValueDto><key>file.title</key><value>ãã£ã¼ãé¸æãªã¹ã</value></stringKeyStringValueDto><stringKeyStringValueDto><key>jcr:primaryType</key><value>nt:unstructured</value></stringKeyStringValueDto><stringKeyStringValueDto><key>file.description</key><value>è¤æ°ã®ãã£ã¼ãã¿ã¤ãã表示ãã¾ã</value></stringKeyStringValueDto></stringKeyStringValueDtoes> ** @@ -1109,21 +1103,20 @@ public ListdoGetLocaleProperties( @PathParam ( "pathId * @param pathId Colon separated path for the repository file. * @param locale A string representation of the locale to set properties on. * @param properties The list of locale properties. - * * @return A jax-rs Response object with the appropriate status code, header, and body. * * Example Response:
- *+ ** This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/localeProperties" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully updated locale properties." ), - @ResponseCode ( code = 500, condition = "Unable to update locale properties due to some other error." ) } ) - public Response doSetLocaleProperties( @PathParam ( "pathId" ) String pathId, @QueryParam ( "locale" ) String locale, + @Path( "{pathId : .+}/localeProperties" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully updated locale properties." ), + @ResponseCode( code = 500, condition = "Unable to update locale properties due to some other error." )} ) + public Response doSetLocaleProperties( @PathParam( "pathId" ) String pathId, @QueryParam( "locale" ) String locale, Listproperties ) { try { fileService.doSetLocaleProperties( pathId, locale, properties ); @@ -1137,30 +1130,29 @@ public Response doSetLocaleProperties( @PathParam ( "pathId" ) String pathId, @Q * Delete the locale for the selected file. * * Example Request:
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/deleteLocale?locale=ja + * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/deleteLocale?locale=ja *
PUT data: - *+ ** This PUT body does not contain data. ** * * @param pathId Colon separated path for the repository file. * @param locale A string representations of the locale to be deleted. - * * @return A jax-rs Response object with the appropriate status code, header, and body. * *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/metadata" ) - @Produces ( { MediaType.APPLICATION_JSON } ) + @Path( "{pathId : .+}/metadata" ) + @Produces( {MediaType.APPLICATION_JSON} ) @StatusCodes( { - @ResponseCode( code = 200, condition = "Successfully retrieved metadata." ), - @ResponseCode( code = 403, condition = "Invalid path." ), - @ResponseCode( code = 500, condition = "Server Error." ) } ) - public List* This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/deleteLocale" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully deleted the locale." ), - @ResponseCode ( code = 500, condition = "Unable to delete the locale properties due to some other error." ) } ) - public Response doDeleteLocale( @PathParam ( "pathId" ) String pathId, @QueryParam ( "locale" ) String locale ) { + @Path( "{pathId : .+}/deleteLocale" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully deleted the locale." ), + @ResponseCode( code = 500, condition = "Unable to delete the locale properties due to some other error." )} ) + public Response doDeleteLocale( @PathParam( "pathId" ) String pathId, @QueryParam( "locale" ) String locale ) { try { fileService.doDeleteLocale( pathId, locale ); return buildOkResponse(); @@ -1173,13 +1165,13 @@ public Response doDeleteLocale( @PathParam ( "pathId" ) String pathId, @QueryPar * Retrieves the properties of the root directory. * *Example Request:
* * @return file properties object RepositoryFileDto for the root directory. * *
- * GET pentaho/api/repo/files/properties + * GET pentaho/api/repo/files/properties *Example Response:
- *+ **/ @GET - @Path ( "/deleted" ) - @Produces ( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of files from trash folder of the repository." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) + @Path( "/deleted" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of files from trash folder of the repository." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) public List* <repositoryFileDto> * <createdDate>1406731649407</createdDate> * <fileSize>-1</fileSize> @@ -1197,12 +1189,12 @@ public Response doDeleteLocale( @PathParam ( "pathId" ) String pathId, @QueryPar **/ @GET - @Path ( "/properties" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the properties of the root directory." ), - @ResponseCode ( code = 404, condition = "Unable to retrieve the properties of the root directory due to file not found error." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve the properties of the root directory due to some other error." ) } ) + @Path( "/properties" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the properties of the root directory." ), + @ResponseCode( code = 404, condition = "Unable to retrieve the properties of the root directory due to file not found error." ), + @ResponseCode( code = 500, condition = "Unable to retrieve the properties of the root directory due to some other error." )} ) public RepositoryFileDto doGetRootProperties() { return fileService.doGetRootProperties(); } @@ -1212,27 +1204,26 @@ public RepositoryFileDto doGetRootProperties() { * but will only return true if all permissions checked are valid. * *Example Request:
* * @param pathId Colon separated path for the repository file. * @param permissions Pipe separated permissions to be checked. - * * @return List of permissions for the selected files. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.txt/canAccessMap?permissions=1 + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.txt/canAccessMap?permissions=1 *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/children" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode( code = 200, - condition = "Successfully retrieved the list of child files from selected repository path of the repository." ), - @ResponseCode( code = 500, condition = "Server Error." ) } ) - public List* {"setting":[{"name":"1","value":"true"}]} **/ @GET - @Path ( "{pathId : .+}/canAccessMap" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the permissions of the file." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve the permissions of the file due to some other error." ) } ) - public ListdoGetCanAccessList( @PathParam ( "pathId" ) String pathId, - @QueryParam ( "permissions" ) String permissions ) { + @Path( "{pathId : .+}/canAccessMap" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the permissions of the file." ), + @ResponseCode( code = 500, condition = "Unable to retrieve the permissions of the file due to some other error." )} ) + public List doGetCanAccessList( @PathParam( "pathId" ) String pathId, + @QueryParam( "permissions" ) String permissions ) { return fileService.doGetCanAccessList( pathId, permissions ); } @@ -1240,9 +1231,9 @@ public List doGetCanAccessList( @PathParam ( "pathId" ) String pathId, * Checks whether the current user has permissions to the provided list of paths. * * Example Request:
- * POST pentaho/api/repo/files/pathsAccessList + * POST pentaho/api/repo/files/pathsAccessList *
POST data: - *+ **/ @GET - @Path ( "{pathId : .+}/tree" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of files from root of the repository." ), - @ResponseCode ( code = 404, condition = "Invalid parameters." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) - public RepositoryFileTreeDto doGetTree( @PathParam ( "pathId" ) String pathId, @QueryParam ( "depth" ) Integer depth, - @QueryParam ( "filter" ) String filter, @QueryParam ( "showHidden" ) Boolean showHidden, - @DefaultValue ( "false" ) @QueryParam ( "includeAcls" ) Boolean includeAcls, - @DefaultValue ( "false" ) @QueryParam ( "includeSysDirs" ) Boolean includeSystemFolders ) { + @Path( "{pathId : .+}/tree" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of files from root of the repository." ), + @ResponseCode( code = 404, condition = "Invalid parameters." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public RepositoryFileTreeDto doGetTree( @PathParam( "pathId" ) String pathId, @QueryParam( "depth" ) Integer depth, + @QueryParam( "filter" ) String filter, @QueryParam( "showHidden" ) Boolean showHidden, + @DefaultValue( "false" ) @QueryParam( "includeAcls" ) Boolean includeAcls, + @DefaultValue( "false" ) @QueryParam( "includeSysDirs" ) Boolean includeSystemFolders ) { return fileService.doGetTree( pathId, depth, filter, showHidden, includeAcls, includeSystemFolders ); } @@ -1913,7 +1894,7 @@ public RepositoryFileTreeDto doGetTree( @PathParam ( "pathId" ) String pathId, @ * Retrieve a list of child files from the selected repository path of the repository. * ** <?xml version="1.0" encoding="UTF-8"?> * <stringListWrapper> * <strings>/public</strings> @@ -1251,11 +1242,10 @@ public List*/ @GET - @Path ( "/children" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of child files from root of the repository." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) - public ListdoGetCanAccessList( @PathParam ( "pathId" ) String pathId, * * * @param pathsWrapper Collection of Strings containing the paths to be checked. - * * @return A collection of the permission settings for the paths. * * Example Response:
- *+ **/ @GET - @Path ( "/tree" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of files from root of the repository." ), - @ResponseCode ( code = 404, condition = "Invalid parameters." ), - @ResponseCode ( code = 500, condition = "Server Error." ) - } ) - public RepositoryFileTreeDto doGetRootTree( @QueryParam ( "depth" ) Integer depth, - @QueryParam ( "filter" ) String filter, @QueryParam ( "showHidden" ) Boolean showHidden, - @DefaultValue ( "false" ) @QueryParam ( "includeAcls" ) Boolean includeAcls ) { + @Path( "/tree" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of files from root of the repository." ), + @ResponseCode( code = 404, condition = "Invalid parameters." ), + @ResponseCode( code = 500, condition = "Server Error." ) + } ) + public RepositoryFileTreeDto doGetRootTree( @QueryParam( "depth" ) Integer depth, + @QueryParam( "filter" ) String filter, @QueryParam( "showHidden" ) Boolean showHidden, + @DefaultValue( "false" ) @QueryParam( "includeAcls" ) Boolean includeAcls ) { return fileService.doGetTree( FileUtils.PATH_SEPARATOR, depth, filter, showHidden, includeAcls ); } @@ -1782,7 +1765,7 @@ public RepositoryFileTreeDto doGetRootTree( @QueryParam ( "depth" ) Integer dept * Retrieve a list of child files from the root of the repository. * ** <settings> * <setting> * <name> @@ -1277,12 +1267,12 @@ public List*/ @POST - @Path ( "/pathsAccessList" ) - @Consumes ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the permissions of the given paths." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve the permissions of the given paths due to some other error." ) } ) + @Path( "/pathsAccessList" ) + @Consumes( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the permissions of the given paths." ), + @ResponseCode( code = 500, condition = "Unable to retrieve the permissions of the given paths due to some other error." )} ) public ListdoGetCanAccessList( @PathParam ( "pathId" ) String pathId, * doGetPathsAccessList( StringListWrapper pathsWrapper ) { return fileService.doGetPathsAccessList( pathsWrapper ); } @@ -1291,27 +1281,26 @@ public List doGetPathsAccessList( StringListWrapper pathsWrapper ) { * Check whether the current user has specific permission on the selected repository file. * * Example Request:
* * @param pathId Colon separated path for the repository file. * @param permissions Pipe separated list of permissions. - * * @return String "true" if the user has requested permissions on the file, or "false" otherwise. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/canAccess?permissions=1 + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/canAccess?permissions=1 *Example Response:
- *+ **/ @GET - @Path ( "/reservedCharactersDisplay" ) - @Produces ( { MediaType.TEXT_PLAIN } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully returns a list of repositroy reserved characters" ) } ) + @Path( "/reservedCharactersDisplay" ) + @Produces( {MediaType.TEXT_PLAIN} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns a list of repositroy reserved characters" )} ) public Response doGetReservedCharactersDisplay() { StringBuffer buffer = fileService.doGetReservedCharactersDisplay(); return buildPlainTextOkResponse( buffer.toString() ); @@ -1394,21 +1383,21 @@ public Response doGetReservedCharactersDisplay() { * Checks the users permission to determine if that user can create new content in the repository. * ** true **/ @GET - @Path ( "{pathId : .+}/canAccess" ) - @Produces ( MediaType.TEXT_PLAIN ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the permissions of the given paths." ), - @ResponseCode ( code = 500, condition = "Unable to retrieve the permissions of the given paths due to some other error." ) } ) - public String doGetCanAccess( @PathParam ( "pathId" ) String pathId, - @QueryParam ( "permissions" ) String permissions ) { + @Path( "{pathId : .+}/canAccess" ) + @Produces( MediaType.TEXT_PLAIN ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the permissions of the given paths." ), + @ResponseCode( code = 500, condition = "Unable to retrieve the permissions of the given paths due to some other error." )} ) + public String doGetCanAccess( @PathParam( "pathId" ) String pathId, + @QueryParam( "permissions" ) String permissions ) { return fileService.doGetCanAccess( pathId, permissions ); } @@ -1319,21 +1308,21 @@ public String doGetCanAccess( @PathParam ( "pathId" ) String pathId, * Checks to see if the current user is an administer of the platform and returns a boolean response. * *Example Request:
* * @return String "true" if the user can administer the platform, or "false" otherwise. * *
- * GET pentaho/api/repo/files/canAdminister + * GET pentaho/api/repo/files/canAdminister *Example Response:
- *+ **/ @GET - @Path ( "/reservedCharacters" ) - @Produces ( { MediaType.TEXT_PLAIN } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully returns a list of repositroy reserved characters" ) } ) + @Path( "/reservedCharacters" ) + @Produces( {MediaType.TEXT_PLAIN} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns a list of repositroy reserved characters" )} ) public Response doGetReservedChars() { StringBuffer buffer = fileService.doGetReservedChars(); return buildPlainTextOkResponse( buffer.toString() ); @@ -1370,7 +1359,7 @@ public Response doGetReservedChars() { * Returns the list of reserved characters from the repository. * ** true **/ @GET - @Path ( "/canAdminister" ) - @Produces ( MediaType.TEXT_PLAIN ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully returns a boolean value, either true or false" ) } ) + @Path( "/canAdminister" ) + @Produces( MediaType.TEXT_PLAIN ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns a boolean value, either true or false" )} ) public String doGetCanAdminister() { try { return fileService.doCanAdminister() ? "true" : "false"; @@ -1346,7 +1335,7 @@ public String doGetCanAdminister() { * Returns the list of reserved characters from the repository. * *Example Request:
* * @return List of characters that are reserved by the repository. @@ -1357,10 +1346,10 @@ public String doGetCanAdminister() { *
- * GET pentaho/api/repo/files/reservedCharacters + * GET pentaho/api/repo/files/reservedCharacters *Example Request:
* * @return List of characters that are reserved by the repository. @@ -1381,10 +1370,10 @@ public Response doGetReservedChars() { *
- * GET pentaho/api/repo/files/reservedCharactersDisplay + * GET pentaho/api/repo/files/reservedCharactersDisplay *Example Request:
* * @return String "true" if the user can create new content, or "false" otherwise. * *
- * GET pentaho/api/repo/files/canCreate + * GET pentaho/api/repo/files/canCreate *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/generatedContentForUser" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of RepositoryFileDto objects." ), - @ResponseCode ( code = 200, condition = "Empty list of RepositoryFileDto objects." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) - public List* true **/ @GET - @Path ( "/canCreate" ) - @Produces ( MediaType.TEXT_PLAIN ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully returns true or false depending on the users permissions" ) } ) + @Path( "/canCreate" ) + @Produces( MediaType.TEXT_PLAIN ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns true or false depending on the users permissions" )} ) public String doGetCanCreate() { return fileService.doGetCanCreate(); } @@ -1417,21 +1406,21 @@ public String doGetCanCreate() { * Checks the users permission to determine if that user can edit an existing content in the repository. * *Example Request:
* * @return String "true" if the user can edit existing content, or "false" otherwise. * *
- * GET pentaho/api/repo/files/canEdit + * GET pentaho/api/repo/files/canEdit *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/generatedContent" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the list of RepositoryFileDto objects." ), - @ResponseCode ( code = 200, condition = "Empty list of RepositoryFileDto objects." ) } ) - public List* true **/ @GET - @Path ( "/canEdit" ) - @Produces ( MediaType.TEXT_PLAIN ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully returns true or false depending on the users permissions" ) } ) + @Path( "/canEdit" ) + @Produces( MediaType.TEXT_PLAIN ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns true or false depending on the users permissions" )} ) public String doGetCanEdit() { return fileService.doGetCanEdit(); } @@ -1441,15 +1430,14 @@ public String doGetCanEdit() { * Retrieves the ACL settings of the requested repository file in either xml or json format. * *Example Request:
* * @param pathId colon separated path for the repository file. - * * @return RepositoryFileAclDto object containing the ACL settings of the requested file. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/properties" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the properties for a file." ), - @ResponseCode ( code = 204, condition = "Invalid file path." ) } ) - public RepositoryFileDto doGetProperties( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/properties" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the properties for a file." ), + @ResponseCode( code = 204, condition = "Invalid file path." )} ) + public RepositoryFileDto doGetProperties( @PathParam( "pathId" ) String pathId ) { try { return fileService.doGetProperties( pathId ); } catch ( FileNotFoundException fileNotFound ) { @@ -1541,17 +1528,16 @@ public RepositoryFileDto doGetProperties( @PathParam ( "pathId" ) String pathId * Retrieves the file by creator id * * @param pathId Colon separated path for the destination for files to be copied. - * * @return file properties object RepositoryFileDto */ @GET - @Path ( "{pathId : .+}/creator" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @Facet ( name = "Unsupported" ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved the content creator for a file." ), - @ResponseCode ( code = 403, condition = "Failure to move the file due to path not found." ) } ) - public RepositoryFileDto doGetContentCreator( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/creator" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @Facet( name = "Unsupported" ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the content creator for a file." ), + @ResponseCode( code = 403, condition = "Failure to move the file due to path not found." )} ) + public RepositoryFileDto doGetContentCreator( @PathParam( "pathId" ) String pathId ) { try { return fileService.doGetContentCreator( pathId ); } catch ( Throwable t ) { @@ -1563,11 +1549,10 @@ public RepositoryFileDto doGetContentCreator( @PathParam ( "pathId" ) String pat * Retrieve the list of executed contents for a selected content from the repository. * ** <repositoryFileAclDto> * <aces> * <modifiable>true</modifiable> @@ -1471,12 +1459,12 @@ public String doGetCanEdit() { **/ @GET - @Path ( "{pathId : .+}/acl" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Returns the requested file permissions in xml or json format" ), - @ResponseCode ( code = 500, condition = "File failed to be retrieved. This could be caused by an invalid path, or the file does not exist." ) } ) - public RepositoryFileAclDto doGetFileAcl( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/acl" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Returns the requested file permissions in xml or json format" ), + @ResponseCode( code = 500, condition = "File failed to be retrieved. This could be caused by an invalid path, or the file does not exist." )} ) + public RepositoryFileAclDto doGetFileAcl( @PathParam( "pathId" ) String pathId ) { return fileService.doGetFileAcl( pathId ); } @@ -1484,11 +1472,10 @@ public RepositoryFileAclDto doGetFileAcl( @PathParam ( "pathId" ) String pathId * Retrieves the properties of a selected repository file. * *Example Request:
* * @param pathId Colon separated path for the repository file. - * * @return A RepositoryDto object containing the properties for the given file. * *
- * GET pentaho/api/repo/files/:/properties + * GET pentaho/api/repo/files/:/properties *Example Response:
@@ -1522,12 +1509,12 @@ public RepositoryFileAclDto doGetFileAcl( @PathParam ( "pathId" ) String pathId *Example Request:
* * @param pathId Colon separated path for the destination for files to be copied. - * * @return A list of RepositoryDto objects containing the executed contents for a selected content from the repository. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContent?locale=de + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContent?locale=de *Example Response:
@@ -1617,12 +1602,12 @@ public RepositoryFileDto doGetContentCreator( @PathParam ( "pathId" ) String pat *doGetGeneratedContent( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/generatedContent" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of RepositoryFileDto objects." ), + @ResponseCode( code = 200, condition = "Empty list of RepositoryFileDto objects." )} ) + public List doGetGeneratedContent( @PathParam( "pathId" ) String pathId ) { List repositoryFileDtoList = new ArrayList (); try { repositoryFileDtoList = fileService.doGetGeneratedContent( pathId ); @@ -1638,12 +1623,11 @@ public List doGetGeneratedContent( @PathParam ( "pathId" ) St * Retrieve the executed contents for a selected repository file and a given user. * * Example Request:
* * @param pathId Colon separated path for the destination for files to be copied. * @param user The username for the generated content folder. - * * @return A list of RepositoryDto objects containing the executed contents for a selected file from the repository. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContentForUser?user=admin + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContentForUser?user=admin *Example Response:
@@ -1693,14 +1677,14 @@ public ListdoGetGeneratedContent( @PathParam ( "pathId" ) St * doGetGeneratedContentForUser( @PathParam ( "pathId" ) String pathId, - @QueryParam ( "user" ) String user ) { + @Path( "{pathId : .+}/generatedContentForUser" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of RepositoryFileDto objects." ), + @ResponseCode( code = 200, condition = "Empty list of RepositoryFileDto objects." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public List doGetGeneratedContentForUser( @PathParam( "pathId" ) String pathId, + @QueryParam( "user" ) String user ) { List repositoryFileDtoList = new ArrayList (); try { repositoryFileDtoList = fileService.doGetGeneratedContent( pathId, user ); @@ -1717,7 +1701,7 @@ public List doGetGeneratedContentForUser( @PathParam ( "pathI * Retrieve the recursive list of files from root of the repository based on the filters provided. * * Example Request:
* * @param depth How many level should the search go. @@ -1739,7 +1723,6 @@ public List
- * GET pentaho/api/repo/files/tree?showHidden=false&filter=*|FILES&_=1389042244670 + * GET pentaho/api/repo/files/tree?showHidden=false&filter=*|FILES&_=1389042244670 *doGetGeneratedContentForUser( @PathParam ( "pathI * Omission of a member filter will return all members. It is invalid to both and includeMembers= and an * excludeMembers= clause in the same service call. * @param showHidden Include or exclude hidden files from the file list. - * * @return A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title. * * Example Response:
@@ -1765,16 +1748,16 @@ public ListdoGetGeneratedContentForUser( @PathParam ( "pathI * Example Request:
* * @param filter Filter to be applied for search. The filter can be broken down into 3 parts; File types, Child Node @@ -1804,7 +1787,6 @@ public RepositoryFileTreeDto doGetRootTree( @QueryParam ( "depth" ) Integer dept * excludeMembers= clause in the same service call. * @param showHidden Include or exclude hidden files from the file list. * @param includeAcls Include permission information about the file in the output. - * * @return A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title. * *
- * GET pentaho/api/repo/files/children?showHidden=false&filter=*|FILES&_=1389042244670 + * GET pentaho/api/repo/files/children?showHidden=false&filter=*|FILES&_=1389042244670 *Example Response:
@@ -1830,14 +1812,14 @@ public RepositoryFileTreeDto doGetRootTree( @QueryParam ( "depth" ) Integer dept *doGetRootChildren( @QueryParam ( "filter" ) String filter, - @QueryParam ( "showHidden" ) Boolean showHidden, - @DefaultValue ( "false" ) @QueryParam ( "includeAcls" ) Boolean includeAcls ) { + @Path( "/children" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved the list of child files from root of the repository." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public List doGetRootChildren( @QueryParam( "filter" ) String filter, + @QueryParam( "showHidden" ) Boolean showHidden, + @DefaultValue( "false" ) @QueryParam( "includeAcls" ) Boolean includeAcls ) { return fileService.doGetChildren( FileUtils.PATH_SEPARATOR, filter, showHidden, includeAcls ); } @@ -1845,7 +1827,7 @@ public List doGetRootChildren( @QueryParam ( "filter" ) Strin * Retrieve the recursive list of children of the selected repository file. * * Example Request:
* * @param pathId The path from the root folder to the root node of the tree to return using colon characters in place of / @@ -1870,7 +1852,6 @@ public List
- * GET pentaho/api/repo/files/:public/tree?showHidden=false&filter=*|FILES&_=1389042244670 + * GET pentaho/api/repo/files/:public/tree?showHidden=false&filter=*|FILES&_=1389042244670 *doGetRootChildren( @QueryParam ( "filter" ) Strin * excludeMembers= clause in the same service call. * @param showHidden Include or exclude hidden files from the file list. * @param includeAcls Include permission information about the file in the output. - * * @return A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title. * * Example Response:
@@ -1896,16 +1877,16 @@ public ListdoGetRootChildren( @QueryParam ( "filter" ) Strin * Example Request:
* * @param pathId The path from the root folder to the root node of the tree to return using colon characters in place of / @@ -1937,7 +1918,6 @@ public RepositoryFileTreeDto doGetTree( @PathParam ( "pathId" ) String pathId, @ * excludeMembers= clause in the same service call. * @param showHidden Include or exclude hidden files from the file list. * @param includeAcls Include permission information about the file in the output. - * * @return A RepositoryFileTreeDto object containing the files at the selected repository path of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title. * *
- * GET pentaho/api/repo/files/:jmeter-test/children + * GET pentaho/api/repo/files/:jmeter-test/children *Example Response:
@@ -1963,15 +1943,15 @@ public RepositoryFileTreeDto doGetTree( @PathParam ( "pathId" ) String pathId, @ *doGetChildren( @PathParam ( "pathId" ) String pathId, - @QueryParam ( "filter" ) String filter, @QueryParam ( "showHidden" ) Boolean showHidden, - @DefaultValue ( "false" ) @QueryParam ( "includeAcls" ) Boolean includeAcls ) { + @Path( "{pathId : .+}/children" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, + condition = "Successfully retrieved the list of child files from selected repository path of the repository." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public List doGetChildren( @PathParam( "pathId" ) String pathId, + @QueryParam( "filter" ) String filter, @QueryParam( "showHidden" ) Boolean showHidden, + @DefaultValue( "false" ) @QueryParam( "includeAcls" ) Boolean includeAcls ) { return fileService.doGetChildren( pathId, filter, showHidden, includeAcls ); } @@ -1980,7 +1960,7 @@ public List doGetChildren( @PathParam ( "pathId" ) String pat * Retrieve the list of files in the user's trash folder. * * Example Request:
* * @return A list of RepositoryDto objects containing the files in the trash folder of the repository. @@ -2029,11 +2009,11 @@ public List
- * GET pentaho/api/repo/files/deleted + * GET pentaho/api/repo/files/deleted *doGetChildren( @PathParam ( "pathId" ) String pat * doGetDeletedFiles() { return fileService.doGetDeletedFiles(); } @@ -2043,12 +2023,11 @@ public List doGetDeletedFiles() { * the metadata child, it is considered metadata from PUC and is included in the setMetadata call. * * Example Request:
* * @param pathId The path from the root folder to the root node of the tree to return using colon characters in place of / * or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file. - * * @return A jax-rs Response object with the appropriate status code, header, and body. * *
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata + * GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata *Example Response:
@@ -2062,13 +2041,13 @@ public ListdoGetDeletedFiles() { * doGetMetadata( @PathParam ( "pathId" ) String pathId ) { + @ResponseCode( code = 200, condition = "Successfully retrieved metadata." ), + @ResponseCode( code = 403, condition = "Invalid path." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public List doGetMetadata( @PathParam( "pathId" ) String pathId ) { try { return fileService.doGetMetadata( pathId ); } catch ( FileNotFoundException e ) { @@ -2081,9 +2060,9 @@ public List doGetMetadata( @PathParam ( "pathId" ) Stri * Rename the selected file. * * Example Request:
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/rename?newName=test_file_8 + * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/rename?newName=test_file_8 *
PUT data: - *+ ** This PUT body does not contain data. ** @@ -2091,22 +2070,21 @@ public ListdoGetMetadata( @PathParam ( "pathId" ) Stri * @param pathId The path from the root folder to the root node of the tree to return using colon characters in place of / * or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file. * @param newName String indicating the new name of the file. - * * @return Response with 200 OK, if the file does not exist to be renamed the response will return 200 OK with the string "File to be renamed does not exist". * * Example Response:
- *+ ** @return file properties object* This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/rename" ) - @Consumes ( { MediaType.WILDCARD } ) - @Produces ( { MediaType.WILDCARD } ) + @Path( "{pathId : .+}/rename" ) + @Consumes( {MediaType.WILDCARD} ) + @Produces( {MediaType.WILDCARD} ) @StatusCodes( { - @ResponseCode( code = 200, condition = "Successfully renamed file." ), - @ResponseCode( code = 403, condition = "Forbidden." ), - @ResponseCode( code = 404, condition = "File not found." ) } ) + @ResponseCode( code = 200, condition = "Successfully renamed file." ), + @ResponseCode( code = 403, condition = "Forbidden." ), + @ResponseCode( code = 404, condition = "File not found." )} ) public Response doRename( @PathParam( "pathId" ) String pathId, @QueryParam( "newName" ) String newName ) { try { if ( FileUtils.containsControlCharacters( newName ) ) { @@ -2132,9 +2110,9 @@ public Response doRename( @PathParam( "pathId" ) String pathId, @QueryParam( "ne * the metadata child, it is considered metadata from PUC and is included in the setMetadata call. * *Example Request:
- * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata + * PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata *
PUT data: - *+ **/ @GET - @Path ( "/canUpload" ) - @Produces ( { MediaType.TEXT_PLAIN } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Returns a boolean response." ) + @Path( "/canUpload" ) + @Produces( {MediaType.TEXT_PLAIN} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Returns a boolean response." ) } ) - public Response canUpload( @QueryParam ( "dirPath" ) @DefaultValue( "" ) String dirPath ) { + public Response canUpload( @QueryParam( "dirPath" ) @DefaultValue( "" ) String dirPath ) { return Response.ok( ( String.valueOf( SystemUtils.canUpload( dirPath ) ) ) ).build(); } @@ -2470,7 +2443,7 @@ protected String getUserHomeFolder() { /** * Checks if the given users and roles are valid, i.e. don't contain illegal characters. * Illegal characters may lead to repository corruption. - * + ** <?xml version="1.0" encoding="UTF-8" standalone="yes"?><stringKeyStringValueDtoes><stringKeyStringValueDto><key>metadata.key.1</key><value>metadata.value.1</value></stringKeyStringValueDto></stringKeyStringValueDtoes> ** @@ -2142,24 +2120,23 @@ public Response doRename( @PathParam( "pathId" ) String pathId, @QueryParam( "ne * @param pathId The path from the root folder to the root node of the tree to return using colon characters in place of / * or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file. * @param metadata A list of StringKeyStringValueDto objects. - * * @return A jax-rs Response object with the appropriate status code, header, and body. * *Example Response:
- *+ **/ @GET - @Path ( "/canDownload" ) - @Produces ( { MediaType.TEXT_PLAIN } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Returns a boolean response." ) + @Path( "/canDownload" ) + @Produces( {MediaType.TEXT_PLAIN} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Returns a boolean response." ) } ) - public Response canDownload( @QueryParam ( "dirPath" ) @DefaultValue( "" ) String dirPath ) { + public Response canDownload( @QueryParam( "dirPath" ) @DefaultValue( "" ) String dirPath ) { return Response.ok( ( String.valueOf( SystemUtils.canDownload( dirPath ) ) ) ).build(); } @@ -2276,11 +2250,10 @@ public Response canDownload( @QueryParam ( "dirPath" ) @DefaultValue( "" ) Strin * Validates if a current user is authorized to upload content to the given dir * ** This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/metadata" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @Consumes ( { MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully retrieved metadata." ), - @ResponseCode ( code = 403, condition = "Invalid path." ), - @ResponseCode ( code = 400, condition = "Invalid payload." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) - public Response doSetMetadata( @PathParam ( "pathId" ) String pathId, Listmetadata ) { + @Path( "{pathId : .+}/metadata" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @Consumes( {MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully retrieved metadata." ), + @ResponseCode( code = 403, condition = "Invalid path." ), + @ResponseCode( code = 400, condition = "Invalid payload." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public Response doSetMetadata( @PathParam( "pathId" ) String pathId, List metadata ) { try { fileService.doSetMetadata( pathId, metadata ); return buildOkResponse(); @@ -2174,32 +2151,31 @@ public Response doSetMetadata( @PathParam ( "pathId" ) String pathId, List Example Request:
- * PUT pentaho/api/repo/files/:public:jmeter-test-dir/createDir + * PUT pentaho/api/repo/files/:public:jmeter-test-dir/createDir *
PUT data: - *+ ** * * @param pathId Colon separated path for the repository file. - * * @return The Versioning Configuration applicable to the path submitted * ** This PUT body does not contain data. ** * * @param pathId The path from the root folder to the root node of the tree to return using colon characters in * place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file. - * * @return A jax-rs Response object with the appropriate status code, header, and body. * *Example Response:
- *+ *+ * GET pentaho/api/repo/files/:jmeter-test:test_file_1.ktr/versioningConfiguration + ** This response does not contain data. **/ @PUT - @Path ( "{pathId : .+}/createDir" ) - @Consumes ( { MediaType.WILDCARD } ) - @StatusCodes ( { - @ResponseCode ( code = 200, condition = "Successfully created folder." ), - @ResponseCode ( code = 403, condition = "Forbidden." ), - @ResponseCode ( code = 409, condition = "Path already exists." ), - @ResponseCode ( code = 500, condition = "Server Error." ) } ) - public Response doCreateDirs( @PathParam ( "pathId" ) String pathId ) { + @Path( "{pathId : .+}/createDir" ) + @Consumes( {MediaType.WILDCARD} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully created folder." ), + @ResponseCode( code = 403, condition = "Forbidden." ), + @ResponseCode( code = 409, condition = "Path already exists." ), + @ResponseCode( code = 500, condition = "Server Error." )} ) + public Response doCreateDirs( @PathParam( "pathId" ) String pathId ) { try { if ( fileService.doCreateDirSafe( pathId ) ) { return buildOkResponse(); @@ -2217,44 +2193,42 @@ public Response doCreateDirs( @PathParam ( "pathId" ) String pathId ) { * This method is used to determine whether versioning should be active for the given path * *Example Request:
- * GET pentaho/api/repo/files/:jmeter-test:test_file_1.ktr/versioningConfiguration - *Example Response:
- *+ **/ @GET - @Path ( "{pathId : .+}/versioningConfiguration" ) - @Produces ( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } ) - @StatusCodes ( { - @ResponseCode( code = 200, condition = "Successfully returns the versioning configuration" ) } ) + @Path( "{pathId : .+}/versioningConfiguration" ) + @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} ) + @StatusCodes( { + @ResponseCode( code = 200, condition = "Successfully returns the versioning configuration" )} ) public FileVersioningConfiguration doVersioningConfiguration( @PathParam( "pathId" ) String pathId ) { IRepositoryVersionManager repositoryVersionManager = PentahoSystem.get( IRepositoryVersionManager.class ); String path = FileUtils.idToPath( pathId ); return new FileVersioningConfiguration( - repositoryVersionManager.isVersioningEnabled( path ), - repositoryVersionManager.isVersionCommentEnabled( path ) ); + repositoryVersionManager.isVersioningEnabled( path ), + repositoryVersionManager.isVersionCommentEnabled( path ) ); } /** * Validates if a current user is authorized to download content from the given dir. * ** <fileVersioningConfiguration> - * <versionCommentEnabled>true</versionCommentEnabled> - * <versioningEnabled>true</versioningEnabled> + * <versionCommentEnabled>true</versionCommentEnabled> + * <versioningEnabled>true</versioningEnabled> * </fileVersioningConfiguration> - *+ *Example Request:
* - * @param dirPath to be validated for download action for the current user. - * + * @param dirPath to be validated for download action for the current user. * @return A boolean response based on the current user being authorized to download within the system. * *
- * GET pentaho/api/repo/files/canDownload + * GET pentaho/api/repo/files/canDownload *Example Response:
@@ -2263,12 +2237,12 @@ public FileVersioningConfiguration doVersioningConfiguration( @PathParam( "pathI *Example Request:
* - * @param dirPath to be validated for upload action for the current user. - * + * @param dirPath to be validated for upload action for the current user. * @return A boolean response based on the current user being authorized to upload to given dir * *
- * GET pentaho/api/repo/files/canUpload + * GET pentaho/api/repo/files/canUpload *Example Response:
@@ -2289,12 +2262,12 @@ public Response canDownload( @QueryParam ( "dirPath" ) @DefaultValue( "" ) Strin ** RFC 2253 - The names of security principal objects can contain all Unicode characters except the special LDAP * characters defined in RFC 2253. This list of special characters includes: a leading space; a trailing space; * and any of the following characters: # , + " \ < > ; diff --git a/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/RepositoryImportResource.java b/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/RepositoryImportResource.java index bd25336bcc3..a583160e0ff 100644 --- a/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/RepositoryImportResource.java +++ b/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/RepositoryImportResource.java @@ -50,7 +50,7 @@ import java.util.List; import java.util.stream.Collectors; -@Path ( "/repo/files/import" ) +@Path( "/repo/files/import" ) public class RepositoryImportResource { private static final Logger LOGGER = LogManager.getLogger( RepositoryImportResource.class ); @@ -61,9 +61,9 @@ public class RepositoryImportResource { * Attempts to import all files from the zip archive or single file. A log file is produced at the end of import. * *
Example Request:
- * POST pentaho/api/repo/files/import - *
POST data: - *+ * POST pentaho/api/repo/files/import + ** @param acl Acl of the repository file
POST data: + ** ------WebKitFormBoundaryB9hzsGp4wR5SGAZD * Content-Disposition: form-data; name="importDir" * @@ -115,7 +115,6 @@ public class RepositoryImportResource { * @param fileNameOverride If present and the content represents a single file, this parameter contains the filename to use * when storing the file in the repository. If not present, the fileInfo.getFileName will be used. * Note that the later cannot reliably handle foreign character sets. - * * @return A jax-rs Response object with the appropriate header and body. * **/ @POST - @Consumes ( MediaType.MULTIPART_FORM_DATA ) - @Produces ( MediaType.TEXT_HTML ) + @Consumes( MediaType.MULTIPART_FORM_DATA ) + @Produces( MediaType.TEXT_HTML ) @Facet( name = "Unsupported" ) - public Response doPostImport( @FormDataParam ( "importDir" ) String importDir, - @FormDataParam ( "fileUpload" ) InputStream fileUpload, - @FormDataParam ( "overwriteFile" ) String overwriteFile, - @FormDataParam ( "overwriteAclPermissions" ) String overwriteAclPermissions, - @FormDataParam ( "applyAclPermissions" ) String applyAclPermission, - @FormDataParam ( "retainOwnership" ) String retainOwnership, - @FormDataParam ( "charSet" ) String charSet, - @FormDataParam ( "logLevel" ) String logLevel, - @FormDataParam ( "fileUpload" ) FormDataContentDisposition fileInfo, - @FormDataParam ( "fileNameOverride" ) String fileNameOverride ) { - return doPostImportCommon( importDir, Arrays.asList( fileUpload ), overwriteFile, overwriteAclPermissions, applyAclPermission, - retainOwnership, charSet, logLevel, fileInfo, fileNameOverride ); + public Response doPostImport( @FormDataParam( "importDir" ) String importDir, + @FormDataParam( "fileUpload" ) InputStream fileUpload, + @FormDataParam( "overwriteFile" ) String overwriteFile, + @FormDataParam( "overwriteAclPermissions" ) String overwriteAclPermissions, + @FormDataParam( "applyAclPermissions" ) String applyAclPermission, + @FormDataParam( "retainOwnership" ) String retainOwnership, + @FormDataParam( "charSet" ) String charSet, + @FormDataParam( "logLevel" ) String logLevel, + @FormDataParam( "fileUpload" ) FormDataContentDisposition fileInfo, + @FormDataParam( "fileNameOverride" ) String fileNameOverride ) { + return doPostImportCommon( importDir, Arrays.asList( fileUpload ), overwriteFile, overwriteAclPermissions, applyAclPermission, + retainOwnership, charSet, logLevel, fileInfo, fileNameOverride ); } protected void validateImportAccess( String importDir ) throws PentahoAccessControlException { @@ -197,25 +196,25 @@ protected void validateImportAccess( String importDir ) throws PentahoAccessCont * @return */ @POST() - @Path ( "/multiple" ) - @Consumes ( MediaType.MULTIPART_FORM_DATA ) - @Produces ( MediaType.TEXT_HTML ) + @Path( "/multiple" ) + @Consumes( MediaType.MULTIPART_FORM_DATA ) + @Produces( MediaType.TEXT_HTML ) @Facet( name = "Unsupported" ) - public Response doPostImport( @FormDataParam ( "importDir" ) String importDir, - @FormDataParam ( "fileUpload" ) ListExample Response:
@@ -156,21 +155,21 @@ public class RepositoryImportResource { *fileParts, - @FormDataParam ( "overwriteFile" ) String overwriteFile, - @FormDataParam ( "overwriteAclPermissions" ) String overwriteAclPermissions, - @FormDataParam ( "applyAclPermissions" ) String applyAclPermission, - @FormDataParam ( "retainOwnership" ) String retainOwnership, - @FormDataParam ( "charSet" ) String charSet, - @FormDataParam ( "logLevel" ) String logLevel, - @FormDataParam ( "fileUpload" ) FormDataContentDisposition fileInfo, - @FormDataParam ( "fileNameOverride" ) String fileNameOverride ) { + public Response doPostImport( @FormDataParam( "importDir" ) String importDir, + @FormDataParam( "fileUpload" ) List fileParts, + @FormDataParam( "overwriteFile" ) String overwriteFile, + @FormDataParam( "overwriteAclPermissions" ) String overwriteAclPermissions, + @FormDataParam( "applyAclPermissions" ) String applyAclPermission, + @FormDataParam( "retainOwnership" ) String retainOwnership, + @FormDataParam( "charSet" ) String charSet, + @FormDataParam( "logLevel" ) String logLevel, + @FormDataParam( "fileUpload" ) FormDataContentDisposition fileInfo, + @FormDataParam( "fileNameOverride" ) String fileNameOverride ) { List fileUploads = fileParts.stream() - .map(part -> part.getValueAs( InputStream.class )) - .collect( Collectors.toList() ); + .map( part -> part.getValueAs( InputStream.class ) ) + .collect( Collectors.toList() ); return doPostImportCommon( importDir, fileUploads, overwriteFile, overwriteAclPermissions, applyAclPermission, - retainOwnership, charSet, logLevel, fileInfo, fileNameOverride ); + retainOwnership, charSet, logLevel, fileInfo, fileNameOverride ); } /** @@ -234,14 +233,14 @@ public Response doPostImport( @FormDataParam ( "importDir" ) String importDir, * @return */ private Response doPostImportCommon( String importDir, List fileUploads, String overwriteFile, - String overwriteAclPermissions, String applyAclPermission, String retainOwnership, - String charSet, String logLevel, FormDataContentDisposition fileInfo, - String fileNameOverride ) { + String overwriteAclPermissions, String applyAclPermission, String retainOwnership, + String charSet, String logLevel, FormDataContentDisposition fileInfo, + String fileNameOverride ) { IRepositoryImportLogger importLogger = null; ByteArrayOutputStream importLoggerStream = new ByteArrayOutputStream(); boolean logJobStarted = false; - if (StringUtils.isBlank( charSet )) { + if ( StringUtils.isBlank( charSet ) ) { charSet = DEFAULT_CHAR_SET; } @@ -272,12 +271,12 @@ private Response doPostImportCommon( String importDir, List fileUpl importLogger = importer.getRepositoryImportLogger(); importLogger.startJob( importLoggerStream, importDir, level ); - List fileNameOverrides = Arrays.asList( fileNameOverride.split(",") ); + List fileNameOverrides = Arrays.asList( fileNameOverride.split( "," ) ); for ( int i = 0; i < fileNameOverrides.size(); i++ ) { - InputStream fileUpload = fileUploads.get(i); + InputStream fileUpload = fileUploads.get( i ); - String fileName = fileNameOverrides.get(i); + String fileName = fileNameOverrides.get( i ); RepositoryFileImportBundle.Builder bundleBuilder = new RepositoryFileImportBundle.Builder(); bundleBuilder.input( fileUpload ); @@ -297,12 +296,13 @@ private Response doPostImportCommon( String importDir, List fileUpl } bundleBuilder.mime( mimeTypeFromFile ); + importer.getRepositoryImportLogger().setPerformingRestore( false ); importer.importFile( bundle ); } // Flush the Mondrian cache to show imported data-sources. IMondrianCatalogService mondrianCatalogService = PentahoSystem.get( IMondrianCatalogService.class, "IMondrianCatalogService", - PentahoSessionHolder.getSession() ); + PentahoSessionHolder.getSession() ); mondrianCatalogService.reInit( PentahoSessionHolder.getSession() ); logJobStarted = true; } catch ( Exception e ) { diff --git a/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/services/FileService.java b/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/services/FileService.java index 9860af02bfc..e2903f583b1 100644 --- a/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/services/FileService.java +++ b/extensions/src/main/java/org/pentaho/platform/web/http/api/resources/services/FileService.java @@ -40,7 +40,9 @@ import org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto; import org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto; import org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto; +import org.pentaho.platform.api.importexport.ExportException; import org.pentaho.platform.api.util.IPentahoPlatformExporter; +import org.pentaho.platform.api.util.IRepositoryExportLogger; import org.pentaho.platform.engine.core.system.PentahoSessionHolder; import org.pentaho.platform.engine.core.system.PentahoSystem; import org.pentaho.platform.plugin.services.exporter.PentahoPlatformExporter; @@ -49,7 +51,7 @@ import org.pentaho.platform.plugin.services.importer.RepositoryFileImportBundle; import org.pentaho.platform.plugin.services.importexport.BaseExportProcessor; import org.pentaho.platform.plugin.services.importexport.DefaultExportHandler; -import org.pentaho.platform.plugin.services.importexport.ExportException; +import org.pentaho.platform.plugin.services.importexport.RepositoryTextLayout; import org.pentaho.platform.plugin.services.importexport.ExportHandler; import org.pentaho.platform.plugin.services.importexport.IRepositoryImportLogger; import org.pentaho.platform.plugin.services.importexport.ImportSession; @@ -82,6 +84,7 @@ import javax.ws.rs.core.StreamingOutput; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -95,6 +98,8 @@ import java.security.GeneralSecurityException; import java.security.InvalidParameterException; import java.text.Collator; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -131,29 +136,86 @@ public class FileService { private PentahoPlatformExporter backupExporter; - public DownloadFileWrapper systemBackup( String userAgent ) throws IOException, ExportException { + private void validateFilePath( String logFile ) throws IllegalArgumentException { + if ( logFile.contains( ".." ) || logFile.contains( "//" ) || logFile.contains( "\\\\" ) || ( !logFile.endsWith( ".txt" ) && !logFile.endsWith( ".log" ) ) ) { + throw new IllegalArgumentException( Messages.getInstance().getString( "FileService.ERROR_INVALID_LOG_FILENAME", logFile ) ); + } + } + + public DownloadFileWrapper systemBackup( String logFile, String logLevel, String outputFile ) throws IllegalArgumentException, IOException, ExportException { if ( doCanAdminister() ) { - String originalFileName; String encodedFileName; - originalFileName = "SystemBackup.zip"; - encodedFileName = makeEncodedFileName( originalFileName ); - StreamingOutput streamingOutput = getBackupStream(); - final String attachment = HttpMimeTypeListener.buildContentDispositionValue( originalFileName, true ); + encodedFileName = makeEncodedFileName( outputFile ); + IRepositoryExportLogger exportLogger; + Level level = Level.valueOf( logLevel ); + FileOutputStream fileOutputStream = null; + try { + validateFilePath( logFile ); + fileOutputStream = new FileOutputStream( logFile ); + } catch ( FileNotFoundException e ) { + try { + fileOutputStream = retrieveFallbackLogFileLocation( "backup" ); + } catch ( FileNotFoundException fileNotFoundException ) { + throw new ExportException( fileNotFoundException ); + } + } + ByteArrayOutputStream exportLoggerSream = new ByteArrayOutputStream(); + IPentahoPlatformExporter exporter = PentahoSystem.get( IPentahoPlatformExporter.class ); + if ( exporter == null ) { + logger.error( Messages.getInstance().getString( "FileService.ERROR_UNABLE_TO_GET_PLATFORM_EXPORTER" ) ); + throw new ExportException( Messages.getInstance().getString( "FileService.ERROR_UNABLE_TO_GET_PLATFORM_EXPORTER" ) ); + } + exportLogger = exporter.getRepositoryExportLogger(); + if ( exportLogger == null ) { + logger.error( Messages.getInstance().getString( "FileService.ERROR_UNABLE_TO_GET_EXPORT_LOGGER" ) ); + throw new ExportException( Messages.getInstance().getString( "FileService.ERROR_UNABLE_TO_GET_EXPORT_LOGGER" ) ); + } + RepositoryTextLayout stringLayout = new RepositoryTextLayout( level ); + exportLogger.startJob( exportLoggerSream, level, stringLayout ); + StreamingOutput streamingOutput = getBackupStream(); + exportLogger.endJob(); + try { + exportLoggerSream.writeTo( fileOutputStream ); + } catch ( IOException e ) { + logger.error( e.getLocalizedMessage() ); + } + final String attachment = HttpMimeTypeListener.buildContentDispositionValue( outputFile, true ); return new DownloadFileWrapper( streamingOutput, attachment, encodedFileName ); } else { throw new SecurityException(); } } + public FileOutputStream retrieveFallbackLogFileLocation( String filePrefix ) throws FileNotFoundException { + String defaultBaseDir = System.getProperty( "java.io.tmpdir" ); + // Get the current timestamp + SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyyMMdd_HHmmss" ); + String timestamp = dateFormat.format( new Date() ); + String fallbacklogFilePath = defaultBaseDir + File.pathSeparator + filePrefix + "_" + timestamp + ".log"; + return new FileOutputStream( fallbacklogFilePath ); + } + public void systemRestore( final InputStream fileUpload, String overwriteFile, - String applyAclSettings, String overwriteAclSettings ) throws PlatformImportException, SecurityException { + String applyAclSettings, String overwriteAclSettings, String logFile, String logLevel, String backupBundlePath ) throws IllegalArgumentException, PlatformImportException, SecurityException { if ( doCanAdminister() ) { boolean overwriteFileFlag = !"false".equals( overwriteFile ); boolean applyAclSettingsFlag = !"false".equals( applyAclSettings ); boolean overwriteAclSettingsFlag = "true".equals( overwriteAclSettings ); IRepositoryImportLogger importLogger; - Level level = Level.ERROR; + Level level = Level.valueOf( logLevel ); + + FileOutputStream fileOutputStream = null; + try { + validateFilePath( logFile ); + fileOutputStream = new FileOutputStream( logFile ); + } catch ( FileNotFoundException e ) { + try { + fileOutputStream = retrieveFallbackLogFileLocation( "restore" ); + } catch ( FileNotFoundException fileNotFoundException ) { + throw new PlatformImportException( fileNotFoundException.getLocalizedMessage() ); + } + } ByteArrayOutputStream importLoggerStream = new ByteArrayOutputStream(); String importDirectory = "/"; RepositoryFileImportBundle.Builder bundleBuilder = new RepositoryFileImportBundle.Builder(); @@ -163,7 +225,7 @@ public void systemRestore( final InputStream fileUpload, String overwriteFile, bundleBuilder.schedulable( RepositoryFile.SCHEDULABLE_BY_DEFAULT ); bundleBuilder.path( importDirectory ); bundleBuilder.overwriteFile( overwriteFileFlag ); - bundleBuilder.name( "SystemBackup.zip" ); + bundleBuilder.name( backupBundlePath ); bundleBuilder.applyAclSettings( applyAclSettingsFlag ); bundleBuilder.overwriteAclSettings( overwriteAclSettingsFlag ); bundleBuilder.retainOwnership( true ); @@ -173,11 +235,18 @@ public void systemRestore( final InputStream fileUpload, String overwriteFile, IPlatformImporter importer = PentahoSystem.get( IPlatformImporter.class ); importLogger = importer.getRepositoryImportLogger(); - importLogger.startJob( importLoggerStream, importDirectory, level ); + RepositoryTextLayout stringLayout = new RepositoryTextLayout( level ); + importLogger.setPerformingRestore( true ); + importLogger.startJob( importLoggerStream, importDirectory, level, stringLayout ); try { importer.importFile( bundleBuilder.build() ); } finally { importLogger.endJob(); + try { + importLoggerStream.writeTo( fileOutputStream ); + } catch ( IOException e ) { + e.printStackTrace(); + } } } else { throw new SecurityException(); @@ -208,7 +277,7 @@ public void doDeleteFiles( String params ) throws Exception { String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray( params ); try { for ( int i = 0; i < sourceFileIds.length; i++ ) { - getRepoWs().deleteFile( sourceFileIds[i], null ); + getRepoWs().deleteFile( sourceFileIds[ i ], null ); } } catch ( Exception e ) { throw e; @@ -259,9 +328,9 @@ public List doGetCanAccessList( String pathId, String permissions ) { ArrayList permMap = new ArrayList (); while ( tokenizer.hasMoreTokens() ) { Integer perm = Integer.valueOf( tokenizer.nextToken() ); - EnumSet permission = EnumSet.of( RepositoryFilePermission.values()[perm] ); + EnumSet permission = EnumSet.of( RepositoryFilePermission.values()[ perm ] ); permMap.add( new Setting( perm.toString(), new Boolean( getRepository() - .hasAccess( idToPath( pathId ), permission ) ).toString() ) ); + .hasAccess( idToPath( pathId ), permission ) ).toString() ) ); } return permMap; } @@ -270,9 +339,9 @@ public List doGetPathsAccessList( StringListWrapper pathsWrapper ) { List pathsPermissonsSettings = new ArrayList (); String permissions = - RepositoryFilePermission.READ.ordinal() + "|" + RepositoryFilePermission.WRITE.ordinal() + "|" - + RepositoryFilePermission.DELETE.ordinal() + "|" + RepositoryFilePermission.ACL_MANAGEMENT.ordinal() + "|" - + RepositoryFilePermission.ALL.ordinal(); + RepositoryFilePermission.READ.ordinal() + "|" + RepositoryFilePermission.WRITE.ordinal() + "|" + + RepositoryFilePermission.DELETE.ordinal() + "|" + RepositoryFilePermission.ACL_MANAGEMENT.ordinal() + "|" + + RepositoryFilePermission.ALL.ordinal(); List paths = pathsWrapper.getStrings(); for ( String path : paths ) { @@ -298,7 +367,7 @@ public List doGetPathsAccessList( StringListWrapper pathsWrapper ) { * @throws IOException */ public void createFile( String charsetName, String pathId, InputStream fileContents ) - throws Exception { + throws Exception { try { if ( FileUtils.containsControlCharacters( pathId ) ) { throw new InvalidNameException(); @@ -323,14 +392,13 @@ public void createFile( String charsetName, String pathId, InputStream fileConte * Moves a list of files from its current location to another, the list should be comma separated. * * @param destPathId colon separated path for the repository file - * - * :path:to:file:id - *- * @param params comma separated list of files to be moved - *- * path1,path2,... - *- * + *+ * :path:to:file:id + *+ * @param params comma separated list of files to be moved + *+ * path1,path2,... + ** @return booleantrue
if all files were moved correctly orfalse
if the destiny path is * not available * @throws FileNotFoundException @@ -379,13 +447,12 @@ public void doRestoreFiles( String params ) throws InternalError { } /** - * * Restores a list of files from the trash folder to user's home folder, * ignoring files previous locations (with no change of file owner) - * @param params Comma separated list of files to be restored - * @param overwriteMode Default is RENAME (2) which adds a number to the end of the file name. MODE_OVERWRITE (1) - * will just replace existing or MODE_NO_OVERWRITE (3) will not copy if file exist. * + * @param params Comma separated list of files to be restored + * @param overwriteMode Default is RENAME (2) which adds a number to the end of the file name. MODE_OVERWRITE (1) + * will just replace existing or MODE_NO_OVERWRITE (3) will not copy if file exist. */ public boolean doRestoreFilesInHomeDir( String params, int overwriteMode ) { if ( overwriteMode < 1 || overwriteMode > 3 ) { @@ -393,7 +460,7 @@ public boolean doRestoreFilesInHomeDir( String params, int overwriteMode ) { } String userHomeFolderPath = - ClientRepositoryPaths.getUserHomeFolderPath( getSession().getName() ); + ClientRepositoryPaths.getUserHomeFolderPath( getSession().getName() ); String filesToDeletePermanent = null; if ( overwriteMode == MODE_RENAME ) { @@ -473,14 +540,10 @@ public String getFolderFileIdsThatConflictWithSource( String pathToFolder, Strin * Conflict occurs if one of source files has the same * name with any of folder files. * - * @param params - * String with file ids, separated by comma - * @param pathToFolder - * path to folder - * + * @param params String with file ids, separated by comma + * @param pathToFolder path to folder * @return String - * with file ids of not conflict files, separated by comma - * + * with file ids of not conflict files, separated by comma */ protected String getSourceFileIdsThatNotConflictWithFolderFiles( String pathToFolder, String params ) { String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray( params ); @@ -510,13 +573,9 @@ protected String getSourceFileIdsThatNotConflictWithFolderFiles( String pathToFo } /** - * - * @param fileIdsList - * List with file ids. - * @return - * - String of file ids, separated by comma - * - Empty String if {@code fileIdList} is null or empty - * + * @param fileIdsList List with file ids. + * @return - String of file ids, separated by comma + * - Empty String if {@code fileIdList} is null or empty */ protected String getCommaSeparatedFileIds( ListfileIdsList ) { if ( fileIdsList == null || fileIdsList.size() == 0 ) { @@ -563,11 +622,11 @@ public String getEncodedFileName() { } public DownloadFileWrapper doGetFileOrDirAsDownload( String userAgent, String pathId, String strWithManifest ) - throws Throwable { + throws Throwable { // change file id to path String path = idToPath( pathId ); validateDownloadAccess( path ); - IAuthorizationPolicy policy = getPolicy(); + IAuthorizationPolicy policy = getPolicy(); String originalFileName, encodedFileName = null; @@ -603,7 +662,7 @@ public DownloadFileWrapper doGetFileOrDirAsDownload( String userAgent, String pa StreamingOutput streamingOutput = getDownloadStream( repositoryFile, exportProcessor ); return new DownloadFileWrapper( streamingOutput, HttpMimeTypeListener.buildContentDispositionValue( - originalFileName, true ), encodedFileName ); + originalFileName, true ), encodedFileName ); } private String makeEncodedFileName( String originalFile ) throws UnsupportedEncodingException { @@ -649,7 +708,7 @@ public RepositoryFileToStreamWrapper doGetFileAsInline( String pathId ) throws F try { SimpleRepositoryFileData fileData = - getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ); + getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ); final InputStream is = fileData.getInputStream(); // copy streaming output @@ -662,7 +721,7 @@ public RepositoryFileToStreamWrapper doGetFileAsInline( String pathId ) throws F return wrapper; } catch ( Exception e ) { logger.error( Messages.getInstance().getString( - "FileResource.EXPORT_FAILED", repositoryFile.getName() + " " + e.getMessage() ), e ); + "FileResource.EXPORT_FAILED", repositoryFile.getName() + " " + e.getMessage() ), e ); throw new InternalError(); } } @@ -699,7 +758,7 @@ public List doGetLocaleProperties( String pathId, Strin * @param properties */ public void doSetLocaleProperties( String pathId, String locale, List properties ) - throws Exception { + throws Exception { RepositoryFileDto file = getRepoWs().getFile( idToPath( pathId ) ); Properties fileProperties = new Properties(); if ( properties != null && !properties.isEmpty() ) { @@ -730,7 +789,7 @@ public void doCopyFiles( String pathId, Integer mode, String params ) { String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray( params ); //$NON-NLS-1$ CopyFilesOperation copyFilesOperation = - new CopyFilesOperation( getRepository(), getRepoWs(), Arrays.asList( sourceFileIds ), path, mode ); + new CopyFilesOperation( getRepository(), getRepoWs(), Arrays.asList( sourceFileIds ), path, mode ); copyFilesOperation.execute(); } @@ -779,13 +838,13 @@ public RepositoryFileToStreamWrapper doGetFileOrDir( String pathId ) throws File /** * Save the acls of the selected file to the repository - * + * * This method is used to update and save the acls of the selected file to the repository * * @param pathId @param pathId colon separated path for the repository file *
- * :path:to:file:id - *+ * :path:to:file:id + *RepositoryFileAclDto
* @throws FileNotFoundException */ @@ -810,6 +869,7 @@ public void setFileAcls( String pathId, RepositoryFileAclDto acl ) throws FileNo } getRepoWs().updateAcl( acl ); } + /** * Check whether the selected repository folder is visible to the current user * @@ -817,8 +877,8 @@ public void setFileAcls( String pathId, RepositoryFileAclDto acl ) throws FileNo * @return true or false */ public String doGetIsVisible( String pathId ) { - RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); - return repositoryFileDto != null && repositoryFileDto.isHidden() ? "false" : "true"; + RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); + return repositoryFileDto != null && repositoryFileDto.isHidden() ? "false" : "true"; } /** @@ -828,7 +888,7 @@ public String doGetIsVisible( String pathId ) { * @return true or false */ public boolean isFolder( String pathId ) { - RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); + RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); return repositoryFileDto != null && repositoryFileDto.isFolder(); } @@ -839,7 +899,7 @@ public boolean isFolder( String pathId ) { * @return true or false */ public boolean doesExist( String pathId ) { - RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); + RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); return repositoryFileDto != null && repositoryFileDto.getId() != null; } @@ -859,38 +919,38 @@ private boolean isInsideOfAnyHiddenFolder( RepositoryFileDto repositoryFileDto ) } return isInsideOfAnyHiddenFolder( getRepoWs().getFile( idToPath( parentPathId ) ) ); } + /** - * * @param pathId * @return default path to where user can save or open the artifact */ public String doGetDefaultLocation( String pathId ) { - RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); + RepositoryFileDto repositoryFileDto = getRepoWs().getFile( idToPath( pathId ) ); if ( repositoryFileDto == null ) { return ClientRepositoryPaths.getRootFolderPath(); } else if ( isInsideOfAnyHiddenFolder( repositoryFileDto ) ) { String defaultFolder = PentahoSystem.get( ISystemConfig.class ) - .getProperty( PentahoSystem.DEFAULT_FOLDER_WHEN_HOME_FOLDER_IS_HIDDEN_PROPERTY ); + .getProperty( PentahoSystem.DEFAULT_FOLDER_WHEN_HOME_FOLDER_IS_HIDDEN_PROPERTY ); if ( defaultFolder != null && defaultFolder.length() > 0 ) { repositoryFileDto = getRepoWs().getFile( defaultFolder ); if ( repositoryFileDto == null ) { return ClientRepositoryPaths.getRootFolderPath(); } else if ( isInsideOfAnyHiddenFolder( repositoryFileDto ) ) { - repositoryFileDto = getRepoWs().getFile( ClientRepositoryPaths.getPublicFolderPath() ); + repositoryFileDto = getRepoWs().getFile( ClientRepositoryPaths.getPublicFolderPath() ); if ( isInsideOfAnyHiddenFolder( repositoryFileDto ) ) { return ClientRepositoryPaths.getRootFolderPath(); } else { - return ClientRepositoryPaths.getPublicFolderPath(); + return ClientRepositoryPaths.getPublicFolderPath(); } } else { return defaultFolder; } } else { - repositoryFileDto = getRepoWs().getFile( ClientRepositoryPaths.getPublicFolderPath() ); + repositoryFileDto = getRepoWs().getFile( ClientRepositoryPaths.getPublicFolderPath() ); if ( isInsideOfAnyHiddenFolder( repositoryFileDto ) ) { return ClientRepositoryPaths.getRootFolderPath(); } else { - return ClientRepositoryPaths.getPublicFolderPath(); + return ClientRepositoryPaths.getPublicFolderPath(); } } } else { @@ -975,8 +1035,8 @@ public RepositoryFileDto doGetRootProperties() { * * @param pathId @param pathId colon separated path for the repository file *- * :path:to:file:id - *+ * :path:to:file:id + *RepositoryFileDto
* @throws FileNotFoundException */ @@ -987,6 +1047,7 @@ public RepositoryFileDto doGetProperties( String pathId ) throws FileNotFoundExc } return file; } + /** * Gets the permission for whether or not a user can edit files * @@ -994,7 +1055,7 @@ public RepositoryFileDto doGetProperties( String pathId ) throws FileNotFoundExc */ public String doGetCanEdit() { String editPermission = PentahoSystem.getSystemSetting( "edit-permission", "" ); - if( editPermission != null && editPermission.length() > 0 ) { + if ( editPermission != null && editPermission.length() > 0 ) { return getPolicy().isAllowed( editPermission ) ? "true" : "false"; } else { return "true"; @@ -1095,10 +1156,10 @@ public void doSetMetadata( String pathId, Listmetadata RepositoryFileAclDto fileAcl = getRepoWs().getAcl( file.getId() ); boolean canManage = - getSession().getName().equals( fileAcl.getOwner() ) - || ( getPolicy().isAllowed( RepositoryReadAction.NAME ) - && getPolicy().isAllowed( RepositoryCreateAction.NAME ) && getPolicy().isAllowed( - AdministerSecurityAction.NAME ) ); + getSession().getName().equals( fileAcl.getOwner() ) + || ( getPolicy().isAllowed( RepositoryReadAction.NAME ) + && getPolicy().isAllowed( RepositoryCreateAction.NAME ) && getPolicy().isAllowed( + AdministerSecurityAction.NAME ) ); if ( !canManage ) { @@ -1111,7 +1172,7 @@ && getPolicy().isAllowed( RepositoryCreateAction.NAME ) && getPolicy().isAllowed RepositoryFileAclAceDto acl = fileAcl.getAces().get( i ); if ( acl.getRecipient().equals( getSession().getName() ) ) { if ( acl.getPermissions().contains( RepositoryFilePermission.ACL_MANAGEMENT.ordinal() ) - || acl.getPermissions().contains( RepositoryFilePermission.ALL.ordinal() ) ) { + || acl.getPermissions().contains( RepositoryFilePermission.ALL.ordinal() ) ) { canManage = true; break; } @@ -1203,16 +1264,11 @@ public boolean isPath( String pathId ) { } /** - * - * @param params - * id of files, separated by ',' - * + * @param params id of files, separated by ',' * @return false if homeFolder has files - * with names and extension equal to passed files - * true otherwise - * - * @throws IllegalArgumentException - * if {@code params} is null + * with names and extension equal to passed files + * true otherwise + * @throws IllegalArgumentException if {@code params} is null */ public boolean canRestoreToFolderWithNoConflicts( String pathToFolder, String params ) { if ( params == null ) { @@ -1242,54 +1298,54 @@ public IAuthorizationPolicy getPolicy() { /** * Store content creator of the selected repository file * - * @param pathId colon separated path for the repository file - * - * :path:to:file:id - *+ * @param pathId colon separated path for the repository file + *+ * :path:to:file:id + ** @param contentCreator repository file - *- * - * <repositoryFileDto> - * <createdDate>1402911997019</createdDate> - * <fileSize>3461</fileSize> - * <folder>false</folder> - * <hidden>false</hidden> - * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> - * <lastModifiedDate>1406647160536</lastModifiedDate> - * <locale>en</locale> - * <localePropertiesMapEntries> - * <localeMapDto> - * <locale>default</locale> - * <properties> - * <stringKeyStringValueDto> - * <key>file.title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>jcr:primaryType</key> - * <value>nt:unstructured</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>title</key> - * <value>myFile</value> - * </stringKeyStringValueDto> - * <stringKeyStringValueDto> - * <key>file.description</key> - * <value>myFile Description</value> - * </stringKeyStringValueDto> - * </properties> - * </localeMapDto> - * </localePropertiesMapEntries> - * <locked>false</locked> - * <name>myFile.prpt</name></name> - * <originalParentFolderPath>/public/admin</originalParentFolderPath> - * <ownerType>-1</ownerType> - * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> - * <title>myFile</title> - * <versionId>1.9</versionId> - * <versioned>true</versioned> - * </repositoryFileAclDto> - *+ *+ * + * <repositoryFileDto> + * <createdDate>1402911997019</createdDate> + * <fileSize>3461</fileSize> + * <folder>false</folder> + * <hidden>false</hidden> + * <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id> + * <lastModifiedDate>1406647160536</lastModifiedDate> + * <locale>en</locale> + * <localePropertiesMapEntries> + * <localeMapDto> + * <locale>default</locale> + * <properties> + * <stringKeyStringValueDto> + * <key>file.title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>jcr:primaryType</key> + * <value>nt:unstructured</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>title</key> + * <value>myFile</value> + * </stringKeyStringValueDto> + * <stringKeyStringValueDto> + * <key>file.description</key> + * <value>myFile Description</value> + * </stringKeyStringValueDto> + * </properties> + * </localeMapDto> + * </localePropertiesMapEntries> + * <locked>false</locked> + * <name>myFile.prpt</name></name> + * <originalParentFolderPath>/public/admin</originalParentFolderPath> + * <ownerType>-1</ownerType> + * <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path> + * <title>myFile</title> + * <versionId>1.9</versionId> + * <versioned>true</versioned> + * </repositoryFileAclDto> + ** @throws FileNotFoundException */ public void doSetContentCreator( String pathId, RepositoryFileDto contentCreator ) throws FileNotFoundException { @@ -1310,11 +1366,11 @@ public void doSetContentCreator( String pathId, RepositoryFileDto contentCreator * Retrieves the list of locale map for the selected repository file. The list will be empty if a problem occurs. * * @param pathId colon separated path for the repository file - *- * :path:to:file:id - *+ *+ * :path:to:file:id + ** @returnList
the list of locales - *+ ** * <localePropertiesMapEntries> * <localeMapDto> @@ -1372,8 +1428,8 @@ public boolean doCanAdminister() { boolean status = false; try { status = getPolicy().isAllowed( RepositoryReadAction.NAME ) - && getPolicy().isAllowed( RepositoryCreateAction.NAME ) - && getPolicy().isAllowed( AdministerSecurityAction.NAME ); + && getPolicy().isAllowed( RepositoryCreateAction.NAME ) + && getPolicy().isAllowed( AdministerSecurityAction.NAME ); } catch ( Exception e ) { logger.error( Messages.getInstance().getString( "SystemResource.CAN_ADMINISTER" ), e ); } @@ -1391,7 +1447,7 @@ public RepositoryFileAclDto doGetFileAcl( String pathId ) { RepositoryFileAclDto fileAcl = getRepoWs().getAcl( file.getId() ); if ( fileAcl.isEntriesInheriting() ) { Listaces = - getRepoWs().getEffectiveAcesWithForceFlag( file.getId(), fileAcl.isEntriesInheriting() ); + getRepoWs().getEffectiveAcesWithForceFlag( file.getId(), fileAcl.isEntriesInheriting() ); fileAcl.setAces( aces, fileAcl.isEntriesInheriting() ); } addAdminRole( fileAcl ); @@ -1400,7 +1456,7 @@ public RepositoryFileAclDto doGetFileAcl( String pathId ) { protected void addAdminRole( RepositoryFileAclDto fileAcl ) { String adminRoleName = - PentahoSystem.get( String.class, "singleTenantAdminAuthorityName", PentahoSessionHolder.getSession() ); + PentahoSystem.get( String.class, "singleTenantAdminAuthorityName", PentahoSessionHolder.getSession() ); if ( fileAcl.getAces() == null ) { fileAcl.setAces( new LinkedList () ); } @@ -1445,7 +1501,7 @@ public RepositoryFileTreeDto doGetTree( String pathId, Integer depth, String fil } //translating /home and /public folders titles - for ( RepositoryFileTreeDto dto : tree.getChildren( ) ) { + for ( RepositoryFileTreeDto dto : tree.getChildren() ) { if ( dto.getFile().getName().equals( ClientRepositoryPaths.getHomeFolderName() ) && dto.getFile().getPath().equals( ClientRepositoryPaths.getHomeFolderPath() ) ) { dto.getFile().setTitle( Messages.getInstance().getString( "FileResource.HOME_FOLDER_DISPLAY_TITLE" ) ); } else if ( dto.getFile().getName().equals( ClientRepositoryPaths.getPublicFolderName() ) && dto.getFile().getPath().equals( ClientRepositoryPaths.getPublicFolderPath() ) ) { @@ -1521,7 +1577,7 @@ public List doGetGeneratedContent( String pathId, String user * @private */ private List doGetGeneratedContentForUser( String pathId, String userDir ) - throws FileNotFoundException { + throws FileNotFoundException { RepositoryFileDto targetFile = doGetProperties( pathId ); if ( targetFile != null ) { String targetFileId = targetFile.getId(); @@ -1542,7 +1598,7 @@ private List doGetGeneratedContentForUser( String pathId, Str */ public List searchGeneratedContent( String userDir, String targetComparator, String metadataConstant ) - throws FileNotFoundException { + throws FileNotFoundException { List content = new ArrayList (); RepositoryFile workspaceFolder = getRepository().getFile( userDir ); @@ -1600,7 +1656,7 @@ public boolean doRename( String pathId, String newName ) throws Exception { // If destination already exists throw if ( repository.getFile( buf.toString() ) != null ) { throw new IllegalArgumentException( org.pentaho.platform.repository2.messages.Messages.getInstance().getString( - "JcrRepositoryFileDao.ERROR_0003_ILLEGAL_DEST_PATH" ) ); + "JcrRepositoryFileDao.ERROR_0003_ILLEGAL_DEST_PATH" ) ); } repository.moveFile( fileToBeRenamed.getId(), buf.toString(), "Renaming the file" ); RepositoryFile movedFile = repository.getFileById( fileToBeRenamed.getId() ); @@ -1625,8 +1681,8 @@ public boolean doRename( String pathId, String newName ) throws Exception { } } RepositoryFile updatedFile = - new RepositoryFile.Builder( movedFile ).localePropertiesMap( localePropertiesMap ).name( newName ).title( - newName ).build(); + new RepositoryFile.Builder( movedFile ).localePropertiesMap( localePropertiesMap ).name( newName ).title( + newName ).build(); repository.updateFile( updatedFile, RepositoryFileHelper.getFileData( movedFile ), "Updating the file" ); } return true; @@ -1639,12 +1695,12 @@ public boolean doRename( String pathId, String newName ) throws Exception { /** * Creates a new folder with the specified name * - * @param pathId The path from the root folder to the root node of the tree to return using colon characters in - * place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file - * - * :path:to:file - *- * @return A jax-rs Response object with the appropriate status code, header, and body. + * @param pathId The path from the root folder to the root node of the tree to return using colon characters in + * place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file + *+ * :path:to:file + *+ * @return A jax-rs Response object with the appropriate status code, header, and body. * @deprecated use {@link #doCreateDirSafe(String)} instead */ @Deprecated @@ -1711,7 +1767,7 @@ public boolean isValidFolderName( String path ) { * [pentaho-commons-gwt-modules] org.pentaho.gwt.widgets.client.utils.NameUtils#isValidFolderName */ if ( FileUtils.containsReservedCharacter( path, doGetReservedChars().toString().toCharArray() ) - || FileUtils.containsControlCharacters( path ) ) { + || FileUtils.containsControlCharacters( path ) ) { return false; } @@ -1731,11 +1787,11 @@ public boolean isValidFileName( final String name ) { * [pentaho-commons-gwt-modules] org.pentaho.gwt.widgets.client.utils.NameUtils#isValidFileName */ return !( - StringUtils.isEmpty( name ) || // not null, not empty and not all whitespace - !name.trim().equals( name ) || !decode( name ).trim().equals( decode( name ) ) || // no leading or trailing whitespace - FileUtils.containsReservedCharacter( name, doGetReservedChars().toString().toCharArray() ) || // no reserved characters - FileUtils.containsControlCharacters( name ) || FileUtils.containsControlCharacters( decode( name ) ) // control characters - ); + StringUtils.isEmpty( name ) || // not null, not empty and not all whitespace + !name.trim().equals( name ) || !decode( name ).trim().equals( decode( name ) ) || // no leading or trailing whitespace + FileUtils.containsReservedCharacter( name, doGetReservedChars().toString().toCharArray() ) || // no reserved characters + FileUtils.containsControlCharacters( name ) || FileUtils.containsControlCharacters( decode( name ) ) // control characters + ); } private String getParentPath( final String path ) { @@ -1766,7 +1822,7 @@ public RepositoryFileOutputStream getRepositoryFileOutputStream( String path ) { } public RepositoryFileInputStream getRepositoryFileInputStream( RepositoryFile repositoryFile ) - throws FileNotFoundException { + throws FileNotFoundException { return new RepositoryFileInputStream( repositoryFile ); } @@ -1811,7 +1867,7 @@ protected ExportHandler getDownloadExportHandler() { } protected StreamingOutput getDownloadStream( RepositoryFile repositoryFile, BaseExportProcessor exportProcessor ) - throws ExportException, IOException { + throws ExportException, IOException { File zipFile = exportProcessor.performExport( repositoryFile ); final FileInputStream is = new FileInputStream( zipFile ); // copy streaming output @@ -1823,7 +1879,7 @@ public void write( OutputStream output ) throws IOException { }; } - protected RepositoryRequest getRepositoryRequest( String path, Boolean showHidden, Integer depth, String filter ) { + protected RepositoryRequest getRepositoryRequest( String path, Boolean showHidden, Integer depth, String filter ) { return new RepositoryRequest( path, showHidden, depth, filter ); } @@ -1886,7 +1942,7 @@ public boolean isShowingTitle( RepositoryRequest repositoryRequest ) { return false; } } else if ( repositoryRequest.getIncludeMemberSet() != null - && !repositoryRequest.getIncludeMemberSet().contains( "title" ) ) { + && !repositoryRequest.getIncludeMemberSet().contains( "title" ) ) { return false; } return true; @@ -1929,7 +1985,7 @@ protected Collator getCollator( int strength ) { private PentahoPlatformExporter getBackupExporter() { if ( backupExporter == null ) { backupExporter = - (PentahoPlatformExporter) PentahoSystem.get( IPentahoPlatformExporter.class, "IPentahoPlatformExporter", null ); + (PentahoPlatformExporter) PentahoSystem.get( IPentahoPlatformExporter.class, "IPentahoPlatformExporter", null ); } return backupExporter; diff --git a/extensions/src/main/resources/org/pentaho/platform/plugin/services/messages/messages.properties b/extensions/src/main/resources/org/pentaho/platform/plugin/services/messages/messages.properties index db771ce9548..928cfe6bb41 100644 --- a/extensions/src/main/resources/org/pentaho/platform/plugin/services/messages/messages.properties +++ b/extensions/src/main/resources/org/pentaho/platform/plugin/services/messages/messages.properties @@ -194,7 +194,8 @@ PentahoPlatformImporter.ERROR_0008_PUBLISH_JOB_OR_TRANS_WITH_MISSING_PLUGINS=Cou CommandLineProcessor.INFO_IMPORT_SUCCESSFUL=Import was successful CommandLineProcessor.INFO_EXPORT_SUCCESSFUL=Export was successful -CommandLineProcessor.INFO_RESTORE_SUCCESSFUL=Restore was successful +CommandLineProcessor.INFO_RESTORE_SUCCESSFUL=Restore complete +CommandLineProcessor.INFO_RESTORE_SUCCESSFUL=Restore complete CommandLineProcessor.ERROR_0001_MISSING_ARG=Missing Arguments: {0} CommandLineProcessor.ERROR_0002_INVALID_RESPONSE=Invalid ClientResponse received in performREST() @@ -204,6 +205,7 @@ CommandLineProcessor.ERROR_0005_INVALID_FILE_PATH=Invalid file-path: {0} CommandLineProcessor.ERROR_0006_NON_ADMIN_CREDENTIALS=Non admin credentials entered CommandLineProcessor.ERROR_0007_FORBIDDEN=User is not allowed to perform this operation: {0} CommandLineProcessor.ERROR_0008_INVALID_PARAMETER=Invalid parameter syntax: "{0}" +CommandLineProcessor.ERROR_0009_INVALID_LOG_FILE_PATH=Invalid log file path: "{0}" CommandLineProcessor.INFO_OPTION_HELP_DESCRIPTION=print this message CommandLineProcessor.INFO_OPTION_IMPORT_DESCRIPTION=import @@ -216,6 +218,7 @@ CommandLineProcessor.INFO_OPTION_URL_DESCRIPTION=url of repository (e.g. http:// CommandLineProcessor.INFO_OPTION_FILEPATH_DESCRIPTION=Path to directory of files for import, or path to .zip file for export CommandLineProcessor.INFO_OPTION_CHARSET_DESCRIPTION=charset to use for the repository (characters from external systems converted to this charset) CommandLineProcessor.INFO_OPTION_LOGFILE_DESCRIPTION=full path and filename of logfile messages +CommandLineProcessor.INFO_OPTION_LOGLEVEL_DESCRIPTION=Log Level CommandLineProcessor.INFO_OPTION_PATH_DESCRIPTION=repository path to which to add imported files, or to export from (e.g. /public) CommandLineProcessor.INFO_OPTION_OVERWRITE_DESCRIPTION=overwrite files (import only) CommandLineProcessor.INFO_OPTION_PERMISSION_DESCRIPTION=apply ACL manifest permissions to files and folders (import only) @@ -232,6 +235,8 @@ CommandLineProcessor.INFO_REST_RESPONSE_RECEIVED=done response = {0} CommandLineProcessor.INFO_EXPORT_COMPLETED=Export Completed CommandLineProcessor.INFO_EXPORT_WRITTEN_TO=Export written to: {0} CommandLineProcessor.INFO_RESPONSE_STATUS=Response Status: {0} +CommandLineProcessor.INFO_BACKUP_COMPLETED=Backup Completed +CommandLineProcessor.INFO_BACKUP_WRITTEN_TO=Backup written to: {0} CommandLineProcessor.INFO_PRINTHELP_CMDLINE=importexport CommandLineProcessor.INFO_PRINTHELP_HEADER=Unified repository command line import/export tool @@ -302,23 +307,100 @@ SolutionImportHandler.SkipLocaleFile=Skipping [{0}], it is a locale property fil SolutionImportHandler.ConnectionWithoutDatabaseType=Can't import connection [{0}] because it doesn't have a databaseType. SolutionImportHandler.SchedulesWithSpaces=Could not import schedule, attempting to replace spaces with underscores and retrying: {0} + +SolutionImportHandler.INFO_START_IMPORT_PROCESS=Starting the restore process +SolutionImportHandler.INFO_START_IMPORT_FILEFOLDER=*********************** [ Start: Restore File/Folder(s) ] ************************************** +SolutionImportHandler.INFO_COUNT_FILEFOLDER=Found [ {0} ] repository file(s)/folder(s) to restore +SolutionImportHandler.ERROR_IMPORTING_REPOSITORY_OBJECT=Attempting to restore repository object with path [ {0} ] from the cache. Cause [ {1} ] +SolutionImportHandler.INFO_SUCCESSFUL_REPOSITORY_IMPORT_COUNT=Successfully restored [ {0} ] out of [ {1} ] repository file(s)/folder(s) +SolutionImportHandler.INFO_START_IMPORT_LOCALEFILE=****************************[ Start: Restore Locale File(s) ] ********************************** +SolutionImportHandler.ERROR_IMPORTING_LOCALE_FILE=Error performing restore of locale files. Cause [ {0} ] +SolutionImportHandler.INFO_END_IMPORT_LOCALEFILE=****************************[ End: Restore Locale File(s) ] ********************************** +SolutionImportHandler.INFO_END_IMPORT_FILEFOLDER=*********************** [ End: Restore File/Folder(s) ] *********************************** +SolutionImportHandler.INFO_START_IMPORT_DATASOURCE=****************************[ Start: Restore DataSource(s) ] ********************************** +SolutionImportHandler.INFO_COUNT_DATASOURCE=Found [ {0}} ] DataSource(s) to restore +SolutionImportHandler.ERROR_IMPORTING_JDBC_DATASOURCE=Error while attempting to restore JDBC DataSource [ {0} ]. Cause [ {1} ] +SolutionImportHandler.INFO_END_IMPORT_DATASOURCE=****************************[ End: Restore DataSource(s) ] ********************************** +SolutionImportHandler.INFO_SUCCESSFUL_DATASOURCE_IMPORT_COUNT=Successfully restored [ {0} ] out of [ {1} ] +SolutionImportHandler.INFO_START_IMPORT_SCHEDULE=*********************** [ Start: Restore Schedule(s) ] ************************************** +SolutionImportHandler.INFO_END_IMPORT_SCHEDULE=*********************** [ End: Restore Schedule(s) ] ************************************** +SolutionImportHandler.INFO_COUNT_SCHEDULUE=Found {0} schedules in the manifest to restore +SolutionImportHandler.ERROR_IMPORTING_SCHEDULE=Unable to restore schedule [ {0} ] cause [ {1} ] +SolutionImportHandler.INFO_SUCCESSFUL_SCHEDULE_IMPORT_COUNT=Successfully restored [ {0} ] out of [ {1} ] +SolutionImportHandler.INFO_START_IMPORT_METASTORE=********************** [ Start: Restore MetaStore ] ****************************************** +SolutionImportHandler.INFO_END_IMPORT_METASTORE=********************** [ End: Restore MetaStore ] ****************************************** +SolutionImportHandler.INFO_SUCCESSFUL_IMPORT_METASTORE=Successfully restore metastore +SolutionImportHandler.INFO_START_IMPORT_USER=******************************* [Start: Restore User(s)] *************************** +SolutionImportHandler.INFO_COUNT_USER=Found [ {0} ] users to restore +SolutionImportHandler.INFO_SUCCESSFUL_USER_COUNT=Successfully restored [ {0} ] out of [ {1} ] user(s) +SolutionImportHandler.INFO_END_IMPORT_USER=****************************** [End Restore User(s)] *************************** +SolutionImportHandler.INFO_START_IMPORT_USER_SETTING=************************[ Start: Restore user specific settings] ************************* +SolutionImportHandler.INFO_COUNT_USER_SETTING=Found [ {0} ] user specific settings for user [ {1} ] +SolutionImportHandler.INFO_SUCCESSFUL_USER_SETTING_IMPORT_COUNT=Successfully restored [ {0} ] out of [ {1} ] user specific settings +SolutionImportHandler.INFO_END_IMPORT_USER_SETTING=************************[ End: Restore user specific settings] ************************* +SolutionImportHandler.INFO_COUNT_ROLE=Found [ {0} ] roles to restore +SolutionImportHandler.INFO_SUCCESSFUL_ROLE_COUNT=Successfully restored [ {0} ] out of [ {1} ] roles +SolutionImportHandler.INFO_START_IMPORT_ROLE=*********************** [ Start: Restore Role(s) ] *************************************** +SolutionImportHandler.INFO_END_IMPORT_ROLE=*********************** [ End: Restore Role(s) ] *************************************** +SolutionImportHandler.INFO_START_IMPORT_METADATA_DATASOURCE=*********************** [ Start: Restore Metadata DataSource(s) ] ***************************** +SolutionImportHandler.INFO_COUNT_METADATA_DATASOURCE=Found [ {0} ] metadata models to restore +SolutionImportHandler.INFO_SUCCESSFUL_METDATA_DATASOURCE_COUNT=Successfully restored [ {0} ] out of [ {1} ] metadata models +SolutionImportHandler.INFO_END_IMPORT_METADATA_DATASOURCE=*********************** [ End: Restore Metadata DataSource(s) ] ***************************** +SolutionImportHandler.INFO_START_IMPORT_MONDRIAN_DATASOURCE=*********************** [ Start: Restore Mondrian DataSource(s) ] ***************************** +SolutionImportHandler.INFO_COUNT_MONDRIAN_DATASOURCE=Found [ {0} ] mondrian schemas to restore +SolutionImportHandler.INFO_SUCCESSFUL_MONDRIAN_DATASOURCE_IMPORT_COUNT=Successfully restored [ {0} ] out of [ {1} ] DataSource(s) +SolutionImportHandler.INFO_END_IMPORT_MONDRIAN_DATASOURCE=*********************** [ End: Restore Mondrian DataSource(s) ] ***************************** +SolutionImportHandler.INFO_START_IMPORT_REPOSITORY_OBJECT=****************************** [ Start: Restore Repository File/Folder(s) ] ********************************** +SolutionImportHandler.INFO_END_IMPORT_REPOSITORY_OBJECT=****************************** [ End: Restore Repository File/Folder(s) ] ********************************** +SolutionImportHandler.ERROR_NOT_=This not a valid file name. Failing the restore PentahoPlatformExporter.UNSUPPORTED_JobTrigger=Unsupported JobTrigger encountered during export, skipping it: {0} PentahoPlatformExporter.ERROR_EXPORTING_JOBS=There was an error while exporting scheduled jobs ScheduleExportUtil.JOB_MUST_NOT_BE_NULL=Job can not be null - +PentahoPlatformExporter.INFO_START_EXPORT_JDBC_DATASOURCE=*************************** [ Start: Backup JDBC Datasource(s) ] ******************************* +PentahoPlatformExporter.INFO_COUNT_JDBC_DATASOURCE_TO_EXPORT=Found [ {0} ] JDBC DataSource(s) to backup +PentahoPlatformExporter.INFO_SUCCESSFUL_JDBC_DATASOURCE_EXPORT_COUNT=Successfully perform backup of[ {0} ] out of [ {1} ] JDBC DataSource(s) +PentahoPlatformExporter.INFO_END_EXPORT_JDBC_DATASOURCE=*************************** [ End: Backup JDBC Datasource(s) ] ******************************* +PentahoPlatformExporter.INFO_START_EXPORT_REPOSITORY_OBJECT=********************************* [ Start: Backup repository File(s)/Folder(s) ] ******************************* +PentahoPlatformExporter.INFO_END_EXPORT_REPOSITORY_OBJECT=********************************* [ End: Backup repository File(s)/Folder(s) ] ******************************* +PentahoPlatformExporter.ERROR_EXPORT_REPOSITORY_OBJECT=Error while performing backup of a file [ {0} ] +PentahoPlatformExporter.INFO_START_EXPORT_USER=********************************* [ Start: Backup User(s) ] ******************************* +PentahoPlatformExporter.INFO_COUNT_USER_TO_EXPORT=Found [ {0} ] User(s) to backup +PentahoPlatformExporter.INFO_SUCCESSFUL_USER_EXPORT_COUNT=Successfully perform backup of [ {0} ] out of [ {1} ] User(s) +PentahoPlatformExporter.INFO_END_EXPORT_USER=********************************* [ End: Backup User(s) ] ******************************* +PentahoPlatformExporter.INFO_START_EXPORT_ROLE=********************************* [ Start: Backup Role(s) ] ******************************* +PentahoPlatformExporter.INFO_COUNT_ROLE_TO_EXPORT=Found [ {0} ] Role(s) to backup +PentahoPlatformExporter.INFO_SUCCESSFUL_ROLE_EXPORT_COUNT=Successfully perform backup of [ {0} ] out of [ {1} ] Role(s) +PentahoPlatformExporter.INFO_END_EXPORT_ROLE=********************************* [ End: Backup Role(s) ] ******************************* +PentahoPlatformExporter.INFO_START_EXPORT_METASTORE=********************************* [ Start: Backup Metastore ] ******************************* +PentahoPlatformExporter.INFO_END_EXPORT_METASTORE=********************************* [ End: Backup Metastore ] ******************************* +PentahoPlatformExporter.INFO_SUCCESSFUL_EXPORT_METASTORE=Finished adding the metastore to the backup manifest +PentahoPlatformExporter.INFO_START_EXPORT_MONDRIAN_DATASOURCE=********************************* [ Start: Backup Mondrian datasource(s) ] ******************************* +PentahoPlatformExporter.INFO_COUNT_MONDRIAN_DATASOURCE_TO_EXPORT=Found [ {0} ] Role(s) to backup +PentahoPlatformExporter.INFO_SUCCESSFUL_MONDRIAN_DATASOURCE_EXPORT_COUNT=Successfully perform backup of [ {0} ] out of [ {1} ] Role(s) +PentahoPlatformExporter.ERROR_MONDRIAN_DATASOURCE_EXPORT=Error performing backup of Mondrian DataSource. Cause [ {0} ] +PentahoPlatformExporter.INFO_END_EXPORT_MONDRIAN_DATASOURCE=********************************* [ End: Backup Mondrian datasource(s) ] ******************************* +PentahoPlatformExporter.INFO_START_EXPORT_METADATA=********************************* [ Start: Backup Metadata datasource(s) ] ******************************* +PentahoPlatformExporter.INFO_COUNT_METADATA_DATASOURCE_TO_EXPORT=Found [ {0} ] Metadata DataSource(s) to backup +PentahoPlatformExporter.INFO_SUCCESSFUL_METADATA_DATASOURCE_EXPORT_COUNT=Successfully perform backup of [ {0} ] out of [ {1} ] Metadata DataSource(s) +PentahoPlatformExporter.ERROR_METADATA_DATASOURCE_EXPORT=Error performing backup of Mondrian DataSource. Cause [ {0} ] +PentahoPlatformExporter.INFO_END_EXPORT_METADATA=*********************** [ End: Backup metadata datasource(s) ]************************* +PentahoPlatformExporter.ERROR_EXPORT_FILE_CONTENT=Error while performing backup of file content. Cause {0} +PentahoPlatformExporter.ERROR_GENERATING_EXPORT_XML=Error generating export XML +PentahoPlatformExporter.INFO_END_EXPORT_PROCESS=End: Backup process +PentahoPlatformExporter.INFO_START_EXPORT_PROCESS=Start: Backup process ERROR.Encrypting_Password=Could not encrypt password for user {0} ERROR.Restoring_Password=Could restore password for user {0}. Setting a temporary password. ERROR.CreatingUser=Could not create user {0}. ERROR.OverridingExistingUser=Failed to set roles or password for existing user [{0}]. ROLE.Already.Exists=Role {0} already exists, could not create it. -ROLE.importing=Importing role: {0} +ROLE.importing=Performing backup of role: {0} USER.Already.Exists=User {0} already exists, could not create it. -USER.importing=Importing user: {0} +USER.importing=Performing backup of user: {0} ERROR.ScheduledWithoutPermission=File [{0}] doesn't have schedulable permission (isSchedulable=false) but there are some schedule(s) in import bundle which refers the file SCHEDULE.AssigningPermission=Assigning 'isSchedulable=true' permission for file [{0}]. -ERROR.SettingRolePermissions=Could not set permissions for role {0} during import. -PentahoPlatformExporter.ERROR.ExportingMetaStore=Error exporting the MetaStore -ERROR.ImportingUserSetting=Could not import user settings for user {0}. +ERROR.SettingRolePermissions=Could not set permissions for role {0} during backup process. +PentahoPlatformExporter.ERROR.ExportingMetaStore=Error performing backup the MetaStore +ERROR.ImportingUserSetting=Could not backup user settings for user {0}. ZIPFILE.ProcessingEntry=Processing [{0}] ZIPFILE.ExceptionOccurred=Exception occurred when processing Zip: @@ -329,7 +411,7 @@ UserRoleDaoService.PassValidationError_ReadingSecProperties=There was an error r RepositoryFileImportFileHandler.ProcessingFile=Processing [{0}] RepositoryFileImportFileHandler.SkippingImplicitlyCreatedFolder=Skipping entry for folder [{0}]. It was already processed implicitly. -RepositoryFileImportFileHandler.SkippingExistingFile=Not importing existing file [{0}] +RepositoryFileImportFileHandler.SkippingExistingFile=Not performing backup of existing file [{0}] RepositoryFileImportFileHandler.ExistingFolder=Existing folder [{0}] RepositoryFileImportFileHandler.CreatingFolder=Creating folder [{0}] RepositoryFileImportFileHandler.CreatingImpliedFolder=Creating implied folder [{0}] diff --git a/extensions/src/main/resources/org/pentaho/platform/web/http/messages/messages.properties b/extensions/src/main/resources/org/pentaho/platform/web/http/messages/messages.properties index e14d2b9bc4d..2dd0aaf56cf 100644 --- a/extensions/src/main/resources/org/pentaho/platform/web/http/messages/messages.properties +++ b/extensions/src/main/resources/org/pentaho/platform/web/http/messages/messages.properties @@ -152,4 +152,7 @@ FileResource.INCORRECT_EXTENSION={0} has incorrect extension. FileResource.HOME_FOLDER_DISPLAY_TITLE=Home FileResource.PUBLIC_FOLDER_DISPLAY_TITLE=Public -RepositoryResource.USER_NOT_AUTHORIZED_TO_EDIT=User is not authorized to edit the content. Please contact your system administrator. \ No newline at end of file +RepositoryResource.USER_NOT_AUTHORIZED_TO_EDIT=User is not authorized to edit the content. Please contact your system administrator. +FileService.ERROR_INVALID_LOG_FILENAME=Invalid log file name {0} +FileService.ERROR_UNABLE_TO_GET_PLATFORM_EXPORTER=Unable to get platform exporter from the system. Platform exporter has not been configured +FileService.ERROR_UNABLE_TO_GET_EXPORT_LOGGER=Unable to get export logger from the platform exporter. Export logger is null" \ No newline at end of file diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporterTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporterTest.java index 65ca89a6fbd..65969dff0b7 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporterTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/exporter/PentahoPlatformExporterTest.java @@ -13,6 +13,7 @@ package org.pentaho.platform.plugin.services.exporter; +import org.apache.logging.log4j.Level; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,13 +30,12 @@ import org.pentaho.platform.api.scheduler2.IScheduler; import org.pentaho.platform.api.usersettings.IAnyUserSettingService; import org.pentaho.platform.api.usersettings.pojo.IUserSetting; +import org.pentaho.platform.api.util.IRepositoryExportLogger; import org.pentaho.platform.engine.core.system.PentahoSessionHolder; import org.pentaho.platform.engine.core.system.PentahoSystem; import org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService; import org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog; -import org.pentaho.platform.plugin.services.importexport.ExportManifestUserSetting; -import org.pentaho.platform.plugin.services.importexport.RoleExport; -import org.pentaho.platform.plugin.services.importexport.UserExport; +import org.pentaho.platform.plugin.services.importexport.*; import org.pentaho.platform.plugin.services.importexport.exportManifest.ExportManifest; import org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.DatabaseConnection; import org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestMetaStore; @@ -48,6 +48,7 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; +import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.IOException; import java.util.ArrayList; @@ -98,6 +99,9 @@ public void setUp() throws Exception { doReturn( "session name" ).when( session ).getName(); exporter = new PentahoPlatformExporter( repo ); + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + exporter.setRepositoryExportLogger( exportLogger ); } @After @@ -154,7 +158,13 @@ public void testExportUsersAndRoles() { UserDetails userDetails = new User( "testUser", "testPassword", true, true, true, true, authList ); when( userDetailsService.loadUserByUsername( nullable( String.class ) ) ).thenReturn( userDetails ); + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporter.setRepositoryExportLogger( exportLogger ); exporter.exportUsersAndRoles(); + exportLogger.endJob(); verify( manifest ).addUserExport( userCaptor.capture() ); verify( manifest ).addRoleExport( roleCaptor.capture() ); @@ -172,8 +182,13 @@ public void testExportUsersAndRoles() { public void testExportMetadata_noModels() throws Exception { IMetadataDomainRepository mdr = mock( IMetadataDomainRepository.class ); exporter.setMetadataDomainRepository( mdr ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporter.setRepositoryExportLogger( exportLogger ); exporter.exportMetadataModels(); + exportLogger.endJob(); assertEquals( 0, exporter.getExportManifest().getMetadataList().size() ); } @@ -194,13 +209,18 @@ public void testExportMetadata() throws Exception { inputMap.put( "test1", is ); doReturn( inputMap ).when( exporterSpy ).getDomainFilesData( "test1" ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporterSpy.setRepositoryExportLogger( exportLogger ); exporterSpy.exportMetadataModels(); + exportLogger.endJob(); assertEquals( 1, exporterSpy.getExportManifest().getMetadataList().size() ); assertEquals( "test1", exporterSpy.getExportManifest().getMetadataList().get( 0 ).getDomainId() ); assertEquals( PentahoPlatformExporter.METADATA_PATH_IN_ZIP + "test1.xmi", - exporterSpy.getExportManifest().getMetadataList().get( 0 ).getFile() ); + exporterSpy.getExportManifest().getMetadataList().get( 0 ).getFile() ); } @Test @@ -217,8 +237,13 @@ public void testExportDatasources() throws Exception { datasources.add( icon ); when( svc.getDatasources() ).thenReturn( datasources ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporterSpy.setRepositoryExportLogger( exportLogger ); exporterSpy.exportDatasources(); + exportLogger.endJob(); assertEquals( 1, exporterSpy.getExportManifest().getDatasourceList().size() ); DatabaseConnection exportedDatabaseConnection = exporterSpy.getExportManifest().getDatasourceList().get( 0 ); @@ -244,9 +269,13 @@ public void testParseXmlaEnabled() throws Exception { public void testExportMondrianSchemas_noCatalogs() throws Exception { PentahoSystem.registerObject( mondrianCatalogService ); exporterSpy.setMondrianCatalogRepositoryHelper( mondrianCatalogRepositoryHelper ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporterSpy.setRepositoryExportLogger( exportLogger ); exporterSpy.exportMondrianSchemas(); - + exportLogger.endJob(); verify( exportManifest, never() ).addMondrian( ArgumentMatchers.any( ExportManifestMondrian.class ) ); verify( mondrianCatalogRepositoryHelper, never() ).getModrianSchemaFiles( nullable( String.class ) ); } @@ -284,7 +313,7 @@ public void testExportMondrianSchemas_AdditionalParametersSaved() throws Excepti public void testPerformExportMondrianSchemas_XmlUnsafeDataSourceInfoSaved() throws IOException { final String dataSourceInfo = "DataSource=\""DS "Test's" & <Fun>"\";" - + "DynamicSchemaProcessor=\""DSP's & "Other" <stuff>"\";"; + + "DynamicSchemaProcessor=\""DSP's & "Other" <stuff>"\";"; final String dataSourceExpectedValue = "\"DS \"Test's\" &\""; final String dynamicSchemaProcessorExpectedValue = "\"DSP's & \"Other\" \""; @@ -316,8 +345,13 @@ private void executeExportMondrianSchemasForDataSourceInfo( String catalogName, inputMap.put( catalogName, is ); when( mondrianCatalogRepositoryHelper.getModrianSchemaFiles( catalogName ) ).thenReturn( inputMap ); exporterSpy.zos = mock( ZipOutputStream.class ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporterSpy.setRepositoryExportLogger( exportLogger ); exporterSpy.exportMondrianSchemas(); + exportLogger.endJob(); } @Test @@ -327,8 +361,13 @@ public void testExportMetaStore() throws Exception { exporterSpy.setRepoMetaStore( metastore ); ExportManifest manifest = mock( ExportManifest.class ); exporterSpy.setExportManifest( manifest ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + exporterSpy.setRepositoryExportLogger( exportLogger ); exporterSpy.exportMetastore(); + exportLogger.endJob(); verify( exporterSpy.zos ).putNextEntry( ArgumentMatchers.any( ZipEntry.class ) ); verify( manifest ).setMetaStore( ArgumentMatchers.any( ExportManifestMetaStore.class ) ); } diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleFilesProcessorTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleFilesProcessorTest.java index ffb6ae36a1d..0fb2e72575c 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleFilesProcessorTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleFilesProcessorTest.java @@ -73,21 +73,22 @@ public void testProcessLocaleFilesIgnoreProperties() throws Exception { importer.setRepositoryImportLogger( new Log4JRepositoryImportLogger() ); ByteArrayInputStream localePropertiesContent = new ByteArrayInputStream( - ("description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " - + "table, and sending a Hello message to each position.\nname=1. Hello ETL") - .getBytes() ); + ( "description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " + + "table, and sending a Hello message to each position.\nname=1. Hello ETL" ) + .getBytes() ); ByteArrayInputStream localeContent = - new ByteArrayInputStream( "file.title=fileTitle\ntitle=SampleTransformation\nfile.description=".getBytes() ); + new ByteArrayInputStream( "file.title=fileTitle\ntitle=SampleTransformation\nfile.description=".getBytes() ); localeFilesProcessor = spy( new LocaleFilesProcessor() ); localeFilesProcessor.createLocaleEntry( "/", "file1.properties", null, "description", null, localePropertiesContent, 0 ); localeFilesProcessor.createLocaleEntry( "/", "file1.locale", null, "description", null, localeContent, 0 ); - localeFilesProcessor.processLocaleFiles( importer ); + int count = localeFilesProcessor.processLocaleFiles( importer ); + System.out.println( count ); Mockito.verify( localeFilesProcessor, times( 1 ) ) - .proceed( any( IPlatformImporter.class ), any( RepositoryFileImportBundle.Builder.class ), nullable( String.class ), - any( LocaleFileDescriptor.class ) ); + .proceed( any( IPlatformImporter.class ), any( RepositoryFileImportBundle.Builder.class ), nullable( String.class ), + any( LocaleFileDescriptor.class ) ); } @Test @@ -103,23 +104,24 @@ public void testProcessLocaleFilesDontIgnoreProperties() throws Exception { importer.setRepositoryImportLogger( new Log4JRepositoryImportLogger() ); ByteArrayInputStream localePropertiesContent = new ByteArrayInputStream( - ("description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " - + "table, and sending a Hello message to each position.\nname=1. Hello ETL") - .getBytes() ); + ( "description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " + + "table, and sending a Hello message to each position.\nname=1. Hello ETL" ) + .getBytes() ); localeFilesProcessor = spy( new LocaleFilesProcessor() ); localeFilesProcessor.createLocaleEntry( "/", "file1.properties", null, "description", null, localePropertiesContent, 0 ); - localeFilesProcessor.processLocaleFiles( importer ); + int count = localeFilesProcessor.processLocaleFiles( importer ); + System.out.println( count ); Mockito.verify( localeFilesProcessor, times( 1 ) ) - .proceed( any( IPlatformImporter.class ), any( RepositoryFileImportBundle.Builder.class ), nullable( String.class ), - any( LocaleFileDescriptor.class ) ); + .proceed( any( IPlatformImporter.class ), any( RepositoryFileImportBundle.Builder.class ), nullable( String.class ), + any( LocaleFileDescriptor.class ) ); } @Test public void testProcessLocaleFilesTwoLocaleFiles() throws Exception { IRepositoryContentConverterHandler converterHandler = - new DefaultRepositoryContentConverterHandler( new HashMap () ); + new DefaultRepositoryContentConverterHandler( new HashMap () ); List localeMimeList = new ArrayList (); localeMimeList.add( new MimeType( "text/locale", "locale" ) ); @@ -140,8 +142,8 @@ public void testProcessLocaleFilesTwoLocaleFiles() throws Exception { StringBuffer localePropertiesContent = new StringBuffer(); localePropertiesContent.append( - "description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " - + "table, and sending a Hello message to each position.\n" ); + "description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " + + "table, and sending a Hello message to each position.\n" ); localePropertiesContent.append( "name=1. Hello ETL" ); assertTrue( processIsLocalFile( "SampleTransformation.properties", localePropertiesContent ) ); @@ -153,8 +155,8 @@ public void testProcessLocaleFilesTwoLocaleFiles() throws Exception { assertTrue( processIsLocalFile( "SampleTransformation.xaction.locale", localeContent ) ); - localeFilesProcessor.processLocaleFiles( importer ); - + int count = localeFilesProcessor.processLocaleFiles( importer ); + System.out.println( count ); //verify that in case of both .properties and .locale files are at input the only one proceeded is .locale Mockito.verify( localeImportHandlerSpy, times( 1 ) ).importFile( any( IPlatformImportBundle.class ) ); ArgumentCaptor argument = ArgumentCaptor.forClass( IPlatformImportBundle.class ); @@ -165,10 +167,10 @@ public void testProcessLocaleFilesTwoLocaleFiles() throws Exception { @Test public void isXMLLocaleTest() { String xml = "\n" - + " " - + " "; + + "the name " - + "the description " - + "" + + " "; localeFilesProcessor = new LocaleFilesProcessor(); assertTrue( localeFilesProcessor.isXMLlocale( new ByteArrayInputStream( xml.getBytes() ) ) ); } @@ -176,8 +178,8 @@ public void isXMLLocaleTest() { @Test public void isXMLLocaleWrongFormatTest() { String xml = "\n" - + "the name " + + "the description " + + "the name " - + "the description "; + + "the name " + + "the description "; localeFilesProcessor = new LocaleFilesProcessor(); assertFalse( localeFilesProcessor.isXMLlocale( new ByteArrayInputStream( xml.getBytes() ) ) ); } @@ -185,10 +187,10 @@ public void isXMLLocaleWrongFormatTest() { @Test public void isXMLLocaleEmptyValuesTest() { String xml = "\n" - + "" - + " "; + + "" - + " " - + " " + + " "; localeFilesProcessor = new LocaleFilesProcessor(); assertFalse( localeFilesProcessor.isXMLlocale( new ByteArrayInputStream( xml.getBytes() ) ) ); } @@ -196,7 +198,7 @@ public void isXMLLocaleEmptyValuesTest() { private boolean processIsLocalFile( String fileName, StringBuffer localeContent ) throws Exception { RepositoryFile file = new RepositoryFile.Builder( fileName ).build(); RepositoryFileBundle repoFileBundle = - new RepositoryFileBundle( file, null, StringUtils.EMPTY, null, DEFAULT_ENCODING, null ); + new RepositoryFileBundle( file, null, StringUtils.EMPTY, null, DEFAULT_ENCODING, null ); return localeFilesProcessor.isLocaleFile( repoFileBundle, "/", localeContent.toString().getBytes() ); } diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleImportHandlerTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleImportHandlerTest.java index 6900c23b641..8fa7ba87e4a 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleImportHandlerTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/LocaleImportHandlerTest.java @@ -36,6 +36,7 @@ import org.pentaho.platform.util.messages.LocaleHelper; import org.springframework.test.util.ReflectionTestUtils; import org.xml.sax.SAXException; + import javax.xml.parsers.ParserConfigurationException; import java.io.ByteArrayInputStream; import java.io.File; @@ -149,7 +150,8 @@ public void testImportLocaleFiles() throws Exception { localeContent = new StringBuffer( "bla bla" ); assertFalse( processIsLocalFile( "test.properties", localeContent ) ); - localeFilesProcessor.processLocaleFiles( importer ); + int count = localeFilesProcessor.processLocaleFiles( importer ); + System.out.println( count ); } @Test @@ -163,12 +165,12 @@ public void testImportDefaultPropertiesFiles() { when( mockLocale.getFile().getName() ).thenReturn( "someFile.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List" + + " " + + " localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -194,12 +196,12 @@ public void testImportLocalizedPropertiesFiles_fr() { when( mockLocale.getFile().getName() ).thenReturn( "someFile_fr.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -225,12 +227,12 @@ public void testImportLocalizedPropertiesFiles_en_us() { when( mockLocale.getFile().getName() ).thenReturn( "someFile_en_US.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -255,8 +257,8 @@ public void testImportLocalizedPropertiesFiles_en_gb() { when( mockLocale.getFile().getName() ).thenReturn( "someFile_en_GB.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); @@ -283,12 +285,12 @@ public void testImportDefaultWithFileExtensionPropertiesFiles() { when( mockLocale.getFile().getName() ).thenReturn( "someFile.xaction.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -312,12 +314,12 @@ public void testImportLocalizedWithFileExtensionPropertiesFiles_fr() { when( mockLocale.getFile().getName() ).thenReturn( "some_File.xaction_fr.locale" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "some_File.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -341,12 +343,12 @@ public void testImportLocalizedWithFileExtensionPropertiesFiles_en_us() { when( mockLocale.getFile().getName() ).thenReturn( "someFile.xaction_en_US.locale" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -372,12 +374,12 @@ public void testImportLocalizedWithFileExtensionPropertiesFiles_en_gb() { when( mockLocale.getFile().getName() ).thenReturn( "someFile.xaction_en_GB.properties" ); String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle = createBundle( propertiesContent, "someFile.xaction" ); when( mockUnifiedRepository.getFile( nullable( String.class ) ) ).thenReturn( importBundle.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle.getFile() ); when( mockUnifiedRepository.getChildren( nullable( Integer.class ) ) ).thenReturn( localeFolderChildren ); @@ -462,8 +464,8 @@ public void testImportLocaleFolderChild() { String propertyFile = "someFile_rf.xaction.properties"; String propertiesContent = - "description=Some Description\n" - + "title=Some Title"; + "description=Some Description\n" + + "title=Some Title"; RepositoryFileImportBundle importBundle1 = createBundle( propertiesContent, someFile1 ); when( mockUnifiedRepository.getFile( FILE_BUNDLE_PATH + someFile1 ) ).thenReturn( importBundle1.getFile() ); RepositoryFileImportBundle importBundle2 = createBundle( propertiesContent, someFile2 ); @@ -473,7 +475,7 @@ public void testImportLocaleFolderChild() { RepositoryFileImportBundle importProperties = createBundle( propertiesContent, propertyFile ); when( mockUnifiedRepository.getFile( FILE_BUNDLE_PATH + propertyFile ) ).thenReturn( importProperties.getFile() ); - List localeFolderChildren = new ArrayList<>( ); + List localeFolderChildren = new ArrayList<>(); localeFolderChildren.add( importBundle1.getFile() ); localeFolderChildren.add( importBundle2.getFile() ); localeFolderChildren.add( importBundle3.getFile() ); @@ -549,8 +551,8 @@ public void shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven() throws IOExcepti @Test public void shouldNotFailAndReturnNotNullWhenLegalXmlIsGiven() throws Exception { String xml = "\n" - + " " - + " "; + + "" + + " "; LocaleImportHandler lih = new LocaleImportHandler( Collections.emptyList(), null ); assertNotNull( lih.getLocalBundleDocument( new StringBufferInputStream( xml ) ) ); @@ -563,10 +565,10 @@ public void loadPropertiesByXmlTest() throws Exception { when( repFileBundleMock.getFile() ).thenReturn( repFileMock ); when( repFileMock.getName() ).thenReturn( "index.xml" ); String xml = "\n" - + "" - + " "; + + "the name " - + "the description " - + "" + + " "; when( repFileBundleMock.getInputStream() ).thenReturn( new ByteArrayInputStream( xml.getBytes() ) ); assertEquals( localeImportHandler.loadPropertiesByXml( repFileBundleMock ).size(), 2 ); } @@ -578,10 +580,10 @@ public void loadPropertiesByXmlReferenceToVariableInNameTest() throws Exception when( repFileBundleMock.getFile() ).thenReturn( repFileMock ); when( repFileMock.getName() ).thenReturn( "index.xml" ); String xml = "\n" - + "the name " + + "the description " + + "" - + " "; + + "%name " - + "the description " - + "" + + " "; when( repFileBundleMock.getInputStream() ).thenReturn( new ByteArrayInputStream( xml.getBytes() ) ); assertEquals( localeImportHandler.loadPropertiesByXml( repFileBundleMock ).size(), 1 ); } @@ -593,10 +595,10 @@ public void loadPropertiesByXmlReferenceToVariableInDescriptionTest() throws Exc when( repFileBundleMock.getFile() ).thenReturn( repFileMock ); when( repFileMock.getName() ).thenReturn( "index.xml" ); String xml = "\n" - + "%name " + + "the description " + + "" - + " "; + + "the name " - + "%description " - + "" + + " "; when( repFileBundleMock.getInputStream() ).thenReturn( new ByteArrayInputStream( xml.getBytes() ) ); assertEquals( localeImportHandler.loadPropertiesByXml( repFileBundleMock ).size(), 1 ); } @@ -608,10 +610,10 @@ public void loadPropertiesByXmlReferenceToVariablesTest() throws Exception { when( repFileBundleMock.getFile() ).thenReturn( repFileMock ); when( repFileMock.getName() ).thenReturn( "index.xml" ); String xml = "\n" - + "the name " + + "%description " + + "" - + " "; + + "%name " - + "%description " - + "" + + " "; when( repFileBundleMock.getInputStream() ).thenReturn( new ByteArrayInputStream( xml.getBytes() ) ); assertEquals( localeImportHandler.loadPropertiesByXml( repFileBundleMock ).size(), 0 ); } @@ -628,7 +630,7 @@ public void loadPropertiesByXmlWrongFormatTest() { } @Test - public void loadPropertiesByXmlInputStreamExceptionTest() throws Exception { + public void loadPropertiesByXmlInputStreamExceptionTest() throws Exception { RepositoryFileImportBundle repFileBundleMock = mock( RepositoryFileImportBundle.class ); RepositoryFile repFileMock = mock( RepositoryFile.class ); IPlatformImporter platformImporterMock = mock( IPlatformImporter.class ); diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/PlatformImporterTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/PlatformImporterTest.java index 026d4165f12..a5dc07c5ae6 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/PlatformImporterTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/importer/PlatformImporterTest.java @@ -71,6 +71,7 @@ public void testNoMatchingMime() throws Exception { try { importer.setRepositoryImportLogger( importLogger ); + importer.getRepositoryImportLogger().setPerformingRestore( false ); importer.importFile( bundle1 ); String result = new String( outputStream.toByteArray() ); assertTrue( result.contains( "Start Import Job" ) ); // Logged at INFO level @@ -111,10 +112,10 @@ public void testMatchingMimeAndHandler() throws Exception { "parameterized-domain-id" ) ).build(); importer.importFile( bundle1 ); - + verify( mockImportHandler, times( 1 ) ).importFile( bundle1 ); } - + @Test public void testUseDefaultHandler() throws Exception { @@ -133,7 +134,7 @@ public void testUseDefaultHandler() throws Exception { new PentahoPlatformImporter( handlers, new DefaultRepositoryContentConverterHandler( new HashMap%name " + + "%description " + + "() ) ); - + IPlatformImportHandler mockDefaultImportHandler = mock( IPlatformImportHandler.class ); importer.setDefaultHandler( mockDefaultImportHandler ); importer.setRepositoryImportLogger( importLogger ); @@ -147,7 +148,7 @@ public void testUseDefaultHandler() throws Exception { "parameterized-domain-id" ) ).build(); importer.importFile( bundle1 ); - + verify( mockDefaultImportHandler, times( 1 ) ).importFile( bundle1 ); } } diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/BaseExportProcessorTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/BaseExportProcessorTest.java index 896ae97029b..d45c11c4a9c 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/BaseExportProcessorTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/BaseExportProcessorTest.java @@ -33,6 +33,7 @@ import org.junit.Before; import org.junit.Test; import org.pentaho.platform.api.repository2.unified.RepositoryFile; +import org.pentaho.platform.api.importexport.ExportException; import java.io.File; import java.io.IOException; @@ -56,13 +57,13 @@ public File performExport( RepositoryFile exportRepositoryFile ) throws ExportEx @Override public void exportDirectory( RepositoryFile repositoryDir, OutputStream outputStream, String filePath ) - throws ExportException, IOException { + throws ExportException, IOException { // To change body of implemented methods use File | Settings | File Templates. } @Override public void exportFile( RepositoryFile repositoryFile, OutputStream outputStream, String filePath ) - throws ExportException, IOException { + throws ExportException, IOException { // To change body of implemented methods use File | Settings | File Templates. } } diff --git a/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessorTest.java b/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessorTest.java index ceeb44abef3..2d3865c546e 100644 --- a/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessorTest.java +++ b/extensions/src/test/java/org/pentaho/platform/plugin/services/importexport/ZipExportProcessorTest.java @@ -28,6 +28,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.Serializable; +import java.io.ByteArrayOutputStream; + import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -40,6 +42,7 @@ import java.util.zip.ZipInputStream; import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.Level; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -63,6 +66,7 @@ import org.pentaho.platform.api.repository2.unified.RepositoryFileSid.Type; import org.pentaho.platform.api.repository2.unified.RepositoryRequest; import org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData; +import org.pentaho.platform.api.util.IRepositoryExportLogger; import org.pentaho.platform.core.mimetype.MimeType; import org.pentaho.platform.engine.core.system.PentahoSessionHolder; import org.pentaho.platform.engine.core.system.PentahoSystem; @@ -101,7 +105,7 @@ public static void afterClass() throws IOException { @Before public void init() throws IOException, PlatformInitializationException, DomainIdNullException, - DomainAlreadyExistsException, DomainStorageException { + DomainAlreadyExistsException, DomainStorageException { List availableLocales = java.util.Collections.singletonList( LOCALE_DEFAULT ); Properties localePropertries = new Properties(); @@ -119,7 +123,7 @@ public void init() throws IOException, PlatformInitializationException, DomainId final RepositoryFile fileX = new RepositoryFile.Builder( "eval (+)%.prpt" ).path( "/home/test user/two words/eval (+)%.prpt" ).id( "/home/test user/two words/eval (+)%.prpt" ).folder( false ).build(); - final RepositoryFile[] repoFiles = new RepositoryFile[] { file0, file1, file2, file3, fileX }; + final RepositoryFile[] repoFiles = new RepositoryFile[] {file0, file1, file2, file3, fileX}; final Map repoFilesMap = new HashMap (); for ( RepositoryFile f : repoFiles ) { repoFilesMap.put( f.getId(), f ); @@ -130,7 +134,7 @@ public void init() throws IOException, PlatformInitializationException, DomainId @Override public RepositoryFile answer( InvocationOnMock invocation ) throws Throwable { Object[] args = invocation.getArguments(); - final Object fileId = args[0]; + final Object fileId = args[ 0 ]; return getRepoFile( repoFilesMap, fileId ); } @@ -152,16 +156,16 @@ public RepositoryFile answer( InvocationOnMock invocation ) throws Throwable { @Override public List answer( InvocationOnMock invocation ) throws Throwable { // returns the following item from - RepositoryRequest r = (RepositoryRequest) invocation.getArguments()[0]; + RepositoryRequest r = (RepositoryRequest) invocation.getArguments()[ 0 ]; String path = r.getPath(); RepositoryFile thisFile = getRepoFile( repoFilesMap, path ); if ( thisFile == null || !thisFile.isFolder() ) { return Collections.emptyList(); } for ( int i = 0, n = repoFiles.length - 1; i < n; i++ ) { - RepositoryFile iFile = repoFiles[i]; + RepositoryFile iFile = repoFiles[ i ]; if ( iFile == thisFile || iFile.getId().equals( thisFile.getId() ) ) { - return Collections.singletonList( repoFiles[i + 1] ); + return Collections.singletonList( repoFiles[ i + 1 ] ); } } return Collections.emptyList(); @@ -185,10 +189,10 @@ public List answer( InvocationOnMock invocation ) throws Throwab Answer answerGetDataForRead = new Answer () { @Override public IRepositoryFileData answer( InvocationOnMock invocation ) throws Throwable { - Serializable id = (Serializable) invocation.getArguments()[0]; + Serializable id = (Serializable) invocation.getArguments()[ 0 ]; RepositoryFile file = getRepoFile( repoFilesMap, id ); if ( !file.isFolder() ) { - return new SimpleRepositoryFileData( new ByteArrayInputStream( new byte[0] ), "UTF-8", MIME_PRPT.getName() ); + return new SimpleRepositoryFileData( new ByteArrayInputStream( new byte[ 0 ] ), "UTF-8", MIME_PRPT.getName() ); } return null; } @@ -300,11 +304,16 @@ public void testPerformExport_withoutManifest() throws Exception { RepositoryFile expFolder = repo.getFile( expFolderPath ); assertNotNull( expFolder ); + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + zipNoMF.setRepositoryExportLogger( exportLogger ); File result = zipNoMF.performExport( repo.getFile( expFolderPath ) ); - + exportLogger.endJob(); Set zipEntriesFiles = extractZipEntries( result ); final String[] expectedEntries = - new String[] { "two words/eval (+)%.prpt", "two words/eval (+)%.prpt_en.locale", "two words/index_en.locale" }; + new String[] {"two words/eval (+)%.prpt", "two words/eval (+)%.prpt_en.locale", "two words/index_en.locale"}; for ( String e : expectedEntries ) { assertTrue( "expected entry: [" + e + "]", zipEntriesFiles.contains( e ) ); } @@ -321,13 +330,18 @@ public void testPerformExport_withManifest() throws Exception { RepositoryFile expFolder = repo.getFile( expFolderPath ); assertNotNull( expFolder ); - + // mock logger to prevent npe + IRepositoryExportLogger exportLogger = new Log4JRepositoryExportLogger(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + exportLogger.startJob( outputStream, Level.INFO, new RepositoryTextLayout( Level.INFO ) ); + zipMF.setRepositoryExportLogger( exportLogger ); + exportLogger.endJob(); File result = zipMF.performExport( repo.getFile( expFolderPath ) ); Set zipEntriesFiles = extractZipEntries( result ); final String[] expectedEntries = - new String[] { "two+words/eval+%28%2B%29%25.prpt", "two+words/eval+%28%2B%29%25.prpt_en.locale", - "two+words/index_en.locale", "exportManifest.xml" }; + new String[] {"two+words/eval+%28%2B%29%25.prpt", "two+words/eval+%28%2B%29%25.prpt_en.locale", + "two+words/index_en.locale", "exportManifest.xml"}; for ( String e : expectedEntries ) { assertTrue( "expected entry: [" + e + "]", zipEntriesFiles.contains( e ) ); }