Imports a resource from the current xml data.<p>

@see #addResourceAttributesRules(Digester, String)
@see #addResourcePropertyRules(Digester, String)
546899
public void importResource() {

        m_resourceIdWasNull = false;

        try {
            if (m_throwable != null) {
                getReport().println(m_throwable);
                getReport().addError(m_throwable);

                CmsMessageContainer message = Messages.get().container(
                    Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(message.key(), m_throwable);
                }
                m_throwable = null;
                m_importACEs = false;
                m_resource = null;

                return;
            }

            // apply name translation and import path
            String translatedName = getRequestContext().addSiteRoot(
                CmsStringUtil.joinPaths(m_parameters.getDestinationPath(), m_destination));

            boolean resourceImmutable = checkImmutable(translatedName);
            translatedName = getRequestContext().removeSiteRoot(translatedName);
            // if the resource is not immutable and not on the exclude list, import it
            if (!resourceImmutable) {
                // print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_IMPORTING_0), I_CmsReport.FORMAT_NOTE);
                getReport().print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                        translatedName));
                getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

                boolean exists = getCms().existsResource(translatedName, CmsResourceFilter.ALL);

                byte[] content = null;
                // get the file content

                if (m_source != null) {
                    content = m_helper.getFileBytes(m_source);
                }
                int size = 0;
                if (content != null) {
                    size = content.length;
                }
                setDefaultsForEmptyResourceFields();
                // create a new CmsResource
                CmsResource resource = createResourceObjectFromFields(translatedName, size);

                if (m_resourceBuilder.getType().isFolder()
                    || m_resourceIdWasNull
                    || hasContentInVfsOrImport(resource)) {
                    // import this resource in the VFS
                    m_resource = getCms().importResource(
                        translatedName,
                        resource,
                        content,
                        new ArrayList<CmsProperty>(m_properties.values()));
                }

                if (m_resource != null) {
                    m_indexToStructureId.put(Integer.valueOf(m_fileCounter), m_resource.getStructureId());
                }

                // only set permissions if the resource did not exists or if the keep permissions flag is not set
                m_importACEs = (m_resource != null) && (!exists || !m_parameters.isKeepPermissions());

                if (m_resource != null) {
                    getReport().println(
                        org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                        I_CmsReport.FORMAT_OK);

                    if (OpenCms.getResourceManager().getResourceType(
                        m_resource.getTypeId()) instanceof I_CmsLinkParseable) {
                        // store for later use
                        m_parseables.add(m_resource);
                    }
                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_IMPORTING_4,
                                new Object[] {
                                    String.valueOf(m_fileCounter),
                                    String.valueOf(m_totalFiles),
                                    translatedName,
                                    m_destination}));
                    }
                } else {
                    // resource import failed, since no CmsResource was created
                    getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                    getReport().println(
                        org.opencms.report.Messages.get().container(
                            org.opencms.report.Messages.RPT_ARGUMENT_1,
                            translatedName));

                    if (LOG.isInfoEnabled()) {
                        LOG.info(
                            Messages.get().getBundle().key(
                                Messages.LOG_SKIPPING_3,
                                String.valueOf(m_fileCounter),
                                String.valueOf(m_totalFiles),
                                translatedName));
                    }
                }
            } else {
                m_resource = null;
                // skip the file import, just print out the information to the report
                getReport().print(Messages.get().container(Messages.RPT_SKIPPING_0), I_CmsReport.FORMAT_NOTE);
                getReport().println(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_ARGUMENT_1,
                        translatedName));

                if (LOG.isInfoEnabled()) {
                    LOG.info(
                        Messages.get().getBundle().key(
                            Messages.LOG_SKIPPING_3,
                            String.valueOf(m_fileCounter),
                            String.valueOf(m_totalFiles),
                            translatedName));
                }
                // do not import ACEs
                m_importACEs = false;
            }
        } catch (Exception e) {
            m_resource = null;
            m_importACEs = false;

            getReport().println(e);
            getReport().addError(e);

            CmsMessageContainer message = Messages.get().container(
                Messages.ERR_IMPORTEXPORT_ERROR_IMPORTING_RESOURCES_0);
            if (LOG.isDebugEnabled()) {
                LOG.debug(message.key(), e);
            }

            return;
        }
    }
