Example usage for javax.xml.bind JAXBElement getValue

List of usage examples for javax.xml.bind JAXBElement getValue

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getValue.

Prototype

public T getValue() 

Source Link

Document

Return the content model and attribute values for this element.

See #isNil() for a description of a property constraint when this value is null

Usage

From source file:org.anodyneos.jse.cron.CronDaemon.java

public CronDaemon(InputSource source) throws JseException {

    Schedule schedule;/*from  w ww. j av  a2 s  .c  om*/

    // parse source
    try {

        JAXBContext jc = JAXBContext.newInstance("org.anodyneos.jse.cron.config");
        Unmarshaller u = jc.createUnmarshaller();
        //Schedule
        Source schemaSource = new StreamSource(Thread.currentThread().getContextClassLoader()
                .getResourceAsStream("org/anodyneos/jse/cron/cron.xsd"));

        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = sf.newSchema(schemaSource);
        u.setSchema(schema);
        ValidationEventCollector vec = new ValidationEventCollector();
        u.setEventHandler(vec);

        JAXBElement<?> rootElement;
        try {
            rootElement = ((JAXBElement<?>) u.unmarshal(source));
        } catch (UnmarshalException ex) {
            if (!vec.hasEvents()) {
                throw ex;
            } else {
                for (ValidationEvent ve : vec.getEvents()) {
                    ValidationEventLocator vel = ve.getLocator();
                    log.error("Line:Col[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + "]:"
                            + ve.getMessage());
                }
                throw new JseException("Validation failed for source publicId='" + source.getPublicId()
                        + "'; systemId='" + source.getSystemId() + "';");
            }
        }

        schedule = (Schedule) rootElement.getValue();

        if (vec.hasEvents()) {
            for (ValidationEvent ve : vec.getEvents()) {
                ValidationEventLocator vel = ve.getLocator();
                log.warn("Line:Col[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + "]:"
                        + ve.getMessage());
            }
        }

    } catch (JseException e) {
        throw e;
    } catch (Exception e) {
        throw new JseException("Cannot parse " + source + ".", e);
    }

    SpringHelper springHelper = new SpringHelper();

    ////////////////
    //
    // Configure Spring and Create Beans
    //
    ////////////////

    TimeZone defaultTimeZone;

    if (schedule.isSetTimeZone()) {
        defaultTimeZone = getTimeZone(schedule.getTimeZone());
    } else {
        defaultTimeZone = TimeZone.getDefault();
    }

    if (schedule.isSetSpringContext() && schedule.getSpringContext().isSetConfig()) {
        for (Config config : schedule.getSpringContext().getConfig()) {
            springHelper.addXmlClassPathConfigLocation(config.getClassPathResource());
        }
    }

    for (org.anodyneos.jse.cron.config.JobGroup jobGroup : schedule.getJobGroup()) {
        for (Job job : jobGroup.getJob()) {
            if (job.isSetBeanRef()) {
                if (job.isSetBean() || job.isSetClassName()) {
                    throw new JseException("Cannot set bean or class attribute for job when beanRef is set.");
                } // else config ok
            } else {
                if (!job.isSetClassName()) {
                    throw new JseException("must set either class or beanRef for job.");
                }
                GenericBeanDefinition beanDef = new GenericBeanDefinition();
                MutablePropertyValues propertyValues = new MutablePropertyValues();

                if (!job.isSetBean()) {
                    job.setBean(UUID.randomUUID().toString());
                }

                if (springHelper.containsBean(job.getBean())) {
                    throw new JseException(
                            "Bean name already used; overriding not allowed here: " + job.getBean());
                }

                beanDef.setBeanClassName(job.getClassName());

                for (Property prop : job.getProperty()) {
                    String value = null;
                    if (prop.isSetSystemProperty()) {
                        value = System.getProperty(prop.getSystemProperty());
                    }
                    if (null == value) {
                        value = prop.getValue();
                    }

                    propertyValues.addPropertyValue(prop.getName(), value);
                }

                beanDef.setPropertyValues(propertyValues);
                springHelper.registerBean(job.getBean(), beanDef);
                job.setBeanRef(job.getBean());
            }
        }
    }

    springHelper.init();

    ////////////////
    //
    // Configure Timer Services
    //
    ////////////////

    for (org.anodyneos.jse.cron.config.JobGroup jobGroup : schedule.getJobGroup()) {

        String jobGroupName;
        JseTimerService service = new JseTimerService();

        timerServices.add(service);

        if (jobGroup.isSetName()) {
            jobGroupName = jobGroup.getName();
        } else {
            jobGroupName = UUID.randomUUID().toString();
        }

        if (jobGroup.isSetMaxConcurrent()) {
            service.setMaxConcurrent(jobGroup.getMaxConcurrent());
        }

        for (Job job : jobGroup.getJob()) {

            TimeZone jobTimeZone = defaultTimeZone;

            if (job.isSetTimeZone()) {
                jobTimeZone = getTimeZone(job.getTimeZone());
            } else {
                jobTimeZone = defaultTimeZone;
            }

            Object obj;

            Date notBefore = null;
            Date notAfter = null;

            if (job.isSetNotBefore()) {
                notBefore = job.getNotBefore().toGregorianCalendar(jobTimeZone, null, null).getTime();
            }
            if (job.isSetNotAfter()) {
                notAfter = job.getNotAfter().toGregorianCalendar(jobTimeZone, null, null).getTime();
            }

            CronSchedule cs = new CronSchedule(job.getSchedule(), jobTimeZone, job.getMaxIterations(),
                    job.getMaxQueue(), notBefore, notAfter);

            obj = springHelper.getBean(job.getBeanRef());
            log.info("Adding job " + jobGroup.getName() + "/" + job.getName() + " using bean "
                    + job.getBeanRef());
            if (obj instanceof CronJob) {
                ((CronJob) obj).setCronContext(new CronContext(jobGroupName, job.getName(), cs));
            }
            if (obj instanceof JseDateAwareJob) {
                service.createTimer((JseDateAwareJob) obj, cs);
            } else if (obj instanceof Runnable) {
                service.createTimer((Runnable) obj, cs);
            } else {
                throw new JseException("Job must implement Runnable or JseDateAwareJob");
            }
        }
    }
}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

