Said Gedik 2024-08-20 15:35:39 +02:00
commit d23cdea1c8
17 changed files with 145 additions and 24 deletions

View File

@ -17,7 +17,23 @@
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version> <version>2.7.8</version>
</parent> </parent>
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profiles.active>local</spring.profiles.active>
</properties>
</profile>
<profile>
<id>container</id>
<properties>
<spring.profiles.active>container</spring.profiles.active>
</properties>
</profile>
</profiles>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
</properties> </properties>
@ -174,4 +190,5 @@
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -8,10 +8,14 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.session.MapSessionRepository; import org.springframework.session.MapSessionRepository;
import javax.annotation.PostConstruct;
@SpringBootApplication @SpringBootApplication
public class ApiApplication extends SpringBootServletInitializer { public class ApiApplication extends SpringBootServletInitializer {
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
// private String greetingMessage;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args); SpringApplication.run(ApiApplication.class, args);
} }

View File

@ -0,0 +1,56 @@
package com.nttdata.calender;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;
/**
* Java API for Remedy
*/
@Service
public class ApplicationConfig {
@Value("${rssoActive}")
private Boolean rssoActive;
public Boolean getRssoActive() {
if(this.rssoActive==null)
return true;
return rssoActive;
}
@Value("${arserver}")
private String arserver;
public String getArserver() {
return arserver;
}
@Value("${arport}")
private Integer arport;
public Integer getArport() {
return arport;
}
@Value("${aruser}")
private String aruser;
public String getAruser() {
return aruser;
}
@Value("${arpassword}")
private String arpassword;
public String getArpassword() {
return arpassword;
}
}

View File