273178
public static void generateResourceTypeXml(
        Element startNode,
        List<I_CmsResourceType> resourceTypes,
        boolean module) {

        for (int i = 0; i < resourceTypes.size(); i++) {
            I_CmsResourceType resType = resourceTypes.get(i);
            // only add this resource type to the xml output, if it is no additional type defined
            // in a module
            if (resType.isAdditionalModuleResourceType() == module) {
                Element resourceType = startNode.addElement(N_TYPE).addAttribute(A_CLASS, resType.getClassName());
                // add type id and type name
                resourceType.addAttribute(A_NAME, resType.getTypeName());
                resourceType.addAttribute(A_ID, String.valueOf(resType.getTypeId()));
                // add resource mappings
                List<String> mappings = resType.getConfiguredMappings();
                if ((mappings != null) && (mappings.size() > 0)) {
                    Element mappingsNode = resourceType.addElement(N_MAPPINGS);
                    for (int j = 0; j < mappings.size(); j++) {
                        Element mapping = mappingsNode.addElement(N_MAPPING);
                        mapping.addAttribute(A_SUFFIX, mappings.get(j));
                    }
                }
                // add default properties
                List<CmsProperty> properties = resType.getConfiguredDefaultProperties();
                if (properties != null) {
                    if (properties.size() > 0) {
                        Element propertiesNode = resourceType.addElement(N_PROPERTIES);
                        Iterator<CmsProperty> p = properties.iterator();
                        while (p.hasNext()) {
                            CmsProperty property = p.next();
                            Element propertyNode = propertiesNode.addElement(N_PROPERTY);
                            propertyNode.addElement(N_NAME).addText(property.getName());
                            if (property.getStructureValue() != null) {
                                propertyNode.addElement(N_VALUE).addCDATA(property.getStructureValue());
                            }
                            if (property.getResourceValue() != null) {
                                propertyNode.addElement(N_VALUE).addAttribute(A_TYPE, CmsProperty.TYPE_SHARED).addCDATA(
                                    property.getResourceValue());
                            }
                        }
                    }
                }
                // add copy resources
                List<CmsConfigurationCopyResource> copyRes = resType.getConfiguredCopyResources();
                if ((copyRes != null) && (copyRes.size() > 0)) {
                    Element copyResNode = resourceType.addElement(N_COPY_RESOURCES);
                    Iterator<CmsConfigurationCopyResource> p = copyRes.iterator();
                    String adjustLinksFolder = resType.getAdjustLinksFolder();
                    if (adjustLinksFolder != null) {
                        copyResNode.addAttribute(A_ADJUST_LINKS_FOLDER, adjustLinksFolder);
                    }
                    while (p.hasNext()) {
                        CmsConfigurationCopyResource cRes = p.next();
                        Element cNode = copyResNode.addElement(N_COPY_RESOURCE);
                        cNode.addAttribute(A_SOURCE, cRes.getSource());
                        if (!cRes.isTargetWasNull()) {
                            cNode.addAttribute(A_TARGET, cRes.getTarget());
                        }
                        if (!cRes.isTypeWasNull()) {
                            cNode.addAttribute(A_TYPE, cRes.getTypeString());
                        }
                    }
                }
                // add optional parameters
                CmsParameterConfiguration configuration = resType.getConfiguration();
                if (configuration != null) {
                    List<String> ignore = null;
                    if ((resType instanceof CmsResourceTypeXmlContainerPage)) {
                        ignore = new ArrayList<String>(1);
                        ignore.add(CmsResourceTypeXmlContent.CONFIGURATION_SCHEMA);
                    }
                    configuration.appendToXml(resourceType, ignore);
                }
            }
        }
    }
1000045
public void add(Rule rule) {
		List<Token> tokens = rule.getTokens();
		for (Token token : tokens) {
			for (String str : token.getTerms()) {
				if (str.charAt(0) != ':') {
					Library.insertWord(forest, new Value(str, "rule", "10000"));
				}
			}
		}


		for (String str : tokens.get(0).getTerms()) {
			Set<Rule> rules = ruleIndex.get(str);
			if(rules==null){
				rules = new HashSet<>() ;
				ruleIndex.put(str,rules) ;
			}
			rules.add(rule) ;
		}
	}
220696
public void load(RulesDefinition.NewRepository repo, Reader reader) {
    XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
    // just so it won't try to load DTD in if there's DOCTYPE
    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
    SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
    try {
      SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
      rootC.advance(); // <rules>

      SMInputCursor rulesC = rootC.childElementCursor("rule");
      while (rulesC.getNext() != null) {
        // <rule>
        processRule(repo, rulesC);
      }

    } catch (XMLStreamException e) {
      throw new IllegalStateException("XML is not valid", e);
    }
  }
347493
@Override
	public Resource createResource(URI uri) {
		XMLResource result = new BpsimResourceImpl(uri);
		result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
		result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

		result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

		result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
		result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

		result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
		return result;
	}
