Skip to content

Commit

Permalink
Merge branch 'master' into DeleteImplementationDeprecatedCryptography
Browse files Browse the repository at this point in the history
  • Loading branch information
iroqueta authored Oct 31, 2023
2 parents 5395ef3 + 181d56c commit 7ff1b7a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 62 deletions.
98 changes: 49 additions & 49 deletions java/src/main/java/com/genexus/filters/APIObjectFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,82 +19,82 @@
public class APIObjectFilter extends Filter {

private ArrayList<String> appPath = new ArrayList<String>();

static final String PRIVATE_DIR="private";
static final String WEB_INFO="WEB-INF";
public static final Logger logger = LogManager.getLogger(APIObjectFilter.class);

public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
if (request.isHttpServletRequest() && response.isHttpServletResponse()) {
IHttpServletRequest httpRequest = request.getHttpServletRequest();
public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
if (request.isHttpServletRequest() && response.isHttpServletResponse()) {
IHttpServletRequest httpRequest = request.getHttpServletRequest();
String path = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()).substring(1);
String urlString = path.toLowerCase();
boolean isPath = false;
for(String appBasePath : appPath)
{
if (urlString.startsWith(appBasePath))
{
for (String appBasePath : this.appPath) {
if (urlString.startsWith(appBasePath)) {
isPath = true;
break;
}
}
if(isPath)
{
if(isPath) {
String fwdURI = "/rest/" + path;
logger.info("Forwarding from " + path +" to: " + fwdURI) ;
httpRequest.getRequestDispatcher(fwdURI).forward(request,response);
}
else
{
else {
chain.doFilter(request, response);
}
}
else
{
else {
chain.doFilter(request, response);
}
}

public void init(Map<String, String> headers, String path, String sessionCookieName) throws ServletException {
try {
String paramValue = headers.get("BasePath");
if (paramValue != null && !paramValue.isEmpty())
{
if (paramValue.equals("*"))
{
if (path != null && !path.isEmpty())
{
paramValue = path + "private";
Path privateFolder = Paths.get(paramValue);
if (!Files.exists(privateFolder)){
paramValue = path + "WEB-INF" + File.separator + "private";
}
}
}
logger.info("API metadata path: " + paramValue) ;
Stream<Path> walk = Files.walk(Paths.get(paramValue + File.separator));
List<String> result = walk.map(x -> x.toString()).filter(f -> f.endsWith(".grp.json")).collect(Collectors.toList());
for (String temp : result)
{
try{
String read = String.join( "", Files.readAllLines(Paths.get(temp)));
JSONObject jo = new JSONObject(read);
String apipath = jo.getString("BasePath");
appPath.add(apipath.toLowerCase());
}
catch(IOException e)
{
logger.error("Exception in API Filter: ", e);
}
}
}
else
{
logger.info("API base path invalid.");
String paramValue = headers.get("BasePath");
if (paramValue != null && !paramValue.isEmpty()) {
Path privateFolder = null;
if (paramValue.equals("*")) {
if (path != null && !path.isEmpty()) {
privateFolder = Paths.get(path, PRIVATE_DIR);
if (!Files.exists(privateFolder)) {
privateFolder = Paths.get(path, WEB_INFO, PRIVATE_DIR);
}
}
}
else {
privateFolder = Paths.get(paramValue);
}
if (privateFolder != null) {
logger.info("API metadata folder: [" + privateFolder.toString() + "]") ;
Stream<Path> walk = Files.walk(privateFolder);
List<String> result = walk.map(x -> x.toString()).filter(f -> f.endsWith(".grp.json")).collect(Collectors.toList());
for (String temp : result) {
try {
String read = String.join("", Files.readAllLines(Paths.get(temp)));
JSONObject jo = new JSONObject(read);
String apiPath = jo.getString("BasePath");
appPath.add(apiPath.toLowerCase());
}
catch (IOException e) {
logger.error("Exception API Filter Metadata: ", e);
}
}
}
else {
logger.info("API path invalid");
}
}
else {
logger.info("API base path is empty.");
}
}
catch (Exception e) {
logger.error("Exception in API Filter: ", e);
logger.error("Exception in API Filter initilization: ", e);
}
}

public void destroy() {
}

}
22 changes: 9 additions & 13 deletions java/src/main/java/com/genexus/reports/GXReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ public IReportHandler getPrinter()
}
else if (getOutputType() == OUTPUT_PDF)
{
try {
String implementation = com.genexus.Application.getClientContext().getClientPreferences().getPDF_RPT_LIBRARY();
if (implementation.equals("ITEXT"))
reportHandler = new PDFReportItext2(context);
else if (implementation.equals("ITEXT8"))
reportHandler = new PDFReportItext8(context);
else
reportHandler = new PDFReportPDFBox(context);
((GXReportPDFCommons) reportHandler).setOutputStream(getOutputStream());
} catch (Exception e) {
log.error("Failed to set output stream: ", e);
}
String implementation = com.genexus.Application.getClientContext().getClientPreferences().getPDF_RPT_LIBRARY();
if (implementation.equals("ITEXT"))
reportHandler = new PDFReportItext2(context);
else if (implementation.equals("ITEXT8"))
reportHandler = new PDFReportItext8(context);
else
reportHandler = new PDFReportPDFBox(context);
((GXReportPDFCommons) reportHandler).setOutputStream(getOutputStream());
}
else {
throw new RuntimeException("Unrecognized report type: " + getOutputType());
Expand Down Expand Up @@ -139,7 +135,7 @@ protected int getOutputType() {
}

protected java.io.OutputStream getOutputStream() {
throw new RuntimeException("Output stream not set");
return null;
}

//M�todos para la implementaci�n de reportes din�micos
Expand Down

0 comments on commit 7ff1b7a

Please sign in to comment.