Search in sources :

Example 1 with FileAndProperties

use of com.twinsoft.convertigo.engine.admin.util.FileAndProperties in project convertigo by convertigo.

the class Delete method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element rootElement = document.getDocumentElement();
    // String classToCreate = ServiceUtils.getRequiredParameter(request, "classToCreate");
    synchronized (Engine.CERTIFICATES_PATH) {
        FileAndProperties rep = ServiceUtils.startCertificate();
        File file = rep.getF();
        Properties storesProperties = rep.getP();
        String certificateName;
        int i = 1;
        ArrayList<String> mappingsToDelete = new ArrayList<String>();
        while ((certificateName = (String) request.getParameter("certificateName_" + i)) != null) {
            Iterator<Object> it = storesProperties.keySet().iterator();
            while (it.hasNext()) {
                String propertyName = (String) it.next();
                String propertyValue = storesProperties.getProperty(propertyName);
                if (propertyValue.equals(certificateName)) {
                    mappingsToDelete.add(propertyName);
                }
            }
            for (int j = 0; j < mappingsToDelete.size(); j++) {
                // delete found mappings
                ServiceUtils.deleteMapping(storesProperties, mappingsToDelete.get(j), document, rootElement);
            }
            if (storesProperties.remove(certificateName) != null) {
                ServiceUtils.addMessage(document, rootElement, "Certificate " + certificateName + " has successfully been deleted.", "message");
            } else
                throw new ServiceException("Certificate " + certificateName + " didn't exist");
            storesProperties.remove(certificateName + ".type");
            storesProperties.remove(certificateName + ".group");
            i++;
        }
        PropertiesUtils.store(storesProperties, file);
    }
}
Also used : ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) FileAndProperties(com.twinsoft.convertigo.engine.admin.util.FileAndProperties) FileAndProperties(com.twinsoft.convertigo.engine.admin.util.FileAndProperties) Properties(java.util.Properties) File(java.io.File)

Example 2 with FileAndProperties

use of com.twinsoft.convertigo.engine.admin.util.FileAndProperties in project convertigo by convertigo.

the class Delete method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element rootElement = document.getDocumentElement();
    synchronized (Engine.CERTIFICATES_PATH) {
        FileAndProperties rep = ServiceUtils.startCertificate();
        File file = rep.getF();
        Properties storesProperties = rep.getP();
        // String message="";
        String link;
        int i = 1;
        while ((link = (String) request.getParameter("link_" + i)) != null) {
            ServiceUtils.deleteMapping(storesProperties, link, document, rootElement);
            i++;
        }
        PropertiesUtils.store(storesProperties, file);
    }
}
Also used : Element(org.w3c.dom.Element) FileAndProperties(com.twinsoft.convertigo.engine.admin.util.FileAndProperties) FileAndProperties(com.twinsoft.convertigo.engine.admin.util.FileAndProperties) Properties(java.util.Properties) File(java.io.File)

Aggregations

FileAndProperties (com.twinsoft.convertigo.engine.admin.util.FileAndProperties)2 File (java.io.File)2 Properties (java.util.Properties)2 Element (org.w3c.dom.Element)2 ServiceException (com.twinsoft.convertigo.engine.admin.services.ServiceException)1 ArrayList (java.util.ArrayList)1