diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java index f3c454bda5..e0f0852787 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java @@ -17,6 +17,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; import javax.ws.rs.core.Response; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; @@ -42,8 +43,10 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem for (EnrollmentCertificate enrollmentCertificate : enrollmentCertificates) { certificate = new org.wso2.carbon.certificate.mgt.core.bean.Certificate(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - certificate.setSerial(enrollmentCertificate.getSerial()); - certificate.setCertificate(certificateService.pemToX509Certificate(enrollmentCertificate.getPem())); + X509Certificate x509Certificate = certificateService + .pemToX509Certificate(enrollmentCertificate.getPem()); + certificate.setSerial(x509Certificate.getSerialNumber().toString()); + certificate.setCertificate(x509Certificate); certificates.add(certificate); } certificateService.saveCertificate(certificates); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index bb8759e685..3934ceedf1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -231,8 +231,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { policyDeleted = false; } } - if(policyDeleted) { - for(int i : policyIds) { + if (policyDeleted) { + for (int i : policyIds) { Policy policy = pap.getPolicy(i); pap.deletePolicy(policy); } @@ -244,13 +244,16 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } if (policyDeleted) { - return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build(); + return Response.status(Response.Status.OK).entity("Policies have been successfully " + + "deleted").build(); } else { //TODO:Check of this logic is correct - String ModifiedInvalidPolicyIds = invalidPolicyIds.substring(0, invalidPolicyIds.length()-1); - return Response.status(Response.Status.BAD_REQUEST).entity( - new ErrorResponse.ErrorResponseBuilder().setMessage("Policies with the policy ID " + - ModifiedInvalidPolicyIds + " doesn't exist").build()).build(); + String modifiedInvalidPolicyIds = + invalidPolicyIds.substring(0, invalidPolicyIds.length() - 1); + return Response.status(Response.Status.BAD_REQUEST). + entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage("Policies with the policy ID " + modifiedInvalidPolicyIds + + " doesn't exist").build()).build(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs index 4d0f953422..46e213d374 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs @@ -51,14 +51,6 @@ - - -
-
- -
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js index 4ccd72a11f..6de3971b80 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js @@ -92,17 +92,11 @@ $(document).ready(function () { * when a user clicks on "Add Certificate" button. */ $("button#add-certificate-btn").click(function () { - var serialNoInput = $("input#serialNo"); - var serialNo = serialNoInput.val(); - if (!serialNo) { - $(errorMsg).text("Serial Number is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!pemContent) { + if (!pemContent) { $(errorMsg).text(" .pem file must contains certificate information."); $(errorMsgWrapper).removeClass("hidden"); } else { var addCertificateFormData = {}; - addCertificateFormData.serial = serialNo; addCertificateFormData.pem = pemContent; var certificateList = []; certificateList.push(addCertificateFormData); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs index 801c065221..f963ef9237 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs @@ -16,6 +16,7 @@ under the License. }} {{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -110,73 +111,6 @@ By Serial Number
  • - -
    -
    -
    -
    -

    Do you really want to remove this certificate ?

    - - -
    -
    -
    -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    {{/zone}} {{#zone "bottomJs"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js index 01acf088d1..959a3472da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js @@ -54,8 +54,11 @@ function hidePopup() { */ function removeCertificate(serialNumber) { var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber; - $(modalPopupContent).html($('#remove-certificate-modal-content').html()); - showPopup(); + modalDialog.header('Do you really want to remove this certificate ?'); + modalDialog.footer('
    ' + + 'RemoveCancel' + + '
    '); + modalDialog.show(); $("a#remove-certificate-yes-link").click(function () { invokerUtil.delete( @@ -63,23 +66,29 @@ function removeCertificate(serialNumber) { function () { $("#" + serialNumber).remove(); var newCertificateListCount = $(".user-list > span").length; - $("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount); - $(modalPopupContent).html($('#remove-certificate-success-content').html()); + $("#certificate-listing-status-msg").text("Total number of Certificates found : " + + newCertificateListCount); + modalDialog.header('Done. Certificate was successfully removed.'); + modalDialog.footer('
    Ok
    '); $("a#remove-certificate-success-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }, function () { - $(modalPopupContent).html($('#remove-certificate-error-content').html()); + modalDialog.header('An unexpected error occurred. Please try again later.'); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); $("a#remove-certificate-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } ); }); $("a#remove-certificate-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } @@ -103,8 +112,9 @@ function InitiateViewOption() { if ($("#can-view").val()) { $(location).attr('href', $(this).data("url")); } else { - $(modalPopupContent).html($('#errorCertificateView').html()); - showPopup(); + modalDialog.header('Unauthorized action!'); + modalDialog.content('You do not have permission to view this certificate.'); + modalDialog.showAsAWarning(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs index fe9663f24f..8ae4393a8f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs @@ -1,4 +1,5 @@ {{unit "cdmf.unit.ui.title" pageTitle="Group Management"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -55,22 +56,6 @@ - -
    - -
    {{/zone}} {{#zone "bottomJs"}} {{js "js/group-add.js"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js index ae6870abd3..8a40a13f70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js @@ -71,10 +71,13 @@ $(function () { }); function displayErrors(message) { - showPopup(); $('#error-msg').html(message.responseText); - $(modalPopupContent).html($('#group-error-content').html()); + modalDialog.header('Unexpected error occurred!'); + modalDialog.content('

    '); + modalDialog.footer('
    Ok' + + '
    '); + modalDialog.showAsError(); $("a#group-unexpected-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs index 7ad04791e1..88dd2a4a1c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs @@ -17,8 +17,8 @@ }} {{unit "cdmf.unit.ui.title" pageTitle="Group Management"}} {{unit "cdmf.unit.ui.content.title" pageHeader="Groups"}} - {{unit "cdmf.unit.lib.data-table"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -93,213 +93,6 @@ {{/if}} - -
    -
    -
    -
    -

    Enter user name to manage group sharing

    -
    -
    - - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Select sharing roles

    -
    -
    Loading...
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group sharing updated successfully.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to remove this group from your Group List?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group was successfully removed.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Please enter new name and description for the group

    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group was successfully updated.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Bad Request. Please contact your administrator.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Operation not permitted.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Not found.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group does not exist.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Unexpected error occurred!

    - - -
    -
    -
    -
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index bec491c017..2a05f9c45f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -295,9 +295,13 @@ function attachEvents() { $("a.share-group-link").click(function () { var groupName = $(this).data("group-name"); var groupOwner = $(this).data("group-owner"); - $(modalPopupContent).html($('#share-group-w1-modal-content').html()); + modalDialog.header('Enter user name to manage group sharing'); + modalDialog.content(''); + modalDialog.footer('
    Next' + + 'Cancel
    '); $("a#share-group-next-link").show(); - showPopup(); + modalDialog.show(); $("a#share-group-next-link").click(function () { var selectedUser = $('#share-user-selector').val(); if (selectedUser == $("#group-listing").data("current-user")) { @@ -308,7 +312,7 @@ function attachEvents() { } }); $("a#share-group-w1-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); @@ -321,16 +325,18 @@ function attachEvents() { var groupName = $(this).data("group-name"); var groupOwner = $(this).data("group-owner"); - $(modalPopupContent).html($('#remove-group-modal-content').html()); - showPopup(); + modalDialog.header('Do you really want to remove this group from your Group List?'); + modalDialog.footer('
    Yes' + + 'Cancel
    '); + modalDialog.show(); $("a#remove-group-yes-link").click(function () { var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); if (xhr.status == 200) { - $(modalPopupContent).html($('#remove-group-200-content').html()); + modalDialog.header('Group was successfully removed.'); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); } else { @@ -345,7 +351,7 @@ function attachEvents() { }); $("a#remove-group-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); @@ -360,10 +366,15 @@ function attachEvents() { var groupOwner = $(this).data("group-owner"); var groupDescription = $(this).data("group-description"); - $(modalPopupContent).html($('#edit-group-modal-content').html()); + modalDialog.header('Please enter new name and description for the group.'); + modalDialog.content('

    '); + modalDialog.footer('
    Update' + + 'Cancel
    '); $('#edit-group-name').val(groupName); $('#edit-group-description').val(groupDescription); - showPopup(); + modalDialog.show(); $("a#edit-group-yes-link").click(function () { var newGroupName = $('#edit-group-name').val(); @@ -373,8 +384,11 @@ function attachEvents() { var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); if (xhr.status == 200) { + modalDialog.hide(); + modalDialog.header('Group was successfully updated.'); + modalDialog.show(); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); } else { @@ -389,14 +403,19 @@ function attachEvents() { }); $("a#edit-group-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); } function getAllRoles(groupName, groupOwner, selectedUser) { - $(modalPopupContent).html($('#share-group-w2-modal-content').html()); - $('#user-roles').html('
    '); + modalDialog.header('Select sharing roles'); + modalDialog.content('
    Loading...
    '); + modalDialog.footer('
    OKCancel
    '); + modalDialog.show(); + $('#user-roles').html('
    '); $("a#share-group-yes-link").hide(); var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); @@ -417,7 +436,7 @@ function getAllRoles(groupName, groupOwner, selectedUser) { }); $("a#share-group-w2-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } @@ -463,15 +482,17 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) { }); $("a#share-group-w2-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } function updateGroupShare(groupName, groupOwner, selectedUser, roles) { var successCallback = function (data) { - $(modalPopupContent).html($('#share-group-200-content').html()); + // $(modalPopupContent).html($('#share-group-200-content').html()); + modalDialog.header('Group sharing updated successfully.'); + modalDialog.show(); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); }; @@ -483,35 +504,44 @@ function updateGroupShare(groupName, groupOwner, selectedUser, roles) { } function displayErrors(jqXHR) { - showPopup(); if (jqXHR.status == 400) { - $(modalPopupContent).html($('#group-400-content').html()); + modalDialog.header('

    Bad Request. Please contact your administrator.

    '); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); if (jqXHR.responseText) { $('#error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); } $("a#group-400-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 403) { - $(modalPopupContent).html($('#group-403-content').html()); + modalDialog.header('Operation not permitted.'); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); $("a#group-403-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 404) { - $(modalPopupContent).html($('#group-404-content').html()); + modalDialog.header('

    Not found.

    '); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); $("#group-404-message").html(jqXHR.responseText); $("a#group-404-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); + modalDialog.header('Group does not exist..'); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); $("a#group-409-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else { - $(modalPopupContent).html($('#group-unexpected-error-content').html()); + modalDialog.header('Unexpected error occurred!'); + modalDialog.footer('
    Ok
    '); + modalDialog.showAsError(); $("a#group-unexpected-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); console.log("Error code: " + jqXHR.status); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs index 1eb81672aa..4c5280f154 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs @@ -17,6 +17,7 @@ }} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} {{unit "cdmf.unit.data-tables-extended"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "topCss"}}