Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2026 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vip.messages.data.dao.gcs.impl;
Expand Down Expand Up @@ -32,6 +32,7 @@
@Repository
public class GcsComponentChannelDao implements IComponentChannelDao {
private static Logger logger = LoggerFactory.getLogger(GcsComponentChannelDao.class);
private static final int CHUNK_SIZE = 64 * 1024;

@Autowired
private GcsClient gcsClient;
Expand All @@ -53,6 +54,7 @@ public List<ResultMessageChannel> getTransReadableByteChannels(String productNam
Blob blob = gcsClient.getGcsStorage().get(blobId);
if (blob != null) {
ReadChannel readChannel = blob.reader();
readChannel.setChunkSize(CHUNK_SIZE);
InputStream is = Channels.newInputStream(readChannel);
resultChannels.add(new ResultMessageChannel(component, locale, Channels.newChannel(is)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2026 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vip.core.except;
Expand All @@ -18,6 +18,7 @@
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand Down Expand Up @@ -67,6 +68,10 @@ public APIResponseDTO handler(Exception e) {
logger.error("====== HTTP Exception =======");
logger.error(e.getMessage());
response.setResponse(new Response(APIResponseStatus.INTERNAL_SERVER_ERROR.getCode(), e.getMessage()));
} else if (e instanceof HttpMessageNotReadableException) {
logger.error("====== HttpMessageNotReadableException =======");
logger.error(e.getMessage());
response.setResponse(new Response(APIResponseStatus.BAD_REQUEST.getCode(), "Required request body is missing"));
} else {
response.setResponse(new Response(APIResponseStatus.UNKNOWN_ERROR.getCode(), e.getMessage()));
String errorStr = MessageFormat.format("unknown error: {0}" ,e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 VMware, Inc.
* Copyright 2019-2026 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vip.i18n.api.base;
Expand All @@ -16,6 +16,8 @@
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import jakarta.servlet.http.HttpServletResponse;
Expand All @@ -33,6 +35,7 @@
import java.util.stream.Collectors;

public class StreamProductAction extends TranslationProductAction {
private static Logger logger = LoggerFactory.getLogger(StreamProductAction.class);
private static byte[] byteComm = (ConstantsChar.COMMA + "\r\n").getBytes();

@Autowired
Expand Down Expand Up @@ -176,6 +179,15 @@ private void writeTranslationsToChannel(List<ResultMessageChannel> readChannels,
} else {
buf.put(byteComm);
}
if (logger.isDebugEnabled()) {
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory(); // -Xmx configuration limit
long totalMemory = runtime.totalMemory(); // Currently allocated to the JVM
long freeMemory = runtime.freeMemory(); // Unused portion of total allocated memory
long usedMemory = totalMemory - freeMemory; // Memory actively holding objects
logger.debug("FreeMemory: {}, UsedMemory: {}, TotalMemory: {}", freeMemory, usedMemory, totalMemory);
}

transferTo(readChannels.get(idx).getReadableByteChannel(), wbc, buf);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 VMware, Inc.
* Copyright 2019-2026 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vip.core.Interceptor;
Expand Down Expand Up @@ -30,8 +30,13 @@ public APICrossDomainInterceptor(Set<String> allowOrigin, String allowHeaders, S
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String originHeader = request.getHeader("Origin");
if (allowOrigin.contains("*") || allowOrigin.contains(originHeader)) {
response.setHeader("Access-Control-Allow-Origin", originHeader == null ? "" : originHeader);
if (allowOrigin.contains("*")) {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", allowMethods);
response.setHeader("Access-Control-Allow-Headers", allowHeaders);
response.setHeader("Access-Control-Max-Age", maxAge);
} else if (allowOrigin.contains(originHeader)) {
response.setHeader("Access-Control-Allow-Origin", originHeader);
response.setHeader("Access-Control-Allow-Methods", allowMethods);
response.setHeader("Access-Control-Allow-Headers", allowHeaders);
response.setHeader("Access-Control-Allow-Credentials", allowCredentials);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
#Copyright 2019-2022 VMware, Inc.
#Copyright 2019-2026 VMware, Inc.
#SPDX-License-Identifier: EPL-2.0
##

Expand Down Expand Up @@ -71,7 +71,7 @@ vipservice.authority.ldap.searchbase=###

#cross-domain configuration
vipservice.cross.domain.enable=true
vipservice.cross.domain.allowCredentials=true
vipservice.cross.domain.allowCredentials=false
vipservice.cross.domain.alloworigin=*
vipservice.cross.domain.allowmethods=GET, POST, PUT, DELETE, OPTIONS
vipservice.cross.domain.allowheaders=csp-auth-token, Content-Type, x-xmp-ui, Authorization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
#Copyright 2019-2022 VMware, Inc.
#Copyright 2019-2026 VMware, Inc.
#SPDX-License-Identifier: EPL-2.0
##

Expand Down Expand Up @@ -69,7 +69,7 @@ vipservice.authority.ldap.searchbase=####

#cross-domain configuration
vipservice.cross.domain.enable=true
vipservice.cross.domain.allowCredentials=true
vipservice.cross.domain.allowCredentials=false
vipservice.cross.domain.alloworigin=*
vipservice.cross.domain.allowmethods=GET, POST, PUT, DELETE, OPTIONS
vipservice.cross.domain.allowheaders=csp-auth-token, Content-Type, x-xmp-ui, Authorization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
#Copyright 2019-2022 VMware, Inc.
#Copyright 2019-2026 VMware, Inc.
#SPDX-License-Identifier: EPL-2.0
##

Expand Down Expand Up @@ -76,7 +76,7 @@ vipservice.authority.ldap.searchbase=####

#cross-domain configuration
vipservice.cross.domain.enable=true
vipservice.cross.domain.allowCredentials=true
vipservice.cross.domain.allowCredentials=false
vipservice.cross.domain.alloworigin=*
vipservice.cross.domain.allowmethods=GET, POST, PUT, DELETE, OPTIONS
vipservice.cross.domain.allowheaders=csp-auth-token, Content-Type, x-xmp-ui, Authorization
Expand Down
Loading