Exemplo n.º 1
0
  private void _detachUnnecessaryTypes(Element rootElement) {
    List<Element> elements = rootElement.elements();

    for (Element element : elements) {
      String type = element.elementText("type");

      if (!type.contains(".service.") || !type.endsWith("ServiceImpl")) {
        element.detach();
      }
    }
  }
Exemplo n.º 2
0
  private void _updateJavadocsXmlFile(
      String fileName, JavaClass javaClass, Document javaClassDocument) throws Exception {

    String javaClassFullyQualifiedName = javaClass.getFullyQualifiedName();

    /*if (!javaClassFullyQualifiedName.contains(".service.") ||
    	!javaClassFullyQualifiedName.endsWith("ServiceImpl")) {

    	return;
    }*/

    Tuple javadocsXmlTuple = _getJavadocsXmlTuple(fileName);

    if (javadocsXmlTuple == null) {
      return;
    }

    Document javadocsXmlDocument = (Document) javadocsXmlTuple.getObject(3);

    Element javadocsXmlRootElement = javadocsXmlDocument.getRootElement();

    List<Element> javadocElements = javadocsXmlRootElement.elements("javadoc");

    for (Element javadocElement : javadocElements) {
      String type = javadocElement.elementText("type");

      if (type.equals(javaClassFullyQualifiedName)) {
        Element javaClassRootElement = javaClassDocument.getRootElement();

        if (Validator.equals(
            javadocElement.formattedString(), javaClassRootElement.formattedString())) {

          return;
        }

        javadocElement.detach();

        break;
      }
    }

    javadocsXmlRootElement.add(javaClassDocument.getRootElement());
  }
Exemplo n.º 3
0
  protected void exportBinary(
      PortletDataContext portletDataContext,
      Element fileEntryElement,
      FileVersion fileVersion,
      InputStream is,
      String binPath,
      String binPathName)
      throws SystemException {

    fileEntryElement.addAttribute(binPathName, binPath);

    if (is == null) {
      if (_log.isWarnEnabled()) {
        _log.warn("No input stream found for file entry " + fileVersion.getFileEntryId());
      }

      fileEntryElement.detach();

      return;
    }

    portletDataContext.addZipEntry(binPath, is);
  }
  @Override
  protected void doExportStagedModel(PortletDataContext portletDataContext, FileEntry fileEntry)
      throws Exception {

    Element fileEntryElement = portletDataContext.getExportDataElement(fileEntry);

    String fileEntryPath = ExportImportPathUtil.getModelPath(fileEntry);

    if (!fileEntry.isDefaultRepository()) {
      Repository repository = RepositoryLocalServiceUtil.getRepository(fileEntry.getRepositoryId());

      StagedModelDataHandlerUtil.exportReferenceStagedModel(
          portletDataContext, fileEntry, repository, PortletDataContext.REFERENCE_TYPE_STRONG);

      portletDataContext.addClassedModel(fileEntryElement, fileEntryPath, fileEntry);

      long portletRepositoryClassNameId =
          PortalUtil.getClassNameId(PortletRepository.class.getName());

      if (repository.getClassNameId() != portletRepositoryClassNameId) {
        return;
      }
    }

    if (fileEntry.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      StagedModelDataHandlerUtil.exportReferenceStagedModel(
          portletDataContext,
          fileEntry,
          fileEntry.getFolder(),
          PortletDataContext.REFERENCE_TYPE_PARENT);
    }

    LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry;

    liferayFileEntry.setCachedFileVersion(fileEntry.getFileVersion());

    if (!portletDataContext.isPerformDirectBinaryImport()) {
      InputStream is = null;

      try {
        is = FileEntryUtil.getContentStream(fileEntry);
      } catch (Exception e) {
        if (_log.isWarnEnabled()) {
          _log.warn("Unable to retrieve content for file entry " + fileEntry.getFileEntryId(), e);
        }
      }

      if (is == null) {
        fileEntryElement.detach();

        return;
      }

      try {
        String binPath = ExportImportPathUtil.getModelPath(fileEntry, fileEntry.getVersion());

        portletDataContext.addZipEntry(binPath, is);

        fileEntryElement.addAttribute("bin-path", binPath);
      } finally {
        try {
          is.close();
        } catch (IOException ioe) {
          _log.error(ioe, ioe);
        }
      }
    }

    if (portletDataContext.getBooleanParameter(
        DLPortletDataHandler.NAMESPACE, "previews-and-thumbnails")) {

      DLProcessorRegistryUtil.exportGeneratedFiles(portletDataContext, fileEntry, fileEntryElement);
    }

    exportMetaData(portletDataContext, fileEntryElement, fileEntry);

    portletDataContext.addClassedModel(
        fileEntryElement, fileEntryPath, liferayFileEntry, DLFileEntry.class);
  }