public class ArtifactContentEntry
implements Serializable
{
- private String text;
+ private String path;
private boolean file;
private int depth;
- private boolean hasChildren;
-
public ArtifactContentEntry()
{
// no op
}
- public ArtifactContentEntry( String text, boolean file, int depth, boolean hasChildren )
+ public ArtifactContentEntry( String path, boolean file, int depth )
{
- this.text = text;
+ this.path = path;
this.file = file;
this.depth = depth;
- this.hasChildren = hasChildren;
- }
-
- public String getText()
- {
- return text;
}
- public String getId()
+ public String getPath()
{
- return text;
+ return path;
}
- public void setText( String text )
+ public void setPath( String path )
{
- this.text = text;
+ this.path = path;
}
public boolean isFile()
this.depth = depth;
}
- public boolean isHasChildren()
- {
- return hasChildren;
- }
-
- public void setHasChildren( boolean hasChildren )
- {
- this.hasChildren = hasChildren;
- }
-
-
-
@Override
public boolean equals( Object o )
{
ArtifactContentEntry that = (ArtifactContentEntry) o;
- if ( hasChildren != that.hasChildren )
- {
- return false;
- }
if ( depth != that.depth )
{
return false;
{
return false;
}
- if ( text != null ? !text.equals( that.text ) : that.text != null )
+ if ( path != null ? !path.equals( that.path ) : that.path != null )
{
return false;
}
@Override
public int hashCode()
{
- int result = text != null ? text.hashCode() : 0;
+ int result = path != null ? path.hashCode() : 0;
result = 31 * result + ( file ? 1 : 0 );
result = 31 * result + depth;
- result = 31 * result + ( hasChildren ? 1 : 0 );
return result;
}
{
final StringBuilder sb = new StringBuilder();
sb.append( "ArtifactContentEntry" );
- sb.append( "{text='" ).append( text ).append( '\'' );
+ sb.append( "{text='" ).append( path ).append( '\'' );
sb.append( ", file=" ).append( file );
sb.append( ", depth=" ).append( depth );
- sb.append( ", children=" ).append( hasChildren );
sb.append( '}' );
return sb.toString();
}
artifactContentEntryMap.put( entryRootPath,
new ArtifactContentEntry( entryRootPath, !currentEntry.isDirectory(),
- depth, true ) );
+ depth ) );
}
else
{
{
artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName,
!currentEntry.isDirectory(),
- depth, true ) );
+ depth ) );
}
}
}
public int compare( ArtifactContentEntry artifactContentEntry, ArtifactContentEntry artifactContentEntry1 )
{
// include depth too in comparaison ?
- return artifactContentEntry.getText().compareTo( artifactContentEntry1.getText() );
+ return artifactContentEntry.getPath().compareTo( artifactContentEntry1.getPath() );
}
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+ new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+ new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+ new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
- new ArtifactContentEntry( "org/apache", false, 1, true ) );
+ new ArtifactContentEntry( "org/apache", false, 1 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 16 ).contains(
- new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5, true ) );
+ new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
- new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
- new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );
+ new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
+ new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ArtifactContentEntry( "org", false, 0,true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+ new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
deleteTestRepo( testRepoId );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
- new ArtifactContentEntry( "org/apache", false, 1, true ) );
+ new ArtifactContentEntry( "org/apache", false, 1 ) );
deleteTestRepo( testRepoId );
}
log.info( "artifactContentEntries: {}", artifactContentEntries );
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
- new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
- new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );
+ new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
+ new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
deleteTestRepo( testRepoId );
}
script: entriesUrl,
root: ""
},function(file) {
- alert(file);
+ //alert(file);
});
- return;
-
- var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
- entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
- entriesUrl+="?repositoryId="+encodeURIComponent(self.repositoryId);
- $.ajax(entriesUrl,{
- type: "GET",
- dataType: 'json',
- success: function(data) {
- //$("#artifact-details-file-content").html($("#artifact_content_tmpl").tmpl());//{artifactContentEntries:mapArtifactContentEntries(data)}));
- //artifact_content_tmpl
- var artifactContentEntryViewModel=
- new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,[]);
- artifactContentEntryViewModel.show();
- //ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
- }
- });
}
-
-
});
}
});
}
- ArtifactContentEntry=function(text,file,depth,id){
- this.text=text;
+ ArtifactContentEntry=function(path,file,depth){
+ this.path=path;
this.file=file;
this.depth=depth;
- this.id=id;
}
mapArtifactContentEntries=function(data){
}
if ( $.isArray(data)){
return $.map(data,function(e){
- return new ArtifactContentEntry(e.text,e.file,e.depth,e.id);
+ return new ArtifactContentEntry(e.path,e.file,e.depth);
})
}
- return new ArtifactContentEntry(data.text,data.file,data.depth,e.id);
- }
-
- ArtifactContentEntryViewModel=function(groupId,artifactId,version,artifactContentEntries){
- var self=this;
- this.groupId=groupId;
- this.artifactId=artifactId;
- this.version=version;
- this.artifactContentEntries=ko.observableArray(artifactContentEntries);
- this.currentPath=ko.observable();
-
- this.show=function(){
- var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
- entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
- entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
- //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
-
- $("#main-content #artifact_content_tree").fileTree({
- script: entriesUrl
- },function(file) {
- alert(file);
- });
- }
-
- entries=function(){
- return self.artifactContentEntries;
- }
-
- displayPath=function(artifactContentEntry){
- $.log("ArtifactContentEntryViewModel#displayPath:"+artifactContentEntry.name);
-
- var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
- entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
- entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
- entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
- self.currentPath(artifactContentEntry.name);
- $.ajax(entriesUrl,{
- type: "GET",
- dataType: 'json',
- success: function(data) {
- self.artifactContentEntries(mapArtifactContentEntries(data));
- }
- });
-
- }
+ return new ArtifactContentEntry(data.path,data.file,data.depth);
}
MetadataEntry=function(key,value,editable){
</tbody>
</script>
-<script id="artifact_content_main_tmpl" type="text/html">
- <div id="artifact_file_content_div" data-bind='template:{name:"artifact_content_tmpl"}'>
- </div>
-</script>
-
-<script id="artifact_content_tmpl" type="text/html">
- <div id="artifact_content_tree">
- </div>
-</script>
-
<script id="artifact_content_tree_partial" type="text/html">
<ul class="jqueryFileTree" style="display: none;">
{{each artifactContentEntries}}
<li class="directory collapsed">
- <a href="#" rel="${$value.text}/">${$value.text}</a>
+ <a href="#" rel="${$value.path}/">${$value.path}</a>
</li>
{{/each}}
</ul>