Example usage for com.liferay.portal.kernel.upgrade UpgradeException UpgradeException

List of usage examples for com.liferay.portal.kernel.upgrade UpgradeException UpgradeException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.upgrade UpgradeException UpgradeException.

Prototype

public UpgradeException(Throwable cause) 

Source Link

Usage

From source file:com.liferay.calendar.internal.upgrade.v1_0_4.UpgradeClassNames.java

License:Open Source License

protected void deleteCalEventClassName() throws UpgradeException {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        runSQL("delete from Counter where name like '" + _CAL_EVENT_CLASS_NAME + "%'");

        runSQL("delete from ClassName_ where value like '" + _CAL_EVENT_CLASS_NAME + "%'");

        runSQL("delete from ResourceAction where name like '" + _CAL_EVENT_CLASS_NAME + "%'");

        runSQL("delete from ResourceBlock where name like '" + _CAL_EVENT_CLASS_NAME + "%'");

        runSQL("delete from ResourcePermission where name like '" + _CAL_EVENT_CLASS_NAME + "%'");
    } catch (Exception e) {
        throw new UpgradeException(e);
    }/*from w w  w .  j av  a  2s  .  co  m*/
}

From source file:com.liferay.calendar.internal.upgrade.v1_0_4.UpgradeClassNames.java

License:Open Source License

protected void deleteDuplicateResources() throws UpgradeException {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        String oldName = _RESOURCE_NAMES[0][0];
        String newName = _RESOURCE_NAMES[0][1];

        String selectSQL = "select actionId from ResourceAction where name = '" + newName + "'";

        try (PreparedStatement ps = connection.prepareStatement(selectSQL); ResultSet rs = ps.executeQuery()) {

            while (rs.next()) {
                runSQL("delete from ResourceAction where actionId = '" + rs.getString(1) + "' and name= '"
                        + oldName + "'");
            }/*from w w w .  j ava2 s  .co  m*/
        } catch (Exception e) {
            throw new UpgradeException(e);
        }
    }
}

From source file:com.liferay.calendar.internal.upgrade.v1_0_6.UpgradeResourcePermission.java

License:Open Source License

protected List<String> getModelResourceGuestUnsupportedActions() throws UpgradeException {

    try {/* w  w  w  .  j a va2 s .  co m*/
        ResourceActionsImpl resourceActionsImpl = new ResourceActionsImpl();

        Class<?> clazz = getClass();

        ClassLoader classLoader = clazz.getClassLoader();

        for (String config : PropsValues.RESOURCE_ACTIONS_CONFIGS) {
            resourceActionsImpl.read(null, classLoader, config);
        }

        return resourceActionsImpl.getModelResourceGuestUnsupportedActions(_CALENDAR_RESOURCE_NAME);
    } catch (Exception e) {
        throw new UpgradeException(e);
    }
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java

License:Open Source License

protected String createNewDDMFormFieldName(String fieldName, Set<String> existingFieldNames) throws Exception {

    String newFieldName = fieldName.replaceAll(_INVALID_FIELD_NAME_CHARS_REGEX, StringPool.BLANK);

    if (Validator.isNotNull(newFieldName) && !existingFieldNames.contains(newFieldName)) {

        return newFieldName;
    }//w  ww. j  a  v a  2 s . c  om

    throw new UpgradeException(String.format("Unable to automatically update field name \"%s\" because it "
            + "only contains invalid characters or the updated value "
            + "\"%s\" conflicts with a previous field name", fieldName, newFieldName));
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java

License:Open Source License

protected DDMForm getDDMForm(long structureId) throws Exception {
    DDMForm ddmForm = _ddmForms.get(structureId);

    if (ddmForm != null) {
        return ddmForm;
    }//from w  w  w .j a v a  2s. c  o  m

    try (PreparedStatement ps = connection.prepareStatement(
            "select parentStructureId, definition, storageType from " + "DDMStructure where structureId = ?")) {

        ps.setLong(1, structureId);

        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                long parentStructureId = rs.getLong("parentStructureId");
                String definition = rs.getString("definition");
                String storageType = rs.getString("storageType");

                if (storageType.equals("expando") || storageType.equals("xml")) {

                    ddmForm = _ddmFormXSDDeserializer.deserialize(definition);
                } else {
                    ddmForm = _ddmFormJSONDeserializer.deserialize(definition);
                }

                try {
                    validateDDMFormFieldNames(ddmForm);
                } catch (MustNotDuplicateFieldName mndfn) {
                    throw new UpgradeException(String.format(
                            "The field name '%s' from structure ID %d is " + "defined more than once",
                            mndfn.getFieldName(), structureId));
                }

                if (parentStructureId > 0) {
                    DDMForm parentDDMForm = getDDMForm(parentStructureId);

                    Set<String> commonDDMFormFieldNames = SetUtil
                            .intersect(getDDMFormFieldsNames(parentDDMForm), getDDMFormFieldsNames(ddmForm));

                    if (!commonDDMFormFieldNames.isEmpty()) {
                        throw new UpgradeException(
                                "Duplicate DDM form field names: " + StringUtil.merge(commonDDMFormFieldNames));
                    }
                }

                _ddmForms.put(structureId, ddmForm);

                return ddmForm;
            }
        }

        throw new UpgradeException("Unable to find dynamic data mapping structure with ID " + structureId);
    }
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java

License:Open Source License

protected DDMForm getFullHierarchyDDMForm(long structureId) throws Exception {

    DDMForm fullHierarchyDDMForm = _fullHierarchyDDMForms.get(structureId);

    if (fullHierarchyDDMForm != null) {
        return fullHierarchyDDMForm;
    }/*from w  w  w. j a v  a2s  .co m*/

    try (PreparedStatement ps = connection
            .prepareStatement("select parentStructureId from DDMStructure where " + "structureId = ?")) {

        ps.setLong(1, structureId);

        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                long parentStructureId = rs.getLong("parentStructureId");

                fullHierarchyDDMForm = getDDMForm(structureId);

                if (parentStructureId > 0) {
                    DDMForm parentDDMForm = getFullHierarchyDDMForm(parentStructureId);

                    List<DDMFormField> ddmFormFields = fullHierarchyDDMForm.getDDMFormFields();

                    ddmFormFields.addAll(parentDDMForm.getDDMFormFields());
                }

                _fullHierarchyDDMForms.put(structureId, fullHierarchyDDMForm);

                return fullHierarchyDDMForm;
            }
        }

        throw new UpgradeException("Unable to find dynamic data mapping structure with ID " + structureId);
    }
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java

