2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso;
24 import org.openecomp.mso.utils.UUIDChecker;
25 import org.openecomp.mso.logger.MessageEnum;
26 import org.openecomp.mso.logger.MsoLogger;
27 import org.openecomp.mso.requestsdb.RequestsDatabase;
30 import javax.ws.rs.core.Response;
33 public class MsoStatusHandler {
34 private MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
37 @Path("/setStatus/{siteName}")
38 @Produces("text/plain")
39 public Response setSiteStatus (@DefaultValue("true") @QueryParam("enable") Boolean enable,
40 @PathParam("siteName") String siteName) {
41 long startTime = System.currentTimeMillis();
42 // Set logger parameters
43 UUIDChecker.generateUUID (logger);
44 MsoLogger.setServiceName ("SetSiteStatus");
47 if (null == siteName) {
48 logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Not able to find the site name attribute in the config file");
49 return Response.status (Response.Status.INTERNAL_SERVER_ERROR).entity ("Exception: not able to find the site name attribute in the config file").build ();
52 // Query DB for the value
54 RequestsDatabase.updateSiteStatus(siteName, enable);
56 } catch (Exception e) {
57 logger.error (MessageEnum.GENERAL_EXCEPTION, "", "setSiteStatus", MsoLogger.ErrorCode.DataError, "Failed to set site status", e);
58 logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while updating site status");
59 return Response.status (Response.Status.INTERNAL_SERVER_ERROR).entity ("Exception while updating site status").build ();
61 logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
62 return Response.status (Response.Status.OK).entity ("Site status successfully updated to " + enable).build ();