List of usage examples for com.liferay.portal.kernel.xml Element addAttribute
public Element addAttribute(String name, String value);
From source file:com.liferay.exportimport.lar.DeletionSystemEventExporter.java
License:Open Source License
protected void exportDeletionSystemEvent(PortletDataContext portletDataContext, SystemEvent systemEvent, Element deletionSystemEventsElement) { Element deletionSystemEventElement = deletionSystemEventsElement.addElement("deletion-system-event"); deletionSystemEventElement.addAttribute("class-name", PortalUtil.getClassName(systemEvent.getClassNameId())); deletionSystemEventElement.addAttribute("extra-data", systemEvent.getExtraData()); deletionSystemEventElement.addAttribute("group-id", String.valueOf(systemEvent.getGroupId())); if (systemEvent.getReferrerClassNameId() > 0) { deletionSystemEventElement.addAttribute("referrer-class-name", PortalUtil.getClassName(systemEvent.getReferrerClassNameId())); }// w w w. j a v a 2 s . c o m deletionSystemEventElement.addAttribute("uuid", systemEvent.getClassUuid()); ManifestSummary manifestSummary = portletDataContext.getManifestSummary(); manifestSummary.incrementModelDeletionCount( new StagedModelType(systemEvent.getClassNameId(), systemEvent.getReferrerClassNameId())); }
From source file:com.liferay.exportimport.lar.ExportImportHelperImpl.java
License:Open Source License
@Override public void writeManifestSummary(Document document, ManifestSummary manifestSummary) { Element rootElement = document.getRootElement(); Element manifestSummaryElement = rootElement.addElement("manifest-summary"); for (String manifestSummaryKey : manifestSummary.getManifestSummaryKeys()) { Element element = manifestSummaryElement.addElement("staged-model"); element.addAttribute("manifest-summary-key", manifestSummaryKey); long modelAdditionCount = manifestSummary.getModelAdditionCount(manifestSummaryKey); if (modelAdditionCount > 0) { element.addAttribute("addition-count", String.valueOf(modelAdditionCount)); }/*from w ww. j a va2 s .com*/ long modelDeletionCount = manifestSummary.getModelDeletionCount(manifestSummaryKey); if (modelDeletionCount > 0) { element.addAttribute("deletion-count", String.valueOf(modelDeletionCount)); } } }
From source file:com.liferay.exportimport.lar.PermissionExporter.java
License:Open Source License
public void exportPortletDataPermissions(PortletDataContext portletDataContext) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("portlet-data-permissions"); Map<String, List<KeyValuePair>> permissionsMap = portletDataContext.getPermissions(); for (Map.Entry<String, List<KeyValuePair>> entry : permissionsMap.entrySet()) { String[] permissionParts = StringUtil.split(entry.getKey(), CharPool.POUND); String resourceName = permissionParts[0]; long resourcePK = GetterUtil.getLong(permissionParts[1]); Element portletDataElement = rootElement.addElement("portlet-data"); portletDataElement.addAttribute("resource-name", resourceName); portletDataElement.addAttribute("resource-pk", String.valueOf(resourcePK)); List<KeyValuePair> permissions = entry.getValue(); for (KeyValuePair permission : permissions) { String roleName = permission.getKey(); String actions = permission.getValue(); Element permissionsElement = portletDataElement.addElement("permissions"); permissionsElement.addAttribute("role-name", roleName); permissionsElement.addAttribute("actions", actions); }/* w ww .j av a 2 s . c o m*/ } portletDataContext.addZipEntry( ExportImportPathUtil.getRootPath(portletDataContext) + "/portlet-data-permissions.xml", document.formattedString()); }
From source file:com.liferay.exportimport.lar.PermissionExporter.java
License:Open Source License
protected void exportPermissions(PortletDataContext portletDataContext, String resourceName, String resourcePrimKey, Element permissionsElement) throws Exception { List<String> actionIds = ResourceActionsUtil.getPortletResourceActions(resourceName); Map<Long, Set<String>> roleToActionIds = ExportImportPermissionUtil .getRoleIdsToActionIds(portletDataContext.getCompanyId(), resourceName, resourcePrimKey, actionIds); for (Map.Entry<Long, Set<String>> entry : roleToActionIds.entrySet()) { long roleId = entry.getKey(); Role role = RoleLocalServiceUtil.fetchRole(roleId); String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName(role.getDescriptiveName()); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe);//ww w. ja v a 2s.c o m } } } Element roleElement = permissionsElement.addElement("role"); roleElement.addAttribute("uuid", role.getUuid()); roleElement.addAttribute("name", roleName); roleElement.addAttribute("title", role.getTitle()); roleElement.addAttribute("description", role.getDescription()); roleElement.addAttribute("type", String.valueOf(role.getType())); roleElement.addAttribute("subtype", role.getSubtype()); Set<String> availableActionIds = entry.getValue(); for (String actionId : availableActionIds) { Element actionKeyElement = roleElement.addElement("action-key"); actionKeyElement.addText(actionId); } } }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
@Override public void addClassedModel(Element element, String path, ClassedModel classedModel, Class<?> clazz) throws PortalException { element.addAttribute("path", path); populateClassNameAttribute(classedModel, element); if (!hasPrimaryKey(String.class, path)) { if (classedModel instanceof AuditedModel) { AuditedModel auditedModel = (AuditedModel) classedModel; auditedModel.setUserUuid(auditedModel.getUserUuid()); }//from w w w .j ava 2s .c om if (isResourceMain(classedModel)) { Serializable classPK = ExportImportClassedModelUtil.getPrimaryKeyObj(classedModel); long classNameId = ExportImportClassedModelUtil.getClassNameId(classedModel); _addAssetLinks(classNameId, GetterUtil.getLong(classPK)); _addAssetPriority(element, classNameId, GetterUtil.getLong(classPK)); addExpando(element, path, classedModel, clazz); addLocks(clazz, String.valueOf(classPK)); addPermissions(clazz, classPK); } _references.add(getReferenceKey(classedModel)); } addZipEntry(path, classedModel); }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
@Override public Element addReferenceElement(ClassedModel referrerClassedModel, Element element, ClassedModel classedModel, String className, String binPath, String referenceType, boolean missing) { Element referenceElement = doAddReferenceElement(referrerClassedModel, element, classedModel, className, binPath, referenceType, false); String referenceKey = getReferenceKey(classedModel); if (missing) { if (_references.contains(referenceKey)) { return referenceElement; }// w ww .j ava2 s .c om referenceElement.addAttribute("missing", Boolean.TRUE.toString()); if (!_missingReferences.contains(referenceKey)) { _missingReferences.add(referenceKey); doAddReferenceElement(referrerClassedModel, null, classedModel, className, binPath, referenceType, true); } } else { _references.add(referenceKey); referenceElement.addAttribute("missing", Boolean.FALSE.toString()); cleanUpMissingReferences(classedModel); } return referenceElement; }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
@Override public void cleanUpMissingReferences(ClassedModel classedModel) { String referenceKey = getReferenceKey(classedModel); if (_missingReferences.contains(referenceKey)) { _missingReferences.remove(referenceKey); Element missingReferenceElement = getMissingReferenceElement(classedModel); if (classedModel instanceof Layout) { missingReferenceElement.addAttribute("element-path", "/manifest.xml"); } else {// w w w. ja v a 2s. c o m missingReferenceElement.addAttribute("element-path", ExportImportPathUtil.getPortletDataPath(this)); } } }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
@Override public Element getExportDataElement(ClassedModel classedModel, String modelClassSimpleName) { Element groupElement = getExportDataGroupElement(modelClassSimpleName); Element element = null; if (classedModel instanceof StagedModel) { StagedModel stagedModel = (StagedModel) classedModel; String path = ExportImportPathUtil.getModelPath(stagedModel); element = getDataElement(groupElement, "path", path); if (element != null) { return element; }// www . j a v a 2 s .c om element = getDataElement(groupElement, "uuid", stagedModel.getUuid()); if (element != null) { return element; } } element = groupElement.addElement("staged-model"); if (classedModel instanceof StagedGroupedModel) { StagedGroupedModel stagedGroupedModel = (StagedGroupedModel) classedModel; element.addAttribute("group-id", String.valueOf(stagedGroupedModel.getGroupId())); element.addAttribute("uuid", stagedGroupedModel.getUuid()); } else if (classedModel instanceof StagedModel) { StagedModel stagedModel = (StagedModel) classedModel; element.addAttribute("uuid", stagedModel.getUuid()); } return element; }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
/** * @deprecated As of 4.0.0/* ww w . ja v a 2 s. co m*/ */ @Deprecated protected void addAssetPriority(Element element, Class<?> clazz, Serializable classPK) { AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(clazz.getName(), GetterUtil.getLong(classPK)); if (assetEntry == null) { return; } element.addAttribute("asset-priority", String.valueOf(assetEntry.getPriority())); }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
protected void addExpando(Element element, String path, ClassedModel classedModel, Class<?> clazz) { String className = clazz.getName(); if (!_expandoColumnsMap.containsKey(className)) { List<ExpandoColumn> expandoColumns = ExpandoColumnLocalServiceUtil.getDefaultTableColumns(_companyId, className);// w ww. j av a 2 s . c o m for (ExpandoColumn expandoColumn : expandoColumns) { addPermissions(ExpandoColumn.class, Long.valueOf(expandoColumn.getColumnId())); } _expandoColumnsMap.put(className, expandoColumns); } ExpandoBridge expandoBridge = classedModel.getExpandoBridge(); if (expandoBridge == null) { return; } Map<String, Serializable> expandoBridgeAttributes = expandoBridge.getAttributes(); if (!expandoBridgeAttributes.isEmpty()) { String expandoPath = ExportImportPathUtil.getExpandoPath(path); element.addAttribute("expando-path", expandoPath); addZipEntry(expandoPath, expandoBridgeAttributes); } }