mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 11:05:56 +01:00
remove old ui
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* This class represents a web resource (Stylesheet or JavaScript file).
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.12
|
||||
*/
|
||||
public interface Resource
|
||||
{
|
||||
|
||||
/**
|
||||
* Copies the content of the resource to the given {@link OutputStream}.
|
||||
*
|
||||
*
|
||||
* @param output stream to copy the content of the resource
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void copyTo(OutputStream output) throws IOException;
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the name of the resource.
|
||||
*
|
||||
*
|
||||
* @return name of the resource
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the type of the resource.
|
||||
*
|
||||
*
|
||||
* @return type of resource
|
||||
*/
|
||||
public ResourceType getType();
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.ExtensionPoint;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@ExtensionPoint
|
||||
public interface ResourceHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public URL getResource();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResourceType getType();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ResourceHandlerComparator
|
||||
implements Comparator<ResourceHandler>, Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -1760229246326556762L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param otherHandler
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int compare(ResourceHandler handler, ResourceHandler otherHandler)
|
||||
{
|
||||
return Util.compare(handler.getName(), otherHandler.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class collects and manages {@link Resource}
|
||||
* which are used by the web interface.
|
||||
*
|
||||
* TODO remove before 2.0.0
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.12
|
||||
* @deprecated unnecessary for new ui
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ResourceManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the resource with given name and type or
|
||||
* null if no such resource exists.
|
||||
*
|
||||
*
|
||||
* @param type type of the resource
|
||||
* @param name name of the resource
|
||||
*
|
||||
* @return the resource with given name and type
|
||||
*/
|
||||
public Resource getResource(ResourceType type, String name);
|
||||
|
||||
/**
|
||||
* Returns the resources of the given type.
|
||||
*
|
||||
*
|
||||
* @param type type of the resources to return
|
||||
*
|
||||
* @return resources of the given type
|
||||
*/
|
||||
public List<Resource> getResources(ResourceType type);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Compare {@link Resource} objects by its name.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.16
|
||||
*/
|
||||
public class ResourceNameComparator
|
||||
implements Comparator<Resource>, Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final ResourceNameComparator INSTANCE =
|
||||
new ResourceNameComparator();
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 3474356901608301437L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resource
|
||||
* @param otherResource
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int compare(Resource resource, Resource otherResource)
|
||||
{
|
||||
return Util.compare(resource.getName(), otherResource.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
/**
|
||||
* This class represents the type of {@link Resource}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public enum ResourceType
|
||||
{
|
||||
|
||||
/**
|
||||
* Resource type for javascript resources
|
||||
*/
|
||||
SCRIPT("text/javascript", "js"),
|
||||
|
||||
/**
|
||||
* Resource type for stylesheet (css) resources
|
||||
*/
|
||||
STYLESHEET("text/css", "css");
|
||||
|
||||
/**
|
||||
* Constructs a new resource type
|
||||
*
|
||||
*
|
||||
* @param contentType content type of the resource type
|
||||
* @param extension file extension of the resource type
|
||||
*/
|
||||
private ResourceType(String contentType, String extension)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the content type of the resource type.
|
||||
*
|
||||
*
|
||||
* @return content type of the resource type
|
||||
*
|
||||
* @since 1.12
|
||||
*/
|
||||
public String getContentType()
|
||||
{
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file extension of the resource type.
|
||||
*
|
||||
*
|
||||
* @return file extension of the resource type
|
||||
*
|
||||
* @since 1.12
|
||||
*/
|
||||
public String getExtension()
|
||||
{
|
||||
return extension;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final String contentType;
|
||||
|
||||
/** Field description */
|
||||
private final String extension;
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ResourceHandlerComparatorTest
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCompare()
|
||||
{
|
||||
ResourceHandler[] handlers = new ResourceHandler[4];
|
||||
|
||||
handlers[0] = new DummyResourceHandler("xyz");
|
||||
handlers[1] = new DummyResourceHandler("abc");
|
||||
handlers[2] = new DummyResourceHandler(null);
|
||||
handlers[3] = new DummyResourceHandler("mno");
|
||||
Arrays.sort(handlers, new ResourceHandlerComparator());
|
||||
assertEquals("abc", handlers[0].getName());
|
||||
assertEquals("mno", handlers[1].getName());
|
||||
assertEquals("xyz", handlers[2].getName());
|
||||
assertEquals(null, handlers[3].getName());
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 2011-01-18
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
private static class DummyResourceHandler implements ResourceHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public DummyResourceHandler(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//~--- get methods --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public URL getResource()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResourceType getType()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,6 @@
|
||||
"@scm-manager/ui-extensions": "^0.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.3"
|
||||
"@scm-manager/ui-bundler": "^0.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,5 @@
|
||||
<conditions>
|
||||
<min-version>${project.parent.version}</min-version>
|
||||
</conditions>
|
||||
|
||||
<resources>
|
||||
<script>/sonia/scm/git.config.js</script>
|
||||
</resources>
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
Ext.ns("Sonia.git");
|
||||
|
||||
Sonia.git.ConfigPanel = Ext.extend(Sonia.config.SimpleConfigForm, {
|
||||
|
||||
// labels
|
||||
titleText: 'Git Settings',
|
||||
repositoryDirectoryText: 'Repository directory',
|
||||
gcExpressionText: 'Git GC Cron Expression',
|
||||
disabledText: 'Disabled',
|
||||
|
||||
// helpTexts
|
||||
repositoryDirectoryHelpText: 'Location of the Git repositories.',
|
||||
// TODO i18n
|
||||
gcExpressionHelpText: '<p>Use Quartz Cron Expressions (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK) to run git gc in intervals.</p>\n\
|
||||
<table>\n\
|
||||
<tr><th><b>SECOND</b></th><td>Seconds within the minute (0–59)</td></tr>\n\
|
||||
<tr><th><b>MINUTE</b></th><td>Minutes within the hour (0–59)</td></tr>\n\
|
||||
<tr><th><b>HOUR</b></th><td>The hour of the day (0–23)</td></tr>\n\
|
||||
<tr><th><b>DAYOFMONTH</b></th><td>The day of the month (1–31)</td></tr>\n\
|
||||
<tr><th><b>MONTH</b></th><td>The month (1–12)</td></tr>\n\
|
||||
<tr><th><b>DAYOFWEEK</b></th><td>The day of the week (MON, TUE, WED, THU, FRI, SAT, SUN)</td></tr>\n\
|
||||
</table>\n\
|
||||
<p>E.g.: To run the task on every sunday at two o\'clock in the morning: 0 0 2 ? * SUN</p>\n\
|
||||
<p>For more informations please have a look at <a href="http://www.quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/crontrigger.html">Quartz CronTrigger</a></p>',
|
||||
disabledHelpText: 'Enable or disable the Git plugin.\n\
|
||||
Note you have to reload the page, after changing this value.',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var config = {
|
||||
title : this.titleText,
|
||||
configUrl: restUrl + 'config/repositories/git',
|
||||
items : [{
|
||||
xtype: 'textfield',
|
||||
name: 'repositoryDirectory',
|
||||
fieldLabel: this.repositoryDirectoryText,
|
||||
helpText: this.repositoryDirectoryHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'textfield',
|
||||
name: 'gc-expression',
|
||||
fieldLabel: this.gcExpressionText,
|
||||
helpText: this.gcExpressionHelpText,
|
||||
allowBlank : true
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'disabled',
|
||||
fieldLabel: this.disabledText,
|
||||
inputValue: 'true',
|
||||
helpText: this.disabledHelpText
|
||||
}]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.git.ConfigPanel.superclass.initComponent.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Ext.reg("gitConfigPanel", Sonia.git.ConfigPanel);
|
||||
|
||||
// add default branch chooser to settings panel
|
||||
Sonia.git.GitSettingsFormPanel = Ext.extend(Sonia.repository.SettingsFormPanel, {
|
||||
|
||||
defaultBranchText: 'Default Branch',
|
||||
defaultBranchHelpText: 'The default branch which is show first on source or commit view.',
|
||||
|
||||
modifyDefaultConfig: function(config){
|
||||
if (this.item) {
|
||||
var position = -1;
|
||||
for ( var i=0; i<config.items.length; i++ ) {
|
||||
var field = config.items[i];
|
||||
if (field.name === 'public') {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var defaultBranchComboxBox = {
|
||||
fieldLabel: this.defaultBranchText,
|
||||
name: 'defaultBranch',
|
||||
repositoryId: this.item.id,
|
||||
value: this.getDefaultBranch(this.item),
|
||||
useNameAsValue: true,
|
||||
xtype: 'repositoryBranchComboBox',
|
||||
helpText: this.defaultBranchHelpText
|
||||
};
|
||||
|
||||
if (position >= 0) {
|
||||
config.items.splice(position, 0, defaultBranchComboxBox);
|
||||
} else {
|
||||
config.items.push(defaultBranchComboxBox);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getDefaultBranch: function(item){
|
||||
if (item.properties) {
|
||||
for ( var i=0; i<item.properties.length; i++ ) {
|
||||
var prop = item.properties[i];
|
||||
if (prop.key === 'git.default-branch') {
|
||||
return prop.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
setDefaultBranch: function(item, defaultBranch){
|
||||
if (!item.properties) {
|
||||
item.properties = [{
|
||||
key: 'git.default-branch',
|
||||
value: defaultBranch
|
||||
}];
|
||||
} else {
|
||||
|
||||
var found = false;
|
||||
for ( var i=0; i<item.properties.length; i++ ) {
|
||||
var prop = item.properties[i];
|
||||
if (prop.key === 'git.default-branch') {
|
||||
prop.value = defaultBranch;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
item.properties.push({
|
||||
key: 'git.default-branch',
|
||||
value: defaultBranch
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
prepareUpdate: function(item) {
|
||||
if (item.defaultBranch) {
|
||||
var defaultBranch = item.defaultBranch;
|
||||
delete item.defaultBranch;
|
||||
this.setDefaultBranch(item, defaultBranch);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Ext.reg("gitSettingsForm", Sonia.git.GitSettingsFormPanel);
|
||||
|
||||
|
||||
// i18n
|
||||
|
||||
if ( i18n && i18n.country === 'de' ){
|
||||
|
||||
Ext.override(Sonia.git.ConfigPanel, {
|
||||
|
||||
// labels
|
||||
titleText: 'Git Einstellungen',
|
||||
repositoryDirectoryText: 'Repository-Verzeichnis',
|
||||
disabledText: 'Deaktivieren',
|
||||
|
||||
// helpTexts
|
||||
repositoryDirectoryHelpText: 'Verzeichnis der Git-Repositories.',
|
||||
disabledHelpText: 'Aktivieren oder deaktivieren des Git Plugins.\n\
|
||||
Die Seite muss neu geladen werden wenn dieser Wert geändert wird.'
|
||||
|
||||
});
|
||||
|
||||
Ext.override(Sonia.git.GitSettingsFormPanel, {
|
||||
|
||||
// labels
|
||||
defaultBranchText: 'Standard Branch',
|
||||
|
||||
// helpTexts
|
||||
defaultBranchHelpText: 'Der Standard Branch wird für die Source und Commit Ansicht verwendet, \n\
|
||||
wenn kein anderer Branch eingestellt wurde.'
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// register information panel
|
||||
|
||||
initCallbacks.push(function(main){
|
||||
main.registerInfoPanel('git', {
|
||||
checkoutTemplate: 'git clone <a href="{0}" target="_blank">{0}</a>',
|
||||
xtype: 'repositoryExtendedInfoPanel'
|
||||
});
|
||||
main.registerSettingsForm('git', {
|
||||
xtype: 'gitSettingsForm'
|
||||
});
|
||||
});
|
||||
|
||||
// register panel
|
||||
|
||||
registerConfigPanel({
|
||||
xtype : 'gitConfigPanel'
|
||||
});
|
||||
|
||||
// register type icon
|
||||
|
||||
Sonia.repository.typeIcons['git'] = 'resources/images/icons/16x16/git.png';
|
||||
@@ -606,9 +606,9 @@
|
||||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.3":
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.3.tgz#06f99d8b17e9aa1bb6e69c2732160e1f46724c3c"
|
||||
"@scm-manager/ui-bundler@^0.0.4":
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.4.tgz#0191a026d25b826692bccbc2b76d550388dd5528"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0-rc.2"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0-rc.2"
|
||||
@@ -623,6 +623,7 @@
|
||||
budo "^11.3.2"
|
||||
colors "^1.3.1"
|
||||
commander "^2.17.1"
|
||||
fast-xml-parser "^3.12.0"
|
||||
jest "^23.5.0"
|
||||
jest-junit "^5.1.0"
|
||||
node-mkdirs "^0.0.1"
|
||||
@@ -2134,6 +2135,12 @@ fast-levenshtein@~2.0.4:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
|
||||
fast-xml-parser@^3.12.0:
|
||||
version "3.12.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-3.12.0.tgz#84ddcd98ca005f94e99af3ac387adc32ffb239d8"
|
||||
dependencies:
|
||||
nimnjs "^1.3.2"
|
||||
|
||||
fb-watchman@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
|
||||
@@ -3764,6 +3771,21 @@ nice-try@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
|
||||
|
||||
nimn-date-parser@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn-date-parser/-/nimn-date-parser-1.0.0.tgz#4ce55d1fd5ea206bbe82b76276f7b7c582139351"
|
||||
|
||||
nimn_schema_builder@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn_schema_builder/-/nimn_schema_builder-1.1.0.tgz#b370ccf5b647d66e50b2dcfb20d0aa12468cd247"
|
||||
|
||||
nimnjs@^1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/nimnjs/-/nimnjs-1.3.2.tgz#a6a877968d87fad836375a4f616525e55079a5ba"
|
||||
dependencies:
|
||||
nimn-date-parser "^1.0.0"
|
||||
nimn_schema_builder "^1.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"@scm-manager/ui-extensions": "^0.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.3"
|
||||
"@scm-manager/ui-bundler": "^0.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
http://bitbucket.org/sdorra/scm-manager
|
||||
|
||||
jo
|
||||
|
||||
-->
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
-->
|
||||
|
||||
<plugin>
|
||||
|
||||
|
||||
<scm-version>2</scm-version>
|
||||
|
||||
<information>
|
||||
@@ -61,9 +61,4 @@
|
||||
<min-version>${project.parent.version}</min-version>
|
||||
</conditions>
|
||||
|
||||
<resources>
|
||||
<script>/sonia/scm/hg.config.js</script>
|
||||
<script>/sonia/scm/hg.config-wizard.js</script>
|
||||
</resources>
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -1,449 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
Ext.ns("Sonia.hg");
|
||||
|
||||
Sonia.hg.ConfigWizard = Ext.extend(Ext.Window,{
|
||||
|
||||
hgConfig: null,
|
||||
title: 'Mercurial Configuration Wizard',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
this.addEvents('finish');
|
||||
|
||||
var config = {
|
||||
title: this.title,
|
||||
layout: 'fit',
|
||||
width: 420,
|
||||
height: 140,
|
||||
closable: true,
|
||||
resizable: true,
|
||||
plain: true,
|
||||
border: false,
|
||||
modal: true,
|
||||
bodyCssClass: 'x-panel-mc',
|
||||
items: [{
|
||||
id: 'hgConfigWizardPanel',
|
||||
xtype: 'hgConfigWizardPanel',
|
||||
hgConfig: this.hgConfig,
|
||||
listeners: {
|
||||
finish: {
|
||||
fn: this.onFinish,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.hg.ConfigWizard.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
onFinish: function(config){
|
||||
this.fireEvent('finish', config);
|
||||
this.close();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Sonia.hg.InstallationJsonReader = function(){
|
||||
this.RecordType = Ext.data.Record.create([{
|
||||
name: "path",
|
||||
mapping: "path",
|
||||
type: "string"
|
||||
}]);
|
||||
};
|
||||
|
||||
Ext.extend(Sonia.hg.InstallationJsonReader, Ext.data.JsonReader, {
|
||||
|
||||
readRecords: function(o){
|
||||
this.jsonData = o;
|
||||
|
||||
if (debug){
|
||||
console.debug('read installation data from json');
|
||||
console.debug(o);
|
||||
}
|
||||
|
||||
var records = [];
|
||||
var paths = o.path;
|
||||
for ( var i=0; i<paths.length; i++ ){
|
||||
records.push(new this.RecordType({
|
||||
'path': paths[i]
|
||||
}));
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
records: records,
|
||||
totalRecords: records.length
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Sonia.hg.ConfigWizardPanel = Ext.extend(Ext.Panel,{
|
||||
|
||||
hgConfig: null,
|
||||
packageTemplate: '<tpl for="."><div class="x-combo-list-item">\
|
||||
{id} (hg: {hg-version}, py: {python-version}, size: {size:fileSize})\
|
||||
</div></tpl>',
|
||||
|
||||
// text
|
||||
backText: 'Back',
|
||||
nextText: 'Next',
|
||||
finishText: 'Finish',
|
||||
configureLocalText: 'Configure local installation',
|
||||
configureRemoteText: 'Download and install',
|
||||
loadingText: 'Loading ...',
|
||||
hgInstallationText: 'Mercurial Installation',
|
||||
pythonInstallationText: 'Python Installation',
|
||||
hgPackageText: 'Mercurial Package',
|
||||
errorTitleText: 'Error',
|
||||
packageInstallationFailedText: 'Package installation failed',
|
||||
installPackageText: 'install mercurial package {0}',
|
||||
|
||||
initComponent: function(){
|
||||
this.addEvents('finish');
|
||||
|
||||
var packageStore = new Ext.data.JsonStore({
|
||||
storeId: 'pkgStore',
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'config/repositories/hg/packages',
|
||||
disableCaching: false
|
||||
}),
|
||||
fields: [ 'id', 'hg-version', 'python-version', 'size' ],
|
||||
root: 'package',
|
||||
listeners: {
|
||||
load: {
|
||||
fn: this.checkIfPackageAvailable,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var hgInstallationStore = new Ext.data.Store({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'config/repositories/hg/installations/hg'
|
||||
}),
|
||||
fields: [ 'path' ],
|
||||
reader: new Sonia.hg.InstallationJsonReader(),
|
||||
autoLoad: true,
|
||||
autoDestroy: true
|
||||
});
|
||||
|
||||
var pythonInstallationStore = new Ext.data.Store({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'config/repositories/hg/installations/python'
|
||||
}),
|
||||
fields: [ 'path' ],
|
||||
reader: new Sonia.hg.InstallationJsonReader(),
|
||||
autoLoad: true,
|
||||
autoDestroy: true
|
||||
});
|
||||
|
||||
var config = {
|
||||
layout: 'card',
|
||||
activeItem: 0,
|
||||
bodyStyle: 'padding: 5px',
|
||||
defaults: {
|
||||
bodyCssClass: 'x-panel-mc',
|
||||
border: false,
|
||||
labelWidth: 120,
|
||||
width: 250
|
||||
},
|
||||
bbar: ['->',{
|
||||
id: 'move-prev',
|
||||
text: this.backText,
|
||||
handler: this.navHandler.createDelegate(this, [-1]),
|
||||
disabled: true,
|
||||
scope: this
|
||||
},{
|
||||
id: 'move-next',
|
||||
text: this.nextText,
|
||||
handler: this.navHandler.createDelegate(this, [1]),
|
||||
scope: this
|
||||
},{
|
||||
id: 'finish',
|
||||
text: this.finishText,
|
||||
handler: this.applyChanges,
|
||||
scope: this,
|
||||
disabled: true
|
||||
}],
|
||||
items: [{
|
||||
id: 'cod',
|
||||
items: [{
|
||||
id: 'configureOrDownload',
|
||||
xtype: 'radiogroup',
|
||||
name: 'configureOrDownload',
|
||||
columns: 1,
|
||||
items: [{
|
||||
boxLabel: this.configureLocalText,
|
||||
name: 'cod',
|
||||
inputValue: 'localInstall',
|
||||
checked: true
|
||||
},{
|
||||
id: 'remoteInstallRadio',
|
||||
boxLabel: this.configureRemoteText,
|
||||
name: 'cod',
|
||||
inputValue: 'remoteInstall',
|
||||
disabled: true
|
||||
}]
|
||||
}],
|
||||
listeners: {
|
||||
render: {
|
||||
fn: function(panel){
|
||||
panel.body.mask(this.loadingText);
|
||||
var store = Ext.StoreMgr.lookup('pkgStore');
|
||||
store.load.defer(100, store);
|
||||
},
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'localInstall',
|
||||
layout: 'form',
|
||||
defaults: {
|
||||
width: 250
|
||||
},
|
||||
items: [{
|
||||
id: 'mercurial',
|
||||
fieldLabel: this.hgInstallationText,
|
||||
name: 'mercurial',
|
||||
xtype: 'combo',
|
||||
readOnly: false,
|
||||
triggerAction: 'all',
|
||||
lazyRender: true,
|
||||
mode: 'local',
|
||||
editable: true,
|
||||
store: hgInstallationStore,
|
||||
valueField: 'path',
|
||||
displayField: 'path',
|
||||
allowBlank: false,
|
||||
value: this.hgConfig.hgBinary
|
||||
},{
|
||||
id: 'python',
|
||||
fieldLabel: this.pythonInstallationText,
|
||||
name: 'python',
|
||||
xtype: 'combo',
|
||||
readOnly: false,
|
||||
triggerAction: 'all',
|
||||
lazyRender: true,
|
||||
mode: 'local',
|
||||
editable: true,
|
||||
store: pythonInstallationStore,
|
||||
valueField: 'path',
|
||||
displayField: 'path',
|
||||
allowBlank: false,
|
||||
value: this.hgConfig.pythonBinary
|
||||
}]
|
||||
},{
|
||||
id: 'remoteInstall',
|
||||
layout: 'form',
|
||||
defaults: {
|
||||
width: 250
|
||||
},
|
||||
items: [{
|
||||
id: 'package',
|
||||
fieldLabel: this.hgPackageText,
|
||||
name: 'package',
|
||||
xtype: 'combo',
|
||||
readOnly: false,
|
||||
triggerAction: 'all',
|
||||
lazyRender: true,
|
||||
mode: 'local',
|
||||
editable: false,
|
||||
store: packageStore,
|
||||
valueField: 'id',
|
||||
displayField: 'id',
|
||||
allowBlank: false,
|
||||
tpl: this.packageTemplate,
|
||||
listeners: {
|
||||
select: function(){
|
||||
Ext.getCmp('finish').setDisabled(false);
|
||||
}
|
||||
}
|
||||
}]
|
||||
}]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.hg.ConfigWizardPanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
checkIfPackageAvailable: function(store){
|
||||
Ext.getCmp('cod').body.unmask();
|
||||
var c = store.getTotalCount();
|
||||
if ( debug ){
|
||||
console.debug( "found " + c + " package(s)" );
|
||||
}
|
||||
if ( c > 0 ){
|
||||
Ext.getCmp('remoteInstallRadio').setDisabled(false);
|
||||
}
|
||||
},
|
||||
|
||||
navHandler: function(direction){
|
||||
var layout = this.getLayout();
|
||||
var id = layout.activeItem.id;
|
||||
|
||||
var next = -1;
|
||||
|
||||
if ( id === 'cod' && direction === 1 ){
|
||||
var v = Ext.getCmp('configureOrDownload').getValue().getRawValue();
|
||||
var df = false;
|
||||
if ( v === 'localInstall' ){
|
||||
next = 1;
|
||||
} else if ( v === 'remoteInstall' ){
|
||||
next = 2;
|
||||
df = true;
|
||||
}
|
||||
Ext.getCmp('move-prev').setDisabled(false);
|
||||
Ext.getCmp('move-next').setDisabled(true);
|
||||
Ext.getCmp('finish').setDisabled(df);
|
||||
}
|
||||
else if (direction === -1 && (id === 'localInstall' || id === 'remoteInstall')) {
|
||||
next = 0;
|
||||
Ext.getCmp('move-prev').setDisabled(true);
|
||||
Ext.getCmp('move-next').setDisabled(false);
|
||||
Ext.getCmp('finish').setDisabled(true);
|
||||
}
|
||||
|
||||
if ( next >= 0 ){
|
||||
layout.setActiveItem(next);
|
||||
}
|
||||
},
|
||||
|
||||
applyChanges: function(){
|
||||
var v = Ext.getCmp('configureOrDownload').getValue().getRawValue();
|
||||
if ( v === 'localInstall' ){
|
||||
this.applyLocalConfiguration();
|
||||
} else if ( v === 'remoteInstall' ){
|
||||
this.applyRemoteConfiguration();
|
||||
}
|
||||
},
|
||||
|
||||
applyRemoteConfiguration: function(){
|
||||
if ( debug ){
|
||||
console.debug( "apply remote configuration" );
|
||||
}
|
||||
|
||||
var pkg = Ext.getCmp('package').getValue();
|
||||
if ( debug ){
|
||||
console.debug( 'install mercurial package ' + pkg );
|
||||
}
|
||||
|
||||
var lbox = Ext.MessageBox.show({
|
||||
title: this.loadingText,
|
||||
msg: String.format(this.installPackageText, pkg),
|
||||
width: 300,
|
||||
wait: true,
|
||||
animate: true,
|
||||
progress: true,
|
||||
closable: false
|
||||
});
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: restUrl + 'config/repositories/hg/packages/' + pkg,
|
||||
method: 'POST',
|
||||
scope: this,
|
||||
timeout: 900000, // 15min
|
||||
success: function(){
|
||||
if ( debug ){
|
||||
console.debug('package successfully installed');
|
||||
}
|
||||
lbox.hide();
|
||||
this.fireEvent('finish');
|
||||
},
|
||||
failure: function(){
|
||||
if ( debug ){
|
||||
console.debug('package installation failed');
|
||||
}
|
||||
lbox.hide();
|
||||
Ext.MessageBox.show({
|
||||
title: this.errorTitleText,
|
||||
msg: this.packageInstallationFailedText,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
icon:Ext.MessageBox.ERROR
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
applyLocalConfiguration: function(){
|
||||
if ( debug ){
|
||||
console.debug( "apply remote configuration" );
|
||||
}
|
||||
var mercurial = Ext.getCmp('mercurial').getValue();
|
||||
var python = Ext.getCmp('python').getValue();
|
||||
if (debug){
|
||||
console.debug( 'configure mercurial=' + mercurial + " and python=" + python );
|
||||
}
|
||||
delete this.hgConfig.pythonPath;
|
||||
delete this.hgConfig.useOptimizedBytecode;
|
||||
this.hgConfig.hgBinary = mercurial;
|
||||
this.hgConfig.pythonBinary = python;
|
||||
|
||||
if ( debug ){
|
||||
console.debug( this.hgConfig );
|
||||
}
|
||||
|
||||
this.fireEvent('finish', this.hgConfig);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// register xtype
|
||||
Ext.reg('hgConfigWizardPanel', Sonia.hg.ConfigWizardPanel);
|
||||
|
||||
|
||||
// i18n
|
||||
|
||||
if ( i18n && i18n.country === 'de' ){
|
||||
|
||||
Ext.override(Sonia.hg.ConfigWizardPanel, {
|
||||
|
||||
backText: 'Zurück',
|
||||
nextText: 'Weiter',
|
||||
finishText: 'Fertigstellen',
|
||||
configureLocalText: 'Eine lokale Installation Konfigurieren',
|
||||
configureRemoteText: 'Herunterladen und installieren',
|
||||
loadingText: 'Lade ...',
|
||||
hgInstallationText: 'Mercurial Installation',
|
||||
pythonInstallationText: 'Python Installation',
|
||||
hgPackageText: 'Mercurial Package',
|
||||
errorTitleText: 'Fehler',
|
||||
packageInstallationFailedText: 'Package Installation fehlgeschlagen',
|
||||
installPackageText: 'Installiere Mercurial-Package {0}'
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Ext.ns("Sonia.hg");
|
||||
|
||||
Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
||||
|
||||
// labels
|
||||
titleText: 'Mercurial Settings',
|
||||
hgBinaryText: 'HG Binary',
|
||||
pythonBinaryText: 'Python Binary',
|
||||
pythonPathText: 'Python Module Search Path',
|
||||
repositoryDirectoryText: 'Repository directory',
|
||||
useOptimizedBytecodeText: 'Optimized Bytecode (.pyo)',
|
||||
configWizardText: 'Start Configuration Wizard',
|
||||
configWizardLabelText: 'Start Configuration Wizard',
|
||||
encodingText: 'Encoding',
|
||||
disabledText: 'Disabled',
|
||||
showRevisionInIdText: 'Show Revision',
|
||||
|
||||
// helpText
|
||||
hgBinaryHelpText: 'Location of Mercurial binary.',
|
||||
pythonBinaryHelpText: 'Location of Python binary.',
|
||||
pythonPathHelpText: 'Python Module Search Path (PYTHONPATH).',
|
||||
repositoryDirectoryHelpText: 'Location of the Mercurial repositories.',
|
||||
useOptimizedBytecodeHelpText: 'Use the Python "-O" switch.',
|
||||
encodingHelpText: 'Repository Encoding.',
|
||||
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
||||
Note you have to reload the page, after changing this value.',
|
||||
showRevisionInIdHelpText: 'Show revision as part of the node id. Note: \n\
|
||||
You have to restart the ApplicationServer to affect cached changesets.',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var config = {
|
||||
title : this.titleText,
|
||||
items : [{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : this.hgBinaryText,
|
||||
name : 'hgBinary',
|
||||
allowBlank : false,
|
||||
helpText: this.hgBinaryHelpText
|
||||
},{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : this.pythonBinaryText,
|
||||
name : 'pythonBinary',
|
||||
allowBlank : false,
|
||||
helpText: this.pythonBinaryHelpText
|
||||
},{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : this.pythonPathText,
|
||||
name : 'pythonPath',
|
||||
helpText: this.pythonPathHelpText
|
||||
},{
|
||||
xtype: 'textfield',
|
||||
name: 'repositoryDirectory',
|
||||
fieldLabel: this.repositoryDirectoryText,
|
||||
helpText: this.repositoryDirectoryHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'textfield',
|
||||
name: 'encoding',
|
||||
fieldLabel: this.encodingText,
|
||||
helpText: this.encodingHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'useOptimizedBytecode',
|
||||
fieldLabel: this.useOptimizedBytecodeText,
|
||||
inputValue: 'true',
|
||||
helpText: this.useOptimizedBytecodeHelpText
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'showRevisionInId',
|
||||
fieldLabel: this.showRevisionInIdText,
|
||||
inputValue: 'true',
|
||||
helpText: this.showRevisionInIdHelpText
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'disabled',
|
||||
fieldLabel: this.disabledText,
|
||||
inputValue: 'true',
|
||||
helpText: this.disabledHelpText
|
||||
},{
|
||||
xtype: 'button',
|
||||
text: this.configWizardText,
|
||||
fieldLabel: this.configWizardLabelText,
|
||||
handler: function(){
|
||||
var config = this.getForm().getValues();
|
||||
var wizard = new Sonia.hg.ConfigWizard({
|
||||
hgConfig: config
|
||||
});
|
||||
wizard.on('finish', function(config){
|
||||
var self = Ext.getCmp('hgConfigForm');
|
||||
if ( config ){
|
||||
if (debug){
|
||||
console.debug( 'load config from wizard and submit to server' );
|
||||
}
|
||||
self.loadConfig( self.el, 'config/repositories/hg/auto-configuration', 'POST', config );
|
||||
} else {
|
||||
if (debug){
|
||||
console.debug( 'reload config' );
|
||||
}
|
||||
self.onLoad(self.el);
|
||||
}
|
||||
}, this);
|
||||
wizard.show();
|
||||
},
|
||||
scope: this
|
||||
}]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.hg.ConfigPanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
onSubmit: function(values){
|
||||
this.el.mask(this.submitText);
|
||||
Ext.Ajax.request({
|
||||
url: restUrl + 'config/repositories/hg',
|
||||
method: 'POST',
|
||||
jsonData: values,
|
||||
scope: this,
|
||||
disableCaching: true,
|
||||
success: function(){
|
||||
this.el.unmask();
|
||||
},
|
||||
failure: function(){
|
||||
this.el.unmask();
|
||||
alert('failure');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onLoad: function(el){
|
||||
this.loadConfig(el, 'config/repositories/hg', 'GET');
|
||||
},
|
||||
|
||||
loadConfig: function(el, url, method, config){
|
||||
var tid = setTimeout( function(){ el.mask(this.loadingText); }, 100);
|
||||
Ext.Ajax.request({
|
||||
url: restUrl + url,
|
||||
method: method,
|
||||
jsonData: config,
|
||||
scope: this,
|
||||
disableCaching: true,
|
||||
success: function(response){
|
||||
var obj = Ext.decode(response.responseText);
|
||||
this.load(obj);
|
||||
clearTimeout(tid);
|
||||
el.unmask();
|
||||
},
|
||||
failure: function(){
|
||||
el.unmask();
|
||||
clearTimeout(tid);
|
||||
alert('failure');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Ext.reg("hgConfigPanel", Sonia.hg.ConfigPanel);
|
||||
|
||||
// i18n
|
||||
|
||||
if ( i18n && i18n.country === 'de' ){
|
||||
|
||||
Ext.override(Sonia.hg.ConfigPanel, {
|
||||
|
||||
// labels
|
||||
titleText: 'Mercurial Einstellungen',
|
||||
hgBinaryText: 'HG Pfad',
|
||||
pythonBinaryText: 'Python Pfad',
|
||||
pythonPathText: 'Python Modul Suchpfad',
|
||||
repositoryDirectoryText: 'Repository-Verzeichnis',
|
||||
useOptimizedBytecodeText: 'Optimierter Bytecode (.pyo)',
|
||||
autoConfigText: 'Einstellungen automatisch laden',
|
||||
autoConfigLabelText: 'Automatische Einstellung',
|
||||
configWizardText: 'Konfigurations-Assistenten starten',
|
||||
configWizardLabelText: 'Konfigurations-Assistent',
|
||||
disabledText: 'Deaktivieren',
|
||||
showRevisionInIdText: 'Zeige Revision an',
|
||||
|
||||
// helpText
|
||||
hgBinaryHelpText: 'Pfad zum "hg" Befehl.',
|
||||
pythonBinaryHelpText: 'Pfad zum "python" Befehl.',
|
||||
pythonPathHelpText: 'Python Modul Suchpfad (PYTHONPATH).',
|
||||
repositoryDirectoryHelpText: 'Verzeichnis der Mercurial-Repositories.',
|
||||
useOptimizedBytecodeHelpText: 'Optimierten Bytecode verwenden (python -O).',
|
||||
disabledHelpText: 'Aktivieren oder deaktivieren des Mercurial Plugins.\n\
|
||||
Die Seite muss neu geladen werden wenn dieser Wert geändert wird.',
|
||||
showRevisionInIdHelpText: 'Zeige die Revision als teil der NodeId an. \n\
|
||||
Der ApplicationServer muss neugestartet werden um zwischengespeicherte\n\
|
||||
Changesets zuändern.'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// register information panel
|
||||
|
||||
initCallbacks.push(function(main){
|
||||
main.registerInfoPanel('hg', {
|
||||
checkoutTemplate: 'hg clone <a href="{0}" target="_blank">{0}</a>',
|
||||
xtype: 'repositoryExtendedInfoPanel'
|
||||
});
|
||||
});
|
||||
|
||||
// register config panel
|
||||
|
||||
registerConfigPanel({
|
||||
id: 'hgConfigForm',
|
||||
xtype : 'hgConfigPanel'
|
||||
});
|
||||
|
||||
// register type icon
|
||||
|
||||
Sonia.repository.typeIcons['hg'] = 'resources/images/icons/16x16/mercurial.png';
|
||||
|
||||
// override ChangesetViewerGrid to render changeset id's with revisions
|
||||
|
||||
Ext.override(Sonia.repository.ChangesetViewerGrid, {
|
||||
|
||||
isMercurialRepository: function(){
|
||||
return this.repository.type === 'hg';
|
||||
},
|
||||
|
||||
getChangesetId: function(id, record){
|
||||
if ( this.isMercurialRepository() ){
|
||||
var rev = Sonia.util.getProperty(record.get('properties'), 'hg.rev');
|
||||
if ( rev ){
|
||||
id = rev + ':' + id;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
},
|
||||
|
||||
getParentIds: function(id, record){
|
||||
var parents = record.get('parents');
|
||||
if ( this.isMercurialRepository() ){
|
||||
if ( parents && parents.length > 0 ){
|
||||
var properties = record.get('properties');
|
||||
var rev = Sonia.util.getProperty(properties, 'hg.p1.rev');
|
||||
if (rev){
|
||||
parents[0] = rev + ':' + parents[0];
|
||||
}
|
||||
if ( parents.length > 1 ){
|
||||
rev = Sonia.util.getProperty(properties, 'hg.p2.rev');
|
||||
if (rev){
|
||||
parents[1] = rev + ':' + parents[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -606,9 +606,9 @@
|
||||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.3":
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.3.tgz#06f99d8b17e9aa1bb6e69c2732160e1f46724c3c"
|
||||
"@scm-manager/ui-bundler@^0.0.4":
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.4.tgz#0191a026d25b826692bccbc2b76d550388dd5528"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0-rc.2"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0-rc.2"
|
||||
@@ -623,6 +623,7 @@
|
||||
budo "^11.3.2"
|
||||
colors "^1.3.1"
|
||||
commander "^2.17.1"
|
||||
fast-xml-parser "^3.12.0"
|
||||
jest "^23.5.0"
|
||||
jest-junit "^5.1.0"
|
||||
node-mkdirs "^0.0.1"
|
||||
@@ -2130,6 +2131,12 @@ fast-levenshtein@~2.0.4:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
|
||||
fast-xml-parser@^3.12.0:
|
||||
version "3.12.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-3.12.0.tgz#84ddcd98ca005f94e99af3ac387adc32ffb239d8"
|
||||
dependencies:
|
||||
nimnjs "^1.3.2"
|
||||
|
||||
fb-watchman@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
|
||||
@@ -3760,6 +3767,21 @@ nice-try@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
|
||||
|
||||
nimn-date-parser@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn-date-parser/-/nimn-date-parser-1.0.0.tgz#4ce55d1fd5ea206bbe82b76276f7b7c582139351"
|
||||
|
||||
nimn_schema_builder@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn_schema_builder/-/nimn_schema_builder-1.1.0.tgz#b370ccf5b647d66e50b2dcfb20d0aa12468cd247"
|
||||
|
||||
nimnjs@^1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/nimnjs/-/nimnjs-1.3.2.tgz#a6a877968d87fad836375a4f616525e55079a5ba"
|
||||
dependencies:
|
||||
nimn-date-parser "^1.0.0"
|
||||
nimn_schema_builder "^1.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"@scm-manager/ui-extensions": "^0.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.3"
|
||||
"@scm-manager/ui-bundler": "^0.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,5 @@
|
||||
<conditions>
|
||||
<min-version>${project.parent.version}</min-version>
|
||||
</conditions>
|
||||
|
||||
<resources>
|
||||
<script>/sonia/scm/svn.config.js</script>
|
||||
</resources>
|
||||
|
||||
</plugin>
|
||||
</plugin>
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
Ext.ns("Sonia.svn");
|
||||
|
||||
Sonia.svn.ConfigPanel = Ext.extend(Sonia.config.SimpleConfigForm, {
|
||||
|
||||
// labels
|
||||
titleText: 'Subversion Settings',
|
||||
repositoryDirectoryText: 'Repository directory',
|
||||
noneCompatibility: 'No compatibility modus',
|
||||
pre14CompatibleText: 'Pre 1.4 Compatible',
|
||||
pre15CompatibleText: 'Pre 1.5 Compatible',
|
||||
pre16CompatibleText: 'Pre 1.6 Compatible',
|
||||
pre17CompatibleText: 'Pre 1.7 Compatible',
|
||||
with17CompatibleText: 'With 1.7 Compatible',
|
||||
enableGZipText: 'Enable GZip Encoding',
|
||||
disabledText: 'Disabled',
|
||||
|
||||
// helpTexts
|
||||
repositoryDirectoryHelpText: 'Location of the Suberversion repositories.',
|
||||
disabledHelpText: 'Enable or disable the Subversion plugin.\n\
|
||||
Note you have to reload the page, after changing this value.',
|
||||
enableGZipHelpText: 'Enable GZip encoding for svn responses.',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var config = {
|
||||
title : this.titleText,
|
||||
configUrl: restUrl + 'config/repositories/svn',
|
||||
items : [{
|
||||
xtype: 'textfield',
|
||||
name: 'repositoryDirectory',
|
||||
fieldLabel: this.repositoryDirectoryText,
|
||||
helpText: this.repositoryDirectoryHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'radiogroup',
|
||||
name: 'compatibility',
|
||||
columns: 1,
|
||||
items: [{
|
||||
boxLabel: this.noneCompatibility,
|
||||
inputValue: 'NONE',
|
||||
name: 'compatibility'
|
||||
},{
|
||||
boxLabel: this.pre14CompatibleText,
|
||||
inputValue: 'PRE14',
|
||||
name: 'compatibility'
|
||||
},{
|
||||
boxLabel: this.pre15CompatibleText,
|
||||
inputValue: 'PRE15',
|
||||
name: 'compatibility'
|
||||
},{
|
||||
boxLabel: this.pre16CompatibleText,
|
||||
inputValue: 'PRE16',
|
||||
name: 'compatibility'
|
||||
},{
|
||||
boxLabel: this.pre17CompatibleText,
|
||||
inputValue: 'PRE17',
|
||||
name: 'compatibility'
|
||||
},{
|
||||
boxLabel: this.with17CompatibleText,
|
||||
inputValue: 'WITH17',
|
||||
name: 'compatibility'
|
||||
}]
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'enable-gzip',
|
||||
fieldLabel: this.enableGZipText,
|
||||
inputValue: 'true',
|
||||
helpText: this.enableGZipHelpText
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'disabled',
|
||||
fieldLabel: this.disabledText,
|
||||
inputValue: 'true',
|
||||
helpText: this.disabledHelpText
|
||||
}]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.svn.ConfigPanel.superclass.initComponent.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Ext.reg("svnConfigPanel", Sonia.svn.ConfigPanel);
|
||||
|
||||
// i18n
|
||||
|
||||
if ( i18n && i18n.country === 'de' ){
|
||||
|
||||
Ext.override(Sonia.svn.ConfigPanel, {
|
||||
|
||||
// labels
|
||||
titleText: 'Subversion Einstellungen',
|
||||
repositoryDirectoryText: 'Repository-Verzeichnis',
|
||||
noneCompatibility: 'Kein Kompatiblitätsmodus',
|
||||
pre14CompatibleText: 'Mit Versionen vor 1.4 kompatibel',
|
||||
pre15CompatibleText: 'Mit Versionen vor 1.5 kompatibel',
|
||||
pre16CompatibleText: 'Mit Versionen vor 1.6 kompatibel',
|
||||
pre17CompatibleText: 'Mit Versionen vor 1.7 kompatibel',
|
||||
with17CompatibleText: 'Mit Version 1.7 kompatibel',
|
||||
disabledText: 'Deaktivieren',
|
||||
|
||||
// helpTexts
|
||||
repositoryDirectoryHelpText: 'Verzeichnis der Subversion-Repositories.',
|
||||
disabledHelpText: 'Aktivieren oder deaktivieren des Subversion Plugins.\n\
|
||||
Die Seite muss neu geladen werden wenn dieser Wert geändert wird.'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// register information panel
|
||||
|
||||
initCallbacks.push(function(main){
|
||||
main.registerInfoPanel('svn', {
|
||||
checkoutTemplate: 'svn checkout <a href="{0}" target="_blank">{0}</a>',
|
||||
xtype: 'repositoryExtendedInfoPanel'
|
||||
});
|
||||
});
|
||||
|
||||
// register panel
|
||||
|
||||
registerConfigPanel({
|
||||
xtype : 'svnConfigPanel'
|
||||
});
|
||||
|
||||
// register type icon
|
||||
|
||||
Sonia.repository.typeIcons['svn'] = 'resources/images/icons/16x16/subversion.png';
|
||||
@@ -606,9 +606,9 @@
|
||||
lodash "^4.17.10"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.3":
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.3.tgz#06f99d8b17e9aa1bb6e69c2732160e1f46724c3c"
|
||||
"@scm-manager/ui-bundler@^0.0.4":
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.4.tgz#0191a026d25b826692bccbc2b76d550388dd5528"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0-rc.2"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0-rc.2"
|
||||
@@ -623,6 +623,7 @@
|
||||
budo "^11.3.2"
|
||||
colors "^1.3.1"
|
||||
commander "^2.17.1"
|
||||
fast-xml-parser "^3.12.0"
|
||||
jest "^23.5.0"
|
||||
jest-junit "^5.1.0"
|
||||
node-mkdirs "^0.0.1"
|
||||
@@ -2130,6 +2131,12 @@ fast-levenshtein@~2.0.4:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
|
||||
fast-xml-parser@^3.12.0:
|
||||
version "3.12.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-3.12.0.tgz#84ddcd98ca005f94e99af3ac387adc32ffb239d8"
|
||||
dependencies:
|
||||
nimnjs "^1.3.2"
|
||||
|
||||
fb-watchman@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
|
||||
@@ -3760,6 +3767,21 @@ nice-try@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
|
||||
|
||||
nimn-date-parser@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn-date-parser/-/nimn-date-parser-1.0.0.tgz#4ce55d1fd5ea206bbe82b76276f7b7c582139351"
|
||||
|
||||
nimn_schema_builder@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/nimn_schema_builder/-/nimn_schema_builder-1.1.0.tgz#b370ccf5b647d66e50b2dcfb20d0aa12468cd247"
|
||||
|
||||
nimnjs@^1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/nimnjs/-/nimnjs-1.3.2.tgz#a6a877968d87fad836375a4f616525e55079a5ba"
|
||||
dependencies:
|
||||
nimn-date-parser "^1.0.0"
|
||||
nimn_schema_builder "^1.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||
|
||||
@@ -509,7 +509,7 @@
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<webApp>
|
||||
<contextPath>/</contextPath>
|
||||
<contextPath>/scm</contextPath>
|
||||
</webApp>
|
||||
<jettyXml>${project.basedir}/src/main/conf/jetty.xml</jettyXml>
|
||||
<scanIntervalSeconds>0</scanIntervalSeconds>
|
||||
|
||||
@@ -63,10 +63,6 @@ import sonia.scm.repository.api.HookContextFactory;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.repository.spi.HookEventFacade;
|
||||
import sonia.scm.repository.xml.XmlRepositoryDAO;
|
||||
import sonia.scm.resources.DefaultResourceManager;
|
||||
import sonia.scm.resources.DevelopmentResourceManager;
|
||||
import sonia.scm.resources.ResourceManager;
|
||||
import sonia.scm.resources.ScriptResourceServlet;
|
||||
import sonia.scm.schedule.QuartzScheduler;
|
||||
import sonia.scm.schedule.Scheduler;
|
||||
import sonia.scm.security.*;
|
||||
@@ -266,16 +262,6 @@ public class ScmServletModule extends ServletModule
|
||||
transformers.addBinding().to(JsonContentTransformer.class);
|
||||
bind(AdvancedHttpClient.class).to(DefaultAdvancedHttpClient.class);
|
||||
|
||||
// bind resourcemanager
|
||||
if (context.getStage() == Stage.DEVELOPMENT)
|
||||
{
|
||||
bind(ResourceManager.class, DevelopmentResourceManager.class);
|
||||
}
|
||||
else
|
||||
{
|
||||
bind(ResourceManager.class, DefaultResourceManager.class);
|
||||
}
|
||||
|
||||
// bind repository service factory
|
||||
bind(RepositoryServiceFactory.class);
|
||||
|
||||
@@ -295,9 +281,6 @@ public class ScmServletModule extends ServletModule
|
||||
// debug servlet
|
||||
serve(PATTERN_DEBUG).with(DebugServlet.class);
|
||||
|
||||
// plugin resources
|
||||
serve(PATTERN_PLUGIN_SCRIPT).with(ScriptResourceServlet.class);
|
||||
|
||||
// template
|
||||
serve(PATTERN_INDEX, "/").with(TemplateServlet.class);
|
||||
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractResource implements Resource
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for AbstractResource
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractResource.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resources
|
||||
* @param resourceHandlers
|
||||
*/
|
||||
public AbstractResource(PluginLoader pluginLoader, List<String> resources,
|
||||
List<ResourceHandler> resourceHandlers)
|
||||
{
|
||||
this.pluginLoader = pluginLoader;
|
||||
this.resources = resources;
|
||||
this.resourceHandlers = resourceHandlers;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stream
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void appendResources(OutputStream stream) throws IOException
|
||||
{
|
||||
if (Util.isNotEmpty(resources))
|
||||
{
|
||||
for (String resource : resources)
|
||||
{
|
||||
appendResource(stream, resource);
|
||||
}
|
||||
}
|
||||
|
||||
if (Util.isNotEmpty(resourceHandlers))
|
||||
{
|
||||
Collections.sort(resourceHandlers, new ResourceHandlerComparator());
|
||||
|
||||
for (ResourceHandler resourceHandler : resourceHandlers)
|
||||
{
|
||||
processResourceHandler(stream, resourceHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stream
|
||||
* @param path
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendResource(OutputStream stream, String path)
|
||||
throws IOException
|
||||
{
|
||||
URL resource = getResourceAsURL(path);
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
Resources.copy(resource, stream);
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("could not find resource {}", path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stream
|
||||
* @param resourceHandler
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void processResourceHandler(OutputStream stream,
|
||||
ResourceHandler resourceHandler)
|
||||
throws IOException
|
||||
{
|
||||
if (resourceHandler.getType() == getType())
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("process resource handler {}", resourceHandler.getClass());
|
||||
}
|
||||
|
||||
URL resource = resourceHandler.getResource();
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
Resources.copy(resource, stream);
|
||||
}
|
||||
else if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("resource handler {} does not return a resource",
|
||||
resourceHandler.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private URL getResourceAsURL(String path)
|
||||
{
|
||||
URL resource = null;
|
||||
ClassLoader classLoader = pluginLoader.getUberClassLoader();
|
||||
|
||||
if (classLoader != null)
|
||||
{
|
||||
String classLoaderResource = path;
|
||||
|
||||
if (classLoaderResource.startsWith("/"))
|
||||
{
|
||||
classLoaderResource = classLoaderResource.substring(1);
|
||||
}
|
||||
|
||||
resource = classLoader.getResource(classLoaderResource);
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected final List<ResourceHandler> resourceHandlers;
|
||||
|
||||
/** Field description */
|
||||
protected final List<String> resources;
|
||||
|
||||
/** Field description */
|
||||
private final PluginLoader pluginLoader;
|
||||
}
|
||||
@@ -1,314 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginResources;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractResourceManager implements ResourceManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resourceHandlers
|
||||
*/
|
||||
protected AbstractResourceManager(PluginLoader pluginLoader,
|
||||
Set<ResourceHandler> resourceHandlers)
|
||||
{
|
||||
this.pluginLoader = pluginLoader;
|
||||
this.resourceHandlers = resourceHandlers;
|
||||
collectResources(resourceMap);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resourceMap
|
||||
*/
|
||||
protected abstract void collectResources(Map<ResourceKey,
|
||||
Resource> resourceMap);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Resource getResource(ResourceType type, String name)
|
||||
{
|
||||
return resourceMap.get(new ResourceKey(name, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Resource> getResources(ResourceType type)
|
||||
{
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
|
||||
for (Entry<ResourceKey, Resource> e : resourceMap.entrySet())
|
||||
{
|
||||
if (e.getKey().getType() == type)
|
||||
{
|
||||
resources.add(e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(resources, ResourceNameComparator.INSTANCE);
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected List<String> getScriptResources()
|
||||
{
|
||||
List<String> resources = new ArrayList<>();
|
||||
Collection<PluginWrapper> wrappers = pluginLoader.getInstalledPlugins();
|
||||
|
||||
if (wrappers != null)
|
||||
{
|
||||
for (PluginWrapper plugin : wrappers)
|
||||
{
|
||||
processPlugin(resources, plugin.getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
// fix order of script resources, see https://goo.gl/ok03l4
|
||||
Collections.sort(resources);
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resources
|
||||
* @param plugin
|
||||
*/
|
||||
private void processPlugin(List<String> resources, Plugin plugin)
|
||||
{
|
||||
PluginResources pluginResources = plugin.getResources();
|
||||
|
||||
if (pluginResources != null)
|
||||
{
|
||||
Set<String> scriptResources = pluginResources.getScriptResources();
|
||||
|
||||
if (scriptResources != null)
|
||||
{
|
||||
// filter new resources and keep only the old ones, which are starting with a /
|
||||
List<String> filtered = scriptResources.stream()
|
||||
.filter((res) -> res.startsWith("/"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
resources.addAll(filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 12/02/03
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
protected static class ResourceKey
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @param type
|
||||
*/
|
||||
public ResourceKey(String name, ResourceType type)
|
||||
{
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
//~--- methods ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final ResourceKey other = (ResourceKey) obj;
|
||||
|
||||
if ((this.name == null)
|
||||
? (other.name != null)
|
||||
: !this.name.equals(other.name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.type == other.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = 7;
|
||||
|
||||
hash = 53 * hash + ((this.name != null)
|
||||
? this.name.hashCode()
|
||||
: 0);
|
||||
hash = 53 * hash + ((this.type != null)
|
||||
? this.type.hashCode()
|
||||
: 0);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
//~--- get methods --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResourceType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final String name;
|
||||
|
||||
/** Field description */
|
||||
private final ResourceType type;
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected PluginLoader pluginLoader;
|
||||
|
||||
/** Field description */
|
||||
protected Set<ResourceHandler> resourceHandlers;
|
||||
|
||||
/** Field description */
|
||||
protected Map<ResourceKey, Resource> resourceMap = new HashMap<>();
|
||||
|
||||
/** Field description */
|
||||
protected ServletContext servletContext;
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractResourceServlet extends HttpServlet
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -1774434741744054387L;
|
||||
|
||||
/**
|
||||
* the logger for AbstractResourceServlet
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractResourceServlet.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param resourceManager
|
||||
*/
|
||||
public AbstractResourceServlet(ResourceManager resourceManager)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract ResourceType getType();
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String uri = HttpUtil.getStrippedURI(request);
|
||||
ResourceType type = getType();
|
||||
String nameSeparator = HttpUtil.SEPARATOR_PATH.concat(
|
||||
type.getExtension()).concat(
|
||||
HttpUtil.SEPARATOR_PATH);
|
||||
int index = uri.indexOf(nameSeparator);
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
String name = uri.substring(index + nameSeparator.length());
|
||||
Resource resource = resourceManager.getResource(type, name);
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
printResource(response, resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("no resource with type {} and name {} found", type, name);
|
||||
}
|
||||
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* @param resource
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void printResource(HttpServletResponse response, Resource resource)
|
||||
throws IOException
|
||||
{
|
||||
response.setContentType(resource.getType().getContentType());
|
||||
|
||||
try (OutputStream output = response.getOutputStream())
|
||||
{
|
||||
resource.copyTo(output);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final ResourceManager resourceManager;
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.util.ChecksumUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class DefaultResource extends AbstractResource
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resources
|
||||
* @param resourceHandlers
|
||||
* @param type
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public DefaultResource(PluginLoader pluginLoader, List<String> resources,
|
||||
List<ResourceHandler> resourceHandlers, ResourceType type)
|
||||
throws IOException
|
||||
{
|
||||
super(pluginLoader, resources, resourceHandlers);
|
||||
this.type = type;
|
||||
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
|
||||
{
|
||||
appendResources(baos);
|
||||
this.content = baos.toByteArray();
|
||||
this.name = ChecksumUtil.createChecksum(this.content).concat(".").concat(
|
||||
type.getExtension());
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void copyTo(OutputStream output) throws IOException
|
||||
{
|
||||
output.write(content);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResourceType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final byte[] content;
|
||||
|
||||
/** Field description */
|
||||
private final String name;
|
||||
|
||||
/** Field description */
|
||||
private final ResourceType type;
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class DefaultResourceManager extends AbstractResourceManager
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for DefaultResourceManager
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(DefaultResourceManager.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resourceHandlers
|
||||
*/
|
||||
@Inject
|
||||
public DefaultResourceManager(PluginLoader pluginLoader,
|
||||
Set<ResourceHandler> resourceHandlers)
|
||||
{
|
||||
super(pluginLoader, resourceHandlers);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resourceMap
|
||||
*/
|
||||
@Override
|
||||
protected void collectResources(Map<ResourceKey, Resource> resourceMap)
|
||||
{
|
||||
List<String> resources = getScriptResources();
|
||||
|
||||
try
|
||||
{
|
||||
Resource resource = new DefaultResource(pluginLoader, resources,
|
||||
Lists.newArrayList(resourceHandlers),
|
||||
ResourceType.SCRIPT);
|
||||
|
||||
resourceMap.put(new ResourceKey(resource.getName(), ResourceType.SCRIPT),
|
||||
resource);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.error("could not collect resources", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class DevelopmentResource extends AbstractResource
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resources
|
||||
* @param resourceHandlers
|
||||
* @param name
|
||||
* @param type
|
||||
*/
|
||||
public DevelopmentResource(PluginLoader pluginLoader, List<String> resources,
|
||||
List<ResourceHandler> resourceHandlers, String name, ResourceType type)
|
||||
{
|
||||
super(pluginLoader, resources, resourceHandlers);
|
||||
this.type = type;
|
||||
|
||||
if (name.startsWith(HttpUtil.SEPARATOR_PATH))
|
||||
{
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
String ext = ".".concat(type.getExtension());
|
||||
|
||||
if (!name.endsWith(ext))
|
||||
{
|
||||
name = name.concat(ext);
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void copyTo(OutputStream output) throws IOException
|
||||
{
|
||||
appendResources(output);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResourceType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final String name;
|
||||
|
||||
/** Field description */
|
||||
private final ResourceType type;
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class DevelopmentResourceManager extends AbstractResourceManager
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PREFIX_HANDLER = "handler/";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param pluginLoader
|
||||
* @param resourceHandlers
|
||||
*/
|
||||
@Inject
|
||||
public DevelopmentResourceManager(PluginLoader pluginLoader,
|
||||
Set<ResourceHandler> resourceHandlers)
|
||||
{
|
||||
super(pluginLoader, resourceHandlers);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resourceMap
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void collectResources(Map<ResourceKey, Resource> resourceMap)
|
||||
{
|
||||
List<String> scripts = getScriptResources();
|
||||
|
||||
for (String script : scripts)
|
||||
{
|
||||
Resource resource = new DevelopmentResource(pluginLoader,
|
||||
Arrays.asList(script), Collections.EMPTY_LIST,
|
||||
script, ResourceType.SCRIPT);
|
||||
|
||||
resourceMap.put(new ResourceKey(resource.getName(), ResourceType.SCRIPT),
|
||||
resource);
|
||||
}
|
||||
|
||||
for (ResourceHandler handler : resourceHandlers)
|
||||
{
|
||||
String name = handler.getName();
|
||||
|
||||
if (name.startsWith("/"))
|
||||
{
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
name = PREFIX_HANDLER.concat(name);
|
||||
resourceMap.put(new ResourceKey(name, ResourceType.SCRIPT),
|
||||
new DevelopmentResource(pluginLoader, Collections.EMPTY_LIST,
|
||||
Arrays.asList(handler), name, ResourceType.SCRIPT));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class ScriptResourceServlet extends AbstractResourceServlet
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 1279211769033477225L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param resourceManager
|
||||
*/
|
||||
@Inject
|
||||
public ScriptResourceServlet(ResourceManager resourceManager)
|
||||
{
|
||||
super(resourceManager);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected ResourceType getType()
|
||||
{
|
||||
return ResourceType.SCRIPT;
|
||||
}
|
||||
}
|
||||
@@ -38,30 +38,23 @@ package sonia.scm.template;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.resources.ResourceManager;
|
||||
import sonia.scm.resources.ResourceType;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -100,15 +93,12 @@ public class TemplateServlet extends HttpServlet
|
||||
* @param context
|
||||
* @param templateEngineFactory
|
||||
* @param configuration
|
||||
* @param resourceManager
|
||||
*/
|
||||
@Inject
|
||||
public TemplateServlet(SCMContextProvider context,
|
||||
TemplateEngineFactory templateEngineFactory,
|
||||
ResourceManager resourceManager, ScmConfiguration configuration)
|
||||
TemplateEngineFactory templateEngineFactory, ScmConfiguration configuration)
|
||||
{
|
||||
this.templateEngineFactory = templateEngineFactory;
|
||||
this.resourceManager = resourceManager;
|
||||
this.configuration = configuration;
|
||||
this.version = context.getVersion();
|
||||
}
|
||||
@@ -123,21 +113,17 @@ public class TemplateServlet extends HttpServlet
|
||||
* @param response
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||
{
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
String contextPath = request.getContextPath();
|
||||
|
||||
params.put("contextPath", contextPath);
|
||||
params.put("configuration", configuration);
|
||||
params.put("version", version);
|
||||
|
||||
params.put("scripts", resourceManager.getResources(ResourceType.SCRIPT));
|
||||
|
||||
Locale l = request.getLocale();
|
||||
|
||||
if (l == null)
|
||||
@@ -242,9 +228,6 @@ public class TemplateServlet extends HttpServlet
|
||||
/** Field description */
|
||||
private final ScmConfiguration configuration;
|
||||
|
||||
/** Field description */
|
||||
private final ResourceManager resourceManager;
|
||||
|
||||
/** Field description */
|
||||
private final TemplateEngineFactory templateEngineFactory;
|
||||
|
||||
|
||||
10
scm-webapp/src/main/webapp/index.html
Normal file
10
scm-webapp/src/main/webapp/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,97 +0,0 @@
|
||||
/***
|
||||
* Copyright (c) 2015, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* https://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractResourceManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AbstractResourceManagerTest extends ResourceManagerTestBase
|
||||
{
|
||||
|
||||
private DummyResourceManager resourceManager;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Set<ResourceHandler> resourceHandlers = ImmutableSet.of(resourceHandler);
|
||||
resourceManager = new DummyResourceManager(pluginLoader, resourceHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test {@link AbstractResourceManager#getScriptResources()} in the correct order.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*
|
||||
* @see <a href="https://goo.gl/ok03l4">Issue 809</a>
|
||||
*/
|
||||
@Test
|
||||
public void testGetScriptResources() throws IOException
|
||||
{
|
||||
appendScriptResources("a/b.js", "z/a.js", "a/a.js");
|
||||
List<String> scripts = resourceManager.getScriptResources();
|
||||
assertThat(scripts, contains("a/a.js", "a/b.js", "z/a.js"));
|
||||
}
|
||||
|
||||
private static class DummyResourceManager extends AbstractResourceManager
|
||||
{
|
||||
|
||||
public DummyResourceManager(PluginLoader pluginLoader, Set<ResourceHandler> resourceHandlers)
|
||||
{
|
||||
super(pluginLoader, resourceHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void collectResources(Map<ResourceKey, Resource> resourceMap)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/***
|
||||
* Copyright (c) 2015, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* https://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultResourceManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class DefaultResourceManagerTest extends ResourceManagerTestBase {
|
||||
|
||||
private DefaultResourceManager resourceManager;
|
||||
|
||||
/**
|
||||
* Set up {@link DefaultResourceManager} for tests.
|
||||
*/
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Set<ResourceHandler> resourceHandlers = ImmutableSet.of(resourceHandler);
|
||||
resourceManager = new DefaultResourceManager(pluginLoader, resourceHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test {@link DefaultResourceManager#getResources(sonia.scm.resources.ResourceType)} method.
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
@Test
|
||||
public void testGetResources() throws IOException
|
||||
{
|
||||
appendScriptResources("a/b.js", "z/a.js", "a/a.js");
|
||||
List<Resource> resources = resourceManager.getResources(ResourceType.SCRIPT);
|
||||
assertEquals(1, resources.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/***
|
||||
* Copyright (c) 2015, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* https://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.ServletContext;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginCondition;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginResources;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.WebResourceLoader;
|
||||
|
||||
/**
|
||||
* Base class for {@link ResourceManager} tests.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class ResourceManagerTestBase
|
||||
{
|
||||
|
||||
@Mock
|
||||
protected ServletContext servletContext;
|
||||
|
||||
@Mock
|
||||
protected PluginLoader pluginLoader;
|
||||
|
||||
@Mock
|
||||
protected ResourceHandler resourceHandler;
|
||||
|
||||
@Mock
|
||||
protected WebResourceLoader webResourceLoader;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
/**
|
||||
* Append scripts resources to plugin loader.
|
||||
*
|
||||
* @param resources resource names
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void appendScriptResources(String... resources) throws IOException
|
||||
{
|
||||
Set<String> scripts = Sets.newHashSet(resources);
|
||||
Set<String> styles = Sets.newHashSet();
|
||||
Set<String> dependencies = Sets.newHashSet();
|
||||
|
||||
|
||||
Plugin plugin = new Plugin(
|
||||
2,
|
||||
new PluginInformation(),
|
||||
new PluginResources(scripts, styles),
|
||||
new PluginCondition(),
|
||||
false,
|
||||
dependencies
|
||||
);
|
||||
|
||||
Path pluginPath = tempFolder.newFolder().toPath();
|
||||
|
||||
PluginWrapper wrapper = new PluginWrapper(
|
||||
plugin,
|
||||
Thread.currentThread().getContextClassLoader(),
|
||||
webResourceLoader,
|
||||
pluginPath
|
||||
);
|
||||
|
||||
List<PluginWrapper> plugins = ImmutableList.of(wrapper);
|
||||
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(plugins);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user