Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:edu.duke.cabig.c3pr.dao.StudyDao.java

public String generateHQL(List<AdvancedSearchCriteriaParameter> searchParameters, String fileLocation) {
    File file = new File(fileLocation);
    InputStream inputStream;/*from  w w  w  .  ja v  a 2 s.c  om*/
    QueryBuilder queryBuilder = new QueryBuilder();
    try {
        inputStream = new FileInputStream(file);
        Unmarshaller unmarshaller = JAXBContext.newInstance("com.semanticbits.querybuilder")
                .createUnmarshaller();
        queryBuilder = (QueryBuilder) unmarshaller.unmarshal(inputStream);
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    }
    TargetObject targetObject = (TargetObject) queryBuilder.getTargetObject().get(0);
    try {
        return QueryGenerator.generateHQL(targetObject, searchParameters, true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:at.ac.tuwien.dsg.cloud.salsa.engine.smartdeployment.main.SmartDeploymentService.java

@POST
@Path("/requirement/{serviceName}")
@Consumes(MediaType.APPLICATION_XML)/*from w w  w . ja v  a  2 s . co m*/
public void submitQuelleRequirementForService(MultiLevelRequirements requirements,
        @PathParam("serviceName") String serviceName) {
    String saveAs = SalsaConfiguration.getToscaTemplateStorage() + File.separator + serviceName
            + requirementExt;
    JAXBContext jaxbContext;
    try {
        jaxbContext = JAXBContext.newInstance(MultiLevelRequirements.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.marshal(requirements, new File(saveAs));
    } catch (JAXBException ex) {
        EngineLogger.logger.error("Cannot marshall the multilevel requirements that you submitted !");
        ex.printStackTrace();
    }
}

From source file:net.itransformers.idiscover.discoverylisteners.XmlTopologyDeviceLogger.java

public void handleDevice(String deviceName, RawDeviceData rawData, DiscoveredDeviceData discoveredDeviceData,
        Resource resource) {//  w  ww .  j  ava 2  s.co  m
    ByteArrayOutputStream graphMLOutputStream = new ByteArrayOutputStream();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        JaxbMarshalar.marshal(discoveredDeviceData, os, "DiscoveredDevice");
    } catch (JAXBException e) {
        logger.error(e.getMessage(), e);
    }
    XsltTransformer transformer = new XsltTransformer();
    try {
        transformer.transformXML(new ByteArrayInputStream(os.toByteArray()), xsltFileName, graphMLOutputStream,
                null, null);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

    try {
        final String fileName = "node-" + deviceName + ".graphml";
        //            String fullFileName = path + File.separator + fileName;
        final File nodeFile = new File(deviceCentricPath, fileName);
        String graphml = null;
        try {
            graphml = new XmlFormatter().format(new String(graphMLOutputStream.toByteArray()));
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        }
        FileUtils.writeStringToFile(nodeFile, graphml);

        try {
            final File networkGraphml = new File(networkCentricPath + File.separator + "network.graphml");
            if (networkGraphml.exists()) {
                Map<String, String> edgesTypes = new HashMap<String, String>();
                edgesTypes.put("name", "string");
                edgesTypes.put("method", "string");
                edgesTypes.put("dataLink", "string");
                edgesTypes.put("ipLink", "string");
                edgesTypes.put("IPv4Forwarding", "string");
                edgesTypes.put("IPv6Forwarding", "string");
                edgesTypes.put("InterfaceNameA", "string");
                edgesTypes.put("InterfaceNameB", "string");
                edgesTypes.put("IPv4AddressA", "string");
                edgesTypes.put("IPv4AddressB", "string");
                edgesTypes.put("edgeTooltip", "string");
                edgesTypes.put("diff", "string");
                edgesTypes.put("diffs", "string");
                edgesTypes.put("bgpAutonomousSystemA", "string");
                edgesTypes.put("bgpAutonomousSystemB", "string");

                Map<String, String> vertexTypes = new HashMap<String, String>();
                vertexTypes.put("deviceModel", "string");
                vertexTypes.put("deviceType", "string");
                vertexTypes.put("nodeInfo", "string");
                vertexTypes.put("hostname", "string");
                vertexTypes.put("deviceStatus", "string");
                vertexTypes.put("DiscoveredIPv4Address", "string");
                vertexTypes.put("geoCoordinates", "string");
                vertexTypes.put("SubnetPrefix", "string");
                vertexTypes.put("site", "string");
                vertexTypes.put("diff", "string");
                vertexTypes.put("diffs", "string");
                vertexTypes.put("diffs", "string");
                vertexTypes.put("IPv6Forwarding", "string");
                vertexTypes.put("IPv4Forwarding", "string");
                vertexTypes.put("bgpLocalAS", "string");

                Map<String, MergeConflictResolver> edgeConflictResolver = new HashMap<String, MergeConflictResolver>();
                Map<String, MergeConflictResolver> nodeConflictResolver = new HashMap<String, MergeConflictResolver>();
                edgeConflictResolver.put("method", new MergeConflictResolver() {
                    @Override
                    public Object resolveConflict(Object srcValue, Object targetValue) {
                        // if (srcValue instanceof String && targetValue instanceof String) {
                        String[] srcArray = ((String) srcValue).split(",");
                        String[] targetArray = ((String) targetValue).split(",");

                        String[] both = (String[]) ArrayUtils.addAll(srcArray, targetArray);
                        Arrays.sort(both);
                        LinkedHashSet<String> m = new LinkedHashSet<String>();
                        Collections.addAll(m, both);

                        return StringUtils.join(m, ',');

                    }
                });
                new GrahmlMerge(nodeConflictResolver, edgeConflictResolver).merge(nodeFile, networkGraphml,
                        networkGraphml, vertexTypes, edgesTypes, graphtType);
            } else {
                //networkGraphml.createNewFile();
                FileUtils.writeStringToFile(networkGraphml, graphml);
                // new GrahmlMerge().merge(nodeFile, networkGraphml, networkGraphml);
            }
            //TODO remove when you have some time and do the diff in the correct way!
            //                File networkGraphmls = new File(labelPath,graphtType+".graphmls");
            //                if (!networkGraphmls.exists()){
            //                     FileWriter writer = new FileWriter(networkGraphmls);
            //                     writer.write("network.graphml\n");
            //                     writer.close();
            //                }

        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Saves the favorites data/*from w w  w .  ja v  a 2  s. c  om*/
 * 
 */
private static void saveFavData() throws IOException {
    final ObjectFactory factory = new ObjectFactory();
    final IpaGrids favMap = getFavData();
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();

    try {
        final JAXBContext ctx = JAXBContext.newInstance(factory.getClass());
        final Marshaller marshaller = ctx.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);

        marshaller.marshal(favMap, bos);

        PrefHelper.getUserPreferences().put(FAVORITES_PROP, bos.toString("UTF-8"));
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Load static IPA map data/*from   w  ww.ja v a  2 s  . co  m*/
 * 
 */
private static IpaGrids getGridData() {
    ObjectFactory factory = new ObjectFactory();
    if (grids == null) {
        try {
            JAXBContext ctx = JAXBContext.newInstance(factory.getClass());
            Unmarshaller unmarshaller = ctx.createUnmarshaller();
            //            unmarshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
            grids = (IpaGrids) unmarshaller.unmarshal(IpaMap.class.getResource(GRID_FILE));

            // add generated grids
            generateMissingGrids(grids);
        } catch (JAXBException e) {
            e.printStackTrace();
            LOGGER.severe(e.getMessage());
            grids = factory.createIpaGrids();
        }
    }
    return grids;
}

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

/**
 * {@inheritDoc}/* w  w w .j av a  2  s.com*/
 */
@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:ca.phon.ipamap.IpaMap.java

/**
 * Load favorites IPA map data/*from  w  w w .  j ava  2s. com*/
 */
private static IpaGrids getFavData() {
    final ObjectFactory factory = new ObjectFactory();

    final String favXML = PrefHelper.get(FAVORITES_PROP, null);

    // try to load file
    if (favGrid == null && favXML != null) {
        try {
            JAXBContext ctx = JAXBContext.newInstance(factory.getClass());
            Unmarshaller unmarshaller = ctx.createUnmarshaller();
            favGrid = (IpaGrids) unmarshaller.unmarshal(new ByteArrayInputStream(favXML.getBytes()));
        } catch (JAXBException e) {
            e.printStackTrace();
            LOGGER.severe(e.getMessage());
        }
    }

    // create a default grid if still null
    if (favGrid == null) {
        favGrid = factory.createIpaGrids();
        Grid fg = factory.createGrid();
        fg.setCellheight(10);
        fg.setCellwidth(10);
        fg.setCols(MAX_GRID_COLS);
        fg.setRows(2);
        fg.setName("Favorites");
        favGrid.getGrid().add(fg);
    }

    return favGrid;
}

From source file:de.prozesskraft.pmodel.PmodelPartUi1.java

/**
 * constructor als EntryPoint fuer Main falls das dbfile mitgeliefert wird
 *//*from   w w  w .j  a va 2  s  .c  o  m*/
@Inject
public PmodelPartUi1(Composite composite, String pathToProcessFile) {
    shell = composite.getShell();

    java.io.File inFile = new java.io.File(pathToProcessFile);

    if (inFile.exists()) {
        // binary file einlesen
        if (pathToProcessFile.matches(".+\\.pmb$")) {
            log("warn", "assuming binary format.");
            //            System.out.println(inFile.getAbsolutePath());

            Process p1 = new Process();
            p1.setInfilebinary(inFile.getAbsolutePath());
            p1.setOutfilebinary(inFile.getAbsolutePath());

            this.einstellungen.setProcess(p1.readBinary());
        }

        // xml-format einlesen
        else if (pathToProcessFile.matches(".+\\.xml$|.+\\.pmx$")) {
            log("warn", "assuming xml format.");
            this.einstellungen.getProcess().setInfilexml(pathToProcessFile);
            try {
                this.einstellungen.setProcess(this.einstellungen.getProcess().readXml());
            } catch (JAXBException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        else {
            log("fatal", "unknown file extension. please use only 'pmb', 'pmx' or 'xml'.");
        }
    }

    else {
        System.out.println("file does not exist: " + inFile.getAbsolutePath());
    }

    setIni();
    loadIni();
    //      checkLicense();

    //      einstellungen.setRootpositionratiox((float)0.5);
    //      einstellungen.setRootpositionratioy((float)0.1);

    if (this.einstellungen.getProcess() != null) {
        this.einstellungen.getProcess().setStepRanks();
    }
    //      applet = new PmodelViewPage(this, einstellungen);
    applet = new PmodelViewPage(einstellungen);
    createControls(composite);

}

From source file:edu.duke.cabig.c3pr.dao.StudySubjectDao.java

public String generateHQL(List<AdvancedSearchCriteriaParameter> searchParameters) {
    InputStream inputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream("registration-advanced-search.xml");
    Unmarshaller unmarshaller;/*  www. j  a  v a 2  s.  c o m*/
    QueryBuilder queryBuilder = new QueryBuilder();
    try {
        unmarshaller = JAXBContext.newInstance("com.semanticbits.querybuilder").createUnmarshaller();
        queryBuilder = (QueryBuilder) unmarshaller.unmarshal(inputStream);
    } catch (JAXBException e) {
        e.printStackTrace();
    }

    TargetObject targetObject = (TargetObject) queryBuilder.getTargetObject().get(0);
    try {
        return QueryGenerator.generateHQL(targetObject, searchParameters, true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:it.txt.access.capability.revocation.test.RevocationServiceTest.java

@Test
public void testPost()
        throws UnsupportedEncodingException, IOException, JAXBException, ParserConfigurationException,
        NullPointerException, CapabilitySchemaFactoryException, CapabilitySchemaValidationHandlerException,
        DatatypeConfigurationException, GeneralSecurityException, InterruptedException {
    IoTTestForPOST testa = new IoTTestForPOST();

    System.out.println("**********************************************************");
    System.out.println("*               CRP450 : CERTIFCATo                      *");
    System.out.println("**********************************************************");

    StringEntity input = new StringEntity(readFileAsString(System.getProperty("REVOCATION_FIRST")));
    String result = testa.testPost(input);
    assertEquals(StatusCode.CRP450, result);

    System.out.println("**********************************************************");
    System.out.println("*               CRP451 : MISSING ID                      *");
    System.out.println("**********************************************************");

    StringEntity input0 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP451")));
    String result0 = testa.testPost(input0);
    assertEquals(StatusCode.CRP451, result0);

    System.out.println("**********************************************************");
    System.out.println("*               CRP452 : MISSING ISSUER                  *");
    System.out.println("**********************************************************");

    StringEntity input1 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP452")));
    String result1 = testa.testPost(input1);
    assertEquals(StatusCode.CRP452, result1);

    System.out.println("************************************************************************************");
    System.out.println("*CRP453 : BAD ISSUER(the capRev issuer must be the subject of the authorising auCap*");
    System.out.println("************************************************************************************");

    StringEntity input2 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP453")));
    String result2 = testa.testPost(input2);
    assertEquals(StatusCode.CRP453, result2);

    System.out.println("************************************************************************************");
    System.out.println("*         CRP454 : BAD AUTHORISING CAPABILITY(w.r.t. the syntactic validity        *");
    System.out.println("************************************************************************************");

    StringEntity input3 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP454")));
    String result3 = testa.testPost(input3);
    assertEquals(StatusCode.CRP454, result3);
    ///*ww  w. ja  va  2 s. com*/
    // //
    // System.out.println("************************************************************************************");
    // //
    // //
    // System.out.println("*        CRP455 : BAD SIGNER (the capRev issuer must be the certificate signer)    *");
    // //
    // //
    // System.out.println("************************************************************************************");
    //
    System.out.println("************************************************************************************");
    System.out.println("*                        CRP456 : BAD VALIDITY TIME FRAME                          *");
    System.out.println("************************************************************************************");

    StringEntity input5 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP456")));
    String result5 = testa.testPost(input5);
    assertEquals(StatusCode.CRP456, result5);

    System.out.println(
            "********************************************************************************************************************");
    System.out.println(
            "*CRP457 : BAD REVOKED (this happens when the revoked auCap is the same  revocation or resolving its pending status)*");
    System.out.println(
            "********************************************************************************************************************");

    StringEntity input6 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP457")));
    String result6 = testa.testPost(input6);
    assertEquals(StatusCode.CRP457, result6);

    System.out.println("************************************************************************************");
    System.out.println("*                   CRP458 : EXIPERED AUTHORISING CAPABILITY                       *");
    System.out.println("************************************************************************************");

    //create two capability with the 
    String revID = null;
    try {
        // Required initialization
        CapabilitySchemasLoader loader = new CapabilitySchemasLoader(null);
        String schemasPath = System.getProperty("PATH_CAPABILITY_SCHEMA");
        loader.loadCapabilityEntities(schemasPath);
        CapabilitySchemaFactory.getInstance(schemasPath);

        creator = new RevocationCreationByHand();
        creator.setAuthorisingCapability(new File(System.getProperty("AUCAP_CRP458")));
        creator.setAuthorisingCapabilityExpiration(new Date(new Date().getTime() + 2000));
        creator.setCertificatePsw(new char[] { 's', 'y', 's', 'm', 'g', 'r' });
        creator.setKeystore(new File(System.getProperty("KEYSTORE")));
        creator.setKeystorePsw(new char[] { 's', 'y', 's', 'm', 'g', 'r' });
        creator.setNotificationEmail("donato.andrisani@network.txtgroup.com");
        creator.setReason("Why? Because...");
        creator.setRevocationScope("ALL");
        creator.setRevokedCapability(new File(System.getProperty("REVCAP_CRP458")));
        creator.setRevokedCapabilityExpiration(new Date(new Date().getTime() + 10000));
        creator.setRevokedSinceDateTime(new Date());

        CreatedTokens tokens = creator.createRevocation();

        JAXBContext context = JAXBContext.newInstance(AccessRightsCapabilityType.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

        System.out.println("#####----- Modified authorising capability -----#####");
        Document xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getAuthorisingCapability(), xmlDocument);
        assertTrue("The signature of the authorising capability is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####\n\n");

        System.out.println("#####----- Modified revoked capability -----#####");
        xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getRevokedCapability(), xmlDocument);
        assertTrue("The signature of the revoked capability is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####\n\n");

        context = JAXBContext.newInstance(CapabilityRevocationType.class);
        marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        System.out.println("#####----- Revocation -----#####");
        xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getRevocationToken(), xmlDocument);
        assertTrue("The signature of the revocation is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####");
        DataMapper insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"),
                System.getProperty("USER"), System.getProperty("PSW"), tokens.getAuthorisingCapability());
        DataMapper insertCapability1 = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"),
                System.getProperty("USER"), System.getProperty("PSW"), tokens.getRevokedCapability());
        context = JAXBContext.newInstance(CapabilityRevocationType.class);
        revID = tokens.getRevocationToken().getRevocationID();

        Writer writer = new FileWriter(
                "D:/PC-DONATO/workspace/RevocationService/revocationTest/revocationPOSTTest/output_458.xml");
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        try {
            marshaller.marshal(tokens.getRevocationToken(), writer);
            System.out.println("CREATO FILE");
        } finally {
            writer.close();
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (CapabilitySchemaFactoryException e) {
        e.printStackTrace();
    } catch (CapabilitySchemaValidationHandlerException e) {
        e.printStackTrace();
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }

    StringEntity input7 = new StringEntity(readFileAsString(System.getProperty("OUTPUT_458")));
    String result7 = testa.testPost(input7);
    Thread.sleep(4000);
    PendingRevocationsManagement p = new PendingRevocationsManagement();
    p.processPendingCapabilityRevocation();

    ODatabaseDocumentTx capRevDb = new ODatabaseDocumentTx(Constants.revocationDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    String querySelRev = "select statusCode, status from " + Constants.REVOCATION_CLASS + " where "
            + Constants.REVOCATION_ID + " = '" + revID + "'";
    List<ODocument> rev = capRevDb.command(new OCommandSQL(querySelRev)).execute();
    ODocument element = rev.get(0);
    assertEquals(element.field(Constants.STATUS), "REJECTED");

    assertEquals(element.field(Constants.STATUS_CODE), StatusCode.CRP458);

    ODatabaseDocumentTx auCapDb = new ODatabaseDocumentTx(Constants.capabilityDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    String querySelPen = "select statusCode, status, resolvedOn from " + Constants.PENDING_CLASS + " where "
            + Constants.REVOCATION_ID + " = '" + revID + "'";

    List<ODocument> pen = auCapDb.command(new OCommandSQL(querySelPen)).execute();
    ODocument element0 = pen.get(0);

    assertEquals(element0.field(Constants.STATUS), "REJECTED");
    assertEquals(element0.field(Constants.STATUS_CODE), StatusCode.CRP458);
    assertNotNull(element0.field(Constants.RESOLVED_ON));

    create.clearAll();

    System.out.println("************************************************************************************");
    System.out.println("*                   CRP459 : EXPIRED REVOKED CAPABILITY                            *");
    System.out.println("************************************************************************************");

    try {
        // Required initialization
        CapabilitySchemasLoader loader = new CapabilitySchemasLoader(null);
        String schemasPath = System.getProperty("PATH_CAPABILITY_SCHEMA");
        loader.loadCapabilityEntities(schemasPath);
        CapabilitySchemaFactory.getInstance(schemasPath);

        creator = new RevocationCreationByHand();
        creator.setAuthorisingCapability(new File(System.getProperty("AUCAP_CRP458")));
        creator.setAuthorisingCapabilityExpiration(new Date(new Date().getTime() + 10000));
        creator.setCertificatePsw(new char[] { 's', 'y', 's', 'm', 'g', 'r' });
        creator.setKeystore(new File(System.getProperty("KEYSTORE")));
        creator.setKeystorePsw(new char[] { 's', 'y', 's', 'm', 'g', 'r' });
        creator.setNotificationEmail("alice@acme.com");
        creator.setReason("Why? Because...");
        creator.setRevocationScope("ALL");
        creator.setRevokedCapability(new File(System.getProperty("REVCAP_CRP458")));
        creator.setRevokedCapabilityExpiration(new Date(new Date().getTime() + 1000));
        creator.setRevokedSinceDateTime(new Date());

        CreatedTokens tokens = creator.createRevocation();

        JAXBContext context = JAXBContext.newInstance(AccessRightsCapabilityType.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

        System.out.println("#####----- Modified authorising capability -----#####");
        Document xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getAuthorisingCapability(), xmlDocument);
        assertTrue("The signature of the authorising capability is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####\n\n");

        System.out.println("#####----- Modified revoked capability -----#####");
        xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getRevokedCapability(), xmlDocument);
        assertTrue("The signature of the revoked capability is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####\n\n");

        context = JAXBContext.newInstance(CapabilityRevocationType.class);
        marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        System.out.println("#####----- Revocation -----#####");
        xmlDocument = docBuilder.newDocument();
        marshaller.marshal(tokens.getRevocationToken(), xmlDocument);
        assertTrue("The signature of the revocation is not valid!",
                X509DocumentSigner.verifyXMLElementSign(xmlDocument.getDocumentElement()));
        System.out.println(XMLPrinter.printDocumentElement(xmlDocument.getDocumentElement(), true));
        System.out.println("#####--------------- ---------------#####");

        OGlobalConfiguration.CACHE_LEVEL2_ENABLED.setValue(false);
        OGlobalConfiguration.CACHE_LEVEL1_ENABLED.setValue(false);
        DataMapper insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"),
                System.getProperty("USER"), System.getProperty("PSW"), tokens.getAuthorisingCapability());
        DataMapper insertCapability1 = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"),
                System.getProperty("USER"), System.getProperty("PSW"), tokens.getRevokedCapability());

        context = JAXBContext.newInstance(CapabilityRevocationType.class);
        revID = tokens.getRevocationToken().getRevocationID();

        Writer writer = new FileWriter(
                "D:/PC-DONATO/workspace/RevocationService/revocationTest/revocationPOSTTest/output_459.xml");
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new CapabilityNamespacesMapper());
        try {
            marshaller.marshal(tokens.getRevocationToken(), writer);
            System.out.println("CREATO FILE");
        } finally {
            writer.close();
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (CapabilitySchemaFactoryException e) {
        e.printStackTrace();
    } catch (CapabilitySchemaValidationHandlerException e) {
        e.printStackTrace();
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }

    StringEntity input8 = new StringEntity(readFileAsString(System.getProperty("OUTPUT_459")));
    String result8 = testa.testPost(input8);

    Thread.sleep(5000);
    //      PendingRevocationsManagement p  = new PendingRevocationsManagement();
    p.processPendingCapabilityRevocation();

    capRevDb = new ODatabaseDocumentTx(Constants.revocationDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    querySelRev = "select statusCode, status from " + Constants.REVOCATION_CLASS + " where "
            + Constants.REVOCATION_ID + " = '" + revID + "'";
    rev = capRevDb.command(new OCommandSQL(querySelRev)).execute();
    element = rev.get(0);
    assertEquals(element.field(Constants.STATUS), "REJECTED");
    assertEquals(element.field(Constants.STATUS_CODE), StatusCode.CRP459);

    auCapDb = new ODatabaseDocumentTx(Constants.capabilityDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    querySelPen = "select statusCode, status, resolvedOn from " + Constants.PENDING_CLASS + " where "
            + Constants.REVOCATION_ID + " = '" + revID + "'";

    pen = auCapDb.command(new OCommandSQL(querySelPen)).execute();
    element0 = pen.get(0);
    assertEquals(element0.field(Constants.STATUS), "REJECTED");
    assertEquals(element0.field(Constants.STATUS_CODE), StatusCode.CRP459);
    assertNotNull(element0.field(Constants.RESOLVED_ON));
    assertEquals(StatusCode.CRP459, RevocationOutCome.code);

    create.clearAll();

    System.out.println("************************************************************************************");
    System.out.println("*      CRP400 : BAD REVOCATION (w.r.t. the compliance with the XML SCHEMA)         *");
    System.out.println("************************************************************************************");

    StringEntity input9 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP400")));
    String result9 = testa.testPost(input9);
    assertEquals(StatusCode.CRP400, result9);

    System.out.println(
            "**********************************************************************************************************");
    System.out.println(
            "*CRP403 : FORBIDDEN(AFTER RESOLUTION: the authorising auCAp has not the right thr revoke the given auCap)*");
    System.out.println(
            "**********************************************************************************************************");

    StreamSource xml = new StreamSource(System.getProperty("CAPABILITY1"));
    AccessRightsCapabilityType aucap = unMarshall(xml);
    DataMapper insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"),
            System.getProperty("USER"), System.getProperty("PSW"), aucap);

    xml = new StreamSource(System.getProperty("CAPABILITY2"));
    aucap = unMarshall(xml);
    insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"), System.getProperty("USER"),
            System.getProperty("PSW"), aucap);

    StringEntity input10 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP403")));
    String result10 = testa.testPost(input10);

    Thread.sleep(4000);

    p.processPendingCapabilityRevocation();
    assertEquals(StatusCode.CRP403, RevocationOutCome.code);

    insertCapability.clearAll();

    System.out.println(
            "**********************************************************************************************************");
    System.out.println(
            "*                                         CRP201 : ACCEPTED (side POST)                                  *");
    System.out.println(
            "**********************************************************************************************************");

    StringEntity input11 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP201")));
    String result11 = testa.testPost(input11);
    assertEquals(StatusCode.CRP202, result11);

    create.clearAll();

    System.out.println(
            "**********************************************************************************************************");
    System.out.println(
            "*                                         CRP409 : DUPLICATED                                            *");
    System.out.println(
            "**********************************************************************************************************");

    StringEntity prov = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP409")));
    String test = testa.testPost(prov);
    assertEquals(StatusCode.CRP202, test);

    System.out.println(
            "**********************************************************************************************************");
    System.out.println(
            "*                                         CRP201 : ACCEPTED (side RESOLUTION PENDING)                    *");
    System.out.println(
            "**********************************************************************************************************");

    xml = new StreamSource(System.getProperty("CAPABILITY22"));
    aucap = unMarshall(xml);
    insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"), System.getProperty("USER"),
            System.getProperty("PSW"), aucap);

    xml = new StreamSource(System.getProperty("CAPABILITY33"));
    aucap = unMarshall(xml);
    insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"), System.getProperty("USER"),
            System.getProperty("PSW"), aucap);

    input11 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP201")));
    result11 = testa.testPost(input11);
    Thread.sleep(4000);
    p.processPendingCapabilityRevocation();
    assertEquals(StatusCode.CRP201, RevocationOutCome.code);

    capRevDb = new ODatabaseDocumentTx(Constants.revocationDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    querySelRev = "select statusCode, status  from " + Constants.REVOCATION_CLASS + " where "
            + Constants.REVOCATION_ID + " = '_e49af3ee828b03a32c39df493cf4c674'";
    rev = capRevDb.command(new OCommandSQL(querySelRev)).execute();
    element = rev.get(0);

    assertEquals(element.field(Constants.STATUS), "ACCEPTED");
    assertEquals(element.field(Constants.STATUS_CODE), StatusCode.CRP201);

    auCapDb = new ODatabaseDocumentTx(Constants.capabilityDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);
    String queryPend = "select statusCode, status, capabilityID, resolvedOn  from " + Constants.PENDING_CLASS
            + " where " + Constants.REVOCATION_ID + " = '_e49af3ee828b03a32c39df493cf4c674'";
    List<ODocument> res = auCapDb.command(new OCommandSQL(queryPend)).execute();
    ODocument elem = res.get(0);

    String Revoked_Index_Sel = "select from index:" + Constants.REVOKED_INDEX_NAME;
    List<ODocument> Revoked_Index = auCapDb.command(new OCommandSQL(Revoked_Index_Sel)).execute();

    assertEquals(elem.field(Constants.STATUS), "ACCEPTED");
    assertEquals(elem.field(Constants.STATUS_CODE), StatusCode.CRP201);
    assertNotNull(elem.field(Constants.RESOLVED_ON));
    assertNotNull(Revoked_Index);

    System.out.println(
            "**********************************************************************************************************");
    System.out.println(
            "*                                         CRP200 :  WAS ACCEPTED                                         *");
    System.out.println(
            "**********************************************************************************************************");

    xml = new StreamSource(System.getProperty("CAPABILITY11"));
    aucap = unMarshall(xml);
    insertCapability = new DataMapper(System.getProperty("CAPABILITY_DB_PATH"), System.getProperty("USER"),
            System.getProperty("PSW"), aucap);

    StringEntity input12 = new StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP200")));
    String result12 = testa.testPost(input12);

    Thread.sleep(5000);
    p.processPendingCapabilityRevocation();
    assertEquals(StatusCode.CRP200, RevocationOutCome.code);

    capRevDb = new ODatabaseDocumentTx(Constants.revocationDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);

    querySelRev = "select statusCode, status  from " + Constants.REVOCATION_CLASS + " where "
            + Constants.REVOCATION_ID + " = '_a1192622c7f69af47a906ef7ef1a4b15'";
    rev = capRevDb.command(new OCommandSQL(querySelRev)).execute();
    element = rev.get(0);

    assertEquals(element.field(Constants.STATUS), "WAS_ACCEPTED");
    assertEquals(element.field(Constants.STATUS_CODE), StatusCode.CRP200);

    auCapDb = new ODatabaseDocumentTx(Constants.capabilityDBUrl).open(Constants.iUserName,
            Constants.iUserPassword);
    queryPend = "select statusCode, status, capabilityID, resolvedOn  from " + Constants.PENDING_CLASS
            + " where " + Constants.REVOCATION_ID + " = '_a1192622c7f69af47a906ef7ef1a4b15'";
    res = auCapDb.command(new OCommandSQL(queryPend)).execute();
    elem = res.get(0);

    assertEquals(elem.field(Constants.STATUS), "WAS_ACCEPTED");
    assertEquals(elem.field(Constants.STATUS_CODE), StatusCode.CRP200);
    assertNotNull(elem.field(Constants.RESOLVED_ON));

    //       System.out.println("**********************************************************************************************************");
    //       System.out.println("*                                       CRP500 :  INTERNAL SERVER ERROR                                  *");
    //       System.out.println("**********************************************************************************************************");
    //      
    //       OServerAdmin admin = new
    //       OServerAdmin(System.getProperty("REVOCATION_DB_PATH_ERRATO"));
    //       admin.connect(Constants.iUserName, Constants.iUserPassword);
    //       admin.dropDatabase();
    //      
    //       StringEntity input13 = new
    //       StringEntity(readFileAsString(System.getProperty("REVOCATION_CRP500")));
    //       String result13 = testa.testPost(input13);
    //       assertEquals(StatusCode.CRP500, result13);
    create.clearAll();
}