/** * Checks whether the content for the resource being imported exists either in the VFS or in the import file.<p> * * @param resource the resource which should be checked * * @return true if the content exists in the VFS or import file */ private boolean hasContentInVfsOrImport(CmsResource resource) { if (m_contentFiles.contains(resource.getResourceId())) { return true; } try { List<CmsResource> resources = getCms().readSiblings(resource, CmsResourceFilter.ALL); if (!resources.isEmpty()) { return true; } } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } return false; }
String site = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); List<String> orgUnits = new ArrayList<String>(m_orgUnitResources.keySet()); Collections.sort(orgUnits); try { OpenCms.getOrgUnitManager().addResourceToOrgUnit(getCms(), orgUnitName, resourceName); } catch (CmsException e) { getReport().addWarning(e); getCms(), CmsOrganizationalUnit.getParentFqn(orgUnitName)).get(0)).getRootPath(); if (!resources.contains(resName)) { OpenCms.getOrgUnitManager().removeResourceFromOrgUnit(getCms(), orgUnitName, resName); getCms().getRequestContext().setSiteRoot(site);
/** * Sets the userCreated.<p> * * @param userCreated the userCreated to set * * @see #N_USERCREATED * @see #addResourceAttributesRules(Digester, String) */ public void setUserCreated(String userCreated) { try { String userCreatedName = OpenCms.getImportExportManager().translateUser(userCreated); try { m_userCreated = getCms().readUser(userCreatedName).getId(); } catch (@SuppressWarnings("unused") CmsDbEntryNotFoundException e) { m_userCreated = getCms().getRequestContext().getCurrentUser().getId(); } } catch (Throwable e) { setThrowable(e); } }
/** * Imports an ACE from the current xml data.<p> * * @see #addResourceAceRules(Digester, String) */ public void importAccessControlEntries() { // only set permissions if the resource did not exists or if the keep permissions flag is not set if ((m_resource == null) || !m_importACEs) { return; } if ((m_aces == null) || (m_aces.size() == 0)) { // no ACE in the list return; } // if the resource was imported add the access control entries if available try { getCms().importAccessControlEntries(m_resource, m_aces); } catch (@SuppressWarnings("unused") CmsException exc) { getReport().println( Messages.get().container(Messages.RPT_IMPORT_ACL_DATA_FAILED_0), I_CmsReport.FORMAT_WARNING); } finally { m_aces = null; } }
if (acePrincipalId.startsWith(I_CmsPrincipal.PRINCIPAL_GROUP)) { principal = OpenCms.getImportExportManager().translateGroup(principal); principalId = getCms().readGroup(principal).getId(); } else if (acePrincipalId.startsWith(I_CmsPrincipal.PRINCIPAL_USER)) { principal = OpenCms.getImportExportManager().translateUser(principal); principalId = getCms().readUser(principal).getId(); } else if (acePrincipalId.startsWith(CmsRole.PRINCIPAL_ROLE)) { principalId = CmsRole.valueOfRoleName(principal).getId();
/** * Sets the userLastModified.<p> * * @param userLastModified the userLastModified to set * * @see #N_USERLASTMODIFIED * @see #addResourceAttributesRules(Digester, String) */ public void setUserLastModified(String userLastModified) { if (null == userLastModified) { // The optional user last modified information is not provided m_userLastModified = m_cms.getRequestContext().getCurrentUser().getId(); } else { // use the user last modified information from the manifest try { String userLastModifiedName = OpenCms.getImportExportManager().translateUser(userLastModified); try { m_userLastModified = getCms().readUser(userLastModifiedName).getId(); } catch (@SuppressWarnings("unused") CmsDbEntryNotFoundException e) { m_userLastModified = getCms().getRequestContext().getCurrentUser().getId(); } } catch (Throwable e) { setThrowable(e); } } }
Messages.get().getBundle().key( Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_RELATION_1, getCms().getRequestContext().removeSiteRoot(m_resource.getRootPath())), m_throwable);
Messages.get().getBundle().key( Messages.LOG_IMPORTEXPORT_ERROR_IMPORTING_ACE_1, getCms().getRequestContext().removeSiteRoot(m_resource.getRootPath())), m_throwable);
m_orgUnit = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), m_orgUnitName); String site = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); String resName = itResNames.next(); try { resources.add(getCms().readResource(resName, CmsResourceFilter.ALL)); itResNames.remove(); } catch (@SuppressWarnings("unused") CmsVfsResourceNotFoundException e) { getCms().getRequestContext().setSiteRoot(site); getCms(), CmsOrganizationalUnit.getParentFqn(m_orgUnitName)).get(0)); getCms(), m_orgUnitName, m_orgUnitDescription, for (int i = 1; i < resources.size(); i++) { OpenCms.getOrgUnitManager().addResourceToOrgUnit( getCms(), m_orgUnitName, resources.get(i).getRootPath());
getCms().readProject(m_projectName); CmsProject project = getCms().createProject( m_projectName, m_projectDescription, String site = getCms().getRequestContext().getSiteRoot(); CmsProject currentProject = getCms().getRequestContext().getCurrentProject(); try { getCms().getRequestContext().setSiteRoot(""); getCms().getRequestContext().setCurrentProject(project); String resName = itResNames.next(); try { getCms().copyResourceToProject(resName); } catch (@SuppressWarnings("unused") CmsVfsResourceNotFoundException e) { getCms().getRequestContext().setSiteRoot(site); getCms().getRequestContext().setCurrentProject(currentProject);
getCms().readGroup(groupName); try { parentGroupId = getCms().readGroup(m_groupParent).getId(); } catch (@SuppressWarnings("unused") CmsDbEntryNotFoundException exc) { getCms().createGroup( groupName, m_groupDescription, while (it.hasNext()) { String childGroup = it.next(); getCms().setParentGroup(childGroup, groupName);
/** * Rewrites all parseable files, to assure link check.<p> * * This is a global process, that is executed only once at the * end of the import to be sure that all link targets are * available.<p> * * @see #addXmlDigesterRules(Digester) */ public void rewriteParseables() { if (m_parseables.isEmpty()) { return; } I_CmsReport report = getReport(); CmsObject cms = getCms(); cms.getRequestContext().setAttribute(CmsLogEntry.ATTR_LOG_ENTRY, Boolean.FALSE); report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); parseLinks(cms, report); report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); m_parseables = null; }
String translatedName = getCms().getRequestContext().addSiteRoot( m_parameters.getDestinationPath() + m_destination); translatedName = getCms().getRequestContext().removeSiteRoot(translatedName); getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); boolean exists = getCms().existsResource(translatedName, CmsResourceFilter.ALL); m_userCreated = getCms().getRequestContext().getCurrentUser().getId(); m_type, m_flags, getCms().getRequestContext().getCurrentProject().getUuid(), CmsResource.STATE_NEW, m_dateCreated, m_resource = getCms().importResource( translatedName, resource,