::
cd portal-BE/
+ If you get this error "unable to prepare context: path ".\r" not found" please use this command dos2unix build.sh
./build.sh
Viewing your app
package org.onap.portal.controller;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class LoginController {
- @RequestMapping(value = "login", method = RequestMethod.GET)
+ @GetMapping(value = "login")
public String loginView() {
return "login";
}
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
this.dataValidator = dataValidator;
}
- @RequestMapping(value = {"/portalApi/loggedinUser"}, method = RequestMethod.GET, produces = "application/json")
+ @GetMapping(value = {"/portalApi/loggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE)
public PortalRestResponse<ProfileDetail> getLoggedinUser(Principal principal) {
PortalRestResponse<ProfileDetail> portalRestResponse = null;
try {
return portalRestResponse;
}
- @RequestMapping(value = {
- "/portalApi/modifyLoggedinUser"}, method = RequestMethod.PUT, produces = "application/json")
+ @PutMapping(value = {"/portalApi/modifyLoggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE)
public PortalRestResponse<String> modifyLoggedinUser(Principal principal,
@RequestBody ProfileDetail profileDetail) {
PortalRestResponse<String> portalRestResponse = null;
String errorMsg = "";
if (!dataValidator.isValid(profileDetail)) {
errorMsg = "Required field(s) is missing";
- portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, dataValidator.getConstraintViolationsString(profileDetail), null);
+ portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
+ dataValidator.getConstraintViolationsString(profileDetail), null);
logger.error(EELFLoggerDelegate.errorLogger, "modifyLoggedinUser failed", errorMsg);
} else {
FnUser user = userService.loadUserByUsername(principal.getName());
user.setMiddleName(profileDetail.getMiddleName());
user.setLoginId(profileDetail.getLoginId());
if (!HIDDEN_DEFAULT_PASSWORD.equals(profileDetail.getLoginPassword())) {
- user.setLoginPwd(CipherUtil.encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!"));
+ user.setLoginPwd(CipherUtil
+ .encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!"));
}
userService.saveFnUser(principal, user);
// Update user info in the session
--- /dev/null
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+
+package org.onap.portal.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders;
+import org.onap.portal.logging.aop.EPAuditLog;
+import org.onap.portal.service.WidgetMService;
+import org.onap.portal.utils.EcompPortalUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+
+@EPAuditLog
+@RestController
+@EnableAspectJAutoProxy
+public class WidgetsCatalogMarkupController {
+
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogMarkupController.class);
+ private RestTemplate template = new RestTemplate();
+ private final String whatService = "widgets-service";
+
+ @Autowired
+ private WidgetMService widgetMService;
+
+ @Bean
+ public CommonsMultipartResolver multipartResolver() {
+ return new CommonsMultipartResolver();
+ }
+
+ static {
+ // for localhost testing only
+ javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
+
+ public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
+ if (hostname.equals("localhost")) {
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+
+ @GetMapping(value = "/portalApi/microservices/markup/{widgetId}")
+ public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response,
+ @PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
+ return template
+ .getForObject(
+ EcompPortalUtils.widgetMsProtocol() + "://"
+ + widgetMService.getServiceLocation(whatService,
+ SystemProperties.getProperty("microservices.widget.local.port"))
+ + "/widget/microservices/markup/" + widgetId,
+ String.class, WidgetServiceHeaders.getInstance());
+ }
+
+}
import org.onap.portal.domain.dto.transport.FieldsValidator;
import org.onap.portal.domain.dto.transport.OnboardingWidget;
import org.onap.portal.domain.dto.transport.WidgetCatalogPersonalization;
+import org.onap.portal.logging.aop.EPAuditLog;
import org.onap.portal.service.AdminRolesService;
import org.onap.portal.service.PersUserWidgetService;
import org.onap.portal.service.WidgetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
+@EPAuditLog
@RestController
-@Configuration
@EnableAspectJAutoProxy
public class WidgetsController {
this.persUserWidgetService = persUserWidgetService;
}
- @RequestMapping(value = {"/portalApi/widgets"}, method = RequestMethod.GET, produces = "application/json")
+ @GetMapping(value = {"/portalApi/widgets"}, produces = MediaType.APPLICATION_JSON_VALUE)
public List<OnboardingWidget> getOnboardingWidgets(Principal principal, HttpServletRequest request,
HttpServletResponse response) {
FnUser user = fnUserService.loadUserByUsername(principal.getName());
return onboardingWidgets;
}
- @RequestMapping(value = {"/portalApi/widgets/{widgetId}"}, method = {
- RequestMethod.PUT}, produces = "application/json")
+ @PutMapping(value = {"/portalApi/widgets/{widgetId}"}, produces = MediaType.APPLICATION_JSON_VALUE)
public FieldsValidator putOnboardingWidget(Principal principal, HttpServletRequest request,
@PathVariable("widgetId") Long widgetId,
@RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) {
return true;
}
- @RequestMapping(value = {"/portalApi/widgets"}, method = {RequestMethod.POST}, produces = "application/json")
+ @PostMapping(value = {"/portalApi/widgets"}, produces = MediaType.APPLICATION_JSON_VALUE)
public FieldsValidator postOnboardingWidget(Principal principal, HttpServletRequest request,
@RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) {
FnUser user = fnUserService.loadUserByUsername(principal.getName());
return fieldsValidator;
}
- @RequestMapping(value = {"/portalApi/widgets/{widgetId}"}, method = {
- RequestMethod.DELETE}, produces = "application/json")
+ @DeleteMapping(value = {"/portalApi/widgets/{widgetId}"}, produces = MediaType.APPLICATION_JSON_VALUE)
public FieldsValidator deleteOnboardingWidget(Principal principal, HttpServletRequest request,
@PathVariable("widgetId") Long widgetId, HttpServletResponse response) {
FnUser user = fnUserService.loadUserByUsername(principal.getName());
return fieldsValidator;
}
- @RequestMapping(value = {
- "portalApi/widgetCatalogSelection"}, method = RequestMethod.PUT, produces = "application/json")
+ @PutMapping(value = {"portalApi/widgetCatalogSelection"}, produces = MediaType.APPLICATION_JSON_VALUE)
public FieldsValidator putWidgetCatalogSelection(Principal principal, HttpServletRequest request,
@RequestBody WidgetCatalogPersonalization persRequest, HttpServletResponse response) throws IOException {
FieldsValidator result = new FieldsValidator();
return result;
}
}
-
try {
if (persRequest.getWidgetId() == null || user == null) {
EcompPortalUtils.setBadPermissions(user, response, "putWidgetCatalogSelection");
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
-import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
package org.onap.portal.domain.dto.ecomp;
import java.nio.charset.Charset;
-import lombok.AllArgsConstructor;
import lombok.Getter;
-import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
import org.onap.portal.utils.EcompPortalUtils;
@Getter
@Setter
-@EqualsAndHashCode()
+@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class CentralV2RoleFunction extends DomainVo implements Serializable, Comparable {
return false;
}
if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- return true;
+ return other.type == null;
+ } else
+ return type.equals(other.type);
}
}
--- /dev/null
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+
+package org.onap.portal.service;
+
+import org.onap.portal.utils.EcompPortalUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.stereotype.Service;
+
+@Service
+public class WidgetMService {
+
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetMService.class);
+
+ public String getServiceLocation(String service, String fallbackPortOnLocalHost) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Requested Service: " + service);
+ String localFallbackServiceLocation =
+ EcompPortalUtils.localOrDockerHost() + ":" + fallbackPortOnLocalHost;
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "returned service location: " + localFallbackServiceLocation);
+ return localFallbackServiceLocation;
+ }
+}
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.onap.portal.dao.fn.FnUserDao;
import org.onap.portal.domain.db.fn.FnUser;
import org.springframework.beans.factory.annotation.Autowired;
public List<OnboardingApp> getAppsFullList() {
refreshAppsMap(quickRefreshCacheConf);
- List<FnApp> appList = new ArrayList<FnApp> (appsMap.values());
+ List<FnApp> appList = new ArrayList<>(appsMap.values());
appList.removeIf(app -> app.getId() == 1);
List<FnApp> appsFinalList = appList.stream()
.filter(app -> app.getEnabled() && !app.getOpen()).collect(Collectors.toList());
- List<OnboardingApp> onboardingAppsList = new ArrayList<OnboardingApp>();
+ List<OnboardingApp> onboardingAppsList = new ArrayList<>();
for (FnApp app : appsFinalList) {
OnboardingApp onboardingApp = new OnboardingApp();
appsService.createOnboardingFromApp(app, onboardingApp);
public FnApp getApp(Long appId) {
refreshAppsMap(quickRefreshCacheConf);
FnApp app = appsMap.get(appId);
- if(app != null)
- return app;
- return null;
+ return app;
}
public FnApp getAppFromUeb(String appKey) {
public FnApp getAppFromUeb(String appKey, Integer quickCacheRefresh) {
refreshAppsMap(quickCacheRefresh == 1 ? quickRefreshCacheConf:slowRefreshCacheConf);
FnApp app = uebAppsMap.get(appKey);
- if(app != null)
- return app;
- return null;
+ return app;
}
}
* @return List of tokens split from the source
*/
public static List<String> parsingByRegularExpression(String source, String regex) {
- List<String> tokens = new ArrayList<String>();
+ List<String> tokens = new ArrayList<>();
if (source != null && source.length() > 0) {
String[] parsed = source.split(regex);
for (String token : parsed) {
String responseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE);
int responseCodeInt = 0;
try {
- if (responseCode != null && responseCode != "") {
+ if (responseCode != null && !responseCode.isEmpty()) {
responseCodeInt = Integer.valueOf(responseCode);
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
"Please check in system.properties whether the property exists or not!");
return false;
- } else if (new Boolean(rmtCentralAccess)) {
+ } else if (Boolean.valueOf(rmtCentralAccess)) {
logger.debug(EELFLoggerDelegate.debugLogger, "checkIfRemoteCentralAccessAllowed: {}", rmtCentralAccess);
result = true;
}
package org.onap.portal.utils;
public interface PortalConstants {
- public static final Long PORTAL_APP_ID = 1L;
- public static final Long DEFAULT_NOTIFICATION_CREATOR = 1L;
- public static final String REST_AUX_API = "/auxapi";
- public static final String PORTAL_AUX_API = "/portalApi";
- public static final Long ACCOUNT_ADMIN_ROLE_ID = 999L;
- public static final Long SYS_ADMIN_ROLE_ID = 1L;
- public static final String ADMIN_ROLE = "Account Administrator";
- public static final String PORTAL_ADMIN_ROLE = "System Administrator";
- public static final Integer AUDIT_LOG_COMMENT_SIZE = 990;
+ Long PORTAL_APP_ID = 1L;
+ Long DEFAULT_NOTIFICATION_CREATOR = 1L;
+ String REST_AUX_API = "/auxapi";
+ String PORTAL_AUX_API = "/portalApi";
+ Long ACCOUNT_ADMIN_ROLE_ID = 999L;
+ Long SYS_ADMIN_ROLE_ID = 1L;
+ String ADMIN_ROLE = "Account Administrator";
+ String PORTAL_ADMIN_ROLE = "System Administrator";
+ Integer AUDIT_LOG_COMMENT_SIZE = 990;
}