Package org.apache.sling.ide.serialization

Examples of org.apache.sling.ide.serialization.SerializationData


    }

    @Test
    public void emptySerializedData() throws SerializationException, SAXException {

        SerializationData serializationData = sm.newBuilder(null, null).buildSerializationData(null,
                newResourceWithProperties(new HashMap<String, Object>()));

        assertThat(serializationData, is(nullValue()));
    }
View Full Code Here


    }

    @Test
    public void nullSerializedData() throws SerializationException, SAXException {

        SerializationData serializationData = sm.newBuilder(null, null).buildSerializationData(null, null);

        assertThat(serializationData, is(nullValue()));
    }
View Full Code Here

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("jcr:createdBy", "admin");
        data.put("jcr:lastModifiedBy", "author");

        SerializationData serializationData = sm.newBuilder(null, null).buildSerializationData(null, newResourceWithProperties(data));

        String methodName = "stringSerializedData";

        assertXmlOutputIsEqualTo(serializationData.getContents(), methodName);
    }
View Full Code Here

    public void serializedDataIsEscaped() throws SerializationException, SAXException, IOException {

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("jcr:description", "<p class=\"active\">Welcome</p>");

        SerializationData serializationData = sm.newBuilder(null, null).buildSerializationData(null, newResourceWithProperties(data));

        String methodName = "serializedDataIsEscaped";

        assertXmlOutputIsEqualTo(serializationData.getContents(), methodName);
    }
View Full Code Here

            endElement(handler, TAG_RESOURCE);
            handler.endDocument();

            // TODO - also add the serialization type
            return new SerializationData(resource.getPath(), CONTENT_XML, result.toByteArray(), null);
        } catch (TransformerConfigurationException e) {
            // TODO proper exception handling
            throw new RuntimeException(e);
        } catch (TransformerFactoryConfigurationError e) {
            // TODO proper exception handling
View Full Code Here

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            s.writeContent(out);
           
            byte[] result = out.toByteArray();

            return new SerializationData(fileOrFolderPathHint, nameHint, result, serializationKind);

        } catch (RepositoryException e) {
            throw new SerializationException(e);
        } catch (IOException e) {
            throw new SerializationException(e);
View Full Code Here

        logger.trace("crawlChildrenAndImport({0},  {1}, {2}, {3}", repository, path, project, projectRelativePath);

        ResourceProxy resource = executeCommand(repository.newListChildrenNodeCommand(path));
       
        SerializationData serializationData = builder.buildSerializationData(contentSyncRoot, resource);
        logger.trace("For resource at path {0} got serialization data {1}", resource.getPath(), serializationData);

        final List<ResourceProxy> resourceChildren = new LinkedList<ResourceProxy>(resource.getChildren());
    if (serializationData != null) {

            IPath serializationFolderPath = contentSyncRootDir.getProjectRelativePath().append(
                    serializationData.getFolderPath());
 
          switch (serializationData.getSerializationKind()) {
              case FILE: {
                  byte[] contents = executeCommand(repository.newGetNodeCommand(path));
                    createFile(project, getPathForPlainFileNode(resource, serializationFolderPath), contents);
 
                  if (serializationData.hasContents()) {
                        createFolder(project, serializationFolderPath);
                        createFile(project, serializationFolderPath.append(serializationData.getFileName()),
                              serializationData.getContents());
                     
                        // special processing for nt:resource nodes
                        for (Iterator<ResourceProxy> it = resourceChildren.iterator(); it.hasNext();) {
                        ResourceProxy child = it.next();
                          if (Repository.NT_RESOURCE.equals(child.getProperties().get(Repository.JCR_PRIMARY_TYPE))) {

                                ResourceProxy reloadedChildResource = executeCommand(repository
                                        .newListChildrenNodeCommand(child.getPath()));

                                logger.trace(
                                        "Skipping direct handling of {0} node at {1} ; will additionally handle {2} direct children",
                                        Repository.NT_RESOURCE, child.getPath(), reloadedChildResource.getChildren()
                                                .size());

                                if (reloadedChildResource.getChildren().size() != 0) {

                                    String pathName = Text.getName(reloadedChildResource.getPath());
                                    pathName = serializationManager.getOsPath(pathName);
                                    createFolder(project, serializationFolderPath.append(pathName));

                                    // 2. recursively handle all resources
                                    for (ResourceProxy grandChild : reloadedChildResource.getChildren()) {
                                        crawlChildrenAndImport(grandChild.getPath());
                                    }
                                }
                             
                            it.remove();
                            break;
                          }
            }
                  }
                  break;
              }
              case FOLDER:
              case METADATA_PARTIAL: {

                    IFolder folder = createFolder(project, serializationFolderPath);

                    parseIgnoreFiles(folder, path);

                  if (serializationData.hasContents()) {
                        createFile(project, serializationFolderPath.append(serializationData.getFileName()),
                              serializationData.getContents());
                  }
                  break;
              }
 
              case METADATA_FULL: {
                  if (serializationData.hasContents()) {
                        createFile(project, serializationFolderPath.append(serializationData.getFileName()),
                                serializationData.getContents());
                  }
                  break;
              }
          }
 
            logger.trace("Resource at {0} has children: {1}", resource.getPath(), resourceChildren);
 
          if (serializationData.getSerializationKind() == SerializationKind.METADATA_FULL) {
              return;
          }
        } else {
            logger.trace("No serialization data found for {0}", resource.getPath());
        }
View Full Code Here

TOP

Related Classes of org.apache.sling.ide.serialization.SerializationData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.