Package org.apache.sling.ide.log

Examples of org.apache.sling.ide.log.Logger


    class RefreshArchetypesRunnable implements IRunnableWithProgress {
        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            Logger logger = Activator.getDefault().getPluginLogger();

            monitor.beginTask("Discovering archetypes...", 5);
            ArchetypeManager manager = MavenPluginActivator.getDefault().getArchetypeManager();
            monitor.worked(1);

            // optionally allow the parent to install any archetypes
            getWizard().installArchetypes();

            Collection<ArchetypeCatalogFactory> archetypeCatalogs = manager.getArchetypeCatalogs();
            monitor.worked(2);
            ArrayList<Archetype> candidates = new ArrayList<Archetype>();
            for (ArchetypeCatalogFactory catalogFactory : archetypeCatalogs) {
                try {
                    ArchetypeCatalog catalog = catalogFactory.getArchetypeCatalog();
                    @SuppressWarnings("unchecked")
                    java.util.List<Archetype> arcs = catalog.getArchetypes();

                    logger.trace("Catalog factory {0} provided {1} archetypes", catalogFactory,
                            arcs != null ? arcs.size() : 0);

                    if (arcs != null) {
                        candidates.addAll(arcs);
                    }
                } catch (CoreException ce) {
                    throw new InvocationTargetException(ce);
                }
            }
            monitor.worked(1);
            boolean changed = false;

            logger.trace("Considering {0} archetypes from {1} archetype catalogs", candidates.size(),
                    archetypeCatalogs.size());

            for (Archetype candidate : candidates) {
                if (getWizard().acceptsArchetype(candidate)) {
                    String key = keyFor(candidate);
                    Archetype old = archetypesMap.put(key, candidate);

                    logger.trace("Registered archetype {0}", candidate);

                    if (old == null || !old.equals(candidate)) {
                        changed = true;
                    }

                    logger.trace("Old archetype was {0}, changed = {1}", old, changed);
                }
            }

            monitor.worked(1);
            if (changed || archetypesMap.isEmpty()) {
                logger.trace("Triggering refresh since changed is true");
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        Set<String> keys = archetypesMap.keySet();
                        knownArchetypes.removeAll();
                        for (String aKey : keys) {
View Full Code Here


    @Override
    public void configure(ProjectConfigurationRequest configRequest, IProgressMonitor monitor) throws CoreException {
        // at this point the JDT project is already created by the tycho plugin
        // we just need to setup the appropriate facets
        Logger logger = Activator.getDefault().getPluginLogger();
        IProject project = configRequest.getProject();
        logger.trace("BundleProjectActivator called for POM {0} and project {1}", configRequest.getPom().getFullPath(),
                project.getName());

        // check for maven-sling-plugin as well (to make sure this is a Sling project)
        for (Plugin plugin : configRequest.getMavenProject().getBuildPlugins()) {
            if (plugin.getArtifactId().equals(MAVEN_SLING_PLUGIN_ARTIFACT_ID)
                    && plugin.getGroupId().equals(MAVEN_SLING_PLUGIN_GROUP_ID)) {
                logger.trace(
                        "Found maven-sling-plugin in build plugins for project {0}, therefore adding sling bundle facets!",
                        project.getName());
                ConfigurationHelper.convertToBundleProject(project);
                return;
            }
        }
        logger.trace("Couldn't find maven-sling-plugin in build plugins for project {0}", project.getName());
    }
View Full Code Here

     */
    public List<IFile> findMissingScrDescriptors(IFile manifest) throws CoreException {

        IProject project = manifest.getProject();

        Logger pluginLogger = Activator.getDefault().getPluginLogger();

        IJavaProject javaProject = ProjectHelper.asJavaProject(project);

        IFolder outputFolder = (IFolder) project.getWorkspace().getRoot().findMember(javaProject.getOutputLocation());

        if (!outputFolder.getFullPath().isPrefixOf(manifest.getFullPath())) {
            pluginLogger.trace("Ignoring manifest found at {0} since it is not under the output directory at {1}",
                    manifest.getFullPath(), outputFolder.getFullPath());
            return Collections.emptyList();
        }

        List<IFile> missingDescriptors = new ArrayList<IFile>();

        InputStream contents = manifest.getContents();
        try {
            Manifest mf = new Manifest(contents);
            String serviceComponentHeader = mf.getMainAttributes().getValue("Service-Component");
            if (serviceComponentHeader != null) {
                String[] entries = serviceComponentHeader.split(",");
                for (String entry : entries) {
                    entry = entry.trim();

                    if (entry.contains("*")) {
                        pluginLogger.trace("Ignoring wildcard Service-Component entry {0}", entry);
                        continue;
                    }

                    IFile descriptor = outputFolder.getFile(entry);

                    if (descriptor.exists()) {
                        pluginLogger.trace("Found matching resource for Service-Component entry {0}", entry);
                        continue;
                    }

                    missingDescriptors.add(descriptor);

                    pluginLogger.trace("Raising error for missing DS descriptor entry {0}", entry);
                }
            }
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to access "
                    + manifest.getFullPath(), e));
View Full Code Here

            return res;
        }

        IFile m = (IFile) resource;

        Logger pluginLogger = Activator.getDefault() .getPluginLogger();

        try {

            for (IFile descriptor : scValidator.findMissingScrDescriptors(m)) {
                ValidatorMessage dsMessage = ValidatorMessage.create(
                        "No DS descriptor found at path " + descriptor.getProjectRelativePath(), m);
                dsMessage.setAttribute(IMarker.LOCATION, m.getName());
                dsMessage.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);

                res.add(dsMessage);

            }

        } catch (CoreException e) {
            pluginLogger.warn("Failed validating project " + resource.getFullPath(), e);
        }
       
        return res;
    }
View Full Code Here

            } else {
                final FilterResult result = filter.filter(ProjectUtil.getSyncDirectoryFile(project), relativeFilePath);
                return result==FilterResult.ALLOW;
            }
        } catch (CoreException e) {
            Logger logger = Activator.getDefault().getPluginLogger();
            logger.error("Could not verify child node allowance: "+this, e);
            return false;
        }
    }
View Full Code Here

                    IFile contentXml = folder.getFile(".content.xml");
                    if (contentXml.exists()) {
                        try {
                            contentXml.delete(true, new NullProgressMonitor());
                        } catch (CoreException e) {
                            Logger logger = Activator.getDefault().getPluginLogger();
                            logger.error("Could not delete "+contentXml.getFullPath()+", e="+e, e);
                            MessageDialog.openError(null, "Could not delete file",
                                    "Could not delete "+contentXml.getFullPath()+", "+e);
                        }
                    }
                } else {
                    properties.doSetPropertyValue("jcr:primaryType", newPrimaryType);
                }
            }
            return;
        }
       
        if (newSk==SerializationKind.FOLDER) {
            // switching to a folder
            if (currentSk==SerializationKind.FILE) {
                MessageDialog.openWarning(null, "Unable to change primary type",
                        "Changing from a file to a folder type is currently not supported");
                return;
            }
            if (newPrimaryType.equals("nt:folder")) {
                // verify
                if (!verifyNodeTypeChange(ntManager, newPrimaryType)) {
                    return;
                }
            }
            try {
                // create the new directory structure pointing to 'this'
                IFolder newFolder = getParent().prepareCreateFolderChild(getJcrPathName());
               
                if (!newPrimaryType.equals("nt:folder")) {
                    // move any children from the existing 'this' to a new vault file
                    createVaultFileWithContent(newFolder, ".content.xml", newPrimaryType, domElement);
                }
               
                // remove myself
                if (domElement!=null) {
                    domElement.remove();
                    if (underlying!=null) {
                        underlying.save();
                    }
                }

                // add a pointer in the corresponding .content.xml to point to this (folder) child
                getParent().createDomChild(getJcrPathName(),
                        null);
                if (newPrimaryType.equals("nt:folder")) {
                    // delete the .content.xml
                    if (properties!=null && properties.getUnderlying()!=null) {
                        IFile contentXml = properties.getUnderlying().file;
                        if (contentXml!=null && contentXml.exists()) {
                            contentXml.delete(true, new NullProgressMonitor());
                        }
                    }
                }
                ServerUtil.triggerIncrementalBuild(newFolder, null);
                return;
            } catch (CoreException e) {
                MessageDialog.openWarning(null, "Unable to change primaryType", "Exception occurred: "+e);
                Logger logger = Activator.getDefault().getPluginLogger();
                logger.error("Exception occurred", e);
                return;
            }
        } else if (newSk==SerializationKind.FILE) {
            MessageDialog.openWarning(null, "Unable to change primary type",
                    "Changing to/from a file is currently not supported");
View Full Code Here

                    MessageDialog.openWarning(null, "Unable to change primaryType", "Unable to change jcr:primaryType to nt:folder"
                            + " since nt:folder cannot have child of type "+node.getPrimaryType());
                    return false;
                }
            } catch (RepositoryException e) {
                Logger logger = Activator.getDefault().getPluginLogger();
                logger.error("Could not determine allowed primary child node types", e);
            }
        }
        return true;
    }
View Full Code Here

    private ResourceProxy findSerializationDataFromCoveringParent(IResource changedResource, IFolder syncDirectory,
            String resourceLocation, IPath serializationFilePath) throws CoreException, IOException {

        // TODO - this too should be abstracted in the service layer, rather than in the Eclipse-specific code

        Logger logger = Activator.getDefault().getPluginLogger();
        logger.trace("Found plain nt:folder candidate at {0}, trying to find a covering resource for it",
                changedResource.getProjectRelativePath());
        // don't use isRoot() to prevent infinite loop when the final path is '//'
        while (serializationFilePath.segmentCount() != 0) {
            serializationFilePath = serializationFilePath.removeLastSegments(1);
            IFolder folderWithPossibleSerializationFile = (IFolder) syncDirectory.findMember(serializationFilePath);
            if (folderWithPossibleSerializationFile == null) {
                logger.trace("No folder found at {0}, moving up to the next level", serializationFilePath);
                continue;
            }

            // it's safe to use a specific SerializationKind since this scenario is only valid for METADATA_PARTIAL
            // coverage
            String possibleSerializationFilePath = serializationManager.getSerializationFilePath(
                    ((IFolder) folderWithPossibleSerializationFile).getLocation().toOSString(),
                    SerializationKind.METADATA_PARTIAL);

            logger.trace("Looking for serialization data in {0}", possibleSerializationFilePath);

            if (serializationManager.isSerializationFile(possibleSerializationFilePath)) {

                IPath parentSerializationFilePath = Path.fromOSString(possibleSerializationFilePath).makeRelativeTo(
                        syncDirectory.getLocation());
                IFile possibleSerializationFile = syncDirectory.getFile(parentSerializationFilePath);
                if (!possibleSerializationFile.exists()) {
                    logger.trace("Potential serialization data file {0} does not exist, moving up to the next level",
                            possibleSerializationFile.getFullPath());
                    continue;
                }

                InputStream contents = possibleSerializationFile.getContents();
                ResourceProxy serializationData;
                try {
                    serializationData = serializationManager.readSerializationData(
                            parentSerializationFilePath.toPortableString(), contents);
                } finally {
                    IOUtils.closeQuietly(contents);
                }

                String repositoryPath = serializationManager.getRepositoryPath(resourceLocation);
                String potentialPath = serializationData.getPath();
                boolean covered = serializationData.covers(repositoryPath);

                logger.trace(
                        "Found possible serialization data at {0}. Resource :{1} ; our resource: {2}. Covered: {3}",
                        parentSerializationFilePath, potentialPath, repositoryPath, covered);
                // note what we don't need to normalize the children here since this resource's data is covered by
                // another resource
                if (covered) {
View Full Code Here

    @Override
    protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
            throws CoreException {

        Logger logger = Activator.getDefault().getPluginLogger();
       
        if (commandFactory == null) {
            commandFactory = new ResourceChangeCommandFactory(Activator.getDefault().getSerializationManager());
        }

        logger.trace(traceOperation(kind, deltaKind, module));

        if (getServer().getServerState() == IServer.STATE_STOPPED) {
            logger.trace("Ignoring request to publish module when the server is stopped");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }

        if ((kind == IServer.PUBLISH_AUTO || kind == IServer.PUBLISH_INCREMENTAL)
                && deltaKind == ServerBehaviourDelegate.NO_CHANGE) {
            logger.trace("Ignoring request to publish the module when no resources have changed; most likely another module has changed");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }
       
        if (kind == IServer.PUBLISH_FULL && deltaKind == ServerBehaviourDelegate.REMOVED) {
            logger.trace("Ignoring request to unpublish all of the module resources");
            setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
            return;
        }

        if (ProjectHelper.isBundleProject(module[0].getProject())) {
View Full Code Here

  }

    private void publishContentModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
            throws CoreException, SerializationException, IOException {

        Logger logger = Activator.getDefault().getPluginLogger();

    Repository repository = ServerUtil.getConnectedRepository(getServer(), monitor);
       
        // TODO it would be more efficient to have a module -> filter mapping
        // it would be simpler to implement this in SlingContentModuleAdapter, but
        // the behaviour for resources being filtered out is deletion, and that
        // would be an incorrect ( or at least suprising ) behaviour at development time

        List<IModuleResource> addedOrUpdatedResources = new ArrayList<IModuleResource>();
        IModuleResource[] allResources = getResources(module);
        Set<IPath> handledPaths = new HashSet<IPath>();

        switch (deltaKind) {
            case ServerBehaviourDelegate.CHANGED:
                for (IModuleResourceDelta resourceDelta : getPublishedResourceDelta(module)) {

                    StringBuilder deltaTrace = new StringBuilder();
                    deltaTrace.append("- processing delta kind ");

                    switch (resourceDelta.getKind()) {
                        case IModuleResourceDelta.ADDED:
                            deltaTrace.append("ADDED ");
                            break;
                        case IModuleResourceDelta.CHANGED:
                            deltaTrace.append("CHANGED ");
                            break;
                        case IModuleResourceDelta.NO_CHANGE:
                            deltaTrace.append("NO_CHANGE ");
                            break;
                        case IModuleResourceDelta.REMOVED:
                            deltaTrace.append("REMOVED ");
                            break;
                        default:
                            deltaTrace.append("UNKNOWN - ").append(resourceDelta.getKind());
                    }

                    deltaTrace.append("for resource ").append(resourceDelta.getModuleResource());

                    logger.trace(deltaTrace.toString());

                    switch (resourceDelta.getKind()) {
                        case IModuleResourceDelta.ADDED:
                        case IModuleResourceDelta.CHANGED:
                        case IModuleResourceDelta.NO_CHANGE: // TODO is this needed?
View Full Code Here

TOP

Related Classes of org.apache.sling.ide.log.Logger

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.