Compare commits
8 Commits
patch/8.0.
...
patch/7.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cadc0deea | ||
|
|
0a2debf507 | ||
|
|
6019641414 | ||
|
|
9feb0059c5 | ||
|
|
6f824cc0ea | ||
|
|
993069601b | ||
|
|
244bae3ff6 | ||
|
|
4cbc80d2b6 |
@@ -347,6 +347,18 @@
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CANNED_ACCESS_CONTROL_LIST" FIELD="OPENED_LIST" NUM_ROW="100" DYNAMIC_SETTINGS="true">
|
||||
<ITEMS DEFAULT="NONE">
|
||||
<ITEM NAME="NONE" VALUE=""NONE"" />
|
||||
<ITEM NAME="PRIVATE" VALUE=""Private"" />
|
||||
<ITEM NAME="PUBLIC_READ" VALUE=""PublicRead"" />
|
||||
<ITEM NAME="PUBLIC_READ_WRITE" VALUE=""PublicReadWrite"" />
|
||||
<ITEM NAME="AWS_EXEC_READ" VALUE=""AwsExecRead"" />
|
||||
<ITEM NAME="AUTHENTICATED_READ" VALUE=""AuthenticatedRead"" />
|
||||
<ITEM NAME="LOG_DELIVERY_WRITE" VALUE=""LogDeliveryWrite"" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
|
||||
@@ -18,6 +18,8 @@ imports="
|
||||
|
||||
boolean enableACL = "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__ACCESS_CONTROL_LIST__"));
|
||||
List<Map<String, String>> paramsACL = ElementParameterParser.getTableValue(node,"__ACL__");
|
||||
final String cannedACL = ElementParameterParser.getValue(node, "__CANNED_ACCESS_CONTROL_LIST__");
|
||||
final boolean enableCannedACL = (cannedACL != null) && (!cannedACL.isEmpty()) && !("\"NONE\"".equals(cannedACL));
|
||||
%>
|
||||
<%@ include file="../tS3Connection/S3Client.javajet" %>
|
||||
try{
|
||||
@@ -80,6 +82,14 @@ accessCtrlList.grantPermission(grantee_<%=cid%>_<%=grantee_id%>, com.amazonaws.s
|
||||
<%if (enableACL) {%>
|
||||
bucketRequest_<%=cid%>.withAccessControlList(accessCtrlList);
|
||||
<%}%>
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
bucketRequest_<%=cid%>.withCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
conn_<%=cid%>.createBucket(bucketRequest_<%=cid%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
|
||||
@@ -100,3 +100,12 @@ ACL.ITEM.READ=List objects
|
||||
ACL.ITEM.READ_ACL=Read bucket permissions
|
||||
ACL.ITEM.WRITE=Write objects
|
||||
ACL.ITEM.WRITE_ACL=Write bucket permissions
|
||||
|
||||
CANNED_ACCESS_CONTROL_LIST.NAME=Canned Access Control
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.NONE=None
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PRIVATE=Private
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ=Public-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ_WRITE=Public-Read-Write
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AWS_EXEC_READ=Aws-Exec-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AUTHENTICATED_READ=Authenticated-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.LOG_DELIVERY_WRITE=Log-Delivery-Write
|
||||
@@ -1,169 +1,185 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
java.util.List
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
String cid = node.getUniqueName();
|
||||
String from_bucket = ElementParameterParser.getValue(node,"__FROM_BUCKET__");
|
||||
String from_key = ElementParameterParser.getValue(node,"__FROM_KEY__");
|
||||
String to_bucket = ElementParameterParser.getValue(node,"__TO_BUCKET__");
|
||||
String to_key = ElementParameterParser.getValue(node,"__TO_KEY__");
|
||||
String dieOnError = ElementParameterParser.getValue(node, "__DIE_ON_ERROR__");
|
||||
boolean enableServerSideEncryption = "true".equals(ElementParameterParser.getValue(node, "__ENABLE_SERVER_SIDE_ENCRYPTION__"));
|
||||
String kmsid = ElementParameterParser.getValue(node, "__KMSID__");
|
||||
boolean enableKMS = "true".equals(ElementParameterParser.getValue(node, "__ENABLE_KMS__"));
|
||||
|
||||
String partSizeMb = ElementParameterParser.getValue(node, "__PART_SIZE__");
|
||||
|
||||
if((partSizeMb == null) || "".equals(partSizeMb) || "\"\"".equals(partSizeMb)) {
|
||||
partSizeMb = "100";
|
||||
}
|
||||
|
||||
%>
|
||||
<%@ include file="../tS3Connection/S3Client.javajet" %>
|
||||
try{
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Copying an object with key:" + <%=from_key%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
long partSizeInBytes_<%=cid%> = <%=partSizeMb%> * 1024 * 1024;
|
||||
long maxBytes4SingleCopyCall_<%=cid%> = 5 * 1024 * 1024 * 1024;//5GB
|
||||
com.amazonaws.services.s3.model.ObjectMetadata objectMetadata_<%=cid%> = null;
|
||||
<%
|
||||
if(!enableKMS && enableServerSideEncryption){
|
||||
%>
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - No KMS - Normal SSE");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
objectMetadata_<%=cid%> = new com.amazonaws.services.s3.model.ObjectMetadata();
|
||||
objectMetadata_<%=cid%>.setSSEAlgorithm(com.amazonaws.services.s3.model.ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
final String from_bucket_<%=cid%> = <%=from_bucket%>;
|
||||
final String from_key_<%=cid%> = <%=from_key%>;
|
||||
final String to_bucket_<%=cid%> = <%=to_bucket%>;
|
||||
final String to_key_<%=cid%> = <%=to_key%>;
|
||||
|
||||
//get the source metadata information
|
||||
com.amazonaws.services.s3.model.GetObjectMetadataRequest metadataRequest_<%=cid%> = new com.amazonaws.services.s3.model.GetObjectMetadataRequest(from_bucket_<%=cid%>, from_key_<%=cid%>);
|
||||
com.amazonaws.services.s3.model.ObjectMetadata metadataResult_<%=cid%> = conn_<%=cid%>.getObjectMetadata(metadataRequest_<%=cid%>);
|
||||
long objectSize_<%=cid%> = metadataResult_<%=cid%>.getContentLength();
|
||||
|
||||
boolean multiUpload_<%=cid%> = objectSize_<%=cid%> > maxBytes4SingleCopyCall_<%=cid%>;
|
||||
|
||||
if(!multiUpload_<%=cid%>) {
|
||||
com.amazonaws.services.s3.model.CopyObjectRequest putRequest_<%=cid%> = new com.amazonaws.services.s3.model.CopyObjectRequest(from_bucket_<%=cid%>, from_key_<%=cid%>, to_bucket_<%=cid%>, to_key_<%=cid%>);
|
||||
if(objectMetadata_<%=cid%> != null) {
|
||||
putRequest_<%=cid%>.setNewObjectMetadata(objectMetadata_<%=cid%>);
|
||||
}
|
||||
|
||||
<%@ include file="../tS3Put/set_kms.javajet"%>
|
||||
|
||||
conn_<%=cid%>.copyObject(putRequest_<%=cid%>);
|
||||
} else {
|
||||
<%
|
||||
//as the s3 service limit, the multi upload copy may lose s3 object metadata information or changed, but some object metadata information is important like the "x-amz-iv" key for client encrypt with kms
|
||||
//which will make the decrypt not work with different key like expected, so fail asap here and there is very rare risk which use a large file than 5GB and also with client encrypt, so ignore it now.
|
||||
%>
|
||||
java.util.Map<String,String> userMetadata_<%=cid%> = metadataResult_<%=cid%>.getUserMetadata();
|
||||
if((userMetadata_<%=cid%>!=null) && userMetadata_<%=cid%>.get("x-amz-iv")!=null) {
|
||||
throw new RuntimeException("the metadata key : \"x-amz-iv\" exists in the current object metadata, its value is important for client encrypt with KMS, which can't be copied as s3 service limit it");
|
||||
}
|
||||
|
||||
com.amazonaws.services.s3.model.InitiateMultipartUploadRequest putRequest_<%=cid%> = null;
|
||||
if(objectMetadata_<%=cid%> != null) {
|
||||
putRequest_<%=cid%> = new com.amazonaws.services.s3.model.InitiateMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, objectMetadata_<%=cid%>);
|
||||
} else {
|
||||
//even pass the source object metadata, some metadata will change too like "x-amz-iv"
|
||||
putRequest_<%=cid%> = new com.amazonaws.services.s3.model.InitiateMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, metadataResult_<%=cid%>);
|
||||
}
|
||||
|
||||
<%@ include file="../tS3Put/set_kms.javajet"%>
|
||||
|
||||
com.amazonaws.services.s3.model.InitiateMultipartUploadResult initResult_<%=cid%> = conn_<%=cid%>.initiateMultipartUpload(putRequest_<%=cid%>);
|
||||
|
||||
long bytePosition_<%=cid%> = 0;
|
||||
int partNum_<%=cid%> = 1;
|
||||
|
||||
java.util.List<com.amazonaws.services.s3.model.PartETag> partTags_<%=cid%> = new java.util.ArrayList<com.amazonaws.services.s3.model.PartETag>();
|
||||
|
||||
try {
|
||||
while (bytePosition_<%=cid%> < objectSize_<%=cid%>) {
|
||||
long lastByte_<%=cid%> = java.lang.Math.min(bytePosition_<%=cid%> + partSizeInBytes_<%=cid%> - 1, objectSize_<%=cid%> - 1);
|
||||
|
||||
com.amazonaws.services.s3.model.CopyPartRequest copyPartRequest_<%=cid%> = new com.amazonaws.services.s3.model.CopyPartRequest()
|
||||
.withSourceBucketName(from_bucket_<%=cid%>)
|
||||
.withSourceKey(from_key_<%=cid%>)
|
||||
.withDestinationBucketName(to_bucket_<%=cid%>)
|
||||
.withDestinationKey(to_key_<%=cid%>)
|
||||
.withUploadId(initResult_<%=cid%>.getUploadId())
|
||||
.withFirstByte(bytePosition_<%=cid%>)
|
||||
.withLastByte(lastByte_<%=cid%>)
|
||||
.withPartNumber(partNum_<%=cid%>++);
|
||||
partTags_<%=cid%>.add(conn_<%=cid%>.copyPart(copyPartRequest_<%=cid%>).getPartETag());
|
||||
bytePosition_<%=cid%> += partSizeInBytes_<%=cid%>;
|
||||
}
|
||||
|
||||
com.amazonaws.services.s3.model.CompleteMultipartUploadRequest completeRequest_<%=cid%> = new com.amazonaws.services.s3.model.CompleteMultipartUploadRequest(
|
||||
to_bucket_<%=cid%>,
|
||||
to_key_<%=cid%>,
|
||||
initResult_<%=cid%>.getUploadId(),
|
||||
partTags_<%=cid%>);
|
||||
conn_<%=cid%>.completeMultipartUpload(completeRequest_<%=cid%>);
|
||||
} catch (java.lang.Exception uploadException_<%=cid%>) {
|
||||
conn_<%=cid%>.abortMultipartUpload(new com.amazonaws.services.s3.model.AbortMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, initResult_<%=cid%>.getUploadId()));
|
||||
throw uploadException_<%=cid%>;
|
||||
}
|
||||
}
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Copied the object successfully.");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}catch(java.lang.Exception e_<%=cid%>){
|
||||
<%
|
||||
if (("true").equals(dieOnError)) {
|
||||
%>
|
||||
throw(e_<%=cid%>);
|
||||
<%
|
||||
} else {
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.error("<%=cid%> - " + e_<%=cid%>.getMessage());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
System.err.println(e_<%=cid%>.getMessage());
|
||||
<%
|
||||
}
|
||||
if(!("true").equals(useExistingConn)) {
|
||||
%>
|
||||
}finally{
|
||||
if(conn_<%=cid%> !=null){
|
||||
conn_<%=cid%>.shutdown();
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}
|
||||
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
java.util.List
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
String cid = node.getUniqueName();
|
||||
String from_bucket = ElementParameterParser.getValue(node,"__FROM_BUCKET__");
|
||||
String from_key = ElementParameterParser.getValue(node,"__FROM_KEY__");
|
||||
String to_bucket = ElementParameterParser.getValue(node,"__TO_BUCKET__");
|
||||
String to_key = ElementParameterParser.getValue(node,"__TO_KEY__");
|
||||
String dieOnError = ElementParameterParser.getValue(node, "__DIE_ON_ERROR__");
|
||||
boolean enableServerSideEncryption = "true".equals(ElementParameterParser.getValue(node, "__ENABLE_SERVER_SIDE_ENCRYPTION__"));
|
||||
String kmsid = ElementParameterParser.getValue(node, "__KMSID__");
|
||||
boolean enableKMS = "true".equals(ElementParameterParser.getValue(node, "__ENABLE_KMS__"));
|
||||
|
||||
String partSizeMb = ElementParameterParser.getValue(node, "__PART_SIZE__");
|
||||
|
||||
if((partSizeMb == null) || "".equals(partSizeMb) || "\"\"".equals(partSizeMb)) {
|
||||
partSizeMb = "100";
|
||||
}
|
||||
final String cannedACL = ElementParameterParser.getValue(node, "__CANNED_ACCESS_CONTROL_LIST__");
|
||||
final boolean enableCannedACL = (cannedACL != null) && (!cannedACL.isEmpty()) && !("\"NONE\"".equals(cannedACL));
|
||||
%>
|
||||
<%@ include file="../tS3Connection/S3Client.javajet" %>
|
||||
try{
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Copying an object with key:" + <%=from_key%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
long partSizeInBytes_<%=cid%> = <%=partSizeMb%> * 1024 * 1024;
|
||||
long maxBytes4SingleCopyCall_<%=cid%> = 5 * 1024 * 1024 * 1024;//5GB
|
||||
com.amazonaws.services.s3.model.ObjectMetadata objectMetadata_<%=cid%> = null;
|
||||
<%
|
||||
if(!enableKMS && enableServerSideEncryption){
|
||||
%>
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - No KMS - Normal SSE");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
objectMetadata_<%=cid%> = new com.amazonaws.services.s3.model.ObjectMetadata();
|
||||
objectMetadata_<%=cid%>.setSSEAlgorithm(com.amazonaws.services.s3.model.ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
final String from_bucket_<%=cid%> = <%=from_bucket%>;
|
||||
final String from_key_<%=cid%> = <%=from_key%>;
|
||||
final String to_bucket_<%=cid%> = <%=to_bucket%>;
|
||||
final String to_key_<%=cid%> = <%=to_key%>;
|
||||
|
||||
//get the source metadata information
|
||||
com.amazonaws.services.s3.model.GetObjectMetadataRequest metadataRequest_<%=cid%> = new com.amazonaws.services.s3.model.GetObjectMetadataRequest(from_bucket_<%=cid%>, from_key_<%=cid%>);
|
||||
com.amazonaws.services.s3.model.ObjectMetadata metadataResult_<%=cid%> = conn_<%=cid%>.getObjectMetadata(metadataRequest_<%=cid%>);
|
||||
long objectSize_<%=cid%> = metadataResult_<%=cid%>.getContentLength();
|
||||
|
||||
boolean multiUpload_<%=cid%> = objectSize_<%=cid%> > maxBytes4SingleCopyCall_<%=cid%>;
|
||||
|
||||
if(!multiUpload_<%=cid%>) {
|
||||
com.amazonaws.services.s3.model.CopyObjectRequest putRequest_<%=cid%> = new com.amazonaws.services.s3.model.CopyObjectRequest(from_bucket_<%=cid%>, from_key_<%=cid%>, to_bucket_<%=cid%>, to_key_<%=cid%>);
|
||||
if(objectMetadata_<%=cid%> != null) {
|
||||
putRequest_<%=cid%>.setNewObjectMetadata(objectMetadata_<%=cid%>);
|
||||
}
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
putRequest_<%=cid%>.setCannedAccessControlList(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
<%@ include file="../tS3Put/set_kms.javajet"%>
|
||||
|
||||
conn_<%=cid%>.copyObject(putRequest_<%=cid%>);
|
||||
} else {
|
||||
<%
|
||||
//as the s3 service limit, the multi upload copy may lose s3 object metadata information or changed, but some object metadata information is important like the "x-amz-iv" key for client encrypt with kms
|
||||
//which will make the decrypt not work with different key like expected, so fail asap here and there is very rare risk which use a large file than 5GB and also with client encrypt, so ignore it now.
|
||||
%>
|
||||
java.util.Map<String,String> userMetadata_<%=cid%> = metadataResult_<%=cid%>.getUserMetadata();
|
||||
if((userMetadata_<%=cid%>!=null) && userMetadata_<%=cid%>.get("x-amz-iv")!=null) {
|
||||
throw new RuntimeException("the metadata key : \"x-amz-iv\" exists in the current object metadata, its value is important for client encrypt with KMS, which can't be copied as s3 service limit it");
|
||||
}
|
||||
|
||||
com.amazonaws.services.s3.model.InitiateMultipartUploadRequest putRequest_<%=cid%> = null;
|
||||
if(objectMetadata_<%=cid%> != null) {
|
||||
putRequest_<%=cid%> = new com.amazonaws.services.s3.model.InitiateMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, objectMetadata_<%=cid%>);
|
||||
} else {
|
||||
//even pass the source object metadata, some metadata will change too like "x-amz-iv"
|
||||
putRequest_<%=cid%> = new com.amazonaws.services.s3.model.InitiateMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, metadataResult_<%=cid%>);
|
||||
}
|
||||
|
||||
<%@ include file="../tS3Put/set_kms.javajet"%>
|
||||
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
putRequest_<%=cid%>.withCannedACL(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
com.amazonaws.services.s3.model.InitiateMultipartUploadResult initResult_<%=cid%> = conn_<%=cid%>.initiateMultipartUpload(putRequest_<%=cid%>);
|
||||
|
||||
long bytePosition_<%=cid%> = 0;
|
||||
int partNum_<%=cid%> = 1;
|
||||
|
||||
java.util.List<com.amazonaws.services.s3.model.PartETag> partTags_<%=cid%> = new java.util.ArrayList<com.amazonaws.services.s3.model.PartETag>();
|
||||
|
||||
try {
|
||||
while (bytePosition_<%=cid%> < objectSize_<%=cid%>) {
|
||||
long lastByte_<%=cid%> = java.lang.Math.min(bytePosition_<%=cid%> + partSizeInBytes_<%=cid%> - 1, objectSize_<%=cid%> - 1);
|
||||
|
||||
com.amazonaws.services.s3.model.CopyPartRequest copyPartRequest_<%=cid%> = new com.amazonaws.services.s3.model.CopyPartRequest()
|
||||
.withSourceBucketName(from_bucket_<%=cid%>)
|
||||
.withSourceKey(from_key_<%=cid%>)
|
||||
.withDestinationBucketName(to_bucket_<%=cid%>)
|
||||
.withDestinationKey(to_key_<%=cid%>)
|
||||
.withUploadId(initResult_<%=cid%>.getUploadId())
|
||||
.withFirstByte(bytePosition_<%=cid%>)
|
||||
.withLastByte(lastByte_<%=cid%>)
|
||||
.withPartNumber(partNum_<%=cid%>++);
|
||||
partTags_<%=cid%>.add(conn_<%=cid%>.copyPart(copyPartRequest_<%=cid%>).getPartETag());
|
||||
bytePosition_<%=cid%> += partSizeInBytes_<%=cid%>;
|
||||
}
|
||||
|
||||
com.amazonaws.services.s3.model.CompleteMultipartUploadRequest completeRequest_<%=cid%> = new com.amazonaws.services.s3.model.CompleteMultipartUploadRequest(
|
||||
to_bucket_<%=cid%>,
|
||||
to_key_<%=cid%>,
|
||||
initResult_<%=cid%>.getUploadId(),
|
||||
partTags_<%=cid%>);
|
||||
conn_<%=cid%>.completeMultipartUpload(completeRequest_<%=cid%>);
|
||||
} catch (java.lang.Exception uploadException_<%=cid%>) {
|
||||
conn_<%=cid%>.abortMultipartUpload(new com.amazonaws.services.s3.model.AbortMultipartUploadRequest(to_bucket_<%=cid%>, to_key_<%=cid%>, initResult_<%=cid%>.getUploadId()));
|
||||
throw uploadException_<%=cid%>;
|
||||
}
|
||||
}
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Copied the object successfully.");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}catch(java.lang.Exception e_<%=cid%>){
|
||||
<%
|
||||
if (("true").equals(dieOnError)) {
|
||||
%>
|
||||
throw(e_<%=cid%>);
|
||||
<%
|
||||
} else {
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.error("<%=cid%> - " + e_<%=cid%>.getMessage());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
System.err.println(e_<%=cid%>.getMessage());
|
||||
<%
|
||||
}
|
||||
if(!("true").equals(useExistingConn)) {
|
||||
%>
|
||||
}finally{
|
||||
if(conn_<%=cid%> !=null){
|
||||
conn_<%=cid%>.shutdown();
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}
|
||||
|
||||
|
||||
@@ -402,6 +402,18 @@
|
||||
<DEFAULT>100</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CANNED_ACCESS_CONTROL_LIST" FIELD="OPENED_LIST" NUM_ROW="100" DYNAMIC_SETTINGS="true">
|
||||
<ITEMS DEFAULT="NONE">
|
||||
<ITEM NAME="NONE" VALUE=""NONE"" />
|
||||
<ITEM NAME="PRIVATE" VALUE=""Private"" />
|
||||
<ITEM NAME="PUBLIC_READ" VALUE=""PublicRead"" />
|
||||
<ITEM NAME="PUBLIC_READ_WRITE" VALUE=""PublicReadWrite"" />
|
||||
<ITEM NAME="AWS_EXEC_READ" VALUE=""AwsExecRead"" />
|
||||
<ITEM NAME="AUTHENTICATED_READ" VALUE=""AuthenticatedRead"" />
|
||||
<ITEM NAME="BUCKET_OWNER_READ" VALUE=""BucketOwnerRead"" />
|
||||
<ITEM NAME="BUCKET_OWNER_FULL_CONTROL" VALUE=""BucketOwnerFullControl"" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
|
||||
@@ -103,4 +103,15 @@ SIGNING_REGION.ITEM.CA_CENTRAL_1=Canada (Central)
|
||||
ENABLE_KMS.NAME=Use KMS
|
||||
KMSID.NAME=Customer Master Key
|
||||
|
||||
PART_SIZE.NAME=Part size(Mb) for file larger than 5GB
|
||||
PART_SIZE.NAME=Part size(Mb) for file larger than 5GB
|
||||
|
||||
CANNED_ACCESS_CONTROL_LIST.NAME=Canned Access Control
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.NONE=None
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PRIVATE=Private
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ=Public-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ_WRITE=Public-Read-Write
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AWS_EXEC_READ=Aws-Exec-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AUTHENTICATED_READ=Authenticated-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.BUCKET_OWNER_READ=Bucket-Owner-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.BUCKET_OWNER_FULL_CONTROL=Bucket-Owner-Full-Control
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.LOG_DELIVERY_WRITE=Log-Delivery-Write
|
||||
@@ -30,7 +30,8 @@ imports="
|
||||
|
||||
boolean enableACL = "true".equals(ElementParameterParser.getValue(node, "__ACCESS_CONTROL_LIST__"));
|
||||
List<Map<String, String>> paramsACL = ElementParameterParser.getTableValue(node,"__ACL__");
|
||||
|
||||
final String cannedACL = ElementParameterParser.getValue(node, "__CANNED_ACCESS_CONTROL_LIST__");
|
||||
final boolean enableCannedACL = (cannedACL != null) && (!cannedACL.isEmpty()) && !("\"NONE\"".equals(cannedACL));
|
||||
%>
|
||||
<%@ include file="../tS3Connection/S3Client.javajet" %>
|
||||
String key_<%=cid%> = <%=key%>;
|
||||
@@ -141,7 +142,15 @@ accessCtrlList.grantPermission(grantee_<%=cid%>_<%=grantee_id%>, com.amazonaws.s
|
||||
<%if (enableACL) {%>
|
||||
putRequest_<%=cid%>.withAccessControlList(accessCtrlList);
|
||||
<%}%>
|
||||
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
putRequest_<%=cid%>.withCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
|
||||
<%@ include file="./set_kms.javajet"%>
|
||||
|
||||
com.amazonaws.services.s3.transfer.Upload upload_<%=cid%> = tm_<%=cid%>.upload(putRequest_<%=cid%>);
|
||||
@@ -176,7 +185,14 @@ accessCtrlList.grantPermission(grantee_<%=cid%>_<%=grantee_id%>, com.amazonaws.s
|
||||
<%if (enableACL) {%>
|
||||
putRequest_<%=cid%>.withAccessControlList(accessCtrlList);
|
||||
<%}%>
|
||||
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
putRequest_<%=cid%>.withCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
<%@ include file="./set_kms.javajet"%>
|
||||
|
||||
conn_<%=cid%>.putObject(putRequest_<%=cid%>);
|
||||
@@ -187,7 +203,14 @@ accessCtrlList.grantPermission(grantee_<%=cid%>_<%=grantee_id%>, com.amazonaws.s
|
||||
<%if (enableACL) {%>
|
||||
putRequest_<%=cid%>.withAccessControlList(accessCtrlList);
|
||||
<%}%>
|
||||
|
||||
<%if (enableCannedACL) {%>
|
||||
{
|
||||
final String cannedACLChoice = <%= cannedACL %>;
|
||||
if (cannedACLChoice != null && (!cannedACLChoice.isEmpty()) && !("NONE".equals(cannedACLChoice))) {
|
||||
putRequest_<%=cid%>.withCannedACL(com.amazonaws.services.s3.model.CannedAccessControlList.valueOf(cannedACLChoice));
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
<%@ include file="./set_kms.javajet"%>
|
||||
|
||||
com.amazonaws.services.s3.model.InitiateMultipartUploadResult initResponse_<%=cid%> = conn_<%=cid%>.initiateMultipartUpload(putRequest_<%=cid%>);
|
||||
|
||||
@@ -498,7 +498,18 @@
|
||||
<ITEM NAME="WRITE_ACL" FIELD="CHECK"/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CANNED_ACCESS_CONTROL_LIST" FIELD="OPENED_LIST" NUM_ROW="100" DYNAMIC_SETTINGS="true">
|
||||
<ITEMS DEFAULT="NONE">
|
||||
<ITEM NAME="NONE" VALUE=""NONE"" />
|
||||
<ITEM NAME="PRIVATE" VALUE=""Private"" />
|
||||
<ITEM NAME="PUBLIC_READ" VALUE=""PublicRead"" />
|
||||
<ITEM NAME="PUBLIC_READ_WRITE" VALUE=""PublicReadWrite"" />
|
||||
<ITEM NAME="AWS_EXEC_READ" VALUE=""AwsExecRead"" />
|
||||
<ITEM NAME="AUTHENTICATED_READ" VALUE=""AuthenticatedRead"" />
|
||||
<ITEM NAME="BUCKET_OWNER_READ" VALUE=""BucketOwnerRead"" />
|
||||
<ITEM NAME="BUCKET_OWNER_FULL_CONTROL" VALUE=""BucketOwnerFullControl"" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
|
||||
@@ -129,3 +129,14 @@ ACL.ITEM.ID=Account canonical ID / email
|
||||
ACL.ITEM.READ=Read object
|
||||
ACL.ITEM.READ_ACL=Read object permissions
|
||||
ACL.ITEM.WRITE_ACL=Write object permissions
|
||||
|
||||
CANNED_ACCESS_CONTROL_LIST.NAME=Canned Access Control
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.NONE=None
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PRIVATE=Private
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ=Public-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.PUBLIC_READ_WRITE=Public-Read-Write
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AWS_EXEC_READ=Aws-Exec-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.AUTHENTICATED_READ=Authenticated-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.BUCKET_OWNER_READ=Bucket-Owner-Read
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.BUCKET_OWNER_FULL_CONTROL=Bucket-Owner-Full-Control
|
||||
CANNED_ACCESS_CONTROL_LIST.ITEM.LOG_DELIVERY_WRITE=Log-Delivery-Write
|
||||
@@ -148,9 +148,7 @@ public class ComponentsUtils {
|
||||
&& componentDefinition.getFamilies()[0].contains("JDBC")) {
|
||||
jdbcDefinitions.add(componentDefinition);
|
||||
}
|
||||
if (UnifiedComponentUtil.JDBC_COMPONENT_BLACKLIST.contains(componentDefinition.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
loadComponents(components, componentDefinition);
|
||||
}
|
||||
|
||||
@@ -208,7 +206,7 @@ public class ComponentsUtils {
|
||||
// if the component is not needed in the current branding,
|
||||
// and that this one IS a specific component for code generation,
|
||||
// hide it
|
||||
if (hiddenComponent
|
||||
if (UnifiedComponentUtil.JDBC_COMPONENT_BLACKLIST.contains(currentComponent.getName()) || hiddenComponent
|
||||
&& (currentComponent.getOriginalFamilyName().contains("Technical") || currentComponent.isTechnical())) {
|
||||
currentComponent.setVisible(false);
|
||||
currentComponent.setTechnical(true);
|
||||
|
||||
@@ -100,9 +100,6 @@ public class SetupProcessDependenciesRoutinesAction extends AContextualAction {
|
||||
&& ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.DELETED) {
|
||||
canWork = false;
|
||||
}
|
||||
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
|
||||
canWork = false;
|
||||
}
|
||||
|
||||
// If the editProcess action canwork is true, then detect that the job version is the latest verison or not.
|
||||
if (canWork) {
|
||||
@@ -125,7 +122,8 @@ public class SetupProcessDependenciesRoutinesAction extends AContextualAction {
|
||||
ProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
|
||||
ERepositoryStatus status = repFactory.getStatus(node.getObject());
|
||||
if (!repFactory.isPotentiallyEditable(node.getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER
|
||||
|| status == ERepositoryStatus.LOCK_BY_USER || (ERepositoryObjectType.TEST_CONTAINER != null
|
||||
|| status == ERepositoryStatus.LOCK_BY_USER || !ProjectManager.getInstance().isInCurrentMainProject(node)
|
||||
|| (ERepositoryObjectType.TEST_CONTAINER != null
|
||||
&& node.getObjectType().equals(ERepositoryObjectType.TEST_CONTAINER))) {
|
||||
readonly = true;
|
||||
}
|
||||
|
||||
@@ -4854,8 +4854,11 @@ public class Node extends Element implements IGraphicalNode {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkIfCanBeStart() {
|
||||
// tELTSAPMap component is more like a input component than ELT component as it output a flow stream.
|
||||
if (isELTSAPMapComponent()) {
|
||||
// tCollectAndCheck can be start node now in BD jobs
|
||||
if ("tCollectAndCheck".equals(this.getComponent().getName())) {
|
||||
return true;
|
||||
} else if (isELTSAPMapComponent()) {
|
||||
// tELTSAPMap component is more like a input component than ELT component as it output a flow stream.
|
||||
if (!isThereConditionLink() && isOnMainBranch()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -400,6 +400,17 @@
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.core.migrationTask">
|
||||
|
||||
<projecttask
|
||||
beforeLogon="true"
|
||||
breaks="7.3.1"
|
||||
class="org.talend.repository.model.migration.spark.AddKafkaExtraInfo"
|
||||
description="Add key, partition and topic to the output schema of tKafkaInput components"
|
||||
id="org.talend.repository.model.migration.spark.AddKafkaExtraInfo"
|
||||
name="AddKafkaExtraInfo"
|
||||
version="7.3.1">
|
||||
</projecttask>
|
||||
|
||||
<projecttask
|
||||
beforeLogon="true"
|
||||
breaks="5.1.1"
|
||||
@@ -3592,6 +3603,15 @@
|
||||
name="RemoveDefaultProxyIPTask"
|
||||
version="7.3.1">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.3.0"
|
||||
class="org.talend.repository.model.migration.AddAndSetDBVersionValueCosmosDB"
|
||||
description="Add DB Version list to CosmosDB family components and set default value to 'MONGODB_3_2_X'"
|
||||
id="org.talend.repository.model.migration.AddAndSetDBVersionValueCosmosDB"
|
||||
name="AddAndSetDBVersionValueCosmosDB"
|
||||
version="7.3.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.model.migration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractJobMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
|
||||
/**
|
||||
* adds "DB Version" list to CosmosDB family components and sets default value to "MONGODB_3_2_X", see feature TDI-45590.
|
||||
*
|
||||
*/
|
||||
public class AddAndSetDBVersionValueCosmosDB extends AbstractJobMigrationTask {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
|
||||
* ProcessItem)
|
||||
*/
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
ProcessType processType = getProcessType(item);
|
||||
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
String[] componentsName = new String[] {"tCosmosDBConnection", "tCosmosDBInput", "tCosmosDBOutput", "tCosmosDBRow", "tCosmosDBWriteConf"};
|
||||
|
||||
try {
|
||||
|
||||
for (int i = 0; i < componentsName.length; i++) {
|
||||
IComponentFilter filter = new NameComponentFilter(componentsName[i]);
|
||||
ModifyComponentsAction.searchAndModify(item, processType, filter,
|
||||
Arrays.<IComponentConversion> asList(new IComponentConversion() {
|
||||
|
||||
public void transform(NodeType node) {
|
||||
if (ComponentUtilities.getNodeProperty(node, "DB_VERSION") == null) {
|
||||
ComponentUtilities.addNodeProperty(node, "DB_VERSION", "CLOSED_LIST");
|
||||
ComponentUtilities.getNodeProperty(node, "DB_VERSION").setValue("MONGODB_3_2_X");
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2021, 02, 23, 15, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package org.talend.repository.model.migration.spark;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractJobMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ColumnType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.MetadataType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
|
||||
public class AddKafkaExtraInfo extends AbstractJobMigrationTask {
|
||||
|
||||
private static final List<String> IMPACTED_COMPONENTS = Arrays.asList("tKafkaInput");
|
||||
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2020, 12, 23, 13, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ERepositoryObjectType> getTypes() {
|
||||
// Spark batch
|
||||
List<ERepositoryObjectType> types = Arrays
|
||||
.asList(ERepositoryObjectType.TEST_CONTAINER, ERepositoryObjectType.PROCESS_STORM,
|
||||
ERepositoryObjectType.SPARK_STREAMING_JOBLET);
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
|
||||
boolean fullMigrationSucceded = true;
|
||||
ProcessType processType = getProcessType(item);
|
||||
|
||||
if (processType == null) {
|
||||
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
for (String componentName : IMPACTED_COMPONENTS) {
|
||||
|
||||
IComponentConversion addKafkaInfo = new AddKafkaInfo();
|
||||
|
||||
try {
|
||||
ModifyComponentsAction
|
||||
.searchAndModify(item, processType, new NameComponentFilter(componentName),
|
||||
java.util.Collections.singletonList(addKafkaInfo));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
fullMigrationSucceded = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return fullMigrationSucceded ? ExecutionResult.SUCCESS_NO_ALERT : ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
private class AddKafkaInfo implements IComponentConversion {
|
||||
|
||||
@Override
|
||||
public void transform(NodeType node) {
|
||||
|
||||
TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
|
||||
MetadataType newMetadata = fileFact.createMetadataType();
|
||||
|
||||
for (Object metadataObject : node.getMetadata()) {
|
||||
MetadataType metadata = (MetadataType) metadataObject;
|
||||
|
||||
Map<String, String> newColumns = new HashMap<String, String>();
|
||||
|
||||
newColumns.put("topic", "id_String");
|
||||
newColumns.put("partition", "id_Integer");
|
||||
newColumns.put("key", "id_byte[]");
|
||||
|
||||
List<ColumnType> columnList = metadata.getColumn();
|
||||
|
||||
for (Map.Entry<String, String> entry : newColumns.entrySet()) {
|
||||
ColumnType metadataColumn = fileFact.createColumnType();
|
||||
metadataColumn.setName(entry.getKey());
|
||||
metadataColumn.setType(entry.getValue());
|
||||
columnList.add(metadataColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,17 +123,17 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
protected static final char MANIFEST_ITEM_SEPARATOR = ',';
|
||||
|
||||
protected static final String OSGI_EXCLUDE_PROP_FILENAME = "osgi-exclude.properties"; ////$NON-NLS-1$
|
||||
|
||||
private boolean ENABLE_CACHE = StringUtils.equals(System.getProperty("enable.manifest.cache", "true"), "true");
|
||||
|
||||
private boolean ENABLE_CACHE = StringUtils.equals(System.getProperty("enable.manifest.cache", "false"), "true");
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static final Collection<String> EXCLUDED_MODULES = new ArrayList<String>() {
|
||||
|
||||
{
|
||||
File propFile = null;
|
||||
File esbConfigurationLocation = EsbConfigUtils.getEclipseEsbFolder();
|
||||
|
||||
if (esbConfigurationLocation != null && esbConfigurationLocation.exists()
|
||||
&& esbConfigurationLocation.isDirectory()) {
|
||||
|
||||
if (esbConfigurationLocation != null && esbConfigurationLocation.exists() && esbConfigurationLocation.isDirectory()) {
|
||||
propFile = new File(esbConfigurationLocation.getAbsolutePath(), OSGI_EXCLUDE_PROP_FILENAME);
|
||||
}
|
||||
|
||||
@@ -142,11 +142,10 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
if (propFile != null && propFile.exists() && propFile.isFile()) {
|
||||
is = new FileInputStream(propFile);
|
||||
} else {
|
||||
is = RepositoryPlugin.getDefault().getBundle()
|
||||
.getEntry("/resources/" + OSGI_EXCLUDE_PROP_FILENAME)
|
||||
is = RepositoryPlugin.getDefault().getBundle().getEntry("/resources/" + OSGI_EXCLUDE_PROP_FILENAME)
|
||||
.openStream();
|
||||
}
|
||||
|
||||
|
||||
if (is != null) {
|
||||
final Properties p = new Properties();
|
||||
p.load(is);
|
||||
@@ -447,7 +446,7 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
private List<ExportFileResource> cleanupResources(Stream<IComponent> components, List<ExportFileResource> resources, ITaCoKitDependencyService service) {
|
||||
Set<String> tckOnly = service.getTaCoKitOnlyDependencies(components);
|
||||
//final List<ExportFileResource> rmResources = new ArrayList<>();
|
||||
// final List<ExportFileResource> rmResources = new ArrayList<>();
|
||||
//This code is nicer but have to reiterate after, so not so efficient
|
||||
// List<URL> rmDeps = resources.stream()
|
||||
// .filter(rf -> "lib".equals(rf.getDirectoryName()))
|
||||
@@ -901,8 +900,6 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
private static final String TEMPLATE_BLUEPRINT_JOB = "/resources/job-template.xml"; //$NON-NLS-1$
|
||||
|
||||
private Analyzer analyzer = new Analyzer();
|
||||
|
||||
private void createJobBundleBlueprintConfig(ProcessItem processItem, IProcess process, File targetFile) throws IOException {
|
||||
TemplateProcessor.processTemplate("JOB_BLUEPRINT_CONFIG", //$NON-NLS-1$
|
||||
collectJobInfo(processItem, process), targetFile, JobJavaScriptOSGIForESBManager.class.getClassLoader()
|
||||
@@ -972,12 +969,8 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
Manifest manifest = null;
|
||||
try {
|
||||
manifest = analyzer.calcManifest();
|
||||
if(ENABLE_CACHE) {
|
||||
filterPackagesCache(manifest, imports);
|
||||
}else {
|
||||
filterImportPackages(manifest);
|
||||
}
|
||||
|
||||
filterPackagesCache(manifest, imports);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
@@ -1026,7 +1019,6 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
if (dependencyCacheMap == null || dependencyCacheMap.get(key) == null) {
|
||||
Jar bin = new Jar(jarFile);
|
||||
al.clear();
|
||||
al.setJar(bin);
|
||||
// al.setProperty(Analyzer.IMPORT_PACKAGE, "*;resolution:=optional");
|
||||
// bin.putResource(relativePath, new FileResource(jarFile));
|
||||
@@ -1039,6 +1031,7 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
// }
|
||||
Domain d = Domain.domain(manifest);
|
||||
Parameters imports = d.getImportPackage();
|
||||
Parameters privates = d.getPrivatePackage();
|
||||
|
||||
String privatePackageString = manifest.getMainAttributes().getValue(Analyzer.PRIVATE_PACKAGE);
|
||||
String importPackageString = manifest.getMainAttributes().getValue(Analyzer.IMPORT_PACKAGE);
|
||||
@@ -1050,7 +1043,7 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
List<Object> infos = new ArrayList<>();
|
||||
infos.add(imports.keyList());
|
||||
infos.add(privatePackageString);
|
||||
infos.add(privates.keyList());
|
||||
infos.add(relativePath);
|
||||
|
||||
if (dependencyCacheMap == null) {
|
||||
@@ -1093,73 +1086,31 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
}
|
||||
|
||||
private List<String> bundleClasspathKeys = new ArrayList<>();
|
||||
|
||||
private void filterImportPackages(Manifest manifest) {
|
||||
|
||||
// remove import packages which are present in private packages
|
||||
|
||||
List<String> privatePackages = new ArrayList<String>();
|
||||
String privatePackagesString = manifest.getMainAttributes().getValue(Analyzer.PRIVATE_PACKAGE);
|
||||
if (privatePackagesString != null) {
|
||||
String [] packages = privatePackagesString.split(",");
|
||||
for (String p : packages) {
|
||||
privatePackages.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder fileterdImportPackage = new StringBuilder();
|
||||
String importPackagesString = manifest.getMainAttributes().getValue(Analyzer.IMPORT_PACKAGE);
|
||||
if (importPackagesString != null) {
|
||||
String [] packages = importPackagesString.split(",");
|
||||
for (String p : packages) {
|
||||
String importPackage = p.split(";")[0];
|
||||
if (!privatePackages.contains(importPackage) || importPackage.startsWith("routines")) {
|
||||
fileterdImportPackage.append(p).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String str = fileterdImportPackage.toString();
|
||||
if (str != null && str.length() > 0 && str.endsWith(",")) {
|
||||
str = str.substring(0, str.length() - 1);
|
||||
}
|
||||
manifest.getMainAttributes().putValue(Analyzer.IMPORT_PACKAGE, str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void filterPackagesCache(Manifest manifest, Set<String> imports) {
|
||||
|
||||
// List<String> bundleClasspaths = null;
|
||||
// if (manifest.getMainAttributes().getValue(Analyzer.BUNDLE_CLASSPATH) == null) {
|
||||
// bundleClasspaths = new ArrayList<>();
|
||||
// } else {
|
||||
// bundleClasspaths = Stream.of(manifest.getMainAttributes().getValue(Analyzer.BUNDLE_CLASSPATH).split(","))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// manifest.getMainAttributes().putValue(Analyzer.BUNDLE_CLASSPATH, String.join(",", bundleClasspaths));
|
||||
|
||||
Set<String> privateNonRepetitivePackages = null;
|
||||
|
||||
if (manifest.getMainAttributes().getValue(Analyzer.PRIVATE_PACKAGE) == null) {
|
||||
privateNonRepetitivePackages = new HashSet<>();
|
||||
} else {
|
||||
privateNonRepetitivePackages = Stream.of(manifest.getMainAttributes().getValue(Analyzer.PRIVATE_PACKAGE).split(","))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
Set<String> importNonRepetitivePackages = null;
|
||||
|
||||
if (manifest.getMainAttributes().getValue(Analyzer.IMPORT_PACKAGE) == null) {
|
||||
importNonRepetitivePackages = new HashSet<>();
|
||||
} else {
|
||||
importNonRepetitivePackages = imports.stream().map(v -> {
|
||||
if (!StringUtils.endsWith(v, RESOLUTION_OPTIONAL)) {
|
||||
return v + RESOLUTION_OPTIONAL;
|
||||
}
|
||||
return v;
|
||||
}).collect(Collectors.toSet());
|
||||
if (!ENABLE_CACHE) {
|
||||
bundleClasspathKeys.clear();
|
||||
}
|
||||
|
||||
Domain domain = Domain.domain(manifest);
|
||||
Parameters calculatedImports = domain.getImportPackage();
|
||||
Parameters calculatedPrivates = domain.getPrivatePackage();
|
||||
|
||||
Set<String> privateNonRepetitivePackages = new HashSet<>(calculatedPrivates.keySet());
|
||||
|
||||
Set<String> importNonRepetitivePackages = new HashSet<>(calculatedImports.keySet());
|
||||
|
||||
importNonRepetitivePackages.addAll(imports);
|
||||
|
||||
importNonRepetitivePackages = importNonRepetitivePackages.stream().map(v -> {
|
||||
if (!StringUtils.endsWith(v, RESOLUTION_OPTIONAL)) {
|
||||
return v + RESOLUTION_OPTIONAL;
|
||||
}
|
||||
return v;
|
||||
}).collect(Collectors.toSet());
|
||||
|
||||
int size = bundleClasspathKeys.size();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
@@ -1176,10 +1127,9 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
return v;
|
||||
}).collect(Collectors.toSet()));
|
||||
|
||||
Collections.addAll(privateNonRepetitivePackages, infos.get(1).toString().split(","));
|
||||
// bundleClasspaths.add(infos.get(2));
|
||||
privateNonRepetitivePackages.addAll((List<String>) infos.get(1));
|
||||
}
|
||||
|
||||
|
||||
importNonRepetitivePackages.remove("routines.system");
|
||||
importNonRepetitivePackages.remove("routines.system" + RESOLUTION_OPTIONAL);
|
||||
|
||||
@@ -1187,6 +1137,12 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
importNonRepetitivePackages.remove("javax.annotation");
|
||||
importNonRepetitivePackages.remove("javax.annotation" + RESOLUTION_OPTIONAL);
|
||||
importNonRepetitivePackages.add("javax.annotation;version=\"[1.3,2)\"" + RESOLUTION_OPTIONAL);
|
||||
|
||||
// TESB-32507 make org.talend.esb.authorization.xacml.rt.pep not optional
|
||||
if (importNonRepetitivePackages.contains("org.talend.esb.authorization.xacml.rt.pep" + RESOLUTION_OPTIONAL)) {
|
||||
importNonRepetitivePackages.remove("org.talend.esb.authorization.xacml.rt.pep" + RESOLUTION_OPTIONAL);
|
||||
importNonRepetitivePackages.add("org.talend.esb.authorization.xacml.rt.pep");
|
||||
}
|
||||
|
||||
Set<String> fileterdImportPackage = new HashSet<>();
|
||||
|
||||
@@ -1195,14 +1151,14 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
fileterdImportPackage.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
manifest.getMainAttributes().putValue(Analyzer.PRIVATE_PACKAGE, String.join(",", privateNonRepetitivePackages));
|
||||
manifest.getMainAttributes().putValue(Analyzer.IMPORT_PACKAGE, String.join(",", fileterdImportPackage));
|
||||
}
|
||||
|
||||
protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
|
||||
Analyzer analyzer = new Analyzer();
|
||||
Jar bin = new Jar(classesLocation);
|
||||
analyzer.clear();
|
||||
analyzer.setJar(bin);
|
||||
|
||||
final String bundleName = processItem.getProperty().getLabel();
|
||||
@@ -1243,18 +1199,18 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
|
||||
String relativePath = libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName();
|
||||
|
||||
|
||||
bundleClasspathKeys.add(dependencyFile.length() + dependencyFile.getName());
|
||||
bundleClasspath.append(MANIFEST_ITEM_SEPARATOR).append(relativePath);
|
||||
|
||||
|
||||
// analyzer.addClasspath(new File(url.getPath()));
|
||||
// Add dynamic library declaration in manifest
|
||||
if (relativePath.toLowerCase().endsWith(DLL_FILE) || relativePath.toLowerCase().endsWith(SO_FILE)) {
|
||||
bundleNativeCode.append(libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName()).append(
|
||||
OSGI_OS_CODE);
|
||||
}
|
||||
|
||||
//If don't want to enable this feature just comment out
|
||||
|
||||
// If don't want to enable this feature just comment out
|
||||
if (ENABLE_CACHE && cacheManifest(url, relativePath)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1445,8 +1401,8 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
imports.addAll(importCompiler(service, subjobInfo.getProcessItem()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
@@ -1455,7 +1411,8 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream err = new ByteArrayOutputStream();
|
||||
try {
|
||||
org.eclipse.jdt.core.compiler.batch.BatchCompiler.compile(src + " -1.7 -nowarn -maxProblems 100000 ", new PrintWriter(out),
|
||||
org.eclipse.jdt.core.compiler.batch.BatchCompiler.compile(src + " -1.7 -nowarn -maxProblems 100000 ",
|
||||
new PrintWriter(out),
|
||||
new PrintWriter(err), null);
|
||||
String errString = new String(err.toByteArray());
|
||||
String[] errBlocks = errString.split("----------");
|
||||
|
||||
Reference in New Issue
Block a user