private void getBoundary( final JsonObject queryString, IpcPhysicalResponseFactory responseGenerator, IpcRequestProcessor requestProcessor, final JsonObject logicalPortJson) throws VtnServiceException { int status = ClientSession.RESP_FATAL; requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_BOUNDARY_GET, queryString, getUriParametersMember(logicalPortJson)); requestProcessor .getRequestPacket() .setOperation(IpcDataUnitWrapper.setIpcUint32Value(UncOperationEnum.UNC_OP_READ.ordinal())); LOG.debug("Request packet for boundary call created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet boundary call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } JsonObject boundary = responseGenerator.getDomainLogicalPortBoundaryResponse( requestProcessor.getIpcResponsePacket()); if (boundary != null) { logicalPortJson.add(VtnServiceJsonConsts.BOUNDARY, boundary); } }
/** * Implementation the get method of VTN Unified Network Resource API * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException */ @Override public final int get(final JsonObject requestBody) throws VtnServiceException { LOG.trace("Start VTNUnifiedNetworkResource#get()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; int status = ClientSession.RESP_FATAL; try { LOG.debug("Start Ipc framework call"); session = getConnPool() .getSession( UncUPLLEnums.UPLL_IPC_CHANNEL_NAME, UncUPLLEnums.UPLL_IPC_SERVICE_NAME, UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_VTN_UNIFIED_GET, requestBody, getUriParameters()); LOG.debug("Request Packet created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status" + status); final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory(); setInfo( responseGenerator.getVTNUnifiedNetworkResponse( requestProcessor.getIpcResponsePacket(), requestBody, VtnServiceJsonConsts.SHOW)); LOG.debug("Response object created successfully"); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } getConnPool().destroySession(session); } LOG.trace("Complete VTNUnifiedNetworkResource#get()"); return status; }
/** * Implementation of post method of Boundary API * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException */ @Override public final int post(final JsonObject requestBody) throws VtnServiceException { LOG.trace("Starts BoundariesResource#post()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; int status = ClientSession.RESP_FATAL; try { LOG.debug("Start Ipc framework call"); session = getConnPool() .getSession( UncUPPLEnums.UPPL_IPC_CHN_NAME, UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_CONFIGREQ.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_BOUNDARY_CREATE, requestBody, getUriParameters(requestBody)); LOG.debug("Request packet created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status:" + status); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } getConnPool().destroySession(session); } LOG.trace("Completed BoundariesResource#post()"); return status; }
private void getNeighbor( final JsonObject queryString, IpcPhysicalResponseFactory responseGenerator, IpcRequestProcessor requestProcessor, final JsonArray memberArray, final JsonObject logicalPortJson) throws VtnServiceException { int status = ClientSession.RESP_FATAL; JsonArray tmpMembArray = new JsonArray(); for (int neighborIndex = 0; neighborIndex < memberArray.size(); neighborIndex++) { JsonObject member = (JsonObject) memberArray.get(neighborIndex); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_NEIGHBOR_GET, queryString, getUriParametersMemberGreaterThanDefault(logicalPortJson, member)); requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value(UncOperationEnum.UNC_OP_READ.ordinal())); LOG.debug("Request packet for neighbor call created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet neighbor call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } JsonObject neighbor = responseGenerator.getDomainLogicalPortNeighborResponse( requestProcessor.getIpcResponsePacket()); if (neighbor != null) { member.add(VtnServiceJsonConsts.NEIGHBOR, neighbor); } tmpMembArray.add(member); } if (tmpMembArray.size() > 0) { logicalPortJson.add(VtnServiceJsonConsts.MEMBERPORTS, tmpMembArray); } }
/** * Implementation of get method of VtnStations * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException */ @Override public final int get(final JsonObject requestBody) throws VtnServiceException { LOG.trace("Start VtnStationsResource#get()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; int status = ClientSession.RESP_FATAL; try { LOG.debug("Start Ipc framework call"); // Get session from connection pool of UPLL server connections session = getConnPool() .getSession( UncUPLLEnums.UPLL_IPC_CHANNEL_NAME, UncUPLLEnums.UPLL_IPC_SERVICE_NAME, UncUPLLEnums.ServiceID.UPLL_READ_SVC_ID.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); String opType = VtnServiceJsonConsts.NORMAL; if (requestBody.has(VtnServiceJsonConsts.OP)) { opType = requestBody.get(VtnServiceJsonConsts.OP).getAsString(); } if (opType.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) { requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_VTNSTATION_CONTROLLER_GET_COUNT, requestBody, getNullListObject()); } else { requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_VTNSTATION_CONTROLLER_GET, requestBody, getNullListObject()); } /* * Set IP address in request packet */ final IpcDataUnit extraDataUnits[] = new IpcDataUnit[1]; if (requestBody.has(VtnServiceJsonConsts.IPADDR)) { extraDataUnits[0] = IpcDataUnitWrapper.setIpcInet4AddressValue( requestBody.get(VtnServiceJsonConsts.IPADDR).getAsString()); requestProcessor.getRequestPacket().setExtraDataUnits(extraDataUnits); } else if (requestBody.has(VtnServiceJsonConsts.IPV6ADDR)) { extraDataUnits[0] = IpcDataUnitWrapper.setIpcInet6AddressValue( requestBody.get(VtnServiceJsonConsts.IPV6ADDR).getAsString()); requestProcessor.getRequestPacket().setExtraDataUnits(extraDataUnits); } else { LOG.debug("No need to set IPV4 or IPV6 address"); } /* * Exception case : "op" parameter is coming Show API Update * operation type in case "op" parameter is coming from request body */ if (opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL)) { requestProcessor .getRequestPacket() .setOption1( IpcDataUnitWrapper.setIpcUint32Value(UncOption1Enum.UNC_OPT1_DETAIL.ordinal())); } requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value(UncOperationEnum.UNC_OP_READ.ordinal())); LOG.debug("Request packet created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status" + status); /* * Create the Json after getting the key and value structure from * IpcRequestProcessor After getting the response, set the same to * info so that it can be accessed by next call */ final IpcLogicalResponseFactory responseGenerator = new IpcLogicalResponseFactory(); setInfo( responseGenerator.getVtnStationResponse( requestProcessor.getIpcResponsePacket(), requestBody, VtnServiceJsonConsts.SHOW)); LOG.debug("Response object created successfully"); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { /* * Handle the case, where error info required to be set for failures * If error cause can be found from UPLL layer then, set the error * according to error code Otherwise set the error as IPC server * error */ if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } // destroy the session in all cases getConnPool().destroySession(session); } LOG.trace("Completed VtnStationsResource#get()"); return status; }
/** * Implementation of get method of Link API. * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException , in case of error . */ @Override public final int get(final JsonObject requestBody) throws VtnServiceException { LOG.trace("Starts LinksResource#get()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; int status = ClientSession.RESP_FATAL; try { LOG.debug("Start Ipc framework call"); session = getConnPool() .getSession( UncUPPLEnums.UPPL_IPC_CHN_NAME, UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); final List<String> uriParameterList = getUriParameters(requestBody); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LINK_GET, requestBody, uriParameterList); if (!requestBody.has(VtnServiceJsonConsts.LINKNAME)) { getModifiedRequestPacket(requestBody, requestProcessor); LOG.debug("Request packet created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status:" + status); final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory(); JsonObject responseJson = responseGenerator.getLinkResponse(requestProcessor.getIpcResponsePacket(), requestBody); if (responseJson.get(VtnServiceJsonConsts.LINKS).isJsonArray()) { final JsonArray responseArray = responseJson.get(VtnServiceJsonConsts.LINKS).getAsJsonArray(); responseJson = getResponseJsonArrayPhysical( requestBody, requestProcessor, responseGenerator, responseArray, VtnServiceJsonConsts.LINKS, VtnServiceJsonConsts.LINKNAME, IpcRequestPacketEnum.KT_LINK_GET, uriParameterList, VtnServiceIpcConsts.GET_LINK_RESPONSE); } setInfo(responseJson); } else { requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value(UncOperationEnum.UNC_OP_READ.ordinal())); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status:" + status); final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory(); setInfo( responseGenerator.getLinkResponse( requestProcessor.getIpcResponsePacket(), requestBody)); } LOG.debug("Response object created successfully"); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } getConnPool().destroySession(session); } LOG.trace("Completed LinksResource#get()"); return status; }
/** * Implementation of get method of DomainLogicalPorts API * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException */ @Override public final int get(final JsonObject queryString) throws VtnServiceException { LOG.trace("Starts DomainLogicalPortsResource#get()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; JsonObject memberLastIndex = null; int status = ClientSession.RESP_FATAL; IpcDataUnit[] resp = null; try { LOG.debug("Start Ipc framework call"); // Get session from connection pool of UPLL server connections session = getConnPool() .getSession( UncUPPLEnums.UPPL_IPC_CHN_NAME, UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory(); String dataType = VtnServiceJsonConsts.STATE; if (queryString.has(VtnServiceJsonConsts.TARGETDB)) { dataType = queryString.get(VtnServiceJsonConsts.TARGETDB).getAsString(); } requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_GET, queryString, getUriParameters(queryString)); LOG.debug("Request packet for 1st created successfully"); if (!queryString.has(VtnServiceJsonConsts.LOGICAL_PORT_ID)) { status = requestProcessor.processIpcRequest(); LOG.debug("Request packet 1st call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } resp = requestProcessor.getIpcResponsePacket(); JsonObject root = responseGenerator.getDomainLogicalPortResponse(resp, queryString); if (root.get(VtnServiceJsonConsts.LOGICALPORTS).isJsonArray()) { JsonArray domainLogicalPortArray = null; domainLogicalPortArray = root.getAsJsonArray(VtnServiceJsonConsts.LOGICALPORTS); root = getResponseJsonArrayPhysical( queryString, requestProcessor, responseGenerator, domainLogicalPortArray, VtnServiceJsonConsts.LOGICALPORTS, VtnServiceJsonConsts.LOGICAL_PORT_ID, IpcRequestPacketEnum.KT_LOGICAL_PORT_GET, getUriParameters(queryString), VtnServiceIpcConsts.GET_DOMAIN_LOGICAL_PORT_RESPONSE); } String opType = VtnServiceJsonConsts.NORMAL; if (queryString.has(VtnServiceJsonConsts.OP)) { opType = queryString.get(VtnServiceJsonConsts.OP).getAsString(); } final JsonArray logicalPortsArray = new JsonArray(); JsonArray memberArray = null; JsonArray memberArrayNew = null; if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType) && VtnServiceJsonConsts.DETAIL.equalsIgnoreCase(opType)) { final Iterator<JsonElement> logicalPortIterator = root.get(VtnServiceJsonConsts.LOGICALPORTS).getAsJsonArray().iterator(); requestProcessor.setServiceInfo( UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal()); while (logicalPortIterator.hasNext()) { final JsonObject logicalPortsJson = (JsonObject) logicalPortIterator.next(); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_MEMBER_GET, queryString, getUriParametersMember(logicalPortsJson)); requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value( UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN.ordinal())); LOG.debug("Request packet for 2nd call created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet 2nd call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } resp = requestProcessor.getIpcResponsePacket(); memberArray = responseGenerator.getDomainLogicalPortMemberResponse(resp); int memberIndex = 0; memberIndex = memberArray.size(); if (memberArray.size() > 0) { while (memberIndex > 0) { memberIndex = memberArray.size(); memberLastIndex = (JsonObject) memberArray.get(memberIndex - 1); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_MEMBER_GET, queryString, getUriParametersMemberGreaterThanDefault(logicalPortsJson, memberLastIndex)); requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value( UncOperationEnum.UNC_OP_READ_SIBLING.ordinal())); status = requestProcessor.processIpcRequest(); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } resp = requestProcessor.getIpcResponsePacket(); memberArrayNew = responseGenerator.getDomainLogicalPortMemberResponse(resp); if (null != memberArrayNew && !memberArrayNew.isJsonNull()) { memberArray.getAsJsonArray().addAll(memberArrayNew); } else { break; } memberIndex = memberArrayNew.size(); } } // get neighbor information getNeighbor( queryString, responseGenerator, requestProcessor, memberArray, logicalPortsJson); // get logical port boundary informations getBoundary(queryString, responseGenerator, requestProcessor, logicalPortsJson); logicalPortsArray.add(logicalPortsJson); } root.add(VtnServiceJsonConsts.LOGICALPORTS, logicalPortsArray); } setInfo(root); } else { requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value(UncOperationEnum.UNC_OP_READ.ordinal())); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet for 1st call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } final JsonObject root = responseGenerator.getDomainLogicalPortResponse( requestProcessor.getIpcResponsePacket(), queryString); JsonArray memberArray = null; JsonArray memberArrayNew = null; String opType = VtnServiceJsonConsts.NORMAL; if (queryString.has(VtnServiceJsonConsts.OP)) { opType = queryString.get(VtnServiceJsonConsts.OP).getAsString(); } if (VtnServiceJsonConsts.STATE.equalsIgnoreCase(dataType) && opType.equalsIgnoreCase(VtnServiceJsonConsts.DETAIL) && (root.get(VtnServiceJsonConsts.LOGICALPORTS).getAsJsonArray().size() != 0)) { requestProcessor.setServiceInfo( UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal()); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_MEMBER_GET, queryString, getUriParametersMemberShow(queryString)); requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value( UncOperationEnum.UNC_OP_READ_SIBLING_BEGIN.ordinal())); LOG.debug("Request packet 2nd call created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet 2nd call processed with status:" + status); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } memberArray = responseGenerator.getDomainLogicalPortMemberResponse( requestProcessor.getIpcResponsePacket()); int memberIndex = 0; memberIndex = memberArray.size(); JsonObject logicalPort = (JsonObject) root.getAsJsonArray(VtnServiceJsonConsts.LOGICALPORTS).get(0); if (memberArray.size() > 0) { while (memberIndex > 0) { memberIndex = memberArray.size(); memberLastIndex = (JsonObject) memberArray.get(memberIndex - 1); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_LOGICAL_PORT_MEMBER_GET, queryString, getUriParametersMemberGreaterThanDefault(logicalPort, memberLastIndex)); requestProcessor .getRequestPacket() .setOperation( IpcDataUnitWrapper.setIpcUint32Value( UncOperationEnum.UNC_OP_READ_SIBLING.ordinal())); status = requestProcessor.processIpcRequest(); if (status == ClientSession.RESP_FATAL) { throw new VtnServiceException( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage()); } resp = requestProcessor.getIpcResponsePacket(); memberArrayNew = responseGenerator.getDomainLogicalPortMemberResponse(resp); if (null != memberArrayNew && !memberArrayNew.isJsonNull()) { memberArray.getAsJsonArray().addAll(memberArrayNew); } else { break; } memberIndex = memberArrayNew.size(); } } if (null != memberArray) { // get neighbor information getNeighbor(queryString, responseGenerator, requestProcessor, memberArray, logicalPort); } // get logical port boundary informations getBoundary(queryString, responseGenerator, requestProcessor, logicalPort); final JsonArray resultJsonArray = new JsonArray(); resultJsonArray.add(logicalPort); root.add(VtnServiceJsonConsts.LOGICALPORTS, resultJsonArray); } setInfo(root); } LOG.debug("Response object created successfully"); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { /* * Handle the case, where error info required to be set for failures * If error cause can be found from UPLL layer then, set the error * according to error code Otherwise set the error as IPC server * error */ if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } // destroy the session in all cases getConnPool().destroySession(session); } LOG.trace("Completed LogicalPortsResource#get()"); return status; }
/** * Implementation of get method of Boundary API * * @param requestBody the request Json object * @return Error code * @throws VtnServiceException */ @Override public final int get(final JsonObject requestBody) throws VtnServiceException { LOG.trace("Starts BoundariesResource#get()"); ClientSession session = null; IpcRequestProcessor requestProcessor = null; int status = ClientSession.RESP_FATAL; try { LOG.debug("Start Ipc framework call"); session = getConnPool() .getSession( UncUPPLEnums.UPPL_IPC_CHN_NAME, UncUPPLEnums.UPPL_IPC_SVC_NAME, UncUPPLEnums.ServiceID.UPPL_SVC_READREQ.ordinal(), getExceptionHandler()); LOG.debug("Session created successfully"); requestProcessor = new IpcRequestProcessor(session, getSessionID(), getConfigID(), getExceptionHandler()); /* * operation type will be required to resolve the response type */ String opType = VtnServiceJsonConsts.NORMAL; if (requestBody.has(VtnServiceJsonConsts.OP)) { opType = requestBody.get(VtnServiceJsonConsts.OP).getAsString(); } final List<String> uriParameterList = getUriParameters(requestBody); requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_BOUNDARY_GET, requestBody, getUriParameters(requestBody)); if (opType.equalsIgnoreCase(VtnServiceJsonConsts.COUNT)) { requestProcessor.createIpcRequestPacket( IpcRequestPacketEnum.KT_BOUNDARY_GET_COUNT, requestBody, getUriParameters(requestBody)); } LOG.debug("Request packet created successfully"); status = requestProcessor.processIpcRequest(); LOG.debug("Request packet processed with status:" + status); final IpcPhysicalResponseFactory responseGenerator = new IpcPhysicalResponseFactory(); /* * setInfo(responseGenerator.getBoundaryResponse( * requestProcessor.getIpcResponsePacket(), requestBody, * VtnServiceJsonConsts.LIST)); */ JsonObject responseJson = responseGenerator.getBoundaryResponse( requestProcessor.getIpcResponsePacket(), requestBody, VtnServiceJsonConsts.LIST); if (responseJson.get(VtnServiceJsonConsts.BOUNDARIES).isJsonArray()) { final JsonArray responseArray = responseJson.get(VtnServiceJsonConsts.BOUNDARIES).getAsJsonArray(); responseJson = getResponseJsonArrayPhysical( requestBody, requestProcessor, responseGenerator, responseArray, VtnServiceJsonConsts.BOUNDARIES, VtnServiceJsonConsts.BOUNDARYID, IpcRequestPacketEnum.KT_BOUNDARY_GET, uriParameterList, VtnServiceIpcConsts.GET_BOUNDARY_RESPONSE); } setInfo(responseJson); LOG.debug("Response object created successfully"); LOG.debug("Complete Ipc framework call"); } catch (final VtnServiceException e) { getExceptionHandler() .raise( Thread.currentThread().getStackTrace()[1].getClassName() + VtnServiceConsts.HYPHEN + Thread.currentThread().getStackTrace()[1].getMethodName(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorCode(), UncJavaAPIErrorCode.IPC_SERVER_ERROR.getErrorMessage(), e); throw e; } finally { if (status == ClientSession.RESP_FATAL) { if (null != requestProcessor.getErrorJson()) { setInfo(requestProcessor.getErrorJson()); } else { createErrorInfo(UncCommonEnum.UncResultCode.UNC_SERVER_ERROR.getValue()); } status = UncResultCode.UNC_SERVER_ERROR.getValue(); } getConnPool().destroySession(session); } LOG.trace("Completed BoundariesResource#get()"); return status; }