List of usage examples for javax.xml.ws Holder Holder
public Holder()
From source file:com.evolveum.midpoint.testing.model.client.sample.Main.java
private static Collection<UserType> listUsers(ModelPortType modelPort) throws SAXException, IOException, FaultMessage { SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType(); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); // let's say we want to get first 3 users, sorted alphabetically by user name QueryType queryType = new QueryType(); // holds search query + paging options PagingType pagingType = new PagingType(); pagingType.setMaxSize(3);/*from ww w . jav a 2 s. c o m*/ pagingType.setOrderBy(ModelClientUtil.createItemPathType("name")); pagingType.setOrderDirection(OrderDirectionType.ASCENDING); queryType.setPaging(pagingType); modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder, resultHolder); ObjectListType objectList = objectListHolder.value; return (Collection) objectList.getObject(); }
From source file:org.apache.camel.component.cxf.cxfbean.CxfBeanTest.java
@Test public void testJaxWsBeanFromCxfRoute() throws Exception { URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl"); PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first", "PersonService")); Person client = ss.getSoap();//w w w . j a v a2s . co m ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort1() + "/CxfBeanTest/PersonService/"); Holder<String> personId = new Holder<String>(); personId.value = "hello"; Holder<String> ssn = new Holder<String>(); Holder<String> name = new Holder<String>(); client.getPerson(personId, ssn, name); assertEquals("Get a wrong personId", "hello", personId.value); assertEquals("Get a wrong SSN", "000-000-0000", ssn.value); assertEquals("Get a wrong name", "Bonjour", name.value); }
From source file:com.evolveum.midpoint.pwdfilter.opendj.PasswordPusher.java
String getOID(String dn) throws IOException, JAXBException, SAXException, IllegalStateException, FaultMessage { /*Element filter = parseElement("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-2' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-2a' >" + "<path>c:name</path>" + "<value>" + dn + "</value>" + "<recourceRed oid='229bc496-05bb-c47b-4998-66040aabb438'</resourceOid>" + "</equal>");*///w w w. java2 s . c om QueryType query = unmarshallResouce("shadow.xml"); OperationOptionsType options = new OperationOptionsType(); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); midPointModelPort.searchObjects(getTypeUri(ShadowType.class), query, options, objectListHolder, resultHolder); ObjectListType objectList = objectListHolder.value; List<ObjectType> objects = objectList.getObject(); if (objects.isEmpty()) { return null; } if (objects.size() == 1) { ShadowType st = (ShadowType) objects.get(0); return st.getOid(); } throw new IllegalStateException("Expected to find a single user with username '" + dn + "' but found " + objects.size() + " users instead"); }
From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java
protected <O extends ObjectType> O getObject(Class<O> type, String oid) throws FaultMessage { Holder<ObjectType> objectHolder = new Holder<ObjectType>(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); modelPort.getObject(getTypeQName(type), oid, null, objectHolder, resultHolder); assertSuccess(resultHolder.value);//from w ww .j a va 2 s . c om return (O) objectHolder.value; }
From source file:com.evolveum.midpoint.testing.model.client.sample.Main.java
private static Collection<TaskType> listTasks(ModelPortType modelPort) throws SAXException, IOException, FaultMessage { SelectorQualifiedGetOptionsType operationOptions = new SelectorQualifiedGetOptionsType(); // Let's say we want to retrieve tasks' next scheduled time (because this may be a costly operation if // JDBC based quartz scheduler is used, the fetching of this attribute has to be explicitly requested) SelectorQualifiedGetOptionType getNextScheduledTimeOption = new SelectorQualifiedGetOptionType(); // prepare a selector (described by path) + options (saying to retrieve that attribute) ObjectSelectorType selector = new ObjectSelectorType(); selector.setPath(ModelClientUtil.createItemPathType("nextRunStartTimestamp")); getNextScheduledTimeOption.setSelector(selector); GetOperationOptionsType selectorOptions = new GetOperationOptionsType(); selectorOptions.setRetrieve(RetrieveOptionType.INCLUDE); getNextScheduledTimeOption.setOptions(selectorOptions); // add newly created option to the list of operation options operationOptions.getOption().add(getNextScheduledTimeOption); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); modelPort.searchObjects(ModelClientUtil.getTypeQName(TaskType.class), null, operationOptions, objectListHolder, resultHolder); ObjectListType objectList = objectListHolder.value; return (Collection) objectList.getObject(); }
From source file:org.eclipse.packagedrone.repo.channel.web.channel.ChannelController.java
@RequestMapping(value = "/channel/createWithRecipe", method = RequestMethod.POST) public ModelAndView createWithRecipePost(@Valid @FormData("command") final CreateChannel data, @RequestParameter(required = false, value = "recipe") final String recipeId, final BindingResult result) throws UnsupportedEncodingException, RecipeNotFoundException { if (!result.hasErrors()) { final Holder<ChannelId> holder = new Holder<>(); final Holder<String> targetHolder = new Holder<>(); if (recipeId == null || recipeId.isEmpty()) { // without recipe final ChannelDetails desc = new ChannelDetails(); desc.setDescription(data.getDescription()); holder.value = this.channelService.create("apm", desc, Collections.emptyMap()); setChannelNames(holder.value, splitChannelNames(data.getNames())); } else {/*from w w w . j a va 2 s . com*/ // with recipe Activator.getRecipes().process(recipeId, recipe -> { final ChannelDetails desc = new ChannelDetails(); desc.setDescription(data.getDescription()); final ChannelId channel = this.channelService.create("apm", desc, Collections.emptyMap()); setChannelNames(channel, splitChannelNames(data.getNames())); this.channelService.accessRun(By.id(channel.getId()), AspectableChannel.class, aspChannel -> { final LinkTarget target = recipe.setup(channel.getId(), aspChannel); if (target != null) { final Map<String, String> model = new HashMap<>(1); model.put("channelId", channel.getId()); targetHolder.value = target.expand(model).getUrl(); } }); holder.value = channel; }); if (targetHolder.value != null) { return new ModelAndView("redirect:" + targetHolder.value); } } return new ModelAndView( String.format("redirect:/channel/%s/view", URLEncoder.encode(holder.value.getId(), "UTF-8"))); } final Map<String, Object> model = new HashMap<>(1); model.put("recipes", Activator.getRecipes().getSortedRecipes(RecipeInformation::getLabel)); return new ModelAndView("channel/createWithRecipe", model); }
From source file:net.cloudkit.enterprises.ws.SuperPassQueryTest.java
public static void queryDetail(String seqNo) throws MalformedURLException { String serviceName = "eport.superpass.spdec.DecQueryListService"; byte[] requestContext = ("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n" + "<RequestContext>\n" + " <Group name=\"SystemInfo\">\n" + " <Key name=\"NAME_FULL\">???</Key>\n" + " <Key name=\"ClientId\">5300001976914</Key>\n" + " <Key name=\"CertNo\">df630b</Key>\n" + " <Key name=\"SaicSysNo\">766350979</Key>\n" + " <Key name=\"DEP_IN_CODE\">5300</Key>\n" + " <Key name=\"REG_CO_CGAC\">4403180237</Key>\n" + " <Key name=\"ENT_SEQ_NO\">000000000000315537</Key>\n" + " <Key name=\"ENT_TYPE\">3</Key>\n" + " <Key name=\"IcCode\">8930000011040</Key>\n" + " <Key name=\"OperatorName\">?</Key>\n" + " <Key name=\"DEP_CODE_CHG\">5305</Key>\n" + " <Key name=\"SessionId\">3BCCE1ED647530A76964A7B2EE4D1CE2</Key>\n" + " </Group>\n" + " <Group name=\"DataPresentation\">\n" + " <Key name=\"SignatureAlgorithm\"/>\n" + " <Key name=\"EncryptAlgorithm\"/>\n" + " <Key name=\"CompressAlgorithm\"/>\n" + " </Group>\n" + " <Group name=\"Default\">\n" + " <Key name=\"clientSystemId\">0400620001</Key>\n" + " <Key name=\"needWebInvoke\">True</Key>\n" + " </Group>\n" + "</RequestContext>") .getBytes();//from www .j a va2s . co m byte[] requestData = ("<?xml version=\"1.0\"?>\n" + "<DecQueryDetailRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + " <SeqNo>" + seqNo + "</SeqNo>\n" + "</DecQueryDetailRequest>").getBytes(); Holder<byte[]> responseData = new Holder<>(); String responseContext = new String( superPass.service(serviceName, requestContext, requestData, responseData)); String queryListResponse = new String(responseData.value); System.out.println("RESPONSE_CONTEXT:" + responseContext); System.out.println("QUERY_LIST_RESPONSE:" + queryListResponse); }
From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java
protected <O extends ObjectType> int countObjects(Class<O> type) throws FaultMessage { Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); modelPort.searchObjects(getTypeQName(type), null, null, objectListHolder, resultHolder); assertSuccess(resultHolder.value);/*from w w w . j a v a 2s.c om*/ Integer count = objectListHolder.value.getCount(); if (count != null) { assertEquals("Wrong count", (Integer) objectListHolder.value.getObject().size(), count); } return objectListHolder.value.getObject().size(); }
From source file:com.cisco.dvbu.ps.deploytool.dao.wsapi.DataSourceWSDAOImpl.java
public ResourceList takeDataSourceAction(String actionName, String dataSourcePath, IntrospectionPlan plan, boolean runInBackgroundTransaction, String reportDetail, AttributeList dataSourceAttributes, String serverId, String pathToServersXML) throws CompositeException { // For debugging if (logger.isDebugEnabled()) { int planSize = 0; if (plan != null && plan.getEntries() != null && plan.getEntries().getEntry() != null) planSize = plan.getEntries().getEntry().size(); int attrSize = 0; if (dataSourceAttributes != null && dataSourceAttributes.getAttribute() != null) attrSize = dataSourceAttributes.getAttribute().size(); logger.debug(//w w w. j a va 2 s.c o m "DataSourceWSDAOImpl.takeDataSourceAction(actionName , dataSourcePath, plan, runInBackgroundTransaction, reportDetail, dataSourceAttributes, serverId, pathToServersXML). actionName=" + actionName + " dataSourcePath=" + dataSourcePath + " #plans=" + planSize + " runInBackgroundTransaction=" + runInBackgroundTransaction + " reportDetail=" + reportDetail + " #dataSourceAttributes=" + attrSize + " serverId=" + serverId + " pathToServersXML=" + pathToServersXML); } // Declare variables ResourceList returnResList = null; String command = null; // read target server properties from xml and build target server object based on target server name CompositeServer targetServer = WsApiHelperObjects.getServerLogger(serverId, pathToServersXML, "DataSourceWSAOImpl.takeDataSourceAction(" + actionName + ")", logger); // Ping the Server to make sure it is alive and the values are correct. WsApiHelperObjects.pingServer(targetServer, true); // Construct the resource port based on target server name ResourcePortType port = CisApiFactory.getResourcePort(targetServer); try { // Make sure the resource exists before executing any actions if (DeployManagerUtil.getDeployManager().resourceExists(serverId, dataSourcePath, ResourceType.DATA_SOURCE.name(), pathToServersXML)) { /********************************* * UPDATE datasource *********************************/ if (actionName.equalsIgnoreCase(DataSourceDAO.action.UPDATE.name())) { command = "updateDataSource"; if (logger.isDebugEnabled()) { int dsAttrSize = 0; String dsAttrString = ""; if (dataSourceAttributes != null && dataSourceAttributes.getAttribute() != null) { for (Attribute attr : dataSourceAttributes.getAttribute()) { if (dsAttrString.length() != 0) dsAttrString = dsAttrString + ", "; if (attr.getType().toString().equals("PASSWORD_STRING")) dsAttrString = dsAttrString + attr.getName() + "=********"; else dsAttrString = dsAttrString + attr.getName() + "=" + attr.getValue(); } dsAttrSize = dataSourceAttributes.getAttribute().size(); } logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Invoking port.updateDataSource(\"" + dataSourcePath + "\", \"FULL\", null, DS_ATTRIBUTES:[\"" + dsAttrString + "]\"). #dataSourceAttributes=" + dsAttrSize); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { returnResList = port.updateDataSource(dataSourcePath, DetailLevel.FULL, null, dataSourceAttributes); if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Success: port.updateDataSource()."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } /********************************* * ENABLE datasource *********************************/ else if (actionName.equalsIgnoreCase(DataSourceDAO.action.ENABLE.name())) { command = "updateResourceEnabled"; if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Invoking port.updateResourceEnabled(\"" + dataSourcePath + "\", \"DATA_SOURCE\", \"FULL\", true)."); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { returnResList = port.updateResourceEnabled(dataSourcePath, ResourceType.DATA_SOURCE, DetailLevel.FULL, true); if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Success: port.updateResourceEnabled()."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } /********************************* * REINTROSPECT datasource *********************************/ else if (actionName.equalsIgnoreCase(DataSourceDAO.action.REINTROSPECT.name())) { command = "reintrospectDataSource"; if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Invoking port.reintrospectDataSource(\"" + dataSourcePath + "\", true, null, null, null, null)."); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { // Errors were being thrown when attributes were present for dataSourceAttributes. Setting to null. //port.reintrospectDataSource(dataSourcePath, true, dataSourceAttributes, null, null, null); port.reintrospectDataSource(dataSourcePath, true, null, null, null, null); if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Success: port.reintrospectDataSource()."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } /********************************* * INTROSPECT datasource *********************************/ else if (actionName.equalsIgnoreCase(DataSourceDAO.action.INTROSPECT.name())) { command = "introspectResourcesTask"; Holder<String> taskId = new Holder<String>(); Holder<BigInteger> totalResults = new Holder<BigInteger>(); Holder<Boolean> completed = new Holder<Boolean>(); if (logger.isDebugEnabled()) { int dsAttrSize = 0; String dsAttrString = ""; if (dataSourceAttributes != null && dataSourceAttributes.getAttribute() != null) { for (Attribute attr : dataSourceAttributes.getAttribute()) { if (dsAttrString.length() != 0) dsAttrString = dsAttrString + ", "; if (attr.getType().toString().equals("PASSWORD_STRING")) dsAttrString = dsAttrString + attr.getName() + "=********"; else dsAttrString = dsAttrString + attr.getName() + "=" + attr.getValue(); } dsAttrSize = dataSourceAttributes.getAttribute().size(); } String planString = ""; if (plan != null && plan.getEntries() != null && plan.getEntries().getEntry() != null) { for (IntrospectionPlanEntry entry : plan.getEntries().getEntry()) { if (planString.length() != 0) planString = "], " + planString; planString = planString + "PLAN:["; planString = planString + "action=" + entry.getAction(); planString = planString + "path=" + entry.getResourceId().getPath(); planString = planString + "type=" + entry.getResourceId().getType(); String attrList = ""; if (entry.getAttributes() != null && entry.getAttributes().getAttribute() != null) { for (Attribute attr : entry.getAttributes().getAttribute()) { if (attrList.length() != 0) attrList = attrList + ", "; if (attr.getType().toString().equalsIgnoreCase("PASSWORD_STRING")) attrList = attrList + attr.getName() + "=********"; else attrList = attrList + attr.getName() + "=" + attr.getValue(); } } planString = planString + attrList + "]"; } } logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Invoking port.introspectResourcesTask(\"" + dataSourcePath + "\", \"" + planString + "\", \"" + runInBackgroundTransaction + "\", DS_ATTRIBUTES:[\"" + dsAttrString + "]\", taskId, totalResults, completed). #dataSourceAttributes=" + dsAttrSize); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { // Invoke the method to introspect and add, update or remove data source resources port.introspectResourcesTask(dataSourcePath, plan, runInBackgroundTransaction, dataSourceAttributes, taskId, totalResults, completed); if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Success: port.introspectResourcesTask()."); } Boolean block = true; // Make this a blocking call Page page = new Page(); Holder<IntrospectionStatus> status = new Holder<IntrospectionStatus>(); if (logger.isDebugEnabled()) { String simpleStatus = ""; if (status != null && status.value != null && status.value.getStatus() != null) simpleStatus = status.value.getStatus().value(); logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Invoking port.introspectResourcesResult(\"" + taskId.value.toString() + "\", \"" + block.toString() + "\", page, \"FULL\", \"" + totalResults.value.toString() + "\", \"" + completed.value.toString() + "\", \"" + simpleStatus + "\")."); } // Since a blocking call is used, a single call to get results is all that is needed port.introspectResourcesResult(taskId, block, page, DetailLevel.FULL, totalResults, completed, status); if (logger.isDebugEnabled()) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction(\"" + actionName + "\"). Success: port.introspectResourcesResult()."); } boolean errorDetected = false; String errorEntryPaths = ""; // Check the status and print out the report if (status != null && status.value != null && status.value.getStatus() != null) { String simpleStatus = status.value.getStatus().value(); // Print out a status report logger.info("Introspection Report (" + reportDetail + "):"); logger.info(" Status=" + simpleStatus); logger.info(" Start Time=" + status.value.getStartTime().toString()); logger.info(" End Time=" + status.value.getEndTime().toString()); logger.info(" Added=" + status.value.getAddedCount()); logger.info(" Removed=" + status.value.getRemovedCount()); logger.info(" Updated=" + status.value.getUpdatedCount()); logger.info(" Skipped=" + status.value.getSkippedCount()); logger.info(" Completed=" + status.value.getTotalCompletedCount()); logger.info(" Warning=" + status.value.getWarningCount()); logger.info(" Errors=" + status.value.getErrorCount()); logger.info(""); if (status.value.getReport() != null) { List<IntrospectionChangeEntry> reportEntries = status.value.getReport().getEntry(); // Iterate over the report entries for (IntrospectionChangeEntry reportEntry : reportEntries) { // Print out the Resource and Status on 2 separate lines with a blank line separator following if (reportDetail.equals("SIMPLE") || reportDetail.equals("FULL")) { logger.info(" RESOURCE: Path=" + reportEntry.getPath() + " Type=" + reportEntry.getType().value() + " Subtype=" + reportEntry.getSubtype().value()); logger.info(" STATUS: Status=" + reportEntry.getStatus().value() + " Action=" + reportEntry.getAction().value() + " Duration=" + reportEntry.getDurationMs()); } // Print out the Resource and Status as a single line with no blank lines following if (reportDetail.equals("SIMPLE_COMPRESSED")) { logger.info(" RESOURCE: Path=" + reportEntry.getPath() + " Type=" + reportEntry.getType().value() + " Subtype=" + reportEntry.getSubtype().value() + " [STATUS]: Status=" + reportEntry.getStatus().value() + " Action=" + reportEntry.getAction().value() + " Duration=" + reportEntry.getDurationMs()); } boolean entryErrorDetected = false; if (reportEntry.getStatus().value().equalsIgnoreCase("ERROR")) { errorDetected = true; entryErrorDetected = true; if (errorEntryPaths.length() > 0) errorEntryPaths = errorEntryPaths + ", "; errorEntryPaths = errorEntryPaths + reportEntry.getPath(); } if (entryErrorDetected || reportDetail.equals("FULL")) { if (reportEntry.getMessages() != null) { List<MessageEntry> messages = reportEntry.getMessages().getEntry(); for (MessageEntry message : messages) { String severity = ""; String code = ""; String name = ""; String msg = ""; if (message.getSeverity() != null && message.getSeverity().value().length() > 0) severity = " Severity=" + message.getSeverity().value(); if (message.getCode() != null && message.getCode().length() > 0) code = " Code=" + message.getCode(); if (message.getName() != null && message.getName().length() > 0) name = " Name=" + message.getName(); if (message.getMessage() != null && message.getMessage().length() > 0) msg = " Message=" + message.getMessage(); logger.info(" MESSAGES:" + severity + code + name + msg); if (message.getDetail() != null) logger.info(" MESSAGES: Detail=" + message.getDetail()); } } } if (reportDetail.equals("SIMPLE") || reportDetail.equals("FULL")) { logger.info(""); } } } if (errorDetected) { throw new ApplicationException("Resource action=" + DataSourceDAO.action.INTROSPECT.name() + " was not successful. Review the introspection report in the log for more details. Introspection Entry Paths with errors=" + errorEntryPaths); } } else { // Since the status was null, then assume the server is 6.1 which contains a bug where the status has the wrong namespace. // Based on the input of ADD_OR_UPDATE, ADD_OR_UPDATE_RECURSIVELY, or REMOVE, query the resources to determine if the operation was successful. // Print out a status report logger.info("Introspection Report (" + reportDetail + "):"); logger.info(" Start Time=" + status.value.getStartTime().toString()); logger.info(" End Time=" + status.value.getEndTime().toString()); logger.info(" Added=" + status.value.getAddedCount()); logger.info(" Removed=" + status.value.getRemovedCount()); logger.info(" Updated=" + status.value.getUpdatedCount()); logger.info(" Skipped=" + status.value.getSkippedCount()); logger.info(" Completed=" + status.value.getTotalCompletedCount()); logger.info(" Warning=" + status.value.getWarningCount()); logger.info(" Errors=" + status.value.getErrorCount()); logger.info(""); List<IntrospectionPlanEntry> planEntries = plan.getEntries().getEntry(); for (IntrospectionPlanEntry planEntry : planEntries) { String planAction = planEntry.getAction().value().toString(); String resourcePath = dataSourcePath; if (planEntry.getResourceId().getPath() != null && planEntry.getResourceId().getPath().length() > 0) resourcePath = resourcePath + "/" + planEntry.getResourceId().getPath(); String resourceType = null; if (planEntry.getResourceId().getType() != null) resourceType = planEntry.getResourceId().getType().toString(); String subtype = null; if (planEntry.getResourceId().getSubtype() != null) subtype = planEntry.getResourceId().getSubtype().toString(); String planStatus = ""; // Print out the Resource and Status on 2 separate lines with a blank line separator following (this is the first line.) if (reportDetail.equals("SIMPLE") || reportDetail.equals("FULL")) { logger.info(" RESOURCE: Path=" + resourcePath + " Type=" + resourceType + " Subtype=" + subtype); } //Determine if this plan entry exists if (planAction.equalsIgnoreCase("ADD_OR_UPDATE")) { boolean exists = getResourceDAO().resourceExists(serverId, resourcePath, resourceType, pathToServersXML); if (!exists) { throw new ApplicationException( "Resource action=" + DataSourceDAO.action.INTROSPECT.name() + " was not successful. The resource [" + resourcePath + "] does not exist for the requested plan entry action [" + planEntry.getAction().value().toString() + "]."); } planStatus = "SUCCESS"; } //Just get the list of resources for the log. [there is no way to tell whether this was successful or not.] else if (planAction.equalsIgnoreCase("ADD_OR_UPDATE_RECURSIVELY")) { ResourceList resourceList = getResourceDAO().getResourcesFromPath(serverId, resourcePath, resourceType, null, "SIMPLE", pathToServersXML); if (resourceList != null && resourceList.getResource().size() > 0) { for (Resource resource : resourceList.getResource()) { if (resource != null && reportDetail.equals("FULL")) { logger.info(" CHILD RESOURCE: Path=" + resource.getPath() + " Type=" + resource.getType() + " Subtype=" + resource.getSubtype()); } } } planStatus = "SUCCESS"; } //Determine if this plan has been removed else if (planAction.equalsIgnoreCase("REMOVE")) { boolean exists = getResourceDAO().resourceExists(serverId, resourcePath, resourceType, pathToServersXML); if (exists) { throw new ApplicationException( "Resource action=" + DataSourceDAO.action.INTROSPECT.name() + " was not successful. The resource [" + resourcePath + "] was not removed for the requested plan entry action [" + planEntry.getAction().value().toString() + "]."); } planStatus = "SUCCESS"; } else { throw new ApplicationException("Resource action=" + DataSourceDAO.action.INTROSPECT.name() + " was not successful. The status field is null and the plan entry action [" + planEntry.getAction().value().toString() + "] is unknown."); } // Print out the Resource and Status on 2 separate lines with a blank line separator following (this is the second line). if (reportDetail.equals("SIMPLE") || reportDetail.equals("FULL")) { logger.info(" STATUS: Status=" + planStatus + " Action=" + planAction); } // Print out the Resource and Status as a single line with no blank lines following if (reportDetail.equals("SIMPLE_COMPRESSED")) { logger.info(" RESOURCE: Path=" + resourcePath + " Type=" + resourceType + " Subtype=" + subtype + " [STATUS]: Status=" + planStatus + " Action=" + planAction); } // Print out a blank line when report detail is SIMPLE or FULL if (reportDetail.equals("SIMPLE") || reportDetail.equals("FULL")) { logger.info(""); } } } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } if (logger.isDebugEnabled() && returnResList != null) { logger.debug("DataSourceWSDAOImpl.takeDataSourceAction::returnResList.getResource().size()=" + returnResList.getResource().size()); } } else { throw new ApplicationException("The resource " + dataSourcePath + " does not exist."); } } catch (UpdateDataSourceSoapFault e) { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), DataSourceDAO.action.UPDATE.name(), "DataSource", dataSourcePath, targetServer), e.getFaultInfo()); throw new ApplicationException(e.getMessage(), e); } catch (UpdateResourceEnabledSoapFault e) { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), DataSourceDAO.action.ENABLE.name(), "DataSource", dataSourcePath, targetServer), e.getFaultInfo()); throw new ApplicationException(e.getMessage(), e); } catch (ReintrospectDataSourceSoapFault e) { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), DataSourceDAO.action.REINTROSPECT.name(), "DataSource", dataSourcePath, targetServer), e.getFaultInfo()); throw new ApplicationException(e.getMessage(), e); } catch (IntrospectResourcesTaskSoapFault e) { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), DataSourceDAO.action.INTROSPECT.name(), "DataSource", pathToServersXML, targetServer), e.getFaultInfo()); throw new ApplicationException(e.getMessage(), e); } catch (IntrospectResourcesResultSoapFault e) { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), DataSourceDAO.action.INTROSPECT.name(), "DataSource", pathToServersXML, targetServer), e.getFaultInfo()); throw new ApplicationException(e.getMessage(), e); } catch (Exception e) { throw new ApplicationException(e.getMessage(), e); } return returnResList; }
From source file:com.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java
private static UserType searchUserByName(ModelPortType modelPort, String username) throws SAXException, IOException, FaultMessage, JAXBException { // WARNING: in a real case make sure that the username is properly escaped before putting it in XML SearchFilterType filter = ModelClientUtil.parseSearchFilterType( "<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + username + "</value>" + "</equal>"); QueryType query = new QueryType(); query.setFilter(filter);/*from w w w.j ava2 s. c o m*/ SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType(); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(); modelPort.searchObjects(getTypeQName(UserType.class), query, options, objectListHolder, resultHolder); ObjectListType objectList = objectListHolder.value; List<ObjectType> objects = objectList.getObject(); if (objects.isEmpty()) { return null; } if (objects.size() == 1) { return (UserType) objects.get(0); } throw new IllegalStateException("Expected to find a single user with username '" + username + "' but found " + objects.size() + " roles instead"); }