License:Open Source License

protected String getStructureModelResourceName(long classNameId) throws UpgradeException {

    String className = PortalUtil.getClassName(classNameId);

    String structureModelResourceName = _structureModelResourceNames.get(className);

    if (structureModelResourceName == null) {
        throw new UpgradeException(StringBundler.concat("Model ", className, " does not support DDM structure ",
                "permission checking"));
    }//w w  w .j a va  2s.  c  om

    return structureModelResourceName;
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java

License:Open Source License

protected String getTemplateModelResourceName(long classNameId) throws UpgradeException {

    String className = PortalUtil.getClassName(classNameId);

    String templateModelResourceName = _templateModelResourceNames.get(className);

    if (templateModelResourceName == null) {
        throw new UpgradeException(StringBundler.concat("Model ", className, " does not support DDM template ",
                "permission checking"));
    }/*from   w ww  .  ja  va 2 s.co m*/

    return templateModelResourceName;
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_1_2.UpgradeDynamicDataMapping.java

License:Open Source License

protected DDMForm getDDMForm(long structureId) throws Exception {
    DDMForm ddmForm = _ddmForms.get(structureId);

    if (ddmForm != null) {
        return ddmForm;
    }/*from   w ww.j  a v  a  2 s. c o  m*/

    try (PreparedStatement ps = connection
            .prepareStatement("select definition from DDMStructure where structureId = ?")) {

        ps.setLong(1, structureId);

        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                ddmForm = _ddmFormJSONDeserializer.deserialize(rs.getString("definition"));

                _ddmForms.put(structureId, ddmForm);

                return ddmForm;
            }
        }
    }

    throw new UpgradeException("Unable to find dynamic data mapping structure with ID " + structureId);
}

From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_1_2.UpgradeDynamicDataMapping.java

License:Open Source License

protected DDMForm getFullHierarchyDDMForm(long structureId) throws Exception {

    DDMForm fullHierarchyDDMForm = _fullHierarchyDDMForms.get(structureId);

    if (fullHierarchyDDMForm != null) {
        return fullHierarchyDDMForm;
    }//  www .  j ava  2s.  c om

    try (PreparedStatement ps = connection
            .prepareStatement("select parentStructureId from DDMStructure where " + "structureId = ?")) {

        ps.setLong(1, structureId);

        try (ResultSet rs = ps.executeQuery()) {
            if (rs.next()) {
                long parentStructureId = rs.getLong("parentStructureId");

                fullHierarchyDDMForm = getDDMForm(structureId);

                if (parentStructureId > 0) {
                    DDMForm parentDDMForm = getFullHierarchyDDMForm(parentStructureId);

                    List<DDMFormField> ddmFormFields = fullHierarchyDDMForm.getDDMFormFields();

                    ddmFormFields.addAll(parentDDMForm.getDDMFormFields());
                }

                _fullHierarchyDDMForms.put(structureId, fullHierarchyDDMForm);

                return fullHierarchyDDMForm;
            }
        }
    }

    throw new UpgradeException("Unable to find dynamic data mapping structure with ID " + structureId);
}