@SuppressWarnings("unchecked")
private VerificationReportType findVerificationReport(ResponseBaseType responseBase) {

    AnyType optionalOutputs = responseBase.getOptionalOutputs();
    if (null == optionalOutputs) {
        return null;
    }/*  w  w  w.  jav a  2  s .  co  m*/
    List<Object> optionalOutputContent = optionalOutputs.getAny();
    for (Object optionalOutput : optionalOutputContent) {

        if (optionalOutput instanceof Element) {
            Element optionalOutputElement = (Element) optionalOutput;
            if (DSSConstants.VR_NAMESPACE.equals(optionalOutputElement.getNamespaceURI())
                    && "VerificationReport".equals(optionalOutputElement.getLocalName())) {
                JAXBElement<VerificationReportType> verificationReportElement;
                try {
                    verificationReportElement = (JAXBElement<VerificationReportType>) this.vrUnmarshaller
                            .unmarshal(optionalOutputElement);
                } catch (JAXBException e) {
                    throw new RuntimeException("JAXB error parsing verification report: " + e.getMessage(), e);
                }
                return verificationReportElement.getValue();
            }
        }
    }
    return null;
}

From source file:fr.cls.atoll.motu.processor.iso19139.ServiceMetadata.java

/**
 * Gets the service identification type.
 * /*from   w  ww.ja v  a2s  .co  m*/
 * @param element the element
 * 
 * @return the service identification type
 */
