Skip to content

Commit dadab58

Browse files
committed
CXF-9178: Run Jakarta RESTful Web Services 4.0 TCK
(cherry picked from commit 00aec76)
1 parent 7e80cf9 commit dadab58

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import jakarta.ws.rs.ext.MessageBodyWriter;
4545
import jakarta.ws.rs.ext.Provider;
4646
import jakarta.ws.rs.ext.Providers;
47-
import org.apache.cxf.attachment.AttachmentUtil;
4847
import org.apache.cxf.common.logging.LogUtils;
4948
import org.apache.cxf.common.util.StringUtils;
5049
import org.apache.cxf.helpers.CastUtils;
@@ -161,13 +160,13 @@ private <T> EntityPart fromAttachment(Attachment attachment, Class<T> c, final T
161160
final String fileName = (cd != null) ? cd.getFilename() : null;
162161
final String cdName = cd == null ? null : cd.getParameter("name");
163162
final String contentId = attachment.getContentId();
164-
final String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", "");
165163

166164
if (!StringUtils.isEmpty(fileName)) {
167-
return new EntityPartImpl(mc.getProviders(), name, fileName, is, c, genericType, headers,
168-
attachment.getContentType());
165+
return new EntityPartImpl(mc.getProviders(), contentId, fileName, is, c, genericType,
166+
attachment.getHeaders(), attachment.getContentType());
169167
} else {
170-
return new EntityPartImpl(mc.getProviders(), name, null, is, c, genericType, headers,
168+
final String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", "");
169+
return new EntityPartImpl(mc.getProviders(), name, null, is, c, genericType, attachment.getHeaders(),
171170
attachment.getContentType());
172171
}
173172
} else {
@@ -207,7 +206,7 @@ private static <T> Attachment createDataHandler(final EntityPart part, final Cla
207206
return part.getFileName()
208207
.map(fileName -> {
209208
final ContentDisposition cd = new ContentDisposition("form-data;name=file;filename=" + fileName);
210-
return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, part.getContent(), cd);
209+
return new Attachment(part.getName(), part.getContent(), cd);
211210
})
212211
.orElseGet(() -> {
213212
headers.putSingle("Content-Type", mt);

0 commit comments

Comments
 (0)