Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2017 ICF Olson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.citytechinc.cq.component.dialog.util;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMember;
import javassist.CtMethod;
import javassist.NotFoundException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.codehaus.plexus.util.StringUtils;
import com.citytechinc.cq.component.annotations.DialogField;
import com.citytechinc.cq.component.annotations.DialogFieldOverride;
import com.citytechinc.cq.component.annotations.IgnoreDialogField;
import com.citytechinc.cq.component.annotations.Listener;
import com.citytechinc.cq.component.annotations.Property;
import com.citytechinc.cq.component.dialog.ComponentNameTransformer;
import com.citytechinc.cq.component.dialog.Dialog;
import com.citytechinc.cq.component.dialog.DialogFieldConfig;
import com.citytechinc.cq.component.dialog.exception.InvalidComponentClassException;
import com.citytechinc.cq.component.dialog.exception.InvalidComponentFieldException;
import com.citytechinc.cq.component.dialog.exception.OutputFailureException;
import com.citytechinc.cq.component.dialog.factory.DialogFactory;
import com.citytechinc.cq.component.dialog.widget.WidgetRegistry;
import com.citytechinc.cq.component.maven.util.ComponentMojoUtil;
public class DialogUtil {
private DialogUtil() {
};
/**
* Writes a dialog.xml file, the path of which being based on the component
* Class.
*
* @param dialog
* @param componentClass
* @return The written file
* @throws OutputFailureException
* @throws IOException
* @throws ParserConfigurationException
* @throws TransformerException
* @throws ClassNotFoundException
* @throws IllegalArgumentException
* @throws SecurityException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
public static File writeDialogToFile(ComponentNameTransformer transformer, Dialog dialog, CtClass componentClass,
File buildDirectory, String componentPathBase, String defaultComponentPathSuffix)
throws OutputFailureException, IOException, ParserConfigurationException, TransformerException,
ClassNotFoundException, IllegalArgumentException, SecurityException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
return ComponentMojoUtil.writeElementToFile(transformer, dialog, componentClass, buildDirectory,
componentPathBase, defaultComponentPathSuffix, dialog.getFileName());
}
/**
* Writes a provided dialog file to a provided archive output stream at a
* path determined by the class of the component.
*
* @param dialogFile
* @param componentClass
* @param archiveStream
* @param reservedNames A list of files which already exist within the Zip
* Archive. If a dialog.xml file already exists for a particular
* component, it is left untouched.
* @param componentPathBase
* @throws IOException
* @throws ClassNotFoundException
*/
public static void writeDialogToArchiveFile(ComponentNameTransformer transformer, File dialogFile,
CtClass componentClass, ZipArchiveOutputStream archiveStream, Set reservedNames,
String componentPathBase, String defaultComponentPathSuffix) throws IOException, ClassNotFoundException {
ComponentMojoUtil.writeElementToArchiveFile(transformer, dialogFile, componentClass, archiveStream,
reservedNames, componentPathBase, defaultComponentPathSuffix, "/" + dialogFile.getName());
}
/**
* Constructs a list of Dialog objects based on Classes annotated by
* Component annotations. Scans the provided list of classes constructing a
* Dialog object for each one annotated with the Component annotation. Any
* classes provided in the class list which are not thusly annotated are
* ignored.
*
* @param classList
* @param zipOutputStream
* @param reservedNames
* @param classLoader
* @param classPool
* @return A list of constructed Dialog objects
* @throws InvalidComponentClassException
* @throws InvalidComponentFieldException
* @throws OutputFailureException
* @throws IOException
* @throws ParserConfigurationException
* @throws TransformerException
* @throws ClassNotFoundException
* @throws CannotCompileException
* @throws NotFoundException
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
* @throws InstantiationException
*/
public static List