@ -24,6 +24,9 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
import com.nttdata.calender.states.State; import com.nttdata.calender.states.State;
import com.nttdata.calender.supportgroup.SupportGroup; import com.nttdata.calender.supportgroup.SupportGroup;
import org.springframework.beans.factory.annotation.Autowired;
import com.nttdata.calender.ApplicationConfig;
/** /**
* Java API for Remedy * Java API for Remedy
*/ */
@ -35,17 +38,24 @@ public class RemedyJavaAPI {
private static Logger applicationLogger = LogManager.getLogger("application"); private static Logger applicationLogger = LogManager.getLogger("application");
// TODO: work with form CTM:Support Group // TODO: work with form CTM:Support Group
private static final String QUALSTR = "\'Request ID\' != \"\""; private static final String QUALSTR = "\'Request ID\' != \"\"";
private ApplicationConfig appConfig;
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
// private String greetingMessage;
/** /**
* Sets up the Remedy API with the server and admin user/password. * Sets up the Remedy API with the server and admin user/password.
*/ */
public RemedyJavaAPI() throws ARException, NotFoundError {
public RemedyJavaAPI(ApplicationConfig appConfig) throws ARException, NotFoundError {
this.appConfig=appConfig;
System.out.println(appConfig.getRssoActive());
server = new ARServerUser(); server = new ARServerUser();
// server.setServer("itsm-app-dev.asfinag.at"); // server.setServer("itsm-app-dev.asfinag.at");
server.setServer("itsm-app-dev-neu.asfinag.at"); server.setServer(this.appConfig.getArserver());
server.setUser("changecalender_integration"); server.setUser(this.appConfig.getAruser());
server.setPassword("VXrvLm4q#8P#MXthfZNc"); server.setPassword(this.appConfig.getArpassword());
server.setPort(46262); server.setPort(this.appConfig.getArport());
// server.setPort(50000); // server.setPort(50000);
this.connect(); this.connect();

View File

@ -3,6 +3,7 @@ package com.nttdata.calender.api;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
@ -27,14 +28,21 @@ import java.util.List;
@Component @Component
public class RequestInterceptor implements HandlerInterceptor { public class RequestInterceptor implements HandlerInterceptor {
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
// private String greetingMessage;
@Autowired
private RemedyJavaAPI api; private RemedyJavaAPI api;
private static final String FORM_NAME = "ASF:CHG_CAL_Transactions"; private static final String FORM_NAME = "ASF:CHG_CAL_Transactions";
private static final Logger logger = LogManager.getLogger("application"); private static final Logger logger = LogManager.getLogger("application");
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
api = new RemedyJavaAPI(); //api = new RemedyJavaAPI(greetingMessage);
String currentDateTime = LocalDateTime.now().format(dateTimeFormatter); String currentDateTime = LocalDateTime.now().format(dateTimeFormatter);
long transactionId = System.currentTimeMillis(); long transactionId = System.currentTimeMillis();
String out = String.format("Transaction ID = %d %s - handling request: %s", transactionId, currentDateTime, request.getRequestURI()); String out = String.format("Transaction ID = %d %s - handling request: %s", transactionId, currentDateTime, request.getRequestURI());

View File

@ -9,6 +9,8 @@ import org.springframework.web.servlet.HandlerInterceptor;
import com.bmc.thirdparty.org.springframework.beans.factory.annotation.Autowired; import com.bmc.thirdparty.org.springframework.beans.factory.annotation.Autowired;
import com.nttdata.calender.ApplicationConfig;
import com.nttdata.calender.api.RemedyJavaAPI;
/** /**
* Interceptor for handling Rsso related operations. * Interceptor for handling Rsso related operations.
*/ */
@ -17,10 +19,15 @@ public class RssoInterceptor implements HandlerInterceptor {
private final static boolean DEBUG = true; private final static boolean DEBUG = true;
private final Rsso rsso; private final Rsso rsso;
private static final Logger applicationLogger = LogManager.getLogger("application"); private static final Logger applicationLogger = LogManager.getLogger("application");
private ApplicationConfig appConfig;
//EW env Fix
private final RemedyJavaAPI javaAPI;
@Autowired @Autowired
public RssoInterceptor(Rsso rsso) { public RssoInterceptor(Rsso rsso, ApplicationConfig appConfig, RemedyJavaAPI javaAPI) {
this.rsso = rsso; this.rsso = rsso;
this.appConfig=appConfig;
this.javaAPI=javaAPI;
} }
/** /**
@ -39,7 +46,8 @@ public class RssoInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception { throws Exception {
// Check if a session exists, create one if not // Check if a session exists, create one if not
if (DEBUG) { if (!this.appConfig.getRssoActive()) {
this.javaAPI.impersonateUser("WuiQualityKV");
return true; return true;
} }

View File

@ -50,7 +50,7 @@ public class Approval {
// Clear the list before processing a new request // Clear the list before processing a new request
listOfFieldValues.clear(); listOfFieldValues.clear();
remedyJavaAPI.impersonateUser("WuiQualityKV"); //remedyJavaAPI.impersonateUser("WuiQualityKV");
String action = "APPROVAL"; String action = "APPROVAL";
var queryUpdate = new Query.QueryBuilder("ASF:CHG_CAL_Interactions") var queryUpdate = new Query.QueryBuilder("ASF:CHG_CAL_Interactions")

View File

@ -58,7 +58,7 @@ public class Presets {
this.presets = new ArrayList<>(); this.presets = new ArrayList<>();
this.listOfFieldValues = new ArrayList<>(); this.listOfFieldValues = new ArrayList<>();
api.impersonateUser("WuiQualityKV"); //api.impersonateUser("WuiQualityKV");
} }
/** /**

View File

@ -51,7 +51,7 @@ public class SupportGroup {
*/ */
public void querySupportGroups(RemedyJavaAPI api) throws ARException, NotFoundError { public void querySupportGroups(RemedyJavaAPI api) throws ARException, NotFoundError {
api.impersonateUser("WuiQualityKV"); //api.impersonateUser("WuiQualityKV");
applicationLogger.info("\n\n\nRequest: querySupportGroups (Initial)\nUser: " + api.getUser() + "\nAdmin? " applicationLogger.info("\n\n\nRequest: querySupportGroups (Initial)\nUser: " + api.getUser() + "\nAdmin? "
+ (api.isAdministrator() ? "Yes" : "No")); + (api.isAdministrator() ? "Yes" : "No"));
@ -112,7 +112,7 @@ public class SupportGroup {
* @throws ARException if an error occurs during the query * @throws ARException if an error occurs during the query
*/ */
public void queryUserSupportGroup(RemedyJavaAPI api) throws ARException { public void queryUserSupportGroup(RemedyJavaAPI api) throws ARException {
api.impersonateUser("WuiQualityKV"); //api.impersonateUser("WuiQualityKV");
var querySupportGroups = new Query.QueryBuilder("CTM:Support Group Association") var querySupportGroups = new Query.QueryBuilder("CTM:Support Group Association")
.addFieldId("SupportGroupId", 1000000079).build(); .addFieldId("SupportGroupId", 1000000079).build();

View File

@ -0,0 +1 @@
rssoActive=true

View File

@ -0,0 +1,6 @@
rssoActive=false
arserver=itsm-app-dev-neu.asfinag.at
# arserver=${test}
arport=46262
aruser=changecalender_integration
arpassword=VXrvLm4q#8P#MXthfZNc

View File

@ -1,3 +1,4 @@
#server.servlet.context-path=/test #server.servlet.context-path=/test
server.servlet.session.timeout=24h server.servlet.session.timeout=24h
# server.port=${PROBE_PORT:8080} # server.port=${PROBE_PORT:8080}
spring.profiles.active=@spring.profiles.active@

View File

@ -25,6 +25,8 @@ import { GanttModule, ResizeService } from '@syncfusion/ej2-angular-gantt';
import { DateAdapter } from '@angular/material/core'; import { DateAdapter } from '@angular/material/core';
import { MAT_DATE_LOCALE } from '@angular/material/core'; import { MAT_DATE_LOCALE } from '@angular/material/core';
import * as WebFont from 'webfontloader'; // Verwende import * as import * as WebFont from 'webfontloader'; // Verwende import * as
import { AppConfig } from 'src/environments/models/environment.model';
import { APP_CONFIG } from '../app.config';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
@ -188,6 +190,7 @@ export class NttGanttComponent implements OnInit {
public cancelButton: boolean = false; public cancelButton: boolean = false;
public reApproveButton: boolean = false; public reApproveButton: boolean = false;
public implementerButton: boolean = false; public implementerButton: boolean = false;
private config: AppConfig;
@ -200,7 +203,8 @@ export class NttGanttComponent implements OnInit {
* @param dataService injects the dataService for data management and backend communication * @param dataService injects the dataService for data management and backend communication
* @param matDialog injects the matDialog * @param matDialog injects the matDialog
*/ */
constructor(public languageService: LanguageService, public dataService: DataService, public matDialog: MatDialog, private _snackBar: MatSnackBar, public errorService: ErrorService, private location: Location, private dateAdapter: DateAdapter<Date>) { constructor(@Inject(APP_CONFIG) config: AppConfig, public languageService: LanguageService, public dataService: DataService, public matDialog: MatDialog, private _snackBar: MatSnackBar, public errorService: ErrorService, private location: Location, private dateAdapter: DateAdapter<Date>) {
this.config=config;
this.initLanguge(true); this.initLanguge(true);
} }
@ -1026,7 +1030,7 @@ export class NttGanttComponent implements OnInit {
args.milestoneColor = "#bababa"; args.milestoneColor = "#bababa";
} }
} else { } else {
console.log(args); // console.log(args);
args.taskbarElement.innerHTML = null; args.taskbarElement.innerHTML = null;
args.taskbarElement.classlist = null; args.taskbarElement.classlist = null;
@ -1043,6 +1047,8 @@ export class NttGanttComponent implements OnInit {
* @param args event arguments from the syncfusion gantt chart. * @param args event arguments from the syncfusion gantt chart.
*/ */
public taskbarEdited(args: any) { public taskbarEdited(args: any) {
console.log(args);
let data = args.data;
if (args.data.taskData.isFixed !== false) { if (args.data.taskData.isFixed !== false) {
args.cancel = true; args.cancel = true;
} else { } else {
@ -1061,7 +1067,8 @@ export class NttGanttComponent implements OnInit {
); );
elem.scrollLeft = this.planTimeScrollLeft; elem.scrollLeft = this.planTimeScrollLeft;
} }
console.log(found);
this.ganttDefault.refresh();
}); });
} }
} }
@ -1224,9 +1231,9 @@ export class NttGanttComponent implements OnInit {
if (args.dialogModel) { if (args.dialogModel) {
args.cancel = true; args.cancel = true;
if (args.rowData.taskData.resources[0].state == 0) { if (args.rowData.taskData.resources[0].state == 0) {
window.open("https://itsm-"+environment+"-neu-smartit.asfinag.at/smartit/app/#/paketPV/" + args.rowData.taskData.resources[0].packageInstanceId, "_blank"); window.open(this.config.consoleUrl + "/smartit/app/#/paketPV/" + args.rowData.taskData.resources[0].packageInstanceId, "_blank");
} else { } else {
window.open("https://itsm-"+environment+"-neu-smartit.asfinag.at/smartit/app/#/changePV/" + args.rowData.taskData.resources[0].packageInstanceId, "_blank"); window.open(this.config.consoleUrl + "/smartit/app/#/changePV/" + args.rowData.taskData.resources[0].packageInstanceId, "_blank");
} }
this.ganttDefault.hideSpinner(); this.ganttDefault.hideSpinner();
} else { } else {

View File

@ -1 +1 @@
{"production":false,"rssoUrl":"http://orf.at","backendUrl":"http://localhost:8080/api"} {"production":false,"rssoUrl":"http://orf.at","backendUrl":"http://localhost:8080/api", "consoleUrl": "https://itsm-dev-neu-smartit.asfinag.at"}

View File

@ -3,5 +3,6 @@ import { AppConfig } from './models/environment.model';
export const environment: AppConfig = { export const environment: AppConfig = {
production: true, production: true,
rssoUrl: "RSSO_URL", rssoUrl: "RSSO_URL",
backendUrl: "BACKEND_API_URL" backendUrl: "BACKEND_API_URL",
consoleUrl: "CONSOLE_URL"
}; };

View File

@ -5,5 +5,6 @@ import { AppConfig } from './models/environment.model';
export const environment: AppConfig = { export const environment: AppConfig = {
production: false, production: false,
rssoUrl: "#", rssoUrl: "#",
backendUrl: "http://localhost:8080/api" backendUrl: "http://localhost:8080/api",
consoleUrl: "https://itsm-dev-neu-smartit.asfinag.at"
}; };

View File

@ -2,4 +2,5 @@ export interface AppConfig {
production: boolean; production: boolean;
rssoUrl: string; rssoUrl: string;
backendUrl: string; backendUrl: string;
consoleUrl: string;
} }