public static SVServiceIdentificationType getServiceIdentificationType(JAXBElement<?> element) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getServiceIdentificationType(JAXBElement<?>) - entering");
    }

    if (element == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("getServiceIdentificationType(JAXBElement<?>) - exiting");
        }
        return null;
    }

    MDMetadataType metadataType = (MDMetadataType) element.getValue();
    if (metadataType == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("getServiceIdentificationType(JAXBElement<?>) - exiting");
        }
        return null;
    }

    List<MDIdentificationPropertyType> identificationPropertyTypeList = metadataType.getIdentificationInfo();
    if (identificationPropertyTypeList == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("getServiceIdentificationType(JAXBElement<?>) - exiting");
        }
        return null;
    }

    for (MDIdentificationPropertyType identificationPropertyType : identificationPropertyTypeList) {
        AbstractMDIdentificationType abstractMDIdentificationType = identificationPropertyType
                .getAbstractMDIdentification().getValue();
        if (abstractMDIdentificationType == null) {
            continue;
        }
        if (abstractMDIdentificationType instanceof SVServiceIdentificationType) {
            SVServiceIdentificationType returnSVServiceIdentificationType = (SVServiceIdentificationType) abstractMDIdentificationType;
            if (LOG.isDebugEnabled()) {
                LOG.debug("getServiceIdentificationType(JAXBElement<?>) - exiting");
            }
            return returnSVServiceIdentificationType;

        }

    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getServiceIdentificationType(JAXBElement<?>) - exiting");
    }
    return null;
}

From source file:com.tremolosecurity.config.util.UnisonConfigManagerImpl.java

@Override
public void initialize(String name) throws JAXBException, Exception, IOException, FileNotFoundException,
        InstantiationException, IllegalAccessException, ClassNotFoundException, LDAPException,
        KeyStoreException, NoSuchAlgorithmException, CertificateException, ProvisioningException {
    JAXBContext jc = JAXBContext.newInstance("com.tremolosecurity.config.xml");
    Unmarshaller unmarshaller = jc.createUnmarshaller();

    String path = configXML;//from w w w  .  j a  va 2s . c o m
    this.threads = new ArrayList<StopableThread>();

    //path = path.substring(path.lastIndexOf('/') - 1);
    //path = path.substring(path.lastIndexOf('/') - 1);

    path = path.substring(0, path.lastIndexOf('/'));

    JAXBElement<TremoloType> autoidmcfg = this.loadUnisonConfiguration(unmarshaller);
    this.cfg = autoidmcfg.getValue();

    this.byHost = new HashMap<String, ArrayList<UrlHolder>>();
    this.cache = new HashMap<String, UrlHolder>();

    String myVdPath = cfg.getMyvdConfig();

    this.loadKeystore(path, myVdPath);

    this.initSSL();

    this.loadMyVD(path, myVdPath);

    if (cfg.getApplications().getErrorPage() != null) {
        for (ErrorPage ep : cfg.getApplications().getErrorPage()) {
            this.errorPages.put(ep.getCode(), ep.getLocation());
        }
    }

    this.customAzRules = new HashMap<String, CustomAuthorization>();
    if (this.cfg.getCustomAzRules() != null) {
        for (CustomAzRuleType azrule : this.cfg.getCustomAzRules().getAzRule()) {
            HashMap<String, Attribute> azCfg = new HashMap<String, Attribute>();
            for (ParamType pt : azrule.getParams()) {
                Attribute attr = azCfg.get(pt.getName());
                if (attr == null) {
                    attr = new Attribute(pt.getName());
                    azCfg.put(pt.getName(), attr);
                }

                attr.getValues().add(pt.getValue());

            }

            CustomAuthorization cuz = (CustomAuthorization) Class.forName(azrule.getClassName()).newInstance();
            cuz.init(azCfg);

            this.customAzRules.put(azrule.getName(), cuz);
        }
    }

    loadApplicationObjects();

    this.authChains = new HashMap<String, AuthChainType>();

    if (cfg.getAuthChains() != null) {
        Iterator<AuthChainType> itac = cfg.getAuthChains().getChain().iterator();
        while (itac.hasNext()) {
            AuthChainType ac = itac.next();
            this.authChains.put(ac.getName(), ac);
        }
    }

    this.authMechs = new HashMap<String, MechanismType>();

    if (cfg.getAuthMechs() != null) {
        Iterator<MechanismType> itmt = cfg.getAuthMechs().getMechanism().iterator();
        while (itmt.hasNext()) {
            MechanismType mt = itmt.next();
            authMechs.put(mt.getName(), mt);
        }
    }

    this.resGroups = new HashMap<String, ResultGroupType>();

    if (cfg.getResultGroups() != null) {
        Iterator<ResultGroupType> itrgt = cfg.getResultGroups().getResultGroup().iterator();
        while (itrgt.hasNext()) {
            ResultGroupType rgt = itrgt.next();
            this.resGroups.put(rgt.getName(), rgt);
        }
    }

    this.apps = new HashMap<String, ApplicationType>();
    Iterator<ApplicationType> itApp = cfg.getApplications().getApplication().iterator();
    while (itApp.hasNext()) {
        ApplicationType app = itApp.next();
        this.apps.put(app.getName(), app);
    }

    this.provEnvgine = new ProvisioningEngineImpl(this);
    this.provEnvgine.initWorkFlows();
    this.provEnvgine.initMessageConsumers();
    this.provEnvgine.initScheduler();
    this.provEnvgine.initListeners();

    this.postInitialize();

}

