Skip to content

Commit

Permalink
[BACKLOG-7942] Fix retainOwnership flag logic in imported.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkafalas committed Apr 26, 2016
1 parent 0c148fa commit adde4ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* Copyright (c) 2002-2013 Pentaho Corporation.. All rights reserved.
* Copyright (c) 2002-2016 Pentaho Corporation.. All rights reserved.
*/

package org.pentaho.platform.plugin.services.importer;
Expand Down Expand Up @@ -245,7 +245,7 @@ private void updateAclFromBundle( boolean newFile, RepositoryFileImportBundle bu
private void updateAcl( boolean newFile, RepositoryFile repositoryFile, RepositoryFileAcl repositoryFileAcl ) {
getLogger().debug( "File " + ( newFile ? "is new" : "already exists" ) );
if ( repositoryFileAcl != null
&& ( getImportSession().isApplyAclSettings() || getImportSession().isRetainOwnership() ) ) {
&& ( getImportSession().isApplyAclSettings() || !getImportSession().isRetainOwnership() ) ) {
RepositoryFileAcl manifestAcl = repositoryFileAcl;
RepositoryFileAcl originalAcl = repository.getAcl( repositoryFile.getId() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the GNU General Public License for more details.
*
*
* Copyright 2006 - 2013 Pentaho Corporation. All rights reserved.
* Copyright 2006 - 2016 Pentaho Corporation. All rights reserved.
*/

package org.pentaho.platform.plugin.services.importexport;
Expand Down Expand Up @@ -55,6 +55,7 @@ public class ImportSession {

private final HashSet<RepositoryFile> importedRepositoryFiles = new HashSet<RepositoryFile>();
private final List<String> importedScheduleJobIds = new ArrayList<String>();
public static IPlatformImporter iPlatformImporter; //This variable allows injection on unit tests

public static ImportSession getSession() {
ImportSession session = sessions.get();
Expand All @@ -77,7 +78,10 @@ public void initialize() {

public Log getLogger() {
if ( log == null ) {
IRepositoryImportLogger logger = PentahoSystem.get( IPlatformImporter.class ).getRepositoryImportLogger();
if ( iPlatformImporter == null ) {
iPlatformImporter = PentahoSystem.get( IPlatformImporter.class );
}
IRepositoryImportLogger logger = iPlatformImporter.getRepositoryImportLogger();
if ( logger != null && logger.hasLogger() ) {
// An import is running from the /repo/file/import endpoint
log = logger;
Expand All @@ -101,8 +105,8 @@ public Log getLogger() {
* @return
*/
public Boolean isFileHidden( String filePath ) {
if ( ( applyAclSettings || retainOwnership ) && manifest != null
&& manifest.getExportManifestEntity( filePath ) != null ) {
if ( ( applyAclSettings || !retainOwnership ) && manifest != null
&& manifest.getExportManifestEntity( filePath ) != null ) {
return manifest.getExportManifestEntity( filePath ).getRepositoryFile().isHidden();
}
return null;
Expand All @@ -113,7 +117,7 @@ public RepositoryFileAcl processAclForFile( String filePath ) {
// If we are writing ACL's we'll have to check later in RepositoryFileImportHandler whether to overwrite
// based on the isOverwriteAcl setting and whether we are creating or updating the RepositoryFile.
RepositoryFileAcl acl = null;
if ( applyAclSettings || retainOwnership ) {
if ( applyAclSettings || !retainOwnership ) {
try {
if ( manifest != null ) {
ExportManifestEntity entity = manifest.getExportManifestEntity( filePath );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the GNU General Public License for more details.
*
*
* Copyright 2006 - 2013 Pentaho Corporation. All rights reserved.
* Copyright 2006 - 2016 Pentaho Corporation. All rights reserved.
*/

package org.pentaho.platform.plugin.services.importexport;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void testSettingAclProperties() {

@Test
public void fileHiddenPropertyIsNullWhenAclIsDisabled() {
importSession.setAclProperties( false, false, false );
importSession.setAclProperties( false, true, false );
assertNull( importSession.isFileHidden( PATH ) );
}

Expand Down

0 comments on commit adde4ae

Please sign in to comment.