Skip to content
This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

Commit

Permalink
☑️ Code for issue #7 is written, but testing is blocked on https://is…
Browse files Browse the repository at this point in the history
  • Loading branch information
pmonks committed Jun 7, 2015
1 parent 7076259 commit 8f3470b
Show file tree
Hide file tree
Showing 204 changed files with 95 additions and 31 deletions.
44 changes: 22 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ amp/.classpath
amp/.project
amp/.settings/

test-data/SinglePassTests/FileFolderVolumeTests/sub1/
test-data/SinglePassTests/FileFolderVolumeTests/sub2/
test-data/SinglePassTests/FileFolderVolumeTests/sub3/
test-data/SinglePassTests/FileNameTests/Punctuation/
test-data/SinglePassTests/FileNameTests/Unicode/
test-data/SinglePassTests/FileNameTests/file with a very very very very very very very very very very very very very very very very very very long name that is longer than 128 characters.txt
test-data/SinglePassTests/FileNameTests/file with spaces in the name.txt
test-data/SinglePassTests/FileSizeTests/oneGigabyte.bin
test-data/SinglePassTests/FileSizeTests/oneHundredKilobytes.bin
test-data/SinglePassTests/FileSizeTests/oneHundredMegabytes.bin
test-data/SinglePassTests/FileSizeTests/oneKilobyte.bin
test-data/SinglePassTests/FileSizeTests/oneMegabyte.bin
test-data/SinglePassTests/FileSizeTests/tenKilobytes.bin
test-data/SinglePassTests/FileSizeTests/tenMegabytes.bin
test-data/SinglePassTests/FileSizeTests/threeGigabytes.bin
test-data/SinglePassTests/FileSizeTests/zeroByte.bin
test-data/SinglePassTests/FileVolumeTests/100000files/
test-data/SinglePassTests/FileVolumeTests/10000files/
test-data/SinglePassTests/FileVolumeTests/1000files/
test-data/SinglePassTests/FileVolumeTests/100files/
test-data/SinglePassTests/PermissionTests/readable.txt
test-data/SinglePassTests/PermissionTests/unreadable.txt
test/data/SinglePassTests/FileFolderVolumeTests/sub1/
test/data/SinglePassTests/FileFolderVolumeTests/sub2/
test/data/SinglePassTests/FileFolderVolumeTests/sub3/
test/data/SinglePassTests/FileNameTests/Punctuation/
test/data/SinglePassTests/FileNameTests/Unicode/
test/data/SinglePassTests/FileNameTests/file with a very very very very very very very very very very very very very very very very very very long name that is longer than 128 characters.txt
test/data/SinglePassTests/FileNameTests/file with spaces in the name.txt
test/data/SinglePassTests/FileSizeTests/oneGigabyte.bin
test/data/SinglePassTests/FileSizeTests/oneHundredKilobytes.bin
test/data/SinglePassTests/FileSizeTests/oneHundredMegabytes.bin
test/data/SinglePassTests/FileSizeTests/oneKilobyte.bin
test/data/SinglePassTests/FileSizeTests/oneMegabyte.bin
test/data/SinglePassTests/FileSizeTests/tenKilobytes.bin
test/data/SinglePassTests/FileSizeTests/tenMegabytes.bin
test/data/SinglePassTests/FileSizeTests/threeGigabytes.bin
test/data/SinglePassTests/FileSizeTests/zeroByte.bin
test/data/SinglePassTests/FileVolumeTests/100000files/
test/data/SinglePassTests/FileVolumeTests/10000files/
test/data/SinglePassTests/FileVolumeTests/1000files/
test/data/SinglePassTests/FileVolumeTests/100files/
test/data/SinglePassTests/PermissionTests/readable.txt
test/data/SinglePassTests/PermissionTests/unreadable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@

package org.alfresco.extension.bulkimport.actions;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;

import org.alfresco.extension.bulkimport.BulkImporter;
import org.alfresco.extension.bulkimport.source.fs.FilesystemBulkImportSource;

Expand All @@ -41,7 +46,7 @@
* The parameters for this action are:
*
* <ul>
* <li>source-bean-id - the Spring bean id of the source (optional, defaults to the built-in filesystem)</li>
* <li>source-bean-id - the Spring bean id of the source (optional, defaults to the built-in filesystem source)</li>
* <li>parameters - a JSON string of key / value-list pairs containing the parameters for the chosen source (mandatory, see sources for details on the parameters they require)</li>
* <li>target-noderef - the NodeRef of the target space for the imported content (mandatory, must be a writeable cm:folder)</li>
* </ul>
Expand All @@ -52,9 +57,11 @@
public class BulkImportActionExecutor
extends ActionExecuterAbstractBase
{
private final static String PARAM_SOURCE_BEAN_ID = "source-bean-id";
private final static String PARAM_PARAMETERS = "parameters";
private final static String PARAM_TARGET = "target-noderef";
public static final String NAME = "bulk-import";

public final static String PARAM_SOURCE_BEAN_ID = "import-source-bean-id";
public final static String PARAM_PARAMETERS = "parameters";
public final static String PARAM_TARGET = "target-noderef";

private final static String DEFAULT_SOURCE_BEAN_ID = FilesystemBulkImportSource.IMPORT_SOURCE_NAME;

Expand Down Expand Up @@ -99,22 +106,36 @@ protected void executeImpl(final Action actionInstance, final NodeRef actedUponN
NodeRef target = (NodeRef)actionInstance.getParameterValue(PARAM_TARGET);
Map<String, List<String>> parameters = null;

if (sourceBeanId == null)
// Action parameter wrangling
if (sourceBeanId == null || sourceBeanId.trim().length() == 0)
{
sourceBeanId = DEFAULT_SOURCE_BEAN_ID;
}

parameters = parseParametersJson(parametersJson);
try
{
parameters = parseParametersJson(parametersJson);
}
catch (final Exception e)
{
throw new RuntimeException(e);
}

// Initiate the import
bulkImport.start(sourceBeanId, parameters, target);
}


private final Map<String, List<String>> parseParametersJson(final String parametersJson)
throws IOException, JsonMappingException, JsonParseException
{
//####TODO: IMPLEMENT THIS!!!
return(null);
Map<String, List<String>> result = null;
final ObjectMapper mapper = new ObjectMapper();
final TypeReference<HashMap<String,List<String>>> typeReference = new TypeReference<HashMap<String,List<String>>>() {};

result = mapper.readValue(parametersJson, typeReference);

return(result);
}

}
43 changes: 43 additions & 0 deletions test/src/test-bulk-import-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2012-2015 Peter Monks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of an unsupported extension to Alfresco.
*
*/

/*
* This file tests the "bulk-import" repository action.
*/

var bulkImport = actions.create("bulk-import");

if (bulkimport == null)
{
throw "Bulk Import action is not available."
}

if (space === undefined)
{
throw "Bulk Import must be executed in the context of a space."
}

bulkImport.parameters["import-source-bean-id"] = "bit.fs.source"; // Note: optional - will default if not provided
bulkImport.parameters["target-node-ref"] = space.nodeRef;
bulkImport.parameters["parameters"] =
"{ 'sourceDirectory': '/Users/pmonks/Development/Alfresco/forge/alfresco-bulk-import/test/data/SinglePassTests/MIMETypeTests', \
'replaceExisting': false, \
'dryRun': false }";

bulkImport.execute(null);

0 comments on commit 8f3470b

Please sign in to comment.