950627
private void addResourceToModule(String resourcePath, CmsModule module) {

        List<String> currentRessources = Lists.newArrayList(module.getResources());
        for (String resource : currentRessources) {
            if (resourcePath.startsWith(resource)) {
                return;
            }
        }
        currentRessources.add(resourcePath);
        module.setResources(currentRessources);
    }
1210526
private void loadAncestors(CmsResource resource) throws CmsException {

        CmsResource currentResource = resource;
        while ((currentResource != null) && m_cms.existsResource(currentResource.getStructureId(), m_filter)) {
            if (!m_knownResources.add(currentResource)) {
                break;
            }

            if (CmsStringUtil.comparePaths(currentResource.getRootPath(), m_commonRoot)) {
                break;
            }
            CmsResource parent = m_cms.readParentFolder(currentResource.getStructureId());
            if (parent != null) {
                m_mustLoadChildren.add(parent);

            }
            currentResource = parent;
        }
    }
413475
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;
        }
    }
40739
@Override
    public T setResourceAdapterXML(String resourceName) throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName must be specified");
        return setResourceAdapterXML(new ClassLoaderAsset(resourceName));

    }
328193
public void importResources(String importFile, String importPath) throws Exception {

        CmsImportParameters params = new CmsImportParameters(
            OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(importFile),
            importPath,
            true);

        OpenCms.getImportExportManager().importData(
            m_cms,
            new CmsShellReport(m_cms.getRequestContext().getLocale()),
            params);
    }
590928
@Override
    public T addAsResource(String resourceName, ArchivePath target, ClassLoader classLoader)
        throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName should be specified");
        Validate.notNull(target, "Target should be specified");
        Validate.notNull(classLoader, "ClassLoader should be specified");

        return addAsResource(new ClassLoaderAsset(resourceName, classLoader), target);
    }
1192052
@Override
    public T addAsWebResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException {
        Validate.notNull(resourcePackage, "ResourcePackage must be specified");
        Validate.notNullAndNoNullValues(resourceNames,
            "ResourceNames must be specified and can not container null values");
        for (final String resourceName : resourceNames) {
            addAsWebResource(resourcePackage, resourceName);
        }
        return covarientReturn();
    }