From source file:telecom.sudparis.eu.paas.core.server.ressources.manager.application.ApplicationManagerRessource.java

/**
 * {@inheritDoc}/*from   w ww  .  jav  a 2s .  c om*/
 */
@Override
public Response createApplication(String cloudApplicationDescriptor) {
    try {
        copyDeployedApps2Pool();
        if (cloudApplicationDescriptor != null && !cloudApplicationDescriptor.equals("")) {
            InputStream is = new ByteArrayInputStream(cloudApplicationDescriptor.getBytes());
            JAXBContext jaxbContext;
            PaasApplicationManifestType manifest = new PaasApplicationManifestType();
            try {
                jaxbContext = JAXBContext.newInstance("telecom.sudparis.eu.paas.core.server.xml.manifest");
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

                JAXBElement<PaasApplicationManifestType> root = jaxbUnmarshaller.unmarshal(new StreamSource(is),
                        PaasApplicationManifestType.class);
                manifest = root.getValue();

            } catch (JAXBException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // create the application object
            ApplicationType app = new ApplicationType();
            // retrieve appName
            String appName = manifest.getPaasApplication().getName();
            app.setAppName(appName);

            // retrieve app description

            String description = manifest.getPaasApplication().getDescription().toString();
            app.setDescription(description);

            // retrieve uris
            // List<String> uris = new ArrayList<String>();
            // uris.add(appName + "." + HOST_NAME);
            UrisType uris = new UrisType();
            uris.getUri().add(appName + "." + HOST_NAME);
            app.setUris(uris);

            // generate appID
            Long id = getNextId();
            app.setAppId((int) (long) id);

            // retrieve deployableName
            String deployableName = manifest.getPaasApplication().getPaasApplicationVersion()
                    .getPaasApplicationDeployable().getName();

            // retrieve deployableType
            String deployableType = manifest.getPaasApplication().getPaasApplicationVersion()
                    .getPaasApplicationDeployable().getContentType();

            // retrieve deployableDirectory or deployableId
            String deployableId = null;
            String deployableDirectory = manifest.getPaasApplication().getPaasApplicationVersion()
                    .getPaasApplicationDeployable().getLocation();
            // if the deployable is already in the DB we provide it's ID
            DeployableType dep = new DeployableType();
            if (!(deployableDirectory.contains("/") || deployableDirectory.contains("\\"))) {
                dep.setDeployableId(deployableDirectory);
            }
            // Define the deployable element
            else {

                dep.setDeployableDirectory(deployableDirectory);

            }
            dep.setDeployableName(deployableName);
            dep.setDeployableType(deployableType);
            app.setDeployable(dep);
            // retrieve ApplicationVersionInstance Names and number
            List<PaasApplicationVersionInstanceType> listOfInstances = manifest.getPaasApplication()
                    .getPaasApplicationVersion().getPaasApplicationVersionInstance();
            InstancesType listVI = new InstancesType();
            int nbInstances = 0;

            if (listOfInstances != null && listOfInstances.size() > 0)
                for (PaasApplicationVersionInstanceType p : listOfInstances) {
                    if (p != null) {
                        InstanceType vi = new InstanceType();
                        vi.setInstanceName(p.getName());
                        listVI.getInstance().add(vi);
                        nbInstances++;
                    }
                }

            // Update the Application object with the
            // Adequate LinkList
            LinksListType linksList = new LinksListType();
            linksList = ApplicationLinkGenerator.addDescribeAppLink(linksList, id.toString(), apiUrl);
            linksList = ApplicationLinkGenerator.addCreateAppLink(linksList, apiUrl);
            linksList = ApplicationLinkGenerator.addDestroyAppLink(linksList, id.toString(), apiUrl);
            linksList = ApplicationLinkGenerator.addFindAppsLink(linksList, apiUrl);
            linksList = ApplicationLinkGenerator.addUpdateAppLink(linksList, id.toString(), apiUrl);
            app.setLinksList(linksList);
            app.setInstances(listVI);
            app.setNbInstances(nbInstances);
            // app.setCheckExists(CHECK_EXISTS);
            app.setStatus("CREATED");

            ApplicationPool.INSTANCE.add(app);

            return Response.status(Response.Status.OK).entity(new GenericEntity<ApplicationType>(app) {
            }).type(MediaType.APPLICATION_XML_TYPE).build();
        } else {
            System.out.println("Failed to retrieve the cloud Application Descriptor");
            error.setValue("Failed to retrieve the cloud Application Descriptor.");
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
        }
    } catch (Exception e) {
        System.out.println("Failed to create the application: " + e.getMessage());
        e.printStackTrace();
        error.setValue("Failed to create the application: " + e.getMessage());
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error)
                .type(MediaType.APPLICATION_XML_TYPE).build();
    }
}

From source file:edu.harvard.i2b2.eclipse.plugins.metadataLoader.views.loader.TableComposite.java

public void update() {
    String catalogString;//from   w  w w.j a v  a 2s  . c o m
    try {
        // for a local file
        //      FileInputStream catalogStream = new FileInputStream(new File(RunData.getInstance().getCatalogLocation()));
        //   FileInputStream catalogStream = new FileInputStream((RunData.getInstance().getCatalogLocation()));

        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(RunData.getInstance().getCatalogLocation());

        HttpResponse response = httpclient.execute(httpget);

        //         System.out.println(response.getStatusLine());
        HttpEntity entity = response.getEntity();
        if (entity != null) {

            InputStream catalogStream = entity.getContent();

            catalogString = IOUtils.toString(catalogStream, "UTF-8");
            JAXBElement jaxbElement = MetadataLoaderJAXBUtil.getJAXBUtil().unMashallFromString(catalogString);
            OntologyCatalogType catalog = (OntologyCatalogType) jaxbElement.getValue();
            list = catalog.getOntology();
        }
        httpclient.getConnectionManager().shutdown();

        // for a local file
        //   catalogString = IOUtils.toString(catalogStream, "UTF-8");
        //   JAXBElement jaxbElement = MetadataLoaderJAXBUtil.getJAXBUtil().unMashallFromString(catalogString);
        //   OntologyCatalogType catalog  = (OntologyCatalogType) jaxbElement.getValue();
        //   list = catalog.getOntology();
        checkIfPreviouslyInstalled(list, Display.getCurrent(), this.viewer);
        // check to see if any tables previously installed

        refresh();

    } catch (FileNotFoundException e) {
        Display.getCurrent().syncExec(new Runnable() {
            TableViewer theViewer = viewer;

            public void run() {
                // e.getMessage() == Incoming message input stream is null  -- for the case of connection down.
                MessageBox mBox = new MessageBox(theViewer.getTable().getShell(), SWT.ERROR | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage(
                        "Catalog not found at location \n Please make sure the location is correct and try again");
                int result = mBox.open();
                //      TableComposite.getInstance().refresh();
            }
        });
    } catch (JAXBUtilException e) {
        Display.getCurrent().syncExec(new Runnable() {
            TableViewer theViewer = viewer;

            public void run() {
                // e.getMessage() == Incoming message input stream is null  -- for the case of connection down.
                MessageBox mBox = new MessageBox(theViewer.getTable().getShell(), SWT.ERROR | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("Catalog not in correct format");
                int result = mBox.open();
                //      TableComposite.getInstance().refresh();
            }
        });

    } catch (IOException e) {
        Display.getCurrent().syncExec(new Runnable() {
            TableViewer theViewer = viewer;

            public void run() {
                // e.getMessage() == Incoming message input stream is null  -- for the case of connection down.
                MessageBox mBox = new MessageBox(theViewer.getTable().getShell(), SWT.ERROR | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage(
                        "An I/O exception occurred \n Please make sure the location is correct and try again");
                int result = mBox.open();
                //      TableComposite.getInstance().refresh();
            }
        });
    }

}

From source file:com.catify.processengine.core.nodes.NodeFactoryImpl.java

/**
 * Extracts the information of the embedding/parent sub process node's uniqueFlowNodeId. Used for Start and End Events which are logically connected to their
 * embedding sub process nodes./*www .  j  a  v  a 2s  .c om*/
 *
 * @param clientId the client id
 * @param processJaxb the process jaxb
 * @param subProcessesJaxb the sub processes jaxb
 * @param flowNodeJaxb the flow node jaxb
 * @return the unique flow node id of the parent sub process or null if there is none
 */
private String getParentSubProcessUniqueFlowNodeId(String clientId, TProcess processJaxb,
        List<TSubProcess> subProcessesJaxb, TFlowNode flowNodeJaxb) {
    ArrayList<TSubProcess> localSubProcessesJaxb = new ArrayList<TSubProcess>(subProcessesJaxb);

    // check if the current end event node is a embedded in a sub process
    if (localSubProcessesJaxb.size() > 0) {
        // we only check the last sub process, because this can only be the sub process we are looking for
        TSubProcess subProcessJaxb = localSubProcessesJaxb.get(localSubProcessesJaxb.size() - 1);
        for (JAXBElement<? extends TFlowElement> flowElementJaxb : subProcessJaxb.getFlowElement()) {
            // if the given end event node has been found in this sub process this is an embedded end event 
            if (flowElementJaxb.getValue().getId().equals(flowNodeJaxb.getId())) {
                // remove the current sub process from the list of sub processes to be able to get its actor reference
                localSubProcessesJaxb.remove(subProcessJaxb);
                return IdService.getUniqueFlowNodeId(clientId, processJaxb, localSubProcessesJaxb,
                        subProcessJaxb);
            }
        }
    }

    // return null if there is no embedding/parent sub process
    return null;
}

From source file:ch.zhaw.ficore.p2abc.services.user.UserServiceGUI.java

@POST()
@Path("/issuanceArguments/")
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public Response issuanceArguments(final JAXBElement<IssuanceReturn> args_) throws ClientHandlerException,
        UniformInterfaceException, UnsupportedEncodingException, JAXBException, NamingException {
    UiIssuanceArguments args = args_.getValue().uia;
    if (args.tokenCandidates.size() == 1 && args.tokenCandidates.get(0).credentials.size() == 0) {
        Html html = UserGUI.getHtmlPramble("Identity Selection", request);
        Head head = new Head().appendChild(new Title().appendChild(new Text("Obtain Credential [2]")));
        html.appendChild(head);//from  ww  w  .j  a  v a2 s.c o m
        Div mainDiv = new Div().setCSSClass("mainDiv");
        html.appendChild(UserGUI.getBody(mainDiv));
        mainDiv.appendChild(new H2().appendChild(new Text("Obtain Credential")));
        Div div = new Div();
        div.appendChild(new P().setCSSClass("info")
                .appendChild(new Text("The issuer isn't asking you to reveal anything.")));
        Form f = new Form("./obtainCredential3");
        f.setMethod("post");
        f.appendChild(new Input().setType("hidden").setName("uic").setValue(args.uiContext.toString()));
        f.appendChild(new Input().setType("hidden").setName("policyId") // chosenPolicy
                .setValue(Integer.toString(0)));
        f.appendChild(new Input().setType("hidden").setName("candidateId") // chosenPresentationToken
                // or
                // chosenIssuanceToken
                // (weird
                // stuff)
                .setValue(Integer.toString(0)));
        f.appendChild(new Input().setType("hidden").setName("pseudonymId") // chosenPseudonymList
                .setValue(Integer.toString(0)));
        f.appendChild(new Input().setType("submit").setValue("Continue"));
        div.appendChild(f);

        mainDiv.appendChild(div);
        return Response.ok(html.write()).build();
    } else {
        Html html = new Html();
        Head head = new Head().appendChild(new Title().appendChild(new Text("Identity Selection")));
        html.appendChild(head);
        Div mainDiv = new Div();
        html.appendChild(new Body().appendChild(mainDiv));
        mainDiv.appendChild(new H1().appendChild(new Text("Obtain Credential")));
        Div div = UserGUI.getDivForTokenCandidates(args.tokenCandidates, 0, args.uiContext.toString(), "", "",
                ServicesConfiguration.getUserServiceURL());
        mainDiv.appendChild(div);
        return Response.ok(html.write()).build();
    }
}

From source file:org.apache.taverna.scufl2.translator.t2flow.T2FlowParser.java

protected Revision parseIdentificationAnnotations(Annotations annotations) {
    SortedMap<Calendar, UUID> revisions = new TreeMap<>();
    if (annotations == null || annotations.getAnnotationChainOrAnnotationChain22() == null)
        return null;
    for (JAXBElement<AnnotationChain> el : annotations.getAnnotationChainOrAnnotationChain22()) {
        NetSfTavernaT2AnnotationAnnotationAssertionImpl ann = el.getValue()
                .getNetSfTavernaT2AnnotationAnnotationChainImpl().getAnnotationAssertions()
                .getNetSfTavernaT2AnnotationAnnotationAssertionImpl();
        String annClass = ann.getAnnotationBean().getClazz();
        if (!annClass.equals(IDENTIFICATION_ASSERTION))
            continue;
        for (Object obj : ann.getAnnotationBean().getAny()) {
            if (!(obj instanceof Element))
                continue;
            Element elem = (Element) obj;
            if (elem.getNamespaceURI() == null && elem.getLocalName().equals("identification")) {
                String uuid = elem.getTextContent().trim();
                String date = ann.getDate();
                Calendar cal = parseDate(date);
                revisions.put(cal, UUID.fromString(uuid));
            }/*from  w  ww .  j a  v  a 2  s .  c  o  m*/
        }
    }

    Revision rev = null;
    for (Entry<Calendar, UUID> entry : revisions.entrySet()) {
        Calendar cal = entry.getKey();
        UUID uuid = entry.getValue();
        URI uri = WORKFLOW_ROOT.resolve(uuid.toString() + "/");
        rev = new Revision(uri, rev);
        rev.setGeneratedAtTime(cal);
    }
    return rev;
}

From source file:ch.zhaw.ficore.p2abc.services.user.UserServiceGUI.java

@POST
@Path("/presentationArguments/")
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public Response presentationArguments(final JAXBElement<UiPresentationArguments> args_)
        throws ClientHandlerException, UniformInterfaceException, UnsupportedEncodingException, JAXBException,
        NamingException {//from   www .j  a  v a  2s . c  o  m
    UiPresentationArguments args = args_.getValue();
    Html html = UserGUI.getHtmlPramble("Candidate selection", request);
    Div mainDiv = new Div();
    html.appendChild(UserGUI.getBody(mainDiv));

    for (TokenCandidatePerPolicy tcpp : args.tokenCandidatesPerPolicy) {
        List<Object> content = tcpp.policy.getMessage().getApplicationData().getContent();
        if (content == null || content.size() < 1) {
            throw new RuntimeException("Expecting application data!");
        }
        content = tcpp.policy.getMessage().getVerifierIdentity().getContent();
        if (content == null || content.size() < 1) {
            throw new RuntimeException("Expecting verifier identity!");
        }
        String vi = (String) content.get(0);

        mainDiv.appendChild(new H2().appendChild(new Text(tcpp.policy.getPolicyUID().toString())));
        mainDiv.appendChild(new B().appendChild(new Text("Verifier Identity: ")));
        mainDiv.appendChild(new Text(vi));

        Div div = UserGUI.getDivForTokenCandidates(tcpp.tokenCandidates, tcpp.policyId,
                args.uiContext.toString(), (String) content.get(0), "./requestResource3",
                ServicesConfiguration.getUserServiceURL());

        mainDiv.appendChild(div);
    }

    return Response.ok(html.write()).build();
}