Search in sources :

Example 1 with AbstractVirtualFileFilterWithAttributes

use of org.jboss.vfs.util.AbstractVirtualFileFilterWithAttributes in project keycloak by keycloak.

the class KeycloakProviderDependencyProcessor method getKeycloakProviderDeploymentInfo.

public static KeycloakDeploymentInfo getKeycloakProviderDeploymentInfo(DeploymentUnit du) {
    KeycloakDeploymentInfo info = KeycloakDeploymentInfo.create();
    info.name(du.getName());
    final ResourceRoot resourceRoot = du.getAttachment(Attachments.DEPLOYMENT_ROOT);
    if (resourceRoot != null) {
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        if (deploymentRoot != null && deploymentRoot.exists()) {
            if (deploymentRoot.getChild("META-INF/keycloak-themes.json").exists() && deploymentRoot.getChild("theme").exists()) {
                info.themes();
            }
            if (deploymentRoot.getChild("theme-resources").exists()) {
                info.themeResources();
            }
            VirtualFile services = deploymentRoot.getChild("META-INF/services");
            if (services.exists()) {
                try {
                    List<VirtualFile> archives = services.getChildren(new AbstractVirtualFileFilterWithAttributes() {

                        @Override
                        public boolean accepts(VirtualFile file) {
                            return file.getName().startsWith("org.keycloak");
                        }
                    });
                    if (!archives.isEmpty()) {
                        info.services();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return info;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) AbstractVirtualFileFilterWithAttributes(org.jboss.vfs.util.AbstractVirtualFileFilterWithAttributes) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)1 VirtualFile (org.jboss.vfs.VirtualFile)1 AbstractVirtualFileFilterWithAttributes (org.jboss.vfs.util.AbstractVirtualFileFilterWithAttributes)1 KeycloakDeploymentInfo (org.keycloak.provider.KeycloakDeploymentInfo)1