910878
public static void addXmlDigesterRules(Digester digester) {

        // add class generation rule
        digester.addObjectCreate("*/" + N_MODULE, CmsModuleXmlHandler.class);
        digester.addSetNext("*/" + N_MODULE, "setModule");

        // add rules for base module information

        // NOTE: If you change the order of parameters here or add new ones, you may
        // also need to change the corresponding parameter indexes in the method addXmlDigesterRulesForVersion5Modules.
        digester.addCallMethod("*/" + N_MODULE, "createdModule", 15);
        digester.addCallParam("*/" + N_MODULE + "/" + N_NAME, 0);
        digester.addCallParam("*/" + N_MODULE + "/" + N_NICENAME, 1);
        digester.addCallParam("*/" + N_MODULE + "/" + N_GROUP, 2);
        digester.addCallParam("*/" + N_MODULE + "/" + N_CLASS, 3);
        digester.addCallParam("*/" + N_MODULE + "/" + N_IMPORT_SCRIPT, 4);
        digester.addCallParam("*/" + N_MODULE + "/" + N_IMPORT_SITE, 5);
        digester.addCallParam("*/" + N_MODULE + "/" + N_SITE, 6);
        digester.addCallParam("*/" + N_MODULE + "/" + N_EXPORT_MODE, 7, I_CmsXmlConfiguration.A_NAME);
        digester.addCallParam("*/" + N_MODULE + "/" + N_DESCRIPTION, 8);
        digester.addCallParam("*/" + N_MODULE + "/" + N_VERSION, 9);
        digester.addCallParam("*/" + N_MODULE + "/" + N_AUTHORNAME, 10);
        digester.addCallParam("*/" + N_MODULE + "/" + N_AUTHOREMAIL, 11);
        digester.addCallParam("*/" + N_MODULE + "/" + N_DATECREATED, 12);
        digester.addCallParam("*/" + N_MODULE + "/" + N_USERINSTALLED, 13);
        digester.addCallParam("*/" + N_MODULE + "/" + N_DATEINSTALLED, 14);

        digester.addRule("*/" + N_MODULE + "/" + N_AUTOINCREMENT, new Rule() {

            @Override
            public void body(String namespace, String name, String text) throws Exception {

                CmsModuleXmlHandler handler = (CmsModuleXmlHandler)(getDigester().peek());
                handler.setAutoIncrement(Boolean.parseBoolean(text.trim()));
            }
        });

        digester.addRule("*/" + N_MODULE + "/" + N_CHECKPOINT_TIME, new Rule() {

            @Override
            public void body(String namespace, String name, String text) throws Exception {

                CmsModuleXmlHandler handler = (CmsModuleXmlHandler)(getDigester().peek());
                handler.setCheckpointTime(Long.parseLong(text.trim()));
            }
        });

        // add rules for module dependencies
        digester.addCallMethod("*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY, "addDependency", 2);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY,
            0,
            I_CmsXmlConfiguration.A_NAME);
        digester.addCallParam("*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY, 1, A_VERSION);

        // add rules for the module export points
        digester.addCallMethod(
            "*/" + N_MODULE + "/" + I_CmsXmlConfiguration.N_EXPORTPOINTS + "/" + I_CmsXmlConfiguration.N_EXPORTPOINT,
            "addExportPoint",
            2);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + I_CmsXmlConfiguration.N_EXPORTPOINTS + "/" + I_CmsXmlConfiguration.N_EXPORTPOINT,
            0,
            I_CmsXmlConfiguration.A_URI);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + I_CmsXmlConfiguration.N_EXPORTPOINTS + "/" + I_CmsXmlConfiguration.N_EXPORTPOINT,
            1,
            I_CmsXmlConfiguration.A_DESTINATION);

        // add rules for the module resources
        digester.addCallMethod(
            "*/" + N_MODULE + "/" + N_RESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
            "addResource",
            1);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + N_RESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
            0,
            I_CmsXmlConfiguration.A_URI);

        // add rules for the module exclude resources
        digester.addCallMethod(
            "*/" + N_MODULE + "/" + N_EXCLUDERESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
            "addExcludeResource",
            1);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + N_EXCLUDERESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
            0,
            I_CmsXmlConfiguration.A_URI);

        // add rules for the module parameters
        digester.addCallMethod(
            "*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM,
            "addParameter",
            2);
        digester.addCallParam(
            "*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM,
            0,
            I_CmsXmlConfiguration.A_NAME);
        digester.addCallParam("*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM, 1);

        // generic <param> parameter rules
        digester.addCallMethod(
            "*/" + I_CmsXmlConfiguration.N_PARAM,
            I_CmsConfigurationParameterHandler.ADD_PARAMETER_METHOD,
            2);
        digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 0, I_CmsXmlConfiguration.A_NAME);
        digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 1);

        // add resource type rules from VFS
        CmsVfsConfiguration.addResourceTypeXmlRules(digester);

        // add explorer type rules from workplace
        CmsWorkplaceConfiguration.addExplorerTypeXmlRules(digester);

        // finally add all rules for backward compatibility with OpenCms 5.0
        addXmlDigesterRulesForVersion5Modules(digester);
    }
291372
public static base_response Import(nitro_service client, responderhtmlpage resource) throws Exception {
		responderhtmlpage Importresource = new responderhtmlpage();
		Importresource.src = resource.src;
		Importresource.name = resource.name;
		Importresource.comment = resource.comment;
		Importresource.overwrite = resource.overwrite;
		return Importresource.perform_operation(client,"Import");
	}
506374
public void addRules(Digester digester) {

        digester.addRule(m_basePath, new Rule() {

            @SuppressWarnings("synthetic-access")
            @Override
            public void begin(String namespace, String name, Attributes attributes) throws Exception {

                I_CmsConfigurationParameterHandler config = (I_CmsConfigurationParameterHandler)(m_class.newInstance());
                for (String attr : m_attrs) {
                    String attrValue = attributes.getValue(attr);
                    if (attrValue != null) {
                        config.addConfigurationParameter(attr, attrValue);
                    }
                }
                config.initConfiguration();
                getDigester().push(config);
            }

            @Override
            public void end(String namespace, String name) throws Exception {

                getDigester().pop();
            }

        });
    }
812975
public void setResource() {

        selectResource(
            m_infoBean.getResourcePath(),
            m_infoBean.getStructureId(),
            m_infoBean.getProperties().get(CmsClientProperty.PROPERTY_TITLE));
    }
1226687
protected void addResourceRelationRules(Digester digester, String xpath) {

        String xp_rels = xpath + N_RELATIONS + "/" + N_RELATION;
        digester.addCallMethod(xp_rels, "addRelation");
        digester.addCallMethod(xp_rels + "/" + N_ID, "setRelationId", 0);
        digester.addCallMethod(xp_rels + "/" + N_PATH, "setRelationPath", 0);
        digester.addCallMethod(xp_rels + "/" + N_TYPE, "setRelationType", 0);
    }