Compare commits

...

4 Commits

Author SHA1 Message Date
Oleksii Nimych
2f993171ac patch(TPS-3944): fix release notes 2020-04-23 09:51:49 +03:00
Oleksii Nimych
de610e5a4c patch(TPS-3944): fix release notes 2020-04-23 08:56:32 +03:00
Oleksii Nimych
2f66cb3601 patch(TPS-3944): Add release notes 2020-04-21 18:04:25 +03:00
OleksiiNimych
be4d6d2495 fix(TDI-43995): Support listing any path and file (#4611)
* fix(TDI-43995): Support listing any path and file

* fix(TDI-43995): Updated Apache Commons Lang library and added diamond operator

* fix(TDI-43995): Remove Apache Commons Lang library
2020-04-21 17:33:09 +03:00
4 changed files with 166 additions and 116 deletions

70
PATCH_RELEASE_NOTE.md Normal file
View File

@@ -0,0 +1,70 @@
---
version: 7.1.1
module: https://talend.poolparty.biz/coretaxonomy/42
product: https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-3944
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20200423\_TPS-3944\_v1-7.1.1|
| Release Date | 2020-04-23 |
| Target Version | 20181026\_1147-v7.1.1 |
| Product affected | Talend Studio |
## Introduction <!-- mandatory -->
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues <!-- mandatory -->
This patch contains the following fixes:
- [7.1.1]tBoxlist component listing files under root folder when we mentioned file path as subfolder (TDI-43995)
## Prerequisites <!-- mandatory -->
Consider the following requirements for your system:
- Talend Studio 7.1.1 must be installed.
## Installation <!-- mandatory -->
### Installing the patch using Software update <!-- if applicable -->
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio <!-- if applicable -->
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline <!-- if applicable -->
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
## Uninstallation
Backup the Affected files list below. Uninstall the patch by restore the backup files.
## Affected files for this patch
The following files are installed by this patch:
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.1.1.20181026\_1147/components/tBoxList/tBoxList\_begin.javajet
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.1.1.20181026\_1147/components/tBoxList/tBoxList\_end.javajet
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.1.1.20181026\_1147/resources/box/header\_additional\_box.javajet

View File

@@ -17,40 +17,40 @@ imports="
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String useExistingConn = ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__");
String accessToken = ElementParameterParser.getValue(node, "__ACCESS_TOKEN__");
String refreshToken = ElementParameterParser.getValue(node, "__REFRESH_TOKEN__");
String clientId = ElementParameterParser.getValue(node, "__CLIENT_ID__");
String clientSecret = ElementParameterParser.getValue(node, "__CLIENT_SECRET__");
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String connectionKey = "\"conn_" + connection+"\"";
String path = ElementParameterParser.getValue(node, "__PATH__");
String filelistType = ElementParameterParser.getValue(node, "__LIST_MODE__");
boolean includeSubDirectories = "true".equals(ElementParameterParser.getValue(node, "__INCLUDSUBDIR__"));
final boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
log4jFileUtil.componentStartInfo(node);
List<IMetadataTable> metadatas = node.getMetadataList();
IMetadataTable metadata = null;
if ((metadatas!=null)&&(metadatas.size()>0)) {
metadata = metadatas.get(0);
metadata = metadatas.get(0);
}
List< ? extends IConnection> outputConnections = node.getOutgoingSortedConnections();
String dataOutputConnection = null;
String dataOutputConnection = null;
for(IConnection conn : outputConnections) {
if(conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
dataOutputConnection = conn.getName();
break;
} // if(conn) end
} // for(conns) end
%>
<%
if(!"true".equals(useExistingConn)){
@@ -105,115 +105,81 @@ if(!"true".equals(useExistingConn)){
<%=cid%>_client.authenticate(new com.box.boxjavalibv2.dao.BoxOAuthToken(<%=cid%>_map));
}
<%
} else {
} else {
%>
com.box.boxjavalibv2.BoxClient <%=cid%>_client = (com.box.boxjavalibv2.BoxClient)globalMap.get(<%=connectionKey%>);
<%
}
%>
String <%=cid%>_path = normalizePath(<%=path%>);
boolean <%=cid%>_hasError = false;
String <%=cid%>_name = getFolderFromPath(<%=cid%>_path);
com.box.boxjavalibv2.dao.BoxFile <%=cid%>_boxFile = null;
com.box.boxjavalibv2.dao.BoxFolder <%=cid%>_boxFolder = null;
if ((<%=cid%>_name.equals("All Files") && (<%=cid%>_path.isEmpty() || <%=cid%>_path == null)))
{
<%=cid%>_boxFolder = <%=cid%>_client.getFoldersManager().getFolder("0",null);
}
else
{
com.box.restclientv2.requestsbase.BoxDefaultRequestObject <%=cid%>_requestObject = new com.box.restclientv2.requestsbase.BoxDefaultRequestObject();
if (<%=cid%>_name.equals("All Files") || <%=cid%>_path.equals("All Files"))
{
<%=cid%>_boxFolder = <%=cid%>_client.getFoldersManager().getFolder("0", null);
}
else
{
String parentPath = normalizePath(<%=cid%>_path.replace(<%=cid%>_name, ""));
<%=cid%>_boxFolder = <%=cid%>_client.getFoldersManager().getFolder("0", <%=cid%>_requestObject);
if ("All Files".equals(parentPath)) {
for (com.box.boxjavalibv2.dao.BoxTypedObject <%=cid%>_boxTypedObject : <%=cid%>_boxFolder.getItemCollection().getEntries()) {
if (<%=cid%>_boxTypedObject.getValue("name").equals(<%=cid%>_name)) {
if ("folder".equals(<%=cid%>_boxTypedObject.getType())) {
<%=cid%>_boxFolder = <%=cid%>_client.getFoldersManager().getFolder(<%=cid%>_boxTypedObject.getId(), <%=cid%>_requestObject);
} else {
<%=cid%>_boxFile = <%=cid%>_client.getFilesManager().getFile(<%=cid%>_boxTypedObject.getId(),<%=cid%>_requestObject);
}
}
}
com.box.boxjavalibv2.dao.BoxFolder <%=cid%>_rootFolder = <%=cid%>_client.getFoldersManager().getFolder("0", null);
com.box.boxjavalibv2.dao.BoxItem <%=cid%>_boxItem;
} else {
List<String> <%=cid%>_paths = new java.util.ArrayList<String>(java.util.Arrays.asList(parentPath.split("/")));
<%=cid%>_boxFolder = getBoxFolderRecursively(<%=cid%>_paths, <%=cid%>_boxFolder, <%=cid%>_client);
}
}
}
if (<%=cid%>_boxFile == null && <%=cid%>_boxFolder == null)
{
throw new Exception("<%=cid%> - " + "No file or directory found in " + <%=path%>);
}
else if (<%=cid%>_boxFolder != null)
{
java.util.List<com.box.boxjavalibv2.dao.BoxItem> <%=cid%>_children = new java.util.ArrayList<com.box.boxjavalibv2.dao.BoxItem>();
<%if(includeSubDirectories){%>
<%if(filelistType.equalsIgnoreCase("Directories")){%>
<%=cid%>_children = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_children, true, false);
<%} else if (filelistType.equalsIgnoreCase("Files")){%>
<%=cid%>_children = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_children, false, true);
<%} else {%>
<%=cid%>_children = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_children, true, true);
<%}%>
<%}%>
<%else{%>
for (com.box.boxjavalibv2.dao.BoxTypedObject obj : <%=cid%>_boxFolder.getItemCollection().getEntries())
{
<%if(filelistType.equalsIgnoreCase("Directories")){%>
if(obj.getType().equals("folder"))
{
com.box.boxjavalibv2.dao.BoxFolder folder = <%=cid%>_client.getFoldersManager().getFolder(obj.getId(), null);
<%=cid%>_children.add(folder);
}
<%} else if (filelistType.equalsIgnoreCase("Files")){%>
if (obj.getType().equals("file"))
{
com.box.boxjavalibv2.dao.BoxFile file = <%=cid%>_client.getFilesManager().getFile(obj.getId(), null);
<%=cid%>_children.add(file);
}
<%} else {%>
if(obj.getType().equals("folder"))
{
com.box.boxjavalibv2.dao.BoxFolder folder = <%=cid%>_client.getFoldersManager().getFolder(obj.getId(), null);
<%=cid%>_children.add(folder);
}
else if (obj.getType().equals("file"))
{
com.box.boxjavalibv2.dao.BoxFile file = <%=cid%>_client.getFilesManager().getFile(obj.getId(), null);
<%=cid%>_children.add(file);
}
<%}%>
int <%=cid%>_slashPosition = <%=cid%>_path.indexOf("/");
String <%=cid%>_rootFolderName = <%=cid%>_slashPosition == -1 ? <%=cid%>_path : <%=cid%>_path.substring(0, <%=cid%>_slashPosition);
if (<%=cid%>_rootFolderName.equals("All Files")) {
List<String> <%=cid%>_pathItems = new java.util.ArrayList<String>(java.util.Arrays.asList(<%=cid%>_path.split("/")));
<%=cid%>_pathItems.remove(0);
try {
<%=cid%>_boxItem = getBoxItemRecursively(<%=cid%>_pathItems, <%=cid%>_rootFolder, <%=cid%>_client);
} catch (Exception e) {
throw new Exception("<%=cid%> - " + "The path to file or directory was not found in " + <%=cid%>_path, e);
}
<%}%>
for (com.box.boxjavalibv2.dao.BoxItem <%=cid%>_item : <%=cid%>_children)
{
String <%=cid%>_itemPath = getBoxItemPath(<%=cid%>_item);
globalMap.put("<%=cid%>_NAME", <%=cid%>_item.getName());
globalMap.put("<%=cid%>_ID", <%=cid%>_item.getId());
globalMap.put("<%=cid%>_FILE_PATH", <%=cid%>_itemPath);
globalMap.put("<%=cid%>_FILE_DIRECTORY", <%=cid%>_itemPath + <%=cid%>_item.getName());
globalMap.put("<%=cid%>_TYPE",<%=cid%>_item.getType());
globalMap.put("<%=cid%>_LAST_MODIFIED", <%=cid%>_item.getModifiedAt());
globalMap.put("<%=cid%>_SIZE", <%=cid%>_item.getSize());
} else {
throw new Exception("<%=cid%> - " + "The path to file or directory was not found in " + <%=cid%>_path);
}
java.util.List<com.box.boxjavalibv2.dao.BoxItem> <%=cid%>_items = new java.util.ArrayList<>();
if (<%=cid%>_boxItem.getType().equals("folder")) {
com.box.boxjavalibv2.dao.BoxFolder <%=cid%>_boxFolder = (com.box.boxjavalibv2.dao.BoxFolder) <%=cid%>_boxItem;
<%if(includeSubDirectories) {%>
<%if(filelistType.equalsIgnoreCase("Directories")) {%>
<%=cid%>_items = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_items, true, false);
<%} else if (filelistType.equalsIgnoreCase("Files")) {%>
<%=cid%>_items = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_items, false, true);
<%} else {%>
<%=cid%>_items = getChildrenRecursively(<%=cid%>_client, <%=cid%>_boxFolder, <%=cid%>_items, true, true);
<%}%>
<%} else {%>
for (com.box.boxjavalibv2.dao.BoxTypedObject obj : <%=cid%>_boxFolder.getItemCollection().getEntries())
{
<%if(filelistType.equalsIgnoreCase("Directories")) {%>
if(obj.getType().equals("folder"))
{
com.box.boxjavalibv2.dao.BoxFolder folder = <%=cid%>_client.getFoldersManager().getFolder(obj.getId(), null);
<%=cid%>_items.add(folder);
}
<%} else if (filelistType.equalsIgnoreCase("Files")) {%>
if (obj.getType().equals("file"))
{
com.box.boxjavalibv2.dao.BoxFile file = <%=cid%>_client.getFilesManager().getFile(obj.getId(), null);
<%=cid%>_items.add(file);
}
<%} else {%>
if(obj.getType().equals("folder"))
{
com.box.boxjavalibv2.dao.BoxFolder folder = <%=cid%>_client.getFoldersManager().getFolder(obj.getId(), null);
<%=cid%>_items.add(folder);
}
else if (obj.getType().equals("file"))
{
com.box.boxjavalibv2.dao.BoxFile file = <%=cid%>_client.getFilesManager().getFile(obj.getId(), null);
<%=cid%>_items.add(file);
}
<%}%>
}
<%}%>
} else if (<%=cid%>_boxItem.getType().equals("file")) {
com.box.boxjavalibv2.dao.BoxFile <%=cid%>_boxFile = (com.box.boxjavalibv2.dao.BoxFile) <%=cid%>_boxItem;
<%=cid%>_items.add(<%=cid%>_boxFile);
}
for (com.box.boxjavalibv2.dao.BoxItem <%=cid%>_item : <%=cid%>_items) {
String <%=cid%>_itemPath = getBoxItemPath(<%=cid%>_item);
globalMap.put("<%=cid%>_NAME", <%=cid%>_item.getName());
globalMap.put("<%=cid%>_ID", <%=cid%>_item.getId());
globalMap.put("<%=cid%>_FILE_PATH", <%=cid%>_itemPath);
globalMap.put("<%=cid%>_FILE_DIRECTORY", <%=cid%>_itemPath + <%=cid%>_item.getName());
globalMap.put("<%=cid%>_TYPE",<%=cid%>_item.getType());
globalMap.put("<%=cid%>_LAST_MODIFIED", <%=cid%>_item.getModifiedAt());
globalMap.put("<%=cid%>_SIZE", <%=cid%>_item.getSize());

View File

@@ -16,7 +16,6 @@
%>
}
}
//globalMap.put("<%=cid%>_NB_FILE", NB_FILE<%=cid%>);

View File

@@ -158,6 +158,21 @@ if(hasBox){
return folder;
}
private static com.box.boxjavalibv2.dao.BoxItem getBoxItemRecursively(List<String> pathItems, com.box.boxjavalibv2.dao.BoxItem item, com.box.boxjavalibv2.BoxClient client) throws Exception {
if (pathItems.isEmpty()) {
return item;
} else {
String itemName = pathItems.remove(0);
com.box.boxjavalibv2.dao.BoxFolder folder = (com.box.boxjavalibv2.dao.BoxFolder) item;
for (com.box.boxjavalibv2.dao.BoxTypedObject obj : folder.getItemCollection().getEntries()) {
if (obj.getValue("name").equals(itemName)) {
return getBoxItemRecursively(pathItems, client.getBoxItemsManager().getItem(obj.getId(), null, com.box.boxjavalibv2.dao.BoxResourceType.valueOf(obj.getType().toUpperCase())), client);
}
}
throw new Exception("The item " + itemName + " was not found in the directory " + folder.getName());
}
}
private java.util.List<com.box.boxjavalibv2.dao.BoxItem> getChildrenRecursively(com.box.boxjavalibv2.BoxClient client, com.box.boxjavalibv2.dao.BoxFolder folder,
java.util.List<com.box.boxjavalibv2.dao.BoxItem> list, boolean withFolders, boolean withFiles) throws Exception