├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── 76df3287-6cda-33eb-8e9a-044b5e15ffdd_829521842.jpg ├── INSTALL.txt ├── src ├── main │ └── java │ │ └── org │ │ ├── musicbrainz │ │ ├── utils │ │ │ └── package.html │ │ ├── package.html │ │ ├── webservice │ │ │ ├── impl │ │ │ │ └── package.html │ │ │ ├── WebServiceException.java │ │ │ ├── AuthorizationException.java │ │ │ ├── ResponseException.java │ │ │ ├── ResourceNotFoundException.java │ │ │ ├── package.html │ │ │ ├── RequestException.java │ │ │ └── WebService.java │ │ ├── query │ │ │ ├── search │ │ │ │ ├── readysearches │ │ │ │ │ ├── EntitySearchInterface.java │ │ │ │ │ ├── WorkSearchbyTitle.java │ │ │ │ │ ├── LabelSearchbyName.java │ │ │ │ │ ├── ArtistSearchbyName.java │ │ │ │ │ ├── RecordingSearchbyTitle.java │ │ │ │ │ ├── WorkSearchbyArtistId.java │ │ │ │ │ ├── ReleaseGroupSearchbyTitle.java │ │ │ │ │ ├── ReleaseSearchbyTitle.java │ │ │ │ │ └── AnnotationSearchbyEntityId.java │ │ │ │ ├── CollectionSearchWs2.java │ │ │ │ ├── WorkSearchWs2.java │ │ │ │ ├── LabelSearchWs2.java │ │ │ │ ├── ReleaseSearchWs2.java │ │ │ │ ├── ArtistSearchWs2.java │ │ │ │ ├── RecordingSearchWs2.java │ │ │ │ ├── AnnotationSearchWs2.java │ │ │ │ ├── ReleaseGroupSearchWs2.java │ │ │ │ └── SearchWs2.java │ │ │ ├── submission │ │ │ │ ├── SubmissionQueryWs2.java │ │ │ │ ├── UserTagSubmissionWs2.java │ │ │ │ ├── UserRatingSubmissionWs2.java │ │ │ │ ├── SubmissionException.java │ │ │ │ ├── EntityElement.java │ │ │ │ ├── CollectionReleasesHandlerWs2.java │ │ │ │ └── EntityTypeElementList.java │ │ │ ├── browse │ │ │ │ ├── WorkBrowseWs2.java │ │ │ │ ├── LabelBrowseWs2.java │ │ │ │ ├── ArtistBrowseWs2.java │ │ │ │ ├── ReleaseBrowseWs2.java │ │ │ │ ├── RecordingBrowseWs2.java │ │ │ │ └── ReleaseGroupBrowseWs2.java │ │ │ └── QueryWs2.java │ │ ├── wsxml │ │ │ ├── element │ │ │ │ ├── package.html │ │ │ │ └── ListElement.java │ │ │ ├── MbXMLParseException.java │ │ │ ├── MbXMLException.java │ │ │ ├── package.html │ │ │ ├── MbXmlWriter.java │ │ │ └── MbXmlParser.java │ │ ├── filter │ │ │ ├── browsefilter │ │ │ │ ├── LabelBrowseFilterWs2.java │ │ │ │ ├── WorkBrowseFilterWs2.java │ │ │ │ ├── ArtistBrowseFilterWs2.java │ │ │ │ ├── RecordingBrowseFilterWs2.java │ │ │ │ ├── ReleaseGroupBrowseFilterWs2.java │ │ │ │ ├── ReleaseBrowseFilterWs2.java │ │ │ │ └── BrowseFilterWs2.java │ │ │ ├── FilterWs2.java │ │ │ ├── DiscTocFilterWs2.java │ │ │ ├── searchfilter │ │ │ │ ├── AnnotationSearchtFilterWs2.java │ │ │ │ ├── WorkSearchFilterWs2.java │ │ │ │ ├── LabelSearchFilterWs2.java │ │ │ │ ├── ArtistSearchFilterWs2.java │ │ │ │ ├── RecordingSearchFilterWs2.java │ │ │ │ ├── ReleaseGroupSearchFilterWs2.java │ │ │ │ ├── ReleaseSearchFilterWs2.java │ │ │ │ └── SearchFilterWs2.java │ │ │ └── ReleaseStatusFilterWs2.java │ │ ├── model │ │ │ ├── searchresult │ │ │ │ ├── AnnotationResultWs2.java │ │ │ │ ├── WorkResultWs2.java │ │ │ │ ├── LabelResultWs2.java │ │ │ │ ├── ArtistResultWs2.java │ │ │ │ ├── ReleaseResultWs2.java │ │ │ │ ├── CollectionResultWs2.java │ │ │ │ ├── RecordingResultWs2.java │ │ │ │ ├── ReleaseGroupResultWs2.java │ │ │ │ ├── SearchResultWs2.java │ │ │ │ └── listelement │ │ │ │ │ ├── WorkSearchResultsWs2.java │ │ │ │ │ ├── LabelSearchResultsWs2.java │ │ │ │ │ ├── AnnotationSearchResultsWs2.java │ │ │ │ │ ├── ArtistSearchResultsWs2.java │ │ │ │ │ ├── RecordingSearchResultsWs2.java │ │ │ │ │ ├── ReleaseSearchResultsWs2.java │ │ │ │ │ ├── CollectionSearchResultsWs2.java │ │ │ │ │ └── ReleaseGroupSearchResultsWs2.java │ │ │ ├── OffsetWs2.java │ │ │ ├── entity │ │ │ │ ├── listelement │ │ │ │ │ ├── WorkListWs2.java │ │ │ │ │ ├── OffsetListWs2.java │ │ │ │ │ ├── DiscListWs2.java │ │ │ │ │ ├── ArtistListWs2.java │ │ │ │ │ ├── ReleaseListWs2.java │ │ │ │ │ ├── LabelListWs2.java │ │ │ │ │ ├── RecordingListWs2.java │ │ │ │ │ ├── CollectionListWs2.java │ │ │ │ │ └── ReleaseGroupListWs2.java │ │ │ │ └── CollectionWs2.java │ │ │ ├── TagWs2.java │ │ │ ├── RatingsWs2.java │ │ │ ├── AnnotationListWs2.java │ │ │ ├── AnnotationWs2.java │ │ │ ├── RelationListWs2.java │ │ │ ├── LifeSpanWs2.java │ │ │ ├── TrackListWs2.java │ │ │ ├── ReleaseEventListWs2.java │ │ │ ├── ArtistCreditWs2.java │ │ │ ├── LabelInfoListWs2.java │ │ │ ├── CoverArtArchiveWs2.java │ │ │ ├── LabelInfoWs2.java │ │ │ ├── NameCreditWs2.java │ │ │ ├── ReleaseEventWs2.java │ │ │ ├── PuidWs2.java │ │ │ ├── IsrcWs2.java │ │ │ └── AliasWs2.java │ │ ├── MBWS2Exception.java │ │ ├── discid │ │ │ └── DiscIdException.java │ │ ├── coverart │ │ │ ├── ImageGetter.java │ │ │ └── GetterExample.java │ │ └── includes │ │ │ ├── WorkIncludesWs2.java │ │ │ ├── ReleaseGroupIncludesWs2.java │ │ │ ├── RecordingIncludesWs2.java │ │ │ └── CollectionIncludesWs2.java │ │ └── mc2 │ │ └── util │ │ └── exceptions │ │ └── MC2Exception.java └── test │ └── resources │ └── log4j.xml ├── nbproject ├── genfiles.properties └── project.xml ├── AUTHORS.txt ├── .github └── workflows │ ├── publish.yaml │ └── main.yaml ├── COPYING.txt ├── README.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | 3 | ## Android Studio/IntelliJ 4 | .idea 5 | *.iml -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schnatterer/musicbrainzws2-java/nusicFork/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /76df3287-6cda-33eb-8e9a-044b5e15ffdd_829521842.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schnatterer/musicbrainzws2-java/nusicFork/76df3287-6cda-33eb-8e9a-044b5e15ffdd_829521842.jpg -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ------------------------- 3 | 4 | Use the ant targets in build/build.xml to run the unit tests, 5 | build the project or generate the javadoc. -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/utils/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Various utilities to simplify common tasks.

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Provides a collection of classes for MusicBrainz XML Web Service 2.

7 |

Related Documentation

8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/impl/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Default implementation of a web service.

7 | 8 | 9 | 10 | @see org.musicbrainz.webservice.WebService 11 | 12 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/EntitySearchInterface.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | public interface EntitySearchInterface { 6 | 7 | public List getFullList(); 8 | public List getFirstPage(); 9 | public List getNextPage(); 10 | 11 | public boolean hasMore(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/element/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

This package contains some helper classes for the parser (mainly representing xml elements)

7 | 8 | 9 | @see org.musicbrainz.wsxml.MbXmlParser 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/LabelBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.Map; 4 | 5 | public class LabelBrowseFilterWs2 extends BrowseFilterWs2 6 | { 7 | 8 | public LabelBrowseFilterWs2() { 9 | super(); 10 | } 11 | @Override 12 | public Map createParameters() 13 | { 14 | Map map = super.createParameters(); 15 | 16 | return map; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/WorkBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.Map; 4 | 5 | public class WorkBrowseFilterWs2 extends BrowseFilterWs2 6 | { 7 | 8 | public WorkBrowseFilterWs2() { 9 | super(); 10 | } 11 | 12 | @Override 13 | public Map createParameters() 14 | { 15 | Map map = super.createParameters(); 16 | 17 | return map; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=0241f2d4 2 | build.xml.script.CRC32=b27a5aec 3 | build.xml.stylesheet.CRC32=28e38971@1.44.1.45 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=0241f2d4 7 | nbproject/build-impl.xml.script.CRC32=c63ebea6 8 | nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 9 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/ArtistBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.Map; 4 | 5 | public class ArtistBrowseFilterWs2 extends BrowseFilterWs2 6 | { 7 | 8 | public ArtistBrowseFilterWs2() { 9 | super(); 10 | } 11 | 12 | @Override 13 | public Map createParameters() 14 | { 15 | Map map = super.createParameters(); 16 | 17 | return map; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/RecordingBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.Map; 4 | 5 | public class RecordingBrowseFilterWs2 extends BrowseFilterWs2 6 | { 7 | 8 | public RecordingBrowseFilterWs2() { 9 | super(); 10 | } 11 | 12 | @Override 13 | public Map createParameters() 14 | { 15 | Map map = super.createParameters(); 16 | 17 | return map; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/AnnotationResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.AnnotationWs2; 4 | 5 | /** 6 | * Represents an annotation result. 7 | */ 8 | public class AnnotationResultWs2 extends SearchResultWs2 { 9 | 10 | public AnnotationWs2 getAnnotation() { 11 | return (AnnotationWs2)super.getEntity(); 12 | } 13 | 14 | public void setAnnotation(AnnotationWs2 annotation) { 15 | super.setEntity(annotation); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/MBWS2Exception.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz; 2 | 3 | /** 4 | * All application specific exceptions extend this class. 5 | */ 6 | 7 | public class MBWS2Exception extends Exception { 8 | 9 | public MBWS2Exception() { 10 | super(); 11 | } 12 | 13 | public MBWS2Exception(String message, Throwable cause) { 14 | super(message, cause); 15 | } 16 | 17 | public MBWS2Exception(String message) { 18 | super(message); 19 | } 20 | 21 | public MBWS2Exception(Throwable cause) { 22 | super(cause); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/mc2/util/exceptions/MC2Exception.java: -------------------------------------------------------------------------------- 1 | package org.mc2.util.exceptions; 2 | 3 | /** 4 | * All application specific exceptions extend this class. 5 | */ 6 | 7 | public class MC2Exception extends Exception { 8 | private static final long serialVersionUID = 1L; 9 | public MC2Exception() { 10 | super(); 11 | } 12 | 13 | public MC2Exception(String message, Throwable cause) { 14 | super(message, cause); 15 | } 16 | 17 | public MC2Exception(String message) { 18 | super(message); 19 | } 20 | 21 | public MC2Exception(Throwable cause) { 22 | super(cause); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/WorkResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.WorkWs2; 4 | 5 | /** 6 | * Represents an release result. 7 | */ 8 | public class WorkResultWs2 extends SearchResultWs2 { 9 | 10 | /** 11 | * @return the work 12 | */ 13 | public WorkWs2 getWork() { 14 | return (WorkWs2)super.getEntity(); 15 | } 16 | 17 | /** 18 | * @param work the work to set 19 | */ 20 | public void setWork(WorkWs2 work) { 21 | super.setEntity(work); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/OffsetWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | public class OffsetWs2 { 4 | private Integer position; 5 | private Integer offset; 6 | 7 | public OffsetWs2() { 8 | } 9 | 10 | public Integer getPosition() { 11 | return position; 12 | } 13 | 14 | public void setPosition(Integer position) { 15 | this.position = position; 16 | } 17 | 18 | public Integer getOffset() { 19 | return offset; 20 | } 21 | 22 | public void setOffset(Integer offset) { 23 | this.offset = offset; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/LabelResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.LabelWs2; 4 | 5 | /** 6 | * Represents a label result. 7 | */ 8 | public class LabelResultWs2 extends SearchResultWs2 { 9 | 10 | /* 11 | * @return the label 12 | */ 13 | public LabelWs2 getLabel() { 14 | return (LabelWs2)super.getEntity(); 15 | } 16 | 17 | /** 18 | * @param label the label to set 19 | */ 20 | public void setLabel(LabelWs2 label) { 21 | super.setEntity(label); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/WebServiceException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | import org.musicbrainz.MBWS2Exception; 4 | 5 | /** 6 | * A general web service exception 7 | */ 8 | public class WebServiceException extends MBWS2Exception 9 | { 10 | public WebServiceException() { 11 | super(); 12 | } 13 | 14 | public WebServiceException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | public WebServiceException(String message) { 19 | super(message); 20 | } 21 | 22 | public WebServiceException(Throwable cause) { 23 | super(cause); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/discid/DiscIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Nov 29, 2003 3 | */ 4 | package org.musicbrainz.discid; 5 | 6 | 7 | /** 8 | * libshout: org.xiph.libshout.ShoutException 9 | * 10 | * @author andy 11 | */ 12 | public class DiscIdException extends Exception { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | public static final int SHOUTERR_SUCCESS=0; 17 | public static final int SHOUTERR_NOERROR=-1; 18 | 19 | /** 20 | * Constructor 21 | * @param message exception message 22 | */ 23 | public DiscIdException(String message) { 24 | super(message); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/ArtistResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.ArtistWs2; 4 | 5 | 6 | /** 7 | * Represents an artist result. 8 | */ 9 | public class ArtistResultWs2 extends SearchResultWs2 { 10 | 11 | /** 12 | * @return the artist 13 | */ 14 | public ArtistWs2 getArtist() { 15 | return (ArtistWs2)super.getEntity(); 16 | } 17 | 18 | /** 19 | * @param artist the artist to set 20 | */ 21 | public void setArtist(ArtistWs2 artist) { 22 | super.setEntity(artist); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/ReleaseResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.ReleaseWs2; 4 | 5 | /** 6 | * Represents an release result. 7 | */ 8 | public class ReleaseResultWs2 extends SearchResultWs2 { 9 | 10 | /** 11 | * @return the release 12 | */ 13 | public ReleaseWs2 getRelease() { 14 | return (ReleaseWs2)super.getEntity(); 15 | } 16 | 17 | /** 18 | * @param release the track to set 19 | */ 20 | public void setRelease(ReleaseWs2 release) { 21 | super.setEntity(release); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/CollectionResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.CollectionWs2; 4 | 5 | 6 | /** 7 | * Represents an artist result. 8 | */ 9 | public class CollectionResultWs2 extends SearchResultWs2 { 10 | 11 | /** 12 | * @return the artist 13 | */ 14 | public CollectionWs2 getCollection() { 15 | return (CollectionWs2)super.getEntity(); 16 | } 17 | 18 | /** 19 | * @param artist the artist to set 20 | */ 21 | public void setCollection(CollectionWs2 artist) { 22 | super.setEntity(artist); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/MbXMLParseException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.wsxml; 2 | 3 | 4 | /** 5 | * This exception occurs if the xml stream could not be parsed 6 | * (i.e if it is not valid). 7 | * 8 | * @author Patrick Ruhkopf 9 | */ 10 | public class MbXMLParseException extends MbXMLException { 11 | 12 | public MbXMLParseException() { 13 | super(); 14 | } 15 | 16 | public MbXMLParseException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public MbXMLParseException(String message) { 21 | super(message); 22 | } 23 | 24 | public MbXMLParseException(Throwable cause) { 25 | super(cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/MbXMLException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.wsxml; 2 | 3 | import org.musicbrainz.MBWS2Exception; 4 | 5 | /** 6 | * This exception and its sublcasses are thrown by 7 | * {@link MbXmlParser} implementations. 8 | * 9 | * @author Patrick Ruhkopf 10 | */ 11 | public class MbXMLException extends MBWS2Exception { 12 | 13 | public MbXMLException() { 14 | super(); 15 | } 16 | 17 | public MbXMLException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | public MbXMLException(String message) { 22 | super(message); 23 | } 24 | 25 | public MbXMLException(Throwable cause) { 26 | super(cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/RecordingResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.RecordingWs2; 4 | 5 | 6 | /** 7 | * Represents an recording result. 8 | */ 9 | public class RecordingResultWs2 extends SearchResultWs2 { 10 | 11 | /** 12 | * @return the recording 13 | */ 14 | public RecordingWs2 getRecording() { 15 | return (RecordingWs2)super.getEntity(); 16 | } 17 | 18 | /** 19 | * @param recording the recording to set 20 | */ 21 | public void setRecording(RecordingWs2 recording) { 22 | super.setEntity(recording); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/ReleaseGroupResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.ReleaseGroupWs2; 4 | 5 | 6 | /** 7 | * Represents an release result. 8 | */ 9 | public class ReleaseGroupResultWs2 extends SearchResultWs2 { 10 | 11 | /** 12 | * @return the releaseGroup 13 | */ 14 | public ReleaseGroupWs2 getReleaseGroup() { 15 | return (ReleaseGroupWs2)super.getEntity(); 16 | } 17 | 18 | /** 19 | * @param releaseGroup the releaseGroup to set 20 | */ 21 | public void setReleaseGroup(ReleaseGroupWs2 releaseGroup) { 22 | super.setEntity(releaseGroup); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/SubmissionQueryWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import org.musicbrainz.query.QueryWs2; 4 | import org.musicbrainz.webservice.WebService; 5 | import org.musicbrainz.webservice.WebServiceException; 6 | import org.musicbrainz.wsxml.MbXMLException; 7 | import org.musicbrainz.wsxml.element.Metadata; 8 | 9 | 10 | public class SubmissionQueryWs2 extends QueryWs2{ 11 | 12 | 13 | public SubmissionQueryWs2(){ 14 | super(); 15 | } 16 | 17 | public SubmissionQueryWs2(WebService ws){ 18 | super(ws); 19 | } 20 | public Metadata post(Metadata md) throws WebServiceException, MbXMLException{ 21 | 22 | return super.postToWebService(md); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/AuthorizationException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | /** 4 | * An security exception that is thrown when a user is 5 | * not authorized to access a particular resource. 6 | */ 7 | public class AuthorizationException extends WebServiceException { 8 | 9 | /** 10 | * Default constructor 11 | */ 12 | public AuthorizationException() { 13 | } 14 | 15 | /** 16 | * @param message 17 | * @param cause 18 | */ 19 | public AuthorizationException(String message, Throwable cause) { 20 | super(message, cause); 21 | } 22 | 23 | /** 24 | * @param message 25 | */ 26 | public AuthorizationException(String message) { 27 | super(message); 28 | } 29 | 30 | /** 31 | * @param cause 32 | */ 33 | public AuthorizationException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

A parser for the Music Metadata XML Format (MMD).

7 |

8 | This module contains {@link org.musicbrainz.wsxml.impl.JDOMParserWs2}, which parses the 9 | Music Metadata XML Format (MMD) returned by the MusicBrainz webservice. 10 | There are also DOM helper functions in this module used by the parser which probably 11 | aren't useful to users. 12 |

13 |

14 | You can implement your own {@link org.musicbrainz.wsxml.MbXmlParser} and inject it 15 | through one of the {@link org.musicbrainz.query.QueryWs2} constructors to use it.

16 | 17 | 18 | @see org.musicbrainz.wsxml.impl.JDOMParserWs2 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/ResponseException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | /** 4 | * Server returned invalid data. 5 | */ 6 | public class ResponseException extends WebServiceException { 7 | 8 | /** 9 | * 10 | */ 11 | public ResponseException() { 12 | // TODO Auto-generated constructor stub 13 | } 14 | 15 | /** 16 | * @param message 17 | * @param cause 18 | */ 19 | public ResponseException(String message, Throwable cause) { 20 | super(message, cause); 21 | // TODO Auto-generated constructor stub 22 | } 23 | 24 | /** 25 | * @param message 26 | */ 27 | public ResponseException(String message) { 28 | super(message); 29 | // TODO Auto-generated constructor stub 30 | } 31 | 32 | /** 33 | * @param cause 34 | */ 35 | public ResponseException(Throwable cause) { 36 | super(cause); 37 | // TODO Auto-generated constructor stub 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | /** 4 | * Indicates that the requested resource was not found. 5 | */ 6 | public class ResourceNotFoundException extends WebServiceException { 7 | 8 | /** 9 | * 10 | */ 11 | public ResourceNotFoundException() { 12 | // TODO Auto-generated constructor stub 13 | } 14 | 15 | /** 16 | * @param message 17 | * @param cause 18 | */ 19 | public ResourceNotFoundException(String message, Throwable cause) { 20 | super(message, cause); 21 | // TODO Auto-generated constructor stub 22 | } 23 | 24 | /** 25 | * @param message 26 | */ 27 | public ResourceNotFoundException(String message) { 28 | super(message); 29 | // TODO Auto-generated constructor stub 30 | } 31 | 32 | /** 33 | * @param cause 34 | */ 35 | public ResourceNotFoundException(Throwable cause) { 36 | super(cause); 37 | // TODO Auto-generated constructor stub 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Classes for interacting with the MusicBrainz XML web service.

8 |

Implementations of the {@link org.musicbrainz.webservice.WebService} interface talk to 9 | a server implementing the MusicBrainz XML web service. They mainly handle URL generation 10 | and network I/O. Extend {@link org.musicbrainz.webservice.DefaultWebServiceWs2} if maximum 11 | control is needed.

12 |

The {@link org.musicbrainz.query.QueryWs2} class provides a convenient interface to 13 | the most commonly used features of the web service. By default it uses 14 | {@link org.musicbrainz.webservice.impl.HttpClientWebServiceWs2} to retrieve data and 15 | {@link org.musicbrainz.wsxml.impl.JDOMParserWs2} to parse the responses. The results are 16 | object trees using the MusicBrainz domain model.

17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/FilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for collections.

7 | * 8 | *

This is the interface all filters have to implement. Filter classes 9 | * are initialized with a set of criteria and are then applied to 10 | * collections of items. The criteria are usually strings or integer 11 | * values, depending on the filter.

12 | * 13 | * @author Patrick Ruhkopf 14 | */ 15 | public interface FilterWs2 { 16 | 17 | /** 18 | * Create a map of query parameters. 19 | * 20 | * This method creates a list of (parameter, value) 21 | * tuples, based on the contents of the implementing subclass. 22 | * parameter is a string containing a parameter name 23 | * and value an arbitrary string. No escaping of those 24 | * strings is required. 25 | * 26 | * @return A map containing (key, value) pairs. 27 | */ 28 | public Map createParameters(); 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Authors: 2 | 3 | Marco Curti 4 | - Java implementation of the MusicBrainz web service version 2.0 client 5 | 6 | ------------------------------------------------------------------- 7 | Original Authors of jmb-wsc 8 | 9 | Patrick Ruhkopf 10 | - Java implementation of the MusicBrainz web service client 11 | 12 | ------------------------------------------------------------------- 13 | 14 | Original Authors of python-musicbrainz-2 15 | 16 | Matthias Friedrich 17 | - Designed, implemented and documented this package. 18 | 19 | Contributors: 20 | 21 | Lukáš Lalinský 22 | - Fixed several bugs and tested windows/ctypes compatibility. 23 | - Patch for changing TRMs to PUIDs. 24 | - Created and submitted Debian/Ubuntu packages. 25 | 26 | Nikki 27 | - Tested compatibility with python-2.3 on Debian. 28 | - Provided country/language/script lists. 29 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/UserTagSubmissionWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import org.musicbrainz.model.RatingsWs2; 4 | import org.musicbrainz.model.TagWs2; 5 | import org.musicbrainz.model.entity.EntityWs2; 6 | import org.musicbrainz.webservice.WebService; 7 | 8 | /** 9 | * List of Tags to be submitted to the Web Service. 10 | * 11 | **/ 12 | public class UserTagSubmissionWs2 extends SubmissionWs2{ 13 | 14 | 15 | public UserTagSubmissionWs2(){ 16 | super(TAG_POST); 17 | } 18 | public UserTagSubmissionWs2(WebService ws){ 19 | super(ws, TAG_POST); 20 | } 21 | 22 | @Override 23 | protected EntityElement setData(EntityWs2 entity, String entityType) { 24 | 25 | EntityElement el = new EntityElement(); 26 | el.setEntityType(entityType); 27 | el.setId(entity.getId()); 28 | 29 | for (TagWs2 tag : entity.getUserTags()) 30 | { 31 | el.addTag(tag.getName()); 32 | } 33 | return el; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/RequestException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | /** 4 | * A request exception indicates that the web service 5 | * request was invalid (e.g. invalid id or include tags). 6 | */ 7 | public class RequestException extends WebServiceException { 8 | 9 | /** 10 | * 11 | */ 12 | public RequestException() { 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | /** 17 | * @param message 18 | * @param cause 19 | */ 20 | public RequestException(String message, Throwable cause) { 21 | super(message, cause); 22 | // TODO Auto-generated constructor stub 23 | } 24 | 25 | /** 26 | * @param message 27 | */ 28 | public RequestException(String message) { 29 | super(message); 30 | // TODO Auto-generated constructor stub 31 | } 32 | 33 | /** 34 | * @param cause 35 | */ 36 | public RequestException(Throwable cause) { 37 | super(cause); 38 | // TODO Auto-generated constructor stub 39 | } 40 | 41 | /** 42 | * @param args 43 | */ 44 | public static void main(String[] args) { 45 | // TODO Auto-generated method stub 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/WorkListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.WorkWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Works 12 | */ 13 | public class WorkListWs2 extends ListElement{ 14 | 15 | private List works = new ArrayList(); 16 | 17 | /** 18 | * @return the works 19 | */ 20 | public List getWorks() { 21 | return works; 22 | } 23 | 24 | /** 25 | * @param works the works to set 26 | */ 27 | public void setWorks(List works) { 28 | this.works = works; 29 | } 30 | 31 | public void addWorks(WorkWs2 work) 32 | { 33 | if (works == null) { 34 | works = new ArrayList(); 35 | } 36 | 37 | works.add(work); 38 | } 39 | public void addAllWorks(List WorkList) 40 | { 41 | if (works == null) { 42 | works = new ArrayList(); 43 | } 44 | 45 | works.addAll(WorkList); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/TagWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | *

Represents a Tag for an entity (not release at the moment). 7 | * count is the times this tag has been added by different people.

8 | */ 9 | public class TagWs2 10 | { 11 | public TagWs2(){ 12 | 13 | } 14 | public TagWs2(String name){ 15 | this.name = name; 16 | } 17 | private static Logger log = Logger.getLogger(TagWs2.class.getName()); 18 | /** 19 | * The tag 20 | */ 21 | private String name; 22 | /** 23 | * The count of peoples who adds this tag 24 | */ 25 | private Long count; 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | /** 35 | * @return the count 36 | */ 37 | public Long getCount() { 38 | return count; 39 | } 40 | 41 | /** 42 | * @param count the count to set 43 | */ 44 | public void setCount(Long count) { 45 | this.count = count; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/UserRatingSubmissionWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import org.musicbrainz.model.RatingsWs2; 4 | import org.musicbrainz.model.TagWs2; 5 | import org.musicbrainz.model.entity.EntityWs2; 6 | import org.musicbrainz.webservice.WebService; 7 | 8 | /** 9 | * List of Ratings to be submitted to the Web Service. 10 | * 11 | **/ 12 | public class UserRatingSubmissionWs2 extends SubmissionWs2{ 13 | 14 | 15 | public UserRatingSubmissionWs2(){ 16 | 17 | super(RATING_POST); 18 | 19 | } 20 | public UserRatingSubmissionWs2(WebService ws){ 21 | super(ws, RATING_POST); 22 | } 23 | @Override 24 | protected EntityElement setData(EntityWs2 entity, String entityType) { 25 | 26 | EntityElement el = new EntityElement(); 27 | el.setEntityType(entityType); 28 | el.setId(entity.getId()); 29 | 30 | RatingsWs2 rating = entity.getUserRating(); 31 | //rating must be postet in percent ratio. 32 | el.setUserRating(Math.round(rating.getAverageRating()/5*100)); 33 | 34 | return el; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/RatingsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | 7 | */ 8 | public class RatingsWs2 9 | { 10 | 11 | private static Logger log = Logger.getLogger(RatingsWs2.class.getName()); 12 | 13 | /** 14 | * the numebr of people who votes 15 | */ 16 | private Long votesCount=0L; 17 | /** 18 | * the average rating 19 | */ 20 | private Float averageRating=0F; 21 | 22 | /** 23 | * @return the votesCount 24 | */ 25 | public Long getVotesCount() { 26 | return votesCount; 27 | } 28 | 29 | /** 30 | * @param votesCount the votesCount to set 31 | */ 32 | public void setVotesCount(Long votesCount) { 33 | this.votesCount = votesCount; 34 | } 35 | 36 | /** 37 | * @return the averageRating 38 | */ 39 | public Float getAverageRating() { 40 | return averageRating; 41 | } 42 | 43 | /** 44 | * @param averageRating the averageRating to set 45 | */ 46 | public void setAverageRating(Float averageRating) { 47 | this.averageRating = averageRating; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/AnnotationListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.AnnotationWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Annotations 12 | */ 13 | public class AnnotationListWs2 extends ListElement{ 14 | 15 | private List annotations = new ArrayList(); 16 | 17 | public List getAnnotations() { 18 | return annotations; 19 | } 20 | 21 | public void setAnnotations(List annotations) { 22 | this.annotations = annotations; 23 | } 24 | 25 | public void addAnnotations(AnnotationWs2 annotation) 26 | { 27 | if (annotations == null) { 28 | annotations = new ArrayList(); 29 | } 30 | 31 | annotations.add(annotation); 32 | } 33 | public void addAllAnnotations(List annotationList) 34 | { 35 | if (annotations == null) { 36 | annotations = new ArrayList(); 37 | } 38 | 39 | annotations.addAll(annotationList); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/SubmissionException.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import org.musicbrainz.wsxml.MbXMLException; 4 | 5 | 6 | /** 7 | * A submission exception indicates that the web service 8 | * submission (post) request was invalid (e.g. invalir entity type). 9 | */ 10 | public class SubmissionException extends MbXMLException { 11 | 12 | public SubmissionException() { 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | /** 17 | * @param message 18 | * @param cause 19 | */ 20 | public SubmissionException(String message, Throwable cause) { 21 | super(message, cause); 22 | // TODO Auto-generated constructor stub 23 | } 24 | 25 | /** 26 | * @param message 27 | */ 28 | public SubmissionException(String message) { 29 | super(message); 30 | // TODO Auto-generated constructor stub 31 | } 32 | 33 | /** 34 | * @param cause 35 | */ 36 | public SubmissionException(Throwable cause) { 37 | super(cause); 38 | // TODO Auto-generated constructor stub 39 | } 40 | 41 | /** 42 | * @param args 43 | */ 44 | public static void main(String[] args) { 45 | // TODO Auto-generated method stub 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: Publish on maven central 2 | 3 | on: 4 | push: 5 | branches: [ nusicFork ] 6 | 7 | # Allows you to run this workflow manually from the Actions tab 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-20.04 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Set up JDK 11 17 | uses: actions/setup-java@v2 18 | with: 19 | java-version: 11 20 | distribution: 'temurin' 21 | - name: Cache Maven packages 22 | uses: actions/cache@v1 23 | with: 24 | path: ~/.m2 25 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 26 | restore-keys: ${{ runner.os }}-m2 27 | - name: Release Maven package 28 | uses: samuelmeuli/action-maven-publish@v1 29 | with: 30 | server_id: ossrh 31 | gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} 32 | gpg_passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} 33 | nexus_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }} 34 | nexus_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} 35 | maven_profiles: release 36 | maven_args: -DskipTests -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/SearchResultWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult; 2 | 3 | import org.musicbrainz.model.entity.EntityWs2; 4 | 5 | /** 6 | * Represents a search result. 7 | */ 8 | public abstract class SearchResultWs2 9 | { 10 | /** 11 | * The score indicates how good this result matches the search 12 | * parameters. The higher the value, the better the match. 13 | * The score is a number between 0 and 100. 14 | */ 15 | private Integer score; 16 | /** 17 | * The Entity in the result. 18 | */ 19 | private EntityWs2 entity; 20 | 21 | /** 22 | * @return the score 23 | */ 24 | public Integer getScore() { 25 | return score; 26 | } 27 | /** 28 | * @param score the score to set 29 | */ 30 | public void setScore(Integer score) { 31 | this.score = score; 32 | } 33 | 34 | /** 35 | * @return the entity 36 | */ 37 | public EntityWs2 getEntity() { 38 | return entity; 39 | } 40 | 41 | /** 42 | * @param entity the entity to set 43 | */ 44 | public void setEntity(EntityWs2 entity) { 45 | this.entity = entity; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/AnnotationWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import org.musicbrainz.model.entity.EntityWs2; 4 | 5 | /* 6 | *

Annotation Text for any Entity

7 | * 8 | */ 9 | public class AnnotationWs2 extends EntityWs2 10 | { 11 | 12 | private String type; 13 | private String name; 14 | private String entity; 15 | private String text; 16 | 17 | public AnnotationWs2() { 18 | 19 | } 20 | 21 | public String getType() { 22 | return type; 23 | } 24 | public void setType(String type) { 25 | this.type = type; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | public void setName(String title) { 32 | this.name = title; 33 | } 34 | 35 | public String getEntity() { 36 | return entity; 37 | } 38 | public void setEntity(String entity) { 39 | this.entity = entity; 40 | } 41 | 42 | public String getText() { 43 | return text; 44 | } 45 | public void setText(String text) { 46 | this.text = text; 47 | } 48 | 49 | 50 | @Override 51 | public String toString() { 52 | return "annotation mbid: "+getEntity(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/ReleaseGroupBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.Map; 4 | import org.musicbrainz.filter.ReleaseTypeFilterWs2; 5 | 6 | public class ReleaseGroupBrowseFilterWs2 extends BrowseFilterWs2 7 | { 8 | private ReleaseTypeFilterWs2 releaseTypeFilter =new ReleaseTypeFilterWs2(); 9 | 10 | public ReleaseGroupBrowseFilterWs2() { 11 | super(); 12 | } 13 | 14 | @Override 15 | public Map createParameters() 16 | { 17 | Map map = super.createParameters(); 18 | 19 | //Combine default filter's parameters with release filter's 20 | map.putAll(getReleaseTypeFilter().createParameters()); 21 | 22 | return map; 23 | } 24 | 25 | /** 26 | * @return the releaseTypeFilter 27 | */ 28 | public ReleaseTypeFilterWs2 getReleaseTypeFilter() { 29 | return releaseTypeFilter; 30 | } 31 | 32 | /** 33 | * @param releaseTypeFilter the releaseTypeFilter to set 34 | */ 35 | public void setReleaseTypeFilter(ReleaseTypeFilterWs2 releaseTypeFilter) { 36 | this.releaseTypeFilter = releaseTypeFilter; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/RelationListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.wsxml.element.ListElement; 7 | 8 | /** 9 | * A list of Relations 10 | */ 11 | public class RelationListWs2 extends ListElement { 12 | 13 | private List relations 14 | = new ArrayList(); 15 | 16 | /** 17 | * @return the relations 18 | */ 19 | public List getRelations() { 20 | return relations; 21 | } 22 | 23 | /** 24 | * @param relations the relations to set 25 | */ 26 | public void setRelations(List relations) { 27 | this.relations = relations; 28 | } 29 | 30 | public void addRelation(RelationWs2 relation) 31 | { 32 | if (relations == null) 33 | relations = new ArrayList(); 34 | 35 | relations.add(relation); 36 | 37 | } 38 | public void addAllRelations(List RelationList) 39 | { 40 | if (relations == null) { 41 | relations = new ArrayList(); 42 | } 43 | 44 | relations.addAll(RelationList); 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/WorkSearchbyTitle.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.WorkSearchFilterWs2; 6 | import org.musicbrainz.model.searchresult.WorkResultWs2; 7 | import org.musicbrainz.query.search.WorkSearchWs2; 8 | 9 | public class WorkSearchbyTitle { 10 | 11 | private WorkSearchWs2 q; 12 | private WorkSearchFilterWs2 f; 13 | 14 | public WorkSearchbyTitle(String title){ 15 | 16 | f = new WorkSearchFilterWs2(); 17 | f.setLimit((long)100); 18 | f.setOffset((long)0); 19 | f.setMinScore((long)20); 20 | 21 | f.setWorkTitle(title); 22 | 23 | q = new WorkSearchWs2(f); 24 | 25 | } 26 | public List getFullList() { 27 | 28 | return q.getFullList(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | f.setOffset((long)0); 34 | q = new WorkSearchWs2(f); 35 | return q.getFirstPage(); 36 | } 37 | public List getNextPage() { 38 | return q.getNextPage(); 39 | } 40 | 41 | public boolean hasMore(){ 42 | return q.hasMore(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/OffsetListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.logging.Logger; 6 | 7 | import org.musicbrainz.model.OffsetWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | /** 11 | *

A List of disc offsets referred by a disc

12 | 13 | */ 14 | public class OffsetListWs2 extends ListElement 15 | { 16 | private static Logger log = Logger.getLogger(OffsetListWs2.class.getName()); 17 | 18 | private List offsets 19 | = new ArrayList(); 20 | 21 | public OffsetListWs2() { 22 | } 23 | 24 | public OffsetListWs2(List offsets) 25 | { 26 | if (offsets !=null) 27 | { 28 | for (OffsetWs2 element : offsets) 29 | { 30 | addOffset(element); 31 | } 32 | } 33 | } 34 | 35 | public List getOffsets(){ 36 | return offsets; 37 | } 38 | 39 | private void addOffset(OffsetWs2 element){ 40 | 41 | offsets.add(element); 42 | 43 | } 44 | 45 | /* (non-Javadoc) 46 | * @see java.lang.Object#toString() 47 | */ 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/WorkSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.WorkListWs2; 7 | import org.musicbrainz.model.searchresult.WorkResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | public class WorkSearchResultsWs2 extends ListElement{ 11 | 12 | protected List workResults = new ArrayList(); 13 | private WorkListWs2 workList = new WorkListWs2(); 14 | 15 | public void addWorkResult(WorkResultWs2 workResult) 16 | { 17 | if (workResults == null) { 18 | workResults = new ArrayList(); 19 | } 20 | if (getWorkList() == null) { 21 | workList = new WorkListWs2(); 22 | } 23 | workResults.add(workResult); 24 | workList.addWorks(workResult.getWork()); 25 | 26 | workList.setCount(getCount()); 27 | workList.setOffset(getOffset()); 28 | } 29 | 30 | public List getWorkResults() { 31 | return workResults; 32 | } 33 | 34 | public WorkListWs2 getWorkList() { 35 | return workList; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/MbXmlWriter.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.wsxml; 2 | 3 | import java.io.InputStream; 4 | 5 | import org.musicbrainz.query.submission.SubmissionWs2; 6 | import org.musicbrainz.wsxml.element.Metadata; 7 | 8 | 9 | /** 10 | * A simple writer interface to built XML body of the MusicBrainz's 11 | * web service post reqests. The {@link org.musicbrainz.webservice.DefaultWebServiceWs2} class uses 12 | * {@link org.musicbrainz.wsxml.impl.JDOMWriterWs2} as a default {@link MbXmlWriter} implementation. 13 | * However, you can write your own implementation and inject it to the 14 | * {@link org.musicbrainz.webservice.DefaultWebServiceWs2} using particolar constructor. 15 | 16 | */ 17 | public interface MbXmlWriter { 18 | 19 | /** 20 | * Parses a populated {@link Metadata} object and bulid 21 | * the XML string to use as the body of a POST request. 22 | * 23 | * @param metadata the Metadata Object. 24 | * @return an xml String. 25 | * 26 | * @throws MbXMLException A {@link MbXMLException} is thrown 27 | * if the xml could not be writed. In all other exceptional cases 28 | * a general {@link MbXMLException} is thrown. 29 | */ 30 | public String getXmlString (Metadata metadata) throws MbXMLException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/LabelSearchbyName.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | import org.musicbrainz.filter.searchfilter.LabelSearchFilterWs2; 5 | import org.musicbrainz.model.searchresult.LabelResultWs2; 6 | import org.musicbrainz.query.search.LabelSearchWs2; 7 | 8 | 9 | public class LabelSearchbyName implements EntitySearchInterface { 10 | 11 | private LabelSearchWs2 q; 12 | private LabelSearchFilterWs2 f; 13 | 14 | public LabelSearchbyName(String name){ 15 | 16 | f = new LabelSearchFilterWs2(); 17 | f.setLimit((long)100); 18 | f.setOffset((long)0); 19 | f.setMinScore((long)20); 20 | 21 | f.setLabelName(name); 22 | 23 | q = new LabelSearchWs2(f); 24 | 25 | } 26 | public List getFullList() { 27 | 28 | return q.getFullList(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | f.setOffset((long)0); 34 | q = new LabelSearchWs2(f); 35 | return q.getFirstPage(); 36 | } 37 | public List getNextPage() { 38 | return q.getNextPage(); 39 | } 40 | 41 | public boolean hasMore(){ 42 | return q.hasMore(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/ArtistSearchbyName.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.ArtistSearchFilterWs2; 6 | import org.musicbrainz.model.searchresult.ArtistResultWs2; 7 | import org.musicbrainz.query.search.ArtistSearchWs2; 8 | 9 | public class ArtistSearchbyName implements EntitySearchInterface{ 10 | 11 | private ArtistSearchWs2 q; 12 | private ArtistSearchFilterWs2 f; 13 | 14 | public ArtistSearchbyName(String name){ 15 | 16 | f = new ArtistSearchFilterWs2(); 17 | f.setLimit((long)100); 18 | f.setOffset((long)0); 19 | f.setMinScore((long)20); 20 | 21 | f.setArtistName(name); 22 | 23 | q = new ArtistSearchWs2(f); 24 | 25 | } 26 | public List getFullList() { 27 | 28 | return q.getFullList(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | f.setOffset((long)0); 34 | q = new ArtistSearchWs2(f); 35 | return q.getFirstPage(); 36 | } 37 | public List getNextPage() { 38 | return q.getNextPage(); 39 | } 40 | 41 | public boolean hasMore(){ 42 | return q.hasMore(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/MbXmlParser.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.wsxml; 2 | 3 | import java.io.InputStream; 4 | 5 | import org.musicbrainz.wsxml.element.Metadata; 6 | 7 | /** 8 | * A simple parser interface to parse XML responses of the MusicBrainz's 9 | * web service. The {@link org.musicbrainz.webservice.DefaultWebServiceWs2} class uses {@link org.musicbrainz.wsxml.impl.JDOMParserWs2} as a default 10 | * {@link MbXmlParser} implementation. However, you can write your own 11 | * implementation and inject it to the {@link org.musicbrainz.webservice.DefaultWebServiceWs2} using 12 | * particolar constructor: {@link org.musicbrainz.webservice.DefaultWebServiceWs2#DefaultWebServiceWs2(MbXmlParser, MbXmlWriter)} (MbXmlParser)}. 13 | * 14 | * @see Metadata 15 | */ 16 | public interface MbXmlParser { 17 | 18 | /** 19 | * Parses xml from the input stream and returns a populated 20 | * {@link Metadata} object. 21 | * 22 | * @param inputStream The xml stream 23 | * @return A populated {@link Metadata} object. 24 | * 25 | * @throws MbXMLException A {@link MbXMLParseException} is thrown 26 | * if the xml could not be parsed. In all other exceptional cases 27 | * a general {@link MbXMLException} is thrown. 28 | */ 29 | public Metadata parse(InputStream inputStream) throws MbXMLException; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/RecordingSearchbyTitle.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.RecordingSearchFilterWs2; 6 | import org.musicbrainz.model.searchresult.RecordingResultWs2; 7 | import org.musicbrainz.query.search.RecordingSearchWs2; 8 | 9 | public class RecordingSearchbyTitle { 10 | 11 | private RecordingSearchWs2 q; 12 | private RecordingSearchFilterWs2 f; 13 | 14 | public RecordingSearchbyTitle(String title){ 15 | 16 | f = new RecordingSearchFilterWs2(); 17 | f.setLimit((long)100); 18 | f.setOffset((long)0); 19 | f.setMinScore((long)20); 20 | 21 | f.setTitle(title); 22 | 23 | q = new RecordingSearchWs2(f); 24 | 25 | } 26 | public List getFullList() { 27 | 28 | return q.getFullList(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | f.setOffset((long)0); 34 | q = new RecordingSearchWs2(f); 35 | return q.getFirstPage(); 36 | } 37 | public List getNextPage() { 38 | return q.getNextPage(); 39 | } 40 | 41 | public boolean hasMore(){ 42 | return q.hasMore(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/WorkSearchbyArtistId.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.WorkSearchFilterWs2; 6 | import org.musicbrainz.model.searchresult.WorkResultWs2; 7 | import org.musicbrainz.query.search.WorkSearchWs2; 8 | 9 | 10 | public class WorkSearchbyArtistId { 11 | 12 | private WorkSearchWs2 q; 13 | private WorkSearchFilterWs2 f; 14 | 15 | public WorkSearchbyArtistId(String ArtistId){ 16 | 17 | f = new WorkSearchFilterWs2(); 18 | f.setLimit((long)100); 19 | f.setOffset((long)0); 20 | f.setMinScore((long)20); 21 | 22 | String query="arid:"+ArtistId; 23 | 24 | f.setQuery(query); 25 | 26 | q = new WorkSearchWs2(f); 27 | 28 | } 29 | public List getFullList() { 30 | 31 | return q.getFullList(); 32 | 33 | } 34 | public List getFirstPage() { 35 | 36 | f.setOffset((long)0); 37 | q = new WorkSearchWs2(f); 38 | return q.getFirstPage(); 39 | } 40 | public List getNextPage() { 41 | return q.getNextPage(); 42 | } 43 | 44 | public boolean hasMore(){ 45 | return q.hasMore(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/DiscListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import org.musicbrainz.model.entity.DiscWs2; 4 | import org.musicbrainz.wsxml.element.ListElement; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.logging.Logger; 9 | 10 | 11 | /** 12 | *

A List of Disc Info (Disc & catalog number)referred by a release

13 | 14 | */ 15 | public class DiscListWs2 extends ListElement 16 | { 17 | private static Logger log = Logger.getLogger(DiscListWs2.class.getName()); 18 | 19 | /** 20 | * A string containing the complete credit as join 21 | * of credit names in the list. 22 | */ 23 | 24 | private List discs 25 | = new ArrayList(); 26 | 27 | public DiscListWs2(List discs) 28 | { 29 | if (discs!=null) 30 | { 31 | for (DiscWs2 element : discs) 32 | { 33 | addDisc(element); 34 | } 35 | } 36 | } 37 | 38 | public List getDiscs(){ 39 | return discs; 40 | } 41 | 42 | private void addDisc(DiscWs2 element){ 43 | 44 | discs.add(element); 45 | 46 | } 47 | 48 | /* (non-Javadoc) 49 | * @see java.lang.Object#toString() 50 | */ 51 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/DiscTocFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | 7 | public class DiscTocFilterWs2 implements FilterWs2 8 | { 9 | 10 | private String toc; 11 | private Boolean cdStub=true; 12 | 13 | public DiscTocFilterWs2() { 14 | 15 | } 16 | 17 | @Override 18 | public Map createParameters() 19 | { 20 | Map map = new HashMap(); 21 | 22 | // construct the track filter's map 23 | 24 | if (toc != null && !toc.isEmpty()) 25 | map.put("toc",toc); 26 | if (!isCdStub()) 27 | map.put("cdstubs","no"); 28 | 29 | return map; 30 | } 31 | 32 | /** 33 | * @return the toc 34 | */ 35 | public String getToc() { 36 | return toc; 37 | } 38 | 39 | /** 40 | * @param toc the toc to set 41 | */ 42 | public void setToc(String toc) { 43 | this.toc = toc; 44 | } 45 | 46 | /** 47 | * @return the cdStub 48 | */ 49 | public Boolean isCdStub() { 50 | return cdStub; 51 | } 52 | 53 | /** 54 | * @param cdStub the cdStub to set 55 | */ 56 | public void setCdStub(Boolean cdStub) { 57 | this.cdStub = cdStub; 58 | } 59 | 60 | 61 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/LabelSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | import java.util.ArrayList; 3 | import java.util.List; 4 | 5 | import org.musicbrainz.model.entity.listelement.LabelListWs2; 6 | import org.musicbrainz.model.searchresult.LabelResultWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | public class LabelSearchResultsWs2 extends ListElement{ 10 | 11 | private List labelResults = new ArrayList(); 12 | private LabelListWs2 labelList = new LabelListWs2(); 13 | 14 | public void addLabelResult(LabelResultWs2 labelResult) 15 | { 16 | if (getLabelResults() == null) { 17 | labelResults = new ArrayList(); 18 | } 19 | if (getLabelList() == null) { 20 | labelList = new LabelListWs2(); 21 | } 22 | 23 | labelResults.add(labelResult); 24 | labelList.addLabel(labelResult.getLabel()); 25 | labelList.setCount(getCount()); 26 | labelList.setOffset(getOffset()); 27 | } 28 | 29 | public List getLabelResults() { 30 | return labelResults; 31 | } 32 | 33 | public LabelListWs2 getLabelList() { 34 | return labelList; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/ReleaseGroupSearchbyTitle.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.ReleaseGroupSearchFilterWs2; 6 | import org.musicbrainz.model.searchresult.ReleaseGroupResultWs2; 7 | import org.musicbrainz.query.search.ReleaseGroupSearchWs2; 8 | 9 | public class ReleaseGroupSearchbyTitle { 10 | 11 | private ReleaseGroupSearchWs2 q; 12 | private ReleaseGroupSearchFilterWs2 f; 13 | 14 | public ReleaseGroupSearchbyTitle(String title){ 15 | 16 | f = new ReleaseGroupSearchFilterWs2(); 17 | f.setLimit((long)100); 18 | f.setOffset((long)0); 19 | f.setMinScore((long)20); 20 | 21 | f.setTitle(title); 22 | 23 | q = new ReleaseGroupSearchWs2(f); 24 | 25 | } 26 | public List getFullList() { 27 | 28 | return q.getFullList(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | f.setOffset((long)0); 34 | q = new ReleaseGroupSearchWs2(f); 35 | return q.getFirstPage(); 36 | } 37 | public List getNextPage() { 38 | return q.getNextPage(); 39 | } 40 | 41 | public boolean hasMore(){ 42 | return q.hasMore(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/ReleaseSearchbyTitle.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.ReleaseSearchFilterWs2; 7 | import org.musicbrainz.model.searchresult.ReleaseResultWs2; 8 | import org.musicbrainz.query.search.ReleaseSearchWs2; 9 | 10 | public class ReleaseSearchbyTitle { 11 | 12 | private ReleaseSearchWs2 q; 13 | private ReleaseSearchFilterWs2 f; 14 | 15 | public ReleaseSearchbyTitle(String title){ 16 | 17 | f = new ReleaseSearchFilterWs2(); 18 | f.setLimit((long)100); 19 | f.setOffset((long)0); 20 | f.setMinScore((long)20); 21 | 22 | f.setTitle(title); 23 | 24 | q = new ReleaseSearchWs2(f); 25 | 26 | } 27 | public List getFullList() throws MBWS2Exception { 28 | 29 | return q.getFullList(); 30 | 31 | } 32 | public List getFirstPage() throws MBWS2Exception { 33 | 34 | f.setOffset((long)0); 35 | q = new ReleaseSearchWs2(f); 36 | return q.getFirstPage(); 37 | } 38 | public List getNextPage() throws MBWS2Exception { 39 | return q.getNextPage(); 40 | } 41 | 42 | public boolean hasMore(){ 43 | return q.hasMore(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | musicbrainzws2-java 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | libdiscid-java 17 | jar 18 | 19 | jar 20 | clean 21 | jar 22 | 23 | 24 | mc2java 25 | jar 26 | 27 | jar 28 | clean 29 | jar 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/ArtistListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import org.musicbrainz.wsxml.element.ListElement; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.musicbrainz.model.entity.ArtistWs2; 8 | 9 | 10 | /** 11 | * A list of Artists 12 | * 13 | */ 14 | public class ArtistListWs2 extends ListElement{ 15 | 16 | protected List artists = new ArrayList(); 17 | 18 | /** 19 | * @return the artists 20 | */ 21 | public List getArtists() { 22 | return artists; 23 | } 24 | 25 | /** 26 | * @param artists the artists to set 27 | */ 28 | public void setArtist(List artists) { 29 | this.artists = artists; 30 | } 31 | 32 | /** 33 | * Convenience method to adds an artist to the list. 34 | * 35 | * This will create a new ArrayList if {@link #artists} is null. 36 | * 37 | * @param artist 38 | */ 39 | public void addArtist(ArtistWs2 artist) 40 | { 41 | if (artists == null) { 42 | artists = new ArrayList(); 43 | } 44 | artists.add(artist); 45 | } 46 | public void addAllArtists(List artistList) 47 | { 48 | if (artists == null) { 49 | artists = new ArrayList(); 50 | } 51 | 52 | artists.addAll(artistList); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/ReleaseListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.ReleaseWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Releases 12 | */ 13 | public class ReleaseListWs2 extends ListElement{ 14 | 15 | private List releases = new ArrayList(); 16 | 17 | /** 18 | * @return the releases 19 | */ 20 | public List getReleases() { 21 | return releases; 22 | } 23 | 24 | /** 25 | * @param releases the releases to set 26 | */ 27 | public void setReleases(List releases) { 28 | this.releases = releases; 29 | } 30 | 31 | /** 32 | * Adds a release to the list. 33 | * 34 | * It will also create and set new ArrayList if 35 | * {@link #releases} is null. 36 | * 37 | * @param release The release to add 38 | */ 39 | public void addRelease(ReleaseWs2 release) 40 | { 41 | if (releases == null) { 42 | releases = new ArrayList(); 43 | } 44 | 45 | releases.add(release); 46 | } 47 | public void addAllReleases(List releaseList) 48 | { 49 | if (releases == null) { 50 | releases = new ArrayList(); 51 | } 52 | 53 | releases.addAll(releaseList); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/LifeSpanWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | 4 | import java.util.logging.Logger; 5 | 6 | /** 7 | *

A Life Span definition. 8 | * * The definition of the begin date depends on the Entity 9 | * type. For persons, this is the day of birth, for groups 10 | * and Labels is the day was founded 11 | * 12 | * The returned date has the format 'YYYY', 'YYYY-MM', or 13 | * 'YYYY-MM-DD', depending on how much detail is known. 14 | * 15 | * * The definition of the end date depends on the artist's 16 | * type. For persons, this is the day of death, for groups 17 | * and Labels it is the day was dissolved. 18 | * 19 | * The returned date has the format 'YYYY', 'YYYY-MM', or 20 | * 'YYYY-MM-DD', depending on how much detail is known. 21 | 22 | *

23 | */ 24 | public class LifeSpanWs2 25 | { 26 | private static Logger log = Logger.getLogger(LifeSpanWs2.class.getName()); 27 | 28 | private String begin; 29 | private String end; 30 | private boolean ended=false; 31 | 32 | public LifeSpanWs2(String begin, String end, boolean ended) 33 | { 34 | this.begin= begin; 35 | this.end = end; 36 | this.ended = ended; 37 | } 38 | public String getBegin(){ 39 | return begin; 40 | } 41 | public String getEnd(){ 42 | return end; 43 | } 44 | public boolean getEnded(){ 45 | return ended; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/AnnotationSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.AnnotationListWs2; 7 | import org.musicbrainz.model.searchresult.AnnotationResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | public class AnnotationSearchResultsWs2 extends ListElement{ 11 | 12 | protected List annotationResults = new ArrayList(); 13 | private AnnotationListWs2 annotationList = new AnnotationListWs2(); 14 | 15 | public void addAnnotationResult(AnnotationResultWs2 annotationResult) 16 | { 17 | if (annotationResults == null) { 18 | annotationResults = new ArrayList(); 19 | } 20 | if (getAnnotationList() == null) { 21 | annotationList = new AnnotationListWs2(); 22 | } 23 | annotationResults.add(annotationResult); 24 | annotationList.addAnnotations(annotationResult.getAnnotation()); 25 | 26 | annotationList.setCount(getCount()); 27 | annotationList.setOffset(getOffset()); 28 | } 29 | 30 | public List getAnnotationResults() { 31 | return annotationResults; 32 | } 33 | 34 | public AnnotationListWs2 getAnnotationList() { 35 | return annotationList; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/LabelListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.LabelWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Labels 12 | */ 13 | public class LabelListWs2 extends ListElement{ 14 | 15 | private List labels = new ArrayList(); 16 | 17 | /** 18 | * @return the labels 19 | */ 20 | public List getLabels() { 21 | return labels; 22 | } 23 | 24 | /** 25 | * @param labels the labels to set 26 | */ 27 | public void setLabels(List labels) { 28 | this.labels = labels; 29 | } 30 | 31 | /** 32 | * Adds a release to the list. 33 | * 34 | * It will also create and set new ArrayList if 35 | * {@link #labels} is null. 36 | * 37 | * @param label The release to add 38 | */ 39 | public void addLabel(LabelWs2 label) 40 | { 41 | if (labels == null) { 42 | labels = new ArrayList(); 43 | } 44 | 45 | labels.add(label); 46 | } 47 | public void addAllLabels(List labelList) 48 | { 49 | if (labels == null) { 50 | labels = new ArrayList(); 51 | } 52 | 53 | labels.addAll(labelList); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ '*' ] 6 | pull_request: 7 | types: [opened, synchronize, reopened] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-20.04 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | with: 19 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis 20 | - name: Set up JDK 11 21 | uses: actions/setup-java@v2 22 | with: 23 | java-version: 11 24 | distribution: 'temurin' 25 | - name: Cache SonarCloud packages 26 | uses: actions/cache@v1 27 | with: 28 | path: ~/.sonar/cache 29 | key: ${{ runner.os }}-sonar 30 | restore-keys: ${{ runner.os }}-sonar 31 | - name: Cache Maven packages 32 | uses: actions/cache@v1 33 | with: 34 | path: ~/.m2 35 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 36 | restore-keys: ${{ runner.os }}-m2 37 | - name: Build and analyze 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any 40 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 41 | run: ./mvnw -B verify $([[ -n "${SONAR_TOKEN}" ]] && echo org.sonarsource.scanner.maven:sonar-maven-plugin:sonar) -Dsonar.projectKey=info.schnatterer.musicbrainzws2-java:musicbrainzws2-java -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/AnnotationSearchtFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Search annotations by ID for any entity. 7 | * 8 | */ 9 | public class AnnotationSearchtFilterWs2 extends SearchFilterWs2 { 10 | 11 | public static final String ENTITY = "entity"; 12 | 13 | private String entity = null; 14 | 15 | /* (non-Javadoc) 16 | * @see org.musicbrainz.webservice.Filter() 17 | */ 18 | public AnnotationSearchtFilterWs2() { 19 | super(); 20 | } 21 | 22 | @Override 23 | public Map createParameters() 24 | { 25 | Map map = super.createParameters(); 26 | if (this.entity != null) 27 | { 28 | if (map.containsKey(QUERY)) { 29 | throw new IllegalArgumentException("The text and query properties may not be used together!"); 30 | } 31 | 32 | map.put(QUERY, ENTITY+":"+this.entity); 33 | } 34 | else { 35 | if (!map.containsKey(QUERY)) { 36 | throw new IllegalArgumentException("This filter must specify a query or a text!"); 37 | } 38 | } 39 | 40 | return map; 41 | } 42 | 43 | 44 | public String getEntity() { 45 | return entity; 46 | } 47 | 48 | public void setEntity(String entity) { 49 | this.entity = entity; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/RecordingListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.RecordingWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Recordings 12 | */ 13 | public class RecordingListWs2 extends ListElement{ 14 | 15 | private List recordings 16 | = new ArrayList(); 17 | 18 | /** 19 | * @return the recordings 20 | */ 21 | public List getRecordings() { 22 | return recordings; 23 | } 24 | 25 | /** 26 | * @param recordings the recordings to set 27 | */ 28 | public void setRecordings(List recordings) { 29 | this.recordings = recordings; 30 | } 31 | 32 | 33 | /** 34 | * Adds a track to the list. 35 | * 36 | * It will also create and set new ArrayList if 37 | * {@link #recordings} is null. 38 | * 39 | * @param recording The track to add 40 | */ 41 | public void addRecording(RecordingWs2 recording) 42 | { 43 | if (recordings == null) { 44 | recordings = new ArrayList(); 45 | } 46 | 47 | recordings.add(recording); 48 | } 49 | public void addAllRecordings(List recordingList) 50 | { 51 | if (recordings == null) { 52 | recordings = new ArrayList(); 53 | } 54 | 55 | recordings.addAll(recordingList); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/CollectionListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import org.musicbrainz.wsxml.element.ListElement; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.musicbrainz.model.entity.CollectionWs2; 8 | 9 | 10 | /** 11 | * A list of Collections 12 | * 13 | */ 14 | public class CollectionListWs2 extends ListElement{ 15 | 16 | protected List collections = new ArrayList(); 17 | 18 | /** 19 | * @return the collections 20 | */ 21 | public List getCollections() { 22 | return collections; 23 | } 24 | 25 | /** 26 | * @param collections the collections to set 27 | */ 28 | public void setCollection(List collections) { 29 | this.collections = collections; 30 | } 31 | 32 | /** 33 | * Convenience method to adds an collection to the list. 34 | * 35 | * This will create a new ArrayList if {@link #collections} is null. 36 | * 37 | * @param collection 38 | */ 39 | public void addCollection(CollectionWs2 collection) 40 | { 41 | if (collections == null) { 42 | collections = new ArrayList(); 43 | } 44 | collections.add(collection); 45 | } 46 | public void addAllCollections(List collectionList) 47 | { 48 | if (collections == null) { 49 | collections = new ArrayList(); 50 | } 51 | 52 | collections.addAll(collectionList); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/coverart/ImageGetter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package org.musicbrainz.coverart; 6 | 7 | import fm.last.musicbrainz.coverart.CoverArt; 8 | import fm.last.musicbrainz.coverart.CoverArtArchiveClient; 9 | import fm.last.musicbrainz.coverart.CoverArtImage; 10 | import fm.last.musicbrainz.coverart.impl.DefaultCoverArtArchiveClient; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.UUID; 14 | 15 | /** 16 | * 17 | * @author marco 18 | */ 19 | public class ImageGetter { 20 | 21 | private static ImageGetter _instance; 22 | private CoverArtArchiveClient client; 23 | 24 | private ImageGetter (){ 25 | client = new DefaultCoverArtArchiveClient(); 26 | } 27 | public static ImageGetter getInstance() { 28 | 29 | if (_instance == null) _instance = new ImageGetter(); 30 | 31 | return _instance; 32 | } 33 | 34 | public List getImageListByMbID(String id){ 35 | 36 | UUID mbid = UUID.fromString(id); 37 | 38 | CoverArt coverArt = null; 39 | List ImageList = new ArrayList(0); 40 | 41 | coverArt = client.getByMbid(mbid); 42 | if (coverArt != null) { 43 | for (CoverArtImage coverArtImage : coverArt.getImages()) { 44 | 45 | Image image = new Image(coverArtImage); 46 | ImageList.add(image); 47 | 48 | } 49 | } 50 | return ImageList; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Marco Curti, 2007 Patrick Ruhkopf. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the MusicBrainz project nor the names of the 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/coverart/GetterExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package org.musicbrainz.coverart; 6 | 7 | import fm.last.musicbrainz.coverart.CoverArt; 8 | import fm.last.musicbrainz.coverart.CoverArtArchiveClient; 9 | import fm.last.musicbrainz.coverart.CoverArtImage; 10 | import fm.last.musicbrainz.coverart.impl.DefaultCoverArtArchiveClient; 11 | import java.io.File; 12 | import java.util.UUID; 13 | import org.apache.commons.io.FileUtils; 14 | 15 | /** 16 | * 17 | * @author marco 18 | */ 19 | public class GetterExample { 20 | 21 | public static void main(String[] args){ 22 | 23 | CoverArtArchiveClient client = new DefaultCoverArtArchiveClient(); 24 | UUID mbid = UUID.fromString("7f6d3088-837d-495e-905f-be5c70ac2d82"); 25 | 26 | CoverArt coverArt = null; 27 | 28 | try { 29 | coverArt = client.getByMbid(mbid); 30 | if (coverArt != null) { 31 | for (CoverArtImage coverArtImage : coverArt.getImages()) { 32 | 33 | Image image = new Image(coverArtImage); 34 | System.out.print(image.getType()+"\n"); 35 | 36 | coverArtImage.getImage().read(); 37 | 38 | //File output = new File(mbid.toString() + "_" + coverArtImage.getId() + ".jpg"); 39 | //FileUtils.copyInputStreamToFile(coverArtImage.getImage(), output); 40 | } 41 | } 42 | } catch (Exception e) { 43 | // ... 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/WorkSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for the work collection.

7 | * 8 | *

Note that the name and query properties 9 | * may not be used together.

10 | */ 11 | public class WorkSearchFilterWs2 extends SearchFilterWs2 { 12 | 13 | /** 14 | * The name of the artist 15 | */ 16 | private String workTitle = null; 17 | 18 | public WorkSearchFilterWs2() { 19 | super(); 20 | } 21 | 22 | @Override 23 | public Map createParameters() 24 | { 25 | Map map = super.createParameters(); 26 | if (this.workTitle != null) 27 | { 28 | if (map.containsKey(QUERY)) { 29 | throw new IllegalArgumentException("The title and query properties may not be used together!"); 30 | } 31 | 32 | map.put(QUERY, this.workTitle); 33 | } 34 | else { 35 | if (!map.containsKey(QUERY)) { 36 | throw new IllegalArgumentException("This filter must specify a query or a work title!"); 37 | } 38 | } 39 | 40 | return map; 41 | } 42 | 43 | 44 | /** 45 | * @return the workTitle 46 | */ 47 | public String getWorkTitle() { 48 | return workTitle; 49 | } 50 | 51 | /** 52 | * @param workTitle the workTitle to set 53 | */ 54 | public void setWorkTitle(String workTitle) { 55 | this.workTitle = workTitle; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/LabelSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for the label collection.

7 | * 8 | *

Note that the name and query properties 9 | * may not be used together.

10 | */ 11 | public class LabelSearchFilterWs2 extends SearchFilterWs2 { 12 | 13 | /** 14 | * The name of the label 15 | */ 16 | private String labelName = null; 17 | 18 | public LabelSearchFilterWs2() { 19 | super(); 20 | } 21 | 22 | @Override 23 | public Map createParameters() 24 | { 25 | Map map = super.createParameters(); 26 | if (this.labelName != null) 27 | { 28 | if (map.containsKey(QUERY)) { 29 | throw new IllegalArgumentException("The name and query properties may not be used together!"); 30 | } 31 | 32 | map.put(QUERY, this.labelName); 33 | } 34 | else { 35 | if (!map.containsKey(QUERY)) { 36 | throw new IllegalArgumentException("This filter must specify a query or a label name!"); 37 | } 38 | } 39 | 40 | return map; 41 | } 42 | 43 | 44 | /** 45 | * @return the labelName 46 | */ 47 | public String getLabelName() { 48 | return labelName; 49 | } 50 | 51 | /** 52 | * @param labelName the labelName to set 53 | */ 54 | public void setLabelName(String labelName) { 55 | this.labelName = labelName; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/ArtistSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for the artist collection.

7 | * 8 | *

Note that the name and query properties 9 | * may not be used together.

10 | * 11 | */ 12 | public class ArtistSearchFilterWs2 extends SearchFilterWs2 { 13 | 14 | /** 15 | * The name of the artist 16 | */ 17 | private String artistName = null; 18 | 19 | public ArtistSearchFilterWs2() { 20 | super(); 21 | } 22 | 23 | @Override 24 | public Map createParameters() 25 | { 26 | Map map = super.createParameters(); 27 | if (this.artistName != null) 28 | { 29 | if (map.containsKey(QUERY)) { 30 | throw new IllegalArgumentException("The name and query properties may not be used together!"); 31 | } 32 | 33 | map.put(QUERY, this.artistName); 34 | } 35 | else { 36 | if (!map.containsKey(QUERY)) { 37 | throw new IllegalArgumentException("This filter must specify a query or an artist name!"); 38 | } 39 | } 40 | 41 | return map; 42 | } 43 | 44 | 45 | /** 46 | * @return the artistName 47 | */ 48 | public String getArtistName() { 49 | return artistName; 50 | } 51 | 52 | /** 53 | * @param artistName the artistName to set 54 | */ 55 | public void setArtistName(String artistName) { 56 | this.artistName = artistName; 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/ArtistSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.ArtistListWs2; 7 | import org.musicbrainz.model.searchresult.ArtistResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | public class ArtistSearchResultsWs2 extends ListElement{ 11 | 12 | private List artistResults = new ArrayList(); 13 | private ArtistListWs2 artistList = new ArtistListWs2(); 14 | 15 | /** 16 | * Convenience method to adds an {@link ArtistResultWs2} to the list. 17 | * 18 | * This will create a new ArrayList if {@link #artistResults} is null. 19 | * 20 | * @param artistResult The artist result to add 21 | */ 22 | public void addArtistResult(ArtistResultWs2 artistResult) 23 | { 24 | if (getArtistResults() == null) { 25 | artistResults = new ArrayList(); 26 | } 27 | if (getArtistList() == null) { 28 | artistList = new ArtistListWs2(); 29 | } 30 | 31 | artistResults.add(artistResult); 32 | artistList.addArtist(artistResult.getArtist()); 33 | 34 | artistList.setCount(getCount()); 35 | artistList.setOffset(getOffset()); 36 | } 37 | 38 | public List getArtistResults() { 39 | return artistResults; 40 | } 41 | 42 | public ArtistListWs2 getArtistList() { 43 | return artistList; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/RecordingSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | 6 | /** 7 | *

A filter for the recording collection.

8 | * 9 | *

Note that these filter properties properties and query 10 | * may not be used together.

11 | * 12 | */ 13 | public class RecordingSearchFilterWs2 extends SearchFilterWs2 14 | { 15 | /** 16 | * A String containing the release's title 17 | */ 18 | private String title; 19 | 20 | public RecordingSearchFilterWs2() { 21 | super(); 22 | } 23 | 24 | @Override 25 | public Map createParameters() 26 | { 27 | Map map = super.createParameters(); 28 | 29 | if (this.title != null) 30 | { 31 | if (map.containsKey(QUERY)) { 32 | throw new IllegalArgumentException("The title and query properties may not be used together!"); 33 | } 34 | 35 | map.put(QUERY, this.title); 36 | } 37 | else { 38 | if (!map.containsKey(QUERY)) { 39 | throw new IllegalArgumentException("This filter must specify a query or a recording Title!"); 40 | } 41 | } 42 | 43 | return map; 44 | } 45 | 46 | /** 47 | * @return the title 48 | */ 49 | public String getTitle() { 50 | return title; 51 | } 52 | 53 | /** 54 | * @param title the title to set 55 | */ 56 | public void setTitle(String title) { 57 | this.title = title; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/TrackListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import org.musicbrainz.wsxml.element.ListElement; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import java.util.logging.Logger; 9 | import org.mc2.util.miscellaneous.CalendarUtils; 10 | 11 | /** 12 | *

A List of Track Info (Track & catalog number)referred by a release

13 | * 14 | */ 15 | public class TrackListWs2 extends ListElement 16 | { 17 | private static Logger log = Logger.getLogger(TrackListWs2.class.getName()); 18 | 19 | private List tracks 20 | = new ArrayList(); 21 | 22 | public TrackListWs2(List tracks) 23 | { 24 | if (tracks!=null) 25 | { 26 | for (TrackWs2 element : tracks) 27 | { 28 | addTrack(element); 29 | } 30 | } 31 | } 32 | 33 | public List getTracks(){ 34 | return tracks; 35 | } 36 | 37 | private void addTrack(TrackWs2 element){ 38 | 39 | tracks.add(element); 40 | 41 | } 42 | public Long getDurationInMillis(){ 43 | 44 | long dur=0L; 45 | if (getTracks()==null) return 0L; 46 | for (TrackWs2 t : getTracks()) 47 | { 48 | if (t.getRecording()==null || 49 | t.getRecording().getDurationInMillis()==null) 50 | {continue;} 51 | 52 | dur = dur+t.getRecording().getDurationInMillis(); 53 | } 54 | return dur; 55 | } 56 | public String getDuration(){ 57 | return CalendarUtils.calcDurationString(this.getDurationInMillis()); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/ReleaseGroupSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for the release group collection.

7 | * 8 | *

Note that these filter properties properties and query 9 | * may not be used together.

10 | * 11 | */ 12 | public class ReleaseGroupSearchFilterWs2 extends SearchFilterWs2 13 | { 14 | /** 15 | * A String containing the release's title 16 | */ 17 | private String title; 18 | 19 | 20 | public ReleaseGroupSearchFilterWs2() { 21 | super(); 22 | } 23 | 24 | @Override 25 | public Map createParameters() 26 | { 27 | Map map = super.createParameters(); 28 | 29 | if (this.title != null) 30 | { 31 | if (map.containsKey(QUERY)) { 32 | throw new IllegalArgumentException("The title and query properties may not be used together!"); 33 | } 34 | 35 | map.put(QUERY, this.title); 36 | } 37 | else { 38 | if (!map.containsKey(QUERY)) { 39 | throw new IllegalArgumentException("This filter must specify a query or an artist name!"); 40 | } 41 | } 42 | 43 | return map; 44 | } 45 | 46 | /** 47 | * @return the title 48 | */ 49 | public String getTitle() { 50 | return title; 51 | } 52 | 53 | /** 54 | * @param title the title to set 55 | */ 56 | public void setTitle(String title) { 57 | this.title = title; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/ReleaseEventListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import org.musicbrainz.wsxml.element.ListElement; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | import java.util.logging.Logger; 10 | 11 | /** 12 | *

A List of Media (Medium) referred by a release

13 | 14 | */ 15 | public class ReleaseEventListWs2 extends ListElement 16 | { 17 | private static Logger log = Logger.getLogger(ReleaseEventListWs2.class.getName()); 18 | 19 | private List events 20 | = new ArrayList(); 21 | 22 | 23 | public ReleaseEventListWs2(List events) 24 | { 25 | if (events!=null) 26 | { 27 | for (ReleaseEventWs2 element : events) 28 | { 29 | addReleaseEvent(element); 30 | } 31 | } 32 | } 33 | 34 | public List getReleaseEvents(){ 35 | return events; 36 | } 37 | 38 | private void addReleaseEvent(ReleaseEventWs2 element){ 39 | 40 | events.add(element); 41 | 42 | } 43 | @Override 44 | public String toString(){ 45 | 46 | if (getReleaseEvents() == null || 47 | getReleaseEvents().isEmpty()) return ""; 48 | 49 | String out=""; 50 | String separator=""; 51 | Iterator itr = getReleaseEvents().iterator(); 52 | while (itr.hasNext()) { 53 | 54 | ReleaseEventWs2 ev = (ReleaseEventWs2)itr.next(); 55 | out=out+separator+ ev.toString(); 56 | separator=", "; 57 | } 58 | return out; 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/listelement/ReleaseGroupListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.ReleaseGroupWs2; 7 | import org.musicbrainz.wsxml.element.ListElement; 8 | 9 | 10 | /** 11 | * A list of Release Groups 12 | */ 13 | public class ReleaseGroupListWs2 extends ListElement{ 14 | 15 | private List releaseGroups 16 | = new ArrayList(); 17 | 18 | /** 19 | * @return the releaseGroups 20 | */ 21 | public List getReleaseGroups() { 22 | return releaseGroups; 23 | } 24 | 25 | /** 26 | * @param releaseGroups the releaseGroups to set 27 | */ 28 | public void setReleaseGroups(List releaseGroups) { 29 | this.releaseGroups = releaseGroups; 30 | } 31 | 32 | /** 33 | * Adds a releaseGroup to the list. 34 | * 35 | * It will also create and set new ArrayList if 36 | * {@link #releaseGroups} is null. 37 | * 38 | * @param releaseGroup The releaseGroup to add 39 | */ 40 | public void addReleaseGroup(ReleaseGroupWs2 releaseGroup) 41 | { 42 | if (releaseGroups == null) { 43 | releaseGroups = new ArrayList(); 44 | } 45 | 46 | releaseGroups.add(releaseGroup); 47 | } 48 | public void addAllReleaseGroups(List releaseGroupList) 49 | { 50 | if (releaseGroups == null) { 51 | releaseGroups = new ArrayList(); 52 | } 53 | 54 | releaseGroups.addAll(releaseGroupList); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Java Bindings for the MusicBrainz XML Web Service Version 2 (Ws2) 2 | ----------------------------------------------------------------- 3 | 4 | This Java package contains various classes for accessing the MusicBrainz 5 | web service version 2, as well as parsing the MusicBrainz Metadata XML (MMD). 6 | 7 | please visit the project home: http://code.google.com/p/musicbrainzws2-java/ 8 | 9 | visit http://musicbrainz.org/doc/XML_Web_Service/Version_2 10 | 11 | and http://musicbrainz.org/doc/Next_Generation_Schema/SearchServerXML 12 | for model descriptions and details. 13 | 14 | This is an upgrade of the original (WS1) project jmb-wsc by Patrick Ruhkopf. 15 | 16 | I resolved to make a new one after many trial to contact the author and get 17 | a release working in Ws2. 18 | 19 | The contact he left (http://dev.ruhkopf.name/jmb-wsc) is not a valid link anymore. 20 | 21 | Here some note from the original README.TXT: 22 | 23 | This java implementation was inspired by python-musicbrainz-2, 24 | Copyright (c) 2006, Matthias Friedrich. 25 | 26 | In future, this project will possibly be hosted at the MusicBrainz' 27 | homepage. For now, visit 28 | 29 | http://dev.ruhkopf.name/jmb-wsc 30 | 31 | to find new releases or ask questions. 32 | 33 | 34 | KNOWN LIMITATIONS OF THIS VERSION 35 | ------------------------------ 36 | This version ob jmb-wsc does not provide functionality for calculating 37 | DiscIDs from Audio CDs. Furthermore, it does not yet include an xml 38 | writer, so posting data to the web service (like puids) is not possible 39 | at the moment. 40 | 41 | While the unit tests pass, it is in no way guaranteed that they cover 42 | everything. Please inform me about any issues that may come up. 43 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/RecordingSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.RecordingListWs2; 7 | import org.musicbrainz.model.searchresult.RecordingResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | public class RecordingSearchResultsWs2 extends ListElement{ 11 | 12 | protected List recordingResults = new ArrayList(); 13 | private RecordingListWs2 recordingList = new RecordingListWs2(); 14 | 15 | public List getRecordingResults() { 16 | return recordingResults; 17 | } 18 | 19 | public RecordingListWs2 getRecordingList() { 20 | return recordingList; 21 | } 22 | 23 | /** 24 | * Convenience method to adds an track result to the list. 25 | * 26 | * This will create a new ArrayList if {@link #recordingResults} is null. 27 | * 28 | * @param recordingResult The track result to add 29 | */ 30 | public void addRecordingResult(RecordingResultWs2 recordingResult) 31 | { 32 | if (recordingResults == null) { 33 | recordingResults = new ArrayList(); 34 | } 35 | if (recordingList == null) { 36 | recordingList = new RecordingListWs2(); 37 | } 38 | recordingResults.add(recordingResult); 39 | recordingList.addRecording(recordingResult.getRecording()); 40 | 41 | recordingList.setCount(getCount()); 42 | recordingList.setOffset(getOffset()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/readysearches/AnnotationSearchbyEntityId.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search.readysearches; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.filter.searchfilter.AnnotationSearchtFilterWs2; 6 | import org.musicbrainz.model.searchresult.AnnotationResultWs2; 7 | import org.musicbrainz.query.search.AnnotationSearchWs2; 8 | import org.musicbrainz.webservice.WebService; 9 | 10 | public class AnnotationSearchbyEntityId { 11 | 12 | private AnnotationSearchWs2 q; 13 | private AnnotationSearchtFilterWs2 f; 14 | 15 | public AnnotationSearchbyEntityId(String Entity){ 16 | 17 | f = new AnnotationSearchtFilterWs2(); 18 | f.setLimit((long)100); 19 | f.setOffset((long)0); 20 | f.setMinScore((long)20); 21 | 22 | f.setEntity(Entity); 23 | 24 | q = new AnnotationSearchWs2(f); 25 | 26 | } 27 | public AnnotationSearchbyEntityId(WebService ws, String Entity){ 28 | 29 | f = new AnnotationSearchtFilterWs2(); 30 | f.setLimit((long)100); 31 | f.setOffset((long)0); 32 | f.setMinScore((long)20); 33 | 34 | f.setEntity(Entity); 35 | 36 | q = new AnnotationSearchWs2(ws,f); 37 | 38 | } 39 | public List getFullList() { 40 | 41 | return q.getFullList(); 42 | 43 | } 44 | public List getFirstPage() { 45 | 46 | f.setOffset((long)0); 47 | q = new AnnotationSearchWs2(f); 48 | return q.getFirstPage(); 49 | } 50 | public List getNextPage() { 51 | return q.getNextPage(); 52 | } 53 | 54 | public boolean hasMore(){ 55 | return q.hasMore(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/ReleaseSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.ReleaseListWs2; 7 | import org.musicbrainz.model.searchresult.ReleaseResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | 11 | public class ReleaseSearchResultsWs2 extends ListElement{ 12 | 13 | 14 | protected List releaseResults = new ArrayList(); 15 | private ReleaseListWs2 releaseList = new ReleaseListWs2(); 16 | 17 | /** 18 | * Convenience method to adds an release result to the list. 19 | * 20 | * This will create a new ArrayList if {@link #releaseResults} is null. 21 | * 22 | * @param releaseResult The release result to add 23 | */ 24 | 25 | public void addReleaseResult(ReleaseResultWs2 releaseResult) 26 | { 27 | if (releaseResults == null) { 28 | releaseResults = new ArrayList(); 29 | } 30 | if (getReleaseList() == null) { 31 | releaseList = new ReleaseListWs2(); 32 | } 33 | releaseResults.add(releaseResult); 34 | releaseList.addRelease(releaseResult.getRelease()); 35 | 36 | releaseList.setCount(getCount()); 37 | releaseList.setOffset(getOffset()); 38 | } 39 | 40 | /** 41 | * @return the release results 42 | */ 43 | public List getReleaseResults() { 44 | return releaseResults; 45 | } 46 | /** 47 | * @return the releaseList 48 | */ 49 | public ReleaseListWs2 getReleaseList() { 50 | return releaseList; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/CollectionSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.model.searchresult.listelement.CollectionSearchResultsWs2; 7 | import org.musicbrainz.model.searchresult.CollectionResultWs2; 8 | import org.musicbrainz.webservice.AuthorizationException; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | 12 | public class CollectionSearchWs2 extends SearchWs2{ 13 | 14 | public CollectionSearchWs2(){ 15 | super(null); 16 | } 17 | 18 | public CollectionSearchWs2(WebService ws){ 19 | super(ws, null); 20 | } 21 | 22 | public List getResults() throws AuthorizationException, Exception{ 23 | 24 | List results 25 | = new ArrayList (); 26 | 27 | try { 28 | CollectionSearchResultsWs2 temp = execQuery(); 29 | results.addAll(temp.getCollectionResults()); 30 | 31 | 32 | } catch (AuthorizationException ex){ 33 | throw ex; 34 | 35 | }catch (Exception ex) { 36 | throw ex; 37 | } 38 | 39 | return results; 40 | } 41 | private CollectionSearchResultsWs2 execQuery() throws MBWS2Exception 42 | { 43 | 44 | CollectionSearchResultsWs2 le = getMetadata(COLLECTION).getCollectionResultsWs2(); 45 | setListElement(le); 46 | 47 | int sz = le.getCollectionResults().size(); 48 | if (sz>0) 49 | { 50 | setLastScore((int) le.getCollectionResults().get(sz-1).getScore()); 51 | } 52 | return le; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/CollectionSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.CollectionListWs2; 7 | import org.musicbrainz.model.searchresult.CollectionResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | public class CollectionSearchResultsWs2 extends ListElement{ 11 | 12 | private List collectionResults = new ArrayList(); 13 | private CollectionListWs2 collectionList = new CollectionListWs2(); 14 | 15 | /** 16 | * Convenience method to adds an {@link CollectionResultWs2} to the list. 17 | * 18 | * This will create a new ArrayList if {@link #collectionResults} is null. 19 | * 20 | * @param collectionResult The collection result to add 21 | */ 22 | public void addCollectionResult(CollectionResultWs2 collectionResult) 23 | { 24 | if (getCollectionResults() == null) { 25 | collectionResults = new ArrayList(); 26 | } 27 | if (getCollectionList() == null) { 28 | collectionList = new CollectionListWs2(); 29 | } 30 | 31 | collectionResults.add(collectionResult); 32 | collectionList.addCollection(collectionResult.getCollection()); 33 | 34 | collectionList.setCount(getCount()); 35 | collectionList.setOffset(getOffset()); 36 | } 37 | 38 | public List getCollectionResults() { 39 | return collectionResults; 40 | } 41 | 42 | public CollectionListWs2 getCollectionList() { 43 | return collectionList; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/ReleaseSearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

A filter for the release collection.

7 | * 8 | *

Note that these filter properties properties and query 9 | * may not be used together.

10 | 11 | */ 12 | public class ReleaseSearchFilterWs2 extends SearchFilterWs2 13 | { 14 | /** 15 | * A String containing the release's title 16 | */ 17 | private String title; 18 | 19 | /* (non-Javadoc) 20 | * @see org.musicbrainz.webservice.Filter() 21 | */ 22 | public ReleaseSearchFilterWs2() { 23 | super(); 24 | } 25 | 26 | /* (non-Javadoc) 27 | * @see org.musicbrainz.webservice.Filter#createParameters() 28 | */ 29 | @Override 30 | public Map createParameters() 31 | { 32 | Map map = super.createParameters(); 33 | 34 | if (this.title != null) 35 | { 36 | if (map.containsKey(QUERY)) { 37 | throw new IllegalArgumentException("The title and query properties may not be used together!"); 38 | } 39 | 40 | map.put(QUERY, this.title); 41 | } 42 | else { 43 | if (!map.containsKey(QUERY)) { 44 | throw new IllegalArgumentException("This filter must specify a query or a release title!"); 45 | } 46 | } 47 | 48 | return map; 49 | } 50 | 51 | /** 52 | * @return the title 53 | */ 54 | public String getTitle() { 55 | return title; 56 | } 57 | 58 | /** 59 | * @param title the title to set 60 | */ 61 | public void setTitle(String title) { 62 | this.title = title; 63 | } 64 | 65 | 66 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/wsxml/element/ListElement.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.wsxml.element; 2 | 3 | /** 4 | * A ListElement holds metadata about a list returned 5 | * from the web service. This can, for example, be a list 6 | * of releases or artists (see classes that extending this 7 | * class). Extending classes are responsible for the actual 8 | * List. 9 | * 10 | * @author Patrick Ruhkopf 11 | */ 12 | public abstract class ListElement { 13 | 14 | /** 15 | * The actual number of list items, 16 | * see {@link #getCount()} 17 | */ 18 | protected Long count; 19 | 20 | /** 21 | * The offset of the list items 22 | * see {@link #getOffset()} 23 | */ 24 | protected Long offset; 25 | 26 | /** 27 | * Returns the offset of the list. 28 | * 29 | * This is used if the List is incomplete 30 | * (ie. the web service only returned part of all list items). 31 | * Note that the offset value is zero-based, which means 32 | * item 0 is the first item. 33 | * 34 | * @return the offset or null 35 | */ 36 | public Long getOffset() { 37 | return offset; 38 | } 39 | 40 | /** 41 | * @param offset the offset to set 42 | */ 43 | public void setOffset(Long offset) { 44 | this.offset = offset; 45 | } 46 | 47 | 48 | /** 49 | * Returns the actual number of existing list items. 50 | * 51 | * This may or may not match with the number of elements that 52 | * the List holds. If the count is higher than the 53 | * List, it indicates that the list is incomplete. 54 | * 55 | * @return the count or null 56 | */ 57 | public Long getCount() { 58 | return count; 59 | } 60 | 61 | /** 62 | * @param count the count to set 63 | */ 64 | public void setCount(Long count) { 65 | this.count = count; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/ArtistCreditWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.logging.Logger; 6 | 7 | /** 8 | *

An Artist Credit used instead of Artist for collaborations or 9 | * performance name variations.

10 | 11 | */ 12 | public class ArtistCreditWs2 13 | { 14 | private static Logger log = Logger.getLogger(ArtistCreditWs2.class.getName()); 15 | 16 | /** 17 | * A string containing the complete credit as join 18 | * of credit names in the list. 19 | */ 20 | private String artistCreditString=""; 21 | private List nameCredits 22 | = new ArrayList(); 23 | 24 | /** 25 | * Minimal Constructor 26 | * @param nameCredits A list of NameCreditWs2 27 | * describing the Artist Credit. 28 | */ 29 | public ArtistCreditWs2(List nameCredits) 30 | { 31 | if (nameCredits!=null) 32 | { 33 | for (NameCreditWs2 nameCredit : nameCredits) 34 | { 35 | addNameCredit(nameCredit); 36 | } 37 | } 38 | } 39 | public String getArtistCreditString(){ 40 | return artistCreditString; 41 | } 42 | 43 | public List getNameCredits(){ 44 | return nameCredits; 45 | } 46 | 47 | private void addNameCredit(NameCreditWs2 nameCredit){ 48 | 49 | nameCredits.add(nameCredit); 50 | 51 | if (nameCredit.getNameCreditString() != null && !nameCredit.getNameCreditString().equals("")) 52 | { 53 | artistCreditString = 54 | artistCreditString+nameCredit.getNameCreditString(); 55 | } 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return artistCreditString; 61 | } 62 | 63 | 64 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/LabelInfoListWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import org.musicbrainz.wsxml.element.ListElement; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import java.util.logging.Logger; 9 | 10 | /** 11 | *

A List of Label Info (Label & catalog number)referred by a release

12 | 13 | */ 14 | public class LabelInfoListWs2 extends ListElement 15 | { 16 | private static Logger log = Logger.getLogger(LabelInfoListWs2.class.getName()); 17 | 18 | /** 19 | * A string containing the complete credit as join 20 | * of credit names in the list. 21 | */ 22 | private String labelInfoString=""; 23 | 24 | private List labelInfos 25 | = new ArrayList(); 26 | 27 | /** 28 | * Minimal Constructor 29 | * @param labelInfos A list of ArtistCreditElementWs2 30 | * describing the Artist Credit. 31 | */ 32 | public LabelInfoListWs2(List labelInfos) 33 | { 34 | if (labelInfos!=null) 35 | { 36 | for (LabelInfoWs2 element : labelInfos) 37 | { 38 | addLabelInfo(element); 39 | } 40 | } 41 | } 42 | public String getLabelInfoString(){ 43 | return labelInfoString; 44 | } 45 | public List getLabelInfos(){ 46 | return labelInfos; 47 | } 48 | 49 | private void addLabelInfo(LabelInfoWs2 element){ 50 | 51 | labelInfos.add(element); 52 | 53 | if (!labelInfoString.equals("")) 54 | labelInfoString= labelInfoString+", "; 55 | 56 | labelInfoString = labelInfoString+element.getLabelInfoString(); 57 | 58 | } 59 | 60 | /* (non-Javadoc) 61 | * @see java.lang.Object#toString() 62 | */ 63 | @Override 64 | public String toString() { 65 | return labelInfoString; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/searchresult/listelement/ReleaseGroupSearchResultsWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.searchresult.listelement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.model.entity.listelement.ReleaseGroupListWs2; 7 | import org.musicbrainz.model.searchresult.ReleaseGroupResultWs2; 8 | import org.musicbrainz.wsxml.element.ListElement; 9 | 10 | 11 | public class ReleaseGroupSearchResultsWs2 extends ListElement{ 12 | 13 | 14 | protected List releaseGroupResults = new ArrayList(); 15 | private ReleaseGroupListWs2 releaseGroupList = new ReleaseGroupListWs2(); 16 | 17 | /** 18 | * Convenience method to adds an release result to the list. 19 | * 20 | * This will create a new ArrayList if {@link #releaseGroupResults} is null. 21 | * 22 | * @param releaseGroupResult The release result to add 23 | */ 24 | 25 | public void addReleaseGroupResult(ReleaseGroupResultWs2 releaseGroupResult) 26 | { 27 | if (releaseGroupResults == null) { 28 | releaseGroupResults = new ArrayList(); 29 | } 30 | if (getReleaseGroupList() == null) { 31 | releaseGroupList = new ReleaseGroupListWs2(); 32 | } 33 | releaseGroupResults.add(releaseGroupResult); 34 | releaseGroupList.addReleaseGroup(releaseGroupResult.getReleaseGroup()); 35 | 36 | releaseGroupList.setCount(getCount()); 37 | releaseGroupList.setOffset(getOffset()); 38 | } 39 | 40 | /** 41 | * @return the release results 42 | */ 43 | public List getReleaseGroupResults() { 44 | return releaseGroupResults; 45 | } 46 | /** 47 | * @return the releaseGroupList 48 | */ 49 | public ReleaseGroupListWs2 getReleaseGroupList() { 50 | return releaseGroupList; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/includes/WorkIncludesWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.includes; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * A specification on how much data to return with a work. 7 | */ 8 | 9 | public class WorkIncludesWs2 extends IncludesWs2 10 | { 11 | 12 | // Misc inc= arguments 13 | 14 | private boolean aliases = false; 15 | 16 | /** 17 | * Default constructor 18 | */ 19 | public WorkIncludesWs2() 20 | { 21 | 22 | } 23 | /** 24 | * @return the aliases 25 | */ 26 | public boolean isAliases() { 27 | return aliases; 28 | } 29 | /** 30 | * @param aliases the aliases to set 31 | */ 32 | public void setAliases(boolean aliases) { 33 | this.aliases = aliases; 34 | } 35 | /* (non-Javadoc) 36 | * @see org.musicbrainz.webservice.Includes#createIncludeTags() 37 | */ 38 | @Override 39 | public List createIncludeTags() 40 | { 41 | List includeTags = super.createIncludeTags(); 42 | 43 | // not that elegant but straight forward :) 44 | if (isAliases()) includeTags.add(ALIASES_INC); 45 | 46 | return includeTags; 47 | } 48 | /** 49 | * set all the parameters to false. 50 | */ 51 | @Override 52 | public void excludeAll(){ 53 | 54 | super.excludeAll(); 55 | setAliases(false); 56 | 57 | } 58 | /** 59 | * set all the parameters to true. 60 | */ 61 | @Override 62 | public void includeAll(){ 63 | 64 | super.includeAll(); 65 | setAliases(true); 66 | 67 | } 68 | /** 69 | * clone the current status of IncludesWs2 to a new one. 70 | */ 71 | @Override 72 | public WorkIncludesWs2 clone(){ 73 | 74 | WorkIncludesWs2 target = new WorkIncludesWs2(); 75 | copyTo(target); 76 | target.setAliases(isAliases()); 77 | return target; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/CoverArtArchiveWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.logging.Logger; 7 | import org.musicbrainz.coverart.Image; 8 | import org.musicbrainz.coverart.ImageGetter; 9 | 10 | /** 11 | *

A Cover Art Archive definition. 12 | * 13 | * ... nothing found in MB documentation. 14 | * see http://tickets.musicbrainz.org/browse/MBS-4536 15 | 16 | *

17 | */ 18 | public class CoverArtArchiveWs2 19 | { 20 | private static Logger log = Logger.getLogger(CoverArtArchiveWs2.class.getName()); 21 | 22 | /** 23 | * @return the log 24 | */ 25 | public static Logger getLog() { 26 | return log; 27 | } 28 | 29 | 30 | private boolean artwork=false; 31 | private boolean front=false; 32 | private boolean back=false; 33 | private int count=0; 34 | private String mbId; 35 | private List imageList = new ArrayList(); 36 | 37 | public CoverArtArchiveWs2(boolean artwork, int count, boolean front, boolean back, String mbId) 38 | { 39 | this.artwork= artwork; 40 | this.front = front; 41 | this.back = back; 42 | this.count = count; 43 | this.mbId = mbId; 44 | 45 | } 46 | /** 47 | * @return the imageList 48 | */ 49 | public List getImageList() { 50 | if (!imageList.isEmpty())return imageList; 51 | if (artwork) imageList = ImageGetter.getInstance().getImageListByMbID(mbId); 52 | return imageList; 53 | } 54 | /** 55 | * @return the artwork 56 | */ 57 | public boolean hasArtwork() { 58 | return artwork; 59 | } 60 | 61 | /** 62 | * @return the front 63 | */ 64 | public boolean hasFront() { 65 | return front; 66 | } 67 | 68 | /** 69 | * @return the back 70 | */ 71 | public boolean hasBack() { 72 | return back; 73 | } 74 | 75 | /** 76 | * @return the count 77 | */ 78 | public int getCount() { 79 | return count; 80 | } 81 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/includes/ReleaseGroupIncludesWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.includes; 2 | 3 | import java.util.List; 4 | 5 | 6 | /** 7 | * A specification on how much data to return with a release group. 8 | */ 9 | public class ReleaseGroupIncludesWs2 extends IncludesWs2 10 | { 11 | 12 | // The following Includes are allowed ONLY for LookUps 13 | // and NOT for Browse. 14 | 15 | private boolean artists = false; 16 | private boolean releases = false; 17 | 18 | 19 | /** 20 | * Default constructor 21 | */ 22 | public ReleaseGroupIncludesWs2() 23 | { 24 | super(); 25 | } 26 | 27 | @Override 28 | public List createIncludeTags() 29 | { 30 | List includeTags = super.createIncludeTags(); 31 | 32 | 33 | // not that elegant but straight forward :) 34 | if (isReleases()) includeTags.add(RELEASES_INC); 35 | 36 | return includeTags; 37 | } 38 | 39 | /** 40 | * @return the releases 41 | */ 42 | public boolean isReleases() { 43 | return releases; 44 | } 45 | 46 | /** 47 | * @param releases the releases to set 48 | */ 49 | public void setReleases(boolean releases) { 50 | this.releases = releases; 51 | } 52 | /** 53 | * set all the parameters to false. 54 | */ 55 | @Override 56 | public void excludeAll(){ 57 | 58 | super.excludeAll(); 59 | setReleases(false); 60 | 61 | } 62 | /** 63 | * set all the parameters to true. 64 | */ 65 | @Override 66 | public void includeAll(){ 67 | 68 | super.includeAll(); 69 | setReleases(true); 70 | 71 | } 72 | /** 73 | * clone the current status of IncludesWs2 to a new one. 74 | */ 75 | @Override 76 | public ReleaseGroupIncludesWs2 clone(){ 77 | 78 | ReleaseGroupIncludesWs2 target = new ReleaseGroupIncludesWs2(); 79 | copyTo(target); 80 | target.setReleases(isReleases()); 81 | 82 | return target; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/LabelInfoWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.logging.Logger; 4 | import org.musicbrainz.model.entity.LabelWs2; 5 | 6 | /** 7 | *

A single Element (label and catalog) 8 | * of an LabelInfoList 9 | */ 10 | public class LabelInfoWs2 11 | { 12 | private static Logger log = Logger.getLogger(LabelInfoWs2.class.getName()); 13 | 14 | private String catalogNumber; 15 | private LabelWs2 label; 16 | 17 | public LabelInfoWs2(){} 18 | /** 19 | * Minimal Constructor 20 | * @param label the Label 21 | * @param catalogNumber the catalogNumber 22 | */ 23 | public LabelInfoWs2(LabelWs2 label,String catalogNumber) 24 | { 25 | this.label = label; 26 | this.catalogNumber = catalogNumber; 27 | } 28 | public String getCatalogNumber(){ 29 | return catalogNumber; 30 | } 31 | public void setCatalogNumber(String catalogNumber){ 32 | this.catalogNumber = catalogNumber; 33 | } 34 | public LabelWs2 getLabel(){ 35 | return label; 36 | } 37 | public void setLabel(LabelWs2 label){ 38 | this.label = label; 39 | } 40 | public String getLabelName(){ 41 | if (label==null) return ""; 42 | return label.getName(); 43 | } 44 | public String getLabelInfoString(){ 45 | 46 | String labelInfoString=""; 47 | 48 | if (label != null) 49 | { 50 | labelInfoString = label.getName(); 51 | } 52 | 53 | if (catalogNumber!=null&& !catalogNumber.equals("")) 54 | { 55 | if (labelInfoString != null && !labelInfoString.equals("")) 56 | labelInfoString = labelInfoString+" "; 57 | 58 | labelInfoString= labelInfoString+"cat.No: "+catalogNumber; 59 | } 60 | return labelInfoString; 61 | } 62 | /* (non-Javadoc) 63 | * @see java.lang.Object#toString() 64 | */ 65 | @Override 66 | public String toString() { 67 | 68 | return getLabelInfoString(); 69 | } 70 | 71 | 72 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/NameCreditWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.logging.Logger; 4 | import org.musicbrainz.model.entity.ArtistWs2; 5 | 6 | /** 7 | *

A single Element (artist or artist name variation) 8 | * of an Artist Credit 9 | */ 10 | public class NameCreditWs2 11 | { 12 | private static Logger log = Logger.getLogger(NameCreditWs2.class.getName()); 13 | 14 | String joinphrase=null; 15 | String name=null; 16 | ArtistWs2 artist=null; 17 | /** 18 | * Default Constructor 19 | */ 20 | public NameCreditWs2() 21 | { 22 | 23 | } 24 | 25 | /** 26 | * Complete Constructor 27 | * @param joinphrase A string containing the join sentence used to build 28 | * the Artist Credit String ((i.e. &,/, and,...) 29 | * @param name A string containing the name variation used to build 30 | * the Artist Credit String 31 | * @param artist the ArtistWs2 referred by the element. 32 | */ 33 | public NameCreditWs2(String joinphrase, 34 | String name, 35 | ArtistWs2 artist) 36 | { 37 | this.joinphrase = joinphrase; 38 | this.name = name; 39 | this.artist = artist; 40 | } 41 | public String getNameCreditString(){ 42 | 43 | String credit=""; 44 | 45 | if (name != null && !name.equals("")) 46 | { 47 | credit = name; 48 | } 49 | else if (artist !=null) 50 | { 51 | credit = artist.getName(); 52 | } 53 | 54 | if (joinphrase!=null&& !joinphrase.equals("")) 55 | { 56 | credit= credit+joinphrase; 57 | } 58 | return credit; 59 | } 60 | public String getJoinphrase() { 61 | return joinphrase; 62 | } 63 | public void setJoinphrase(String joinphrase) { 64 | this.joinphrase = joinphrase; 65 | } 66 | public String getName() { 67 | return name; 68 | } 69 | public void setName(String name) { 70 | this.name = name; 71 | } 72 | public String getArtistName() { 73 | if (getArtist()==null) return ""; 74 | return getArtist().getUniqueName(); 75 | } 76 | public ArtistWs2 getArtist() { 77 | return artist; 78 | } 79 | public void setArtist(ArtistWs2 artist) { 80 | this.artist = artist; 81 | } 82 | @Override 83 | public String toString() { 84 | 85 | return getNameCreditString(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/EntityElement.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | /** 6 | * Each Submission could contain requests for 7 | * many entities. 8 | * An EntityElement is the specific entity 9 | * request description. 10 | * 11 | **/ 12 | public class EntityElement { 13 | 14 | /* 15 | * The entity type. Must be one of 16 | * LABEL 17 | * ARTIST 18 | * RELEASEGROUP 19 | * WORK 20 | * RECORDING 21 | * 22 | */ 23 | private String entityType; 24 | /* 25 | * The entity id 26 | */ 27 | private String id; 28 | /* 29 | * The tag list for the entity. 30 | * Notes that this wil replace the current tag list, 31 | * so be sure to include ALL the tags you want apply to this 32 | * entity. 33 | */ 34 | private List tagList = new ArrayList(); 35 | /* 36 | * The new rating for the entity. 37 | * Notes that the rating to be submitted range from 0 to 100. 38 | */ 39 | private int userRating = 0; 40 | 41 | /** 42 | * @return the entityTipe 43 | */ 44 | public String getEntityType() { 45 | return entityType; 46 | } 47 | 48 | /** 49 | * @param entityTipe the entityTipe to set 50 | */ 51 | public void setEntityType(String entityTipe) { 52 | this.entityType = entityTipe; 53 | } 54 | 55 | /** 56 | * @return the id 57 | */ 58 | public String getId() { 59 | return id; 60 | } 61 | 62 | /** 63 | * @param id the id to set 64 | */ 65 | public void setId(String id) { 66 | this.id = id; 67 | } 68 | 69 | /** 70 | * @return the tagList 71 | */ 72 | public List getTagList() { 73 | return tagList; 74 | } 75 | 76 | /** 77 | * @param tagList the tagList to set 78 | */ 79 | public void setTagList(List tagList) { 80 | this.tagList = tagList; 81 | } 82 | public void addTag(String tag){ 83 | 84 | this.tagList.add(tag); 85 | } 86 | 87 | /** 88 | * @return the userRating 89 | */ 90 | public int getUserRating() { 91 | return userRating; 92 | } 93 | /** 94 | * @param userRating the userRating to set 95 | */ 96 | public void setUserRating(int userRating) { 97 | this.userRating = userRating; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/ReleaseEventWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | import java.util.logging.Logger; 7 | 8 | /** 9 | *

A single Medium and relative TrackList. 10 | 11 | */ 12 | public class ReleaseEventWs2 13 | { 14 | private static Logger log = Logger.getLogger(ReleaseEventWs2.class.getName()); 15 | 16 | /** 17 | * @return the log 18 | */ 19 | public static Logger getLog() { 20 | return log; 21 | } 22 | 23 | /** 24 | * @param aLog the log to set 25 | */ 26 | public static void setLog(Logger aLog) { 27 | log = aLog; 28 | } 29 | 30 | private String dateString; 31 | private AreaWs2 area; 32 | 33 | /** 34 | * Default Constructor 35 | */ 36 | public ReleaseEventWs2() 37 | { 38 | 39 | } 40 | /** 41 | * Parses the date string and returns a Date 42 | * @return A Date object 43 | */ 44 | public Date getDate() { 45 | return dateFromdateString(); 46 | } 47 | 48 | private Date dateFromdateString() { 49 | SimpleDateFormat f = new SimpleDateFormat("yyyy"); 50 | 51 | if (dateString == null) 52 | return null; 53 | 54 | if (dateString.length() == 10) 55 | f = new SimpleDateFormat("yyyy-MM-dd"); 56 | 57 | if (dateString.length() == 7) 58 | f = new SimpleDateFormat("yyyy-MM"); 59 | 60 | try { 61 | return f.parse(dateString); 62 | } catch (ParseException e) { 63 | log.warning("Could not parse date string - returning null"); 64 | return null; 65 | } 66 | } 67 | /** 68 | * @return the dateString 69 | */ 70 | public String getDateString() { 71 | return dateString; 72 | } 73 | 74 | /** 75 | * @param dateString the dateString to set 76 | */ 77 | public void setDateString(String dateString) { 78 | this.dateString = dateString; 79 | } 80 | 81 | /** 82 | * @return the area 83 | */ 84 | public AreaWs2 getArea() { 85 | return area; 86 | } 87 | 88 | /** 89 | * @param area the area to set 90 | */ 91 | public void setArea(AreaWs2 area) { 92 | this.area = area; 93 | } 94 | @Override 95 | public String toString(){ 96 | return getArea().getName()+" "+getDateString(); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # musicbrainzws2-java 2 | [![Build](https://github.com/schnatterer/musicbrainzws2-java/actions/workflows/main.yaml/badge.svg)](https://github.com/schnatterer/musicbrainzws2-java/actions/workflows/main.yaml) 3 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=info.schnatterer.musicbrainzws2-java%3Amusicbrainzws2-java&metric=alert_status)](https://sonarcloud.io/dashboard?id=info.schnatterer.musicbrainzws2-java%3Amusicbrainzws2-java) 4 | 5 | This is a fork of musicbrainzws2-java, originally hosted [here](https://code.google.com/archive/p/musicbrainzws2-java/). It includes several bugfixes as well as maven integration. The original [wiki](https://code.google.com/p/musicbrainzws2-java/w/list) was migrated and can now be found [here](https://github.com/schnatterer/musicbrainzws2-java/wiki). 6 | You can find the original Readme file [here](README.txt). 7 | 8 | This fork was implemented as part of the [nusic-app](https://github.com/schnatterer/nusic). 9 | 10 | 11 | 12 | ## How to use 13 | 14 | Add the [latest stable version of musicbrainzws2-java](https://search.maven.org/search?q=a:musicbrainzws2-java%20AND%20g:info.schnatterer.musicbrainzws2-java) 15 | to the dependency management tool of your choice. 16 | 17 | ```XML 18 | 19 | info.schnatterer.musicbrainzws2-java 20 | musicbrainzws2-java 21 | 3.0.2 22 | 23 | ``` 24 | 25 | [![Maven Central](https://img.shields.io/maven-central/v/info.schnatterer.musicbrainzws2-java/musicbrainzws2-java.svg)](https://search.maven.org/search?q=a:musicbrainzws2-java%20AND%20g:info.schnatterer.musicbrainzws2-java) 26 | 27 | You can also get snapshot versions from our [snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/info/schnatterer/musicbrainzws2-java/) 28 | (for the most recent commit). 29 | To do so, add the following repo to your `pom.xml` or `settings.xml`: 30 | 31 | ```xml 32 | 33 | snapshots-repo 34 | https://oss.sonatype.org/content/repositories/snapshots 35 | false 36 | true 37 | 38 | ``` 39 | 40 | Older versions were released in a different repo. See [Git history](https://github.com/schnatterer/musicbrainzws2-java/blob/b9bf6d7f8be8df66dfd3d85f7ab6f569475d7c2f/README.md) 41 | for details on how to use them. 42 | 43 | ## Releasing 44 | 45 | ```shell script 46 | ./mvnw release:prepare -Darguments=pgp.skip=true 47 | ``` 48 | 49 | Sets versions in pom.xml, commits, tags and pushes to SCM. Travis builds tag and pushes to Maven Central. 50 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/ReleaseBrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.musicbrainz.filter.ReleaseStatusFilterWs2; 7 | import org.musicbrainz.filter.ReleaseTypeFilterWs2; 8 | 9 | public class ReleaseBrowseFilterWs2 extends BrowseFilterWs2 10 | { 11 | private ReleaseTypeFilterWs2 releaseTypeFilter =new ReleaseTypeFilterWs2(); 12 | private ReleaseStatusFilterWs2 releaseStatusFilter =new ReleaseStatusFilterWs2(); 13 | 14 | private Boolean variousArtists= false; 15 | 16 | 17 | public ReleaseBrowseFilterWs2() { 18 | super(); 19 | } 20 | 21 | @Override 22 | public Map createParameters() 23 | { 24 | Map map = super.createParameters(); 25 | 26 | Map localmap = new HashMap(); 27 | //if (isVariousArtists()) 28 | // map.put("track-artists", ""); 29 | // set related entity to "track_artists" instead. 30 | 31 | //Combine default filter's parameters with release filter's 32 | map.putAll(getReleaseTypeFilter().createParameters()); 33 | map.putAll(getReleaseStatusFilter().createParameters()); 34 | map.putAll(localmap); 35 | 36 | return map; 37 | } 38 | 39 | /** 40 | * @return the releaseTypeFilter 41 | */ 42 | public ReleaseTypeFilterWs2 getReleaseTypeFilter() { 43 | return releaseTypeFilter; 44 | } 45 | 46 | /** 47 | * @param releaseTypeFilter the releaseTypeFilter to set 48 | */ 49 | public void setReleaseTypeFilter(ReleaseTypeFilterWs2 releaseTypeFilter) { 50 | this.releaseTypeFilter = releaseTypeFilter; 51 | } 52 | 53 | /** 54 | * @return the releaseStatusFilter 55 | */ 56 | public ReleaseStatusFilterWs2 getReleaseStatusFilter() { 57 | return releaseStatusFilter; 58 | } 59 | 60 | /** 61 | * @param releaseStatusFilter the releaseStatusFilter to set 62 | */ 63 | public void setReleaseStatusFilter(ReleaseStatusFilterWs2 releaseStatusFilter) { 64 | this.releaseStatusFilter = releaseStatusFilter; 65 | } 66 | 67 | /** 68 | * @return the variousArtists 69 | */ 70 | public Boolean isVariousArtists() { 71 | return variousArtists; 72 | } 73 | 74 | /** 75 | * @param variousArtists the variousArtists to set 76 | */ 77 | public void setVariousArtists(Boolean variousArtists) { 78 | this.variousArtists = variousArtists; 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/WorkBrowseWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.browse; 2 | 3 | import org.musicbrainz.webservice.WebService; 4 | 5 | import java.util.List; 6 | import java.util.ArrayList; 7 | import org.musicbrainz.MBWS2Exception; 8 | import org.musicbrainz.filter.browsefilter.WorkBrowseFilterWs2; 9 | import org.musicbrainz.includes.WorkIncludesWs2; 10 | import org.musicbrainz.model.entity.WorkWs2; 11 | import org.musicbrainz.model.entity.listelement.WorkListWs2; 12 | 13 | public class WorkBrowseWs2 extends BrowseWs2{ 14 | 15 | WorkListWs2 WorkList = null; 16 | 17 | public WorkBrowseWs2(WorkBrowseFilterWs2 filter, 18 | WorkIncludesWs2 include){ 19 | 20 | super(filter, include); 21 | } 22 | public WorkBrowseWs2(WebService ws, 23 | WorkBrowseFilterWs2 filter, 24 | WorkIncludesWs2 include){ 25 | 26 | super(ws,filter, include); 27 | } 28 | 29 | public List getFullList() { 30 | 31 | getFirstPage(); 32 | while (hasMore()) 33 | { 34 | getNextPage(); 35 | } 36 | return WorkList.getWorks(); 37 | 38 | } 39 | public List getFirstPage() { 40 | 41 | WorkList = new WorkListWs2(); 42 | getNextPage(); 43 | 44 | return WorkList.getWorks(); 45 | } 46 | public List getNextPage() { 47 | 48 | if (WorkList == null) 49 | return getFirstPage(); 50 | 51 | List results = getOnePage(); 52 | 53 | WorkList.addAllWorks(results); 54 | filter.setOffset(filter.getOffset()+results.size()); 55 | 56 | return results; 57 | } 58 | public List getResults(){ 59 | 60 | if (WorkList.getWorks() == null) 61 | return getFirstPage(); 62 | 63 | return WorkList.getWorks(); 64 | 65 | } 66 | private List getOnePage() { 67 | 68 | List results 69 | = new ArrayList(0); 70 | 71 | try { 72 | WorkListWs2 temp = execQuery(); 73 | results.addAll(temp.getWorks()); 74 | 75 | } catch (org.musicbrainz.MBWS2Exception ex) { 76 | 77 | ex.printStackTrace(); 78 | } 79 | return results; 80 | } 81 | 82 | 83 | private WorkListWs2 execQuery() throws MBWS2Exception 84 | { 85 | 86 | WorkListWs2 le = getMetadata(WORK).getWorkListWs2(); 87 | listElement = le; 88 | 89 | int sz = le.getWorks().size(); 90 | return le; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/LabelBrowseWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.browse; 2 | 3 | import org.musicbrainz.webservice.WebService; 4 | import java.util.List; 5 | import java.util.ArrayList; 6 | import org.musicbrainz.MBWS2Exception; 7 | import org.musicbrainz.filter.browsefilter.LabelBrowseFilterWs2; 8 | import org.musicbrainz.includes.LabelIncludesWs2; 9 | import org.musicbrainz.model.entity.LabelWs2; 10 | import org.musicbrainz.model.entity.listelement.LabelListWs2; 11 | 12 | public class LabelBrowseWs2 extends BrowseWs2{ 13 | 14 | LabelListWs2 labelList = null; 15 | 16 | public LabelBrowseWs2(LabelBrowseFilterWs2 filter, 17 | LabelIncludesWs2 include){ 18 | 19 | super(filter, include); 20 | } 21 | public LabelBrowseWs2(WebService ws, 22 | LabelBrowseFilterWs2 filter, 23 | LabelIncludesWs2 include){ 24 | 25 | super(ws,filter, include); 26 | } 27 | 28 | public List getFullList() { 29 | 30 | getFirstPage(); 31 | while (hasMore()) 32 | { 33 | getNextPage(); 34 | } 35 | return labelList.getLabels(); 36 | 37 | } 38 | public List getFirstPage() { 39 | 40 | labelList = new LabelListWs2(); 41 | getNextPage(); 42 | 43 | return labelList.getLabels(); 44 | } 45 | public List getNextPage() { 46 | 47 | if (labelList == null) 48 | return getFirstPage(); 49 | 50 | List results = getOnePage(); 51 | 52 | labelList.addAllLabels(results); 53 | filter.setOffset(filter.getOffset()+results.size()); 54 | 55 | return results; 56 | } 57 | public List getResults(){ 58 | 59 | if (labelList.getLabels() == null) 60 | return getFirstPage(); 61 | 62 | return labelList.getLabels(); 63 | 64 | } 65 | private List getOnePage() { 66 | 67 | List results 68 | = new ArrayList(0); 69 | 70 | try { 71 | LabelListWs2 temp = execQuery(); 72 | results.addAll(temp.getLabels()); 73 | 74 | } catch (org.musicbrainz.MBWS2Exception ex) { 75 | 76 | ex.printStackTrace(); 77 | 78 | } 79 | return results; 80 | } 81 | 82 | 83 | private LabelListWs2 execQuery() throws MBWS2Exception 84 | { 85 | 86 | LabelListWs2 le = getMetadata(LABEL).getLabelListWs2(); 87 | listElement = le; 88 | 89 | int sz = le.getLabels().size(); 90 | return le; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/WorkSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.WorkSearchFilterWs2; 7 | import org.musicbrainz.model.searchresult.WorkResultWs2; 8 | import org.musicbrainz.model.searchresult.listelement.WorkSearchResultsWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | public class WorkSearchWs2 extends SearchWs2{ 12 | 13 | WorkSearchResultsWs2 workSearchResults = null; 14 | 15 | public WorkSearchWs2(WorkSearchFilterWs2 filter){ 16 | super(filter); 17 | } 18 | public WorkSearchWs2(WebService ws, WorkSearchFilterWs2 filter){ 19 | super(ws, filter); 20 | } 21 | 22 | public List getFullList() { 23 | 24 | getFirstPage(); 25 | while (hasMore()) 26 | { 27 | getNextPage(); 28 | } 29 | return workSearchResults.getWorkResults(); 30 | 31 | } 32 | public List getFirstPage() { 33 | 34 | workSearchResults = new WorkSearchResultsWs2(); 35 | setLastScore(100); 36 | getNextPage(); 37 | 38 | return workSearchResults.getWorkResults(); 39 | } 40 | 41 | public List getNextPage() { 42 | 43 | List results = getOnePage(); 44 | 45 | workSearchResults.getWorkResults().addAll(results); 46 | getFilter().setOffset(getFilter().getOffset()+results.size()); 47 | 48 | return results; 49 | } 50 | public List getResults(){ 51 | 52 | if (workSearchResults.getWorkResults() == null) 53 | return getFirstPage(); 54 | 55 | return workSearchResults.getWorkResults(); 56 | 57 | } 58 | private List getOnePage(){ 59 | 60 | List results 61 | = new ArrayList (); 62 | 63 | try { 64 | WorkSearchResultsWs2 temp = execQuery(); 65 | results.addAll(temp.getWorkResults()); 66 | 67 | } catch (org.musicbrainz.MBWS2Exception ex) { 68 | 69 | ex.printStackTrace(); 70 | 71 | } 72 | return results; 73 | } 74 | 75 | private WorkSearchResultsWs2 execQuery() throws MBWS2Exception 76 | { 77 | 78 | WorkSearchResultsWs2 le = getMetadata(WORK).getWorkResultsWs2(); 79 | setListElement(le); 80 | 81 | int sz = le.getWorkResults().size(); 82 | if (sz>0) 83 | { 84 | setLastScore((int) le.getWorkResults().get(sz-1).getScore()); 85 | } 86 | return le; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/ArtistBrowseWs2.java: -------------------------------------------------------------------------------- 1 | 2 | package org.musicbrainz.query.browse; 3 | 4 | import java.util.List; 5 | import java.util.ArrayList; 6 | 7 | import org.musicbrainz.MBWS2Exception; 8 | import org.musicbrainz.filter.browsefilter.ArtistBrowseFilterWs2; 9 | import org.musicbrainz.includes.ArtistIncludesWs2; 10 | import org.musicbrainz.model.entity.ArtistWs2; 11 | import org.musicbrainz.model.entity.listelement.ArtistListWs2; 12 | import org.musicbrainz.webservice.WebService; 13 | 14 | public class ArtistBrowseWs2 extends BrowseWs2{ 15 | 16 | ArtistListWs2 artistList = null; 17 | 18 | public ArtistBrowseWs2(ArtistBrowseFilterWs2 filter, 19 | ArtistIncludesWs2 include){ 20 | 21 | super(filter, include); 22 | } 23 | public ArtistBrowseWs2( WebService ws, 24 | ArtistBrowseFilterWs2 filter, 25 | ArtistIncludesWs2 include){ 26 | 27 | super(ws,filter, include); 28 | } 29 | 30 | public List getFullList() { 31 | 32 | getFirstPage(); 33 | while (hasMore()) 34 | { 35 | getNextPage(); 36 | } 37 | return artistList.getArtists(); 38 | 39 | } 40 | public List getFirstPage() { 41 | 42 | artistList = new ArtistListWs2(); 43 | getNextPage(); 44 | 45 | return artistList.getArtists(); 46 | } 47 | public List getNextPage() { 48 | 49 | if (artistList == null) 50 | return getFirstPage(); 51 | 52 | List results = getOnePage(); 53 | 54 | artistList.addAllArtists(results); 55 | filter.setOffset(filter.getOffset()+results.size()); 56 | 57 | return results; 58 | } 59 | public List getResults(){ 60 | 61 | if (artistList.getArtists() == null) 62 | return getFirstPage(); 63 | 64 | return artistList.getArtists(); 65 | 66 | } 67 | private List getOnePage() { 68 | 69 | List results 70 | = new ArrayList(0); 71 | 72 | try { 73 | ArtistListWs2 temp = execQuery(); 74 | results.addAll(temp.getArtists()); 75 | 76 | } catch (org.musicbrainz.MBWS2Exception ex) { 77 | 78 | ex.printStackTrace(); 79 | } 80 | 81 | return results; 82 | } 83 | 84 | 85 | private ArtistListWs2 execQuery() throws MBWS2Exception 86 | { 87 | 88 | ArtistListWs2 le = getMetadata(ARTIST).getArtistListWs2(); 89 | listElement = le; 90 | 91 | int sz = le.getArtists().size(); 92 | return le; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/ReleaseBrowseWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.browse; 2 | 3 | import org.musicbrainz.webservice.WebService; 4 | 5 | import java.util.List; 6 | import java.util.ArrayList; 7 | import org.musicbrainz.MBWS2Exception; 8 | import org.musicbrainz.filter.browsefilter.ReleaseBrowseFilterWs2; 9 | import org.musicbrainz.includes.ReleaseIncludesWs2; 10 | import org.musicbrainz.model.entity.ReleaseWs2; 11 | import org.musicbrainz.model.entity.listelement.ReleaseListWs2; 12 | 13 | public class ReleaseBrowseWs2 extends BrowseWs2{ 14 | 15 | ReleaseListWs2 releaseList = null; 16 | 17 | public ReleaseBrowseWs2(ReleaseBrowseFilterWs2 filter, 18 | ReleaseIncludesWs2 include){ 19 | 20 | super(filter, include); 21 | } 22 | public ReleaseBrowseWs2(WebService ws, 23 | ReleaseBrowseFilterWs2 filter, 24 | ReleaseIncludesWs2 include){ 25 | 26 | super(ws,filter, include); 27 | } 28 | 29 | public List getFullList() { 30 | 31 | getFirstPage(); 32 | while (hasMore()) 33 | { 34 | getNextPage(); 35 | } 36 | return releaseList.getReleases(); 37 | 38 | } 39 | public List getFirstPage() { 40 | 41 | releaseList = new ReleaseListWs2(); 42 | getNextPage(); 43 | 44 | return releaseList.getReleases(); 45 | } 46 | public List getNextPage() { 47 | 48 | if (releaseList == null) 49 | return getFirstPage(); 50 | 51 | List results = getOnePage(); 52 | 53 | releaseList.addAllReleases(results); 54 | filter.setOffset(filter.getOffset()+results.size()); 55 | 56 | return results; 57 | } 58 | public List getResults(){ 59 | 60 | if (releaseList.getReleases() == null) 61 | return getFirstPage(); 62 | 63 | return releaseList.getReleases(); 64 | 65 | } 66 | private List getOnePage() { 67 | 68 | List results 69 | = new ArrayList(0); 70 | 71 | try { 72 | ReleaseListWs2 temp = execQuery(); 73 | results.addAll(temp.getReleases()); 74 | 75 | } catch (org.musicbrainz.MBWS2Exception ex) { 76 | 77 | ex.printStackTrace(); 78 | } 79 | return results; 80 | } 81 | 82 | 83 | private ReleaseListWs2 execQuery() throws MBWS2Exception 84 | { 85 | 86 | ReleaseListWs2 le = getMetadata(RELEASE).getReleaseListWs2(); 87 | listElement = le; 88 | 89 | int sz = le.getReleases().size(); 90 | return le; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/LabelSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.LabelSearchFilterWs2; 7 | import org.musicbrainz.model.searchresult.LabelResultWs2; 8 | import org.musicbrainz.model.searchresult.listelement.LabelSearchResultsWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | public class LabelSearchWs2 extends SearchWs2{ 12 | 13 | LabelSearchResultsWs2 labelSearchResults = null; 14 | 15 | public LabelSearchWs2(LabelSearchFilterWs2 filter){ 16 | super(filter); 17 | } 18 | public LabelSearchWs2(WebService ws, LabelSearchFilterWs2 filter){ 19 | super(ws, filter); 20 | } 21 | public List getFullList() { 22 | 23 | getFirstPage(); 24 | while (hasMore()) 25 | { 26 | getNextPage(); 27 | } 28 | return labelSearchResults.getLabelResults(); 29 | 30 | } 31 | public List getFirstPage() { 32 | 33 | labelSearchResults = new LabelSearchResultsWs2(); 34 | setLastScore(100); 35 | getNextPage(); 36 | 37 | return labelSearchResults.getLabelResults(); 38 | } 39 | 40 | public List getNextPage() { 41 | 42 | List results = getOnePage(); 43 | 44 | labelSearchResults.getLabelResults().addAll(results); 45 | getFilter().setOffset(getFilter().getOffset()+results.size()); 46 | 47 | return results; 48 | } 49 | public List getResults(){ 50 | 51 | if (labelSearchResults.getLabelResults() == null) 52 | return getFirstPage(); 53 | 54 | return labelSearchResults.getLabelResults(); 55 | 56 | } 57 | private List getOnePage(){ 58 | 59 | List results 60 | = new ArrayList (); 61 | 62 | try { 63 | LabelSearchResultsWs2 temp = execQuery(); 64 | results.addAll(temp.getLabelResults()); 65 | return results; 66 | 67 | } catch (org.musicbrainz.MBWS2Exception ex) { 68 | ex.printStackTrace(); 69 | return results; 70 | } 71 | } 72 | 73 | private LabelSearchResultsWs2 execQuery() throws MBWS2Exception 74 | { 75 | 76 | LabelSearchResultsWs2 le = getMetadata(LABEL).getLabelResultsWs2(); 77 | setListElement(le); 78 | 79 | int sz = le.getLabelResults().size(); 80 | if (sz>0) 81 | { 82 | setLastScore((int) le.getLabelResults().get(sz-1).getScore()); 83 | } 84 | return le; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/ReleaseSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.musicbrainz.MBWS2Exception; 7 | import org.musicbrainz.filter.searchfilter.ReleaseSearchFilterWs2; 8 | import org.musicbrainz.model.searchresult.ReleaseResultWs2; 9 | import org.musicbrainz.model.searchresult.listelement.ReleaseSearchResultsWs2; 10 | import org.musicbrainz.webservice.WebService; 11 | 12 | public class ReleaseSearchWs2 extends SearchWs2{ 13 | 14 | ReleaseSearchResultsWs2 releaseSearchResults = null; 15 | 16 | public ReleaseSearchWs2(ReleaseSearchFilterWs2 filter){ 17 | super(filter); 18 | } 19 | 20 | public ReleaseSearchWs2(WebService ws, ReleaseSearchFilterWs2 filter){ 21 | super(ws, filter); 22 | } 23 | 24 | public List getFullList() throws MBWS2Exception { 25 | 26 | getFirstPage(); 27 | while (hasMore()) 28 | { 29 | getNextPage(); 30 | } 31 | return releaseSearchResults.getReleaseResults(); 32 | 33 | } 34 | public List getFirstPage() throws MBWS2Exception { 35 | 36 | releaseSearchResults = new ReleaseSearchResultsWs2(); 37 | setLastScore(100); 38 | getNextPage(); 39 | 40 | return releaseSearchResults.getReleaseResults(); 41 | } 42 | public List getNextPage() throws MBWS2Exception { 43 | 44 | List results = getOnePage(); 45 | 46 | releaseSearchResults.getReleaseResults().addAll(results); 47 | getFilter().setOffset(getFilter().getOffset()+results.size()); 48 | 49 | return results; 50 | } 51 | public List getResults() throws MBWS2Exception{ 52 | 53 | if (releaseSearchResults.getReleaseResults() == null) 54 | return getFirstPage(); 55 | 56 | return releaseSearchResults.getReleaseResults(); 57 | 58 | } 59 | private List getOnePage() throws MBWS2Exception { 60 | 61 | List results 62 | = new ArrayList(0); 63 | 64 | ReleaseSearchResultsWs2 temp = execQuery(); 65 | results.addAll(temp.getReleaseResults()); 66 | 67 | return results; 68 | } 69 | 70 | 71 | private ReleaseSearchResultsWs2 execQuery() throws MBWS2Exception 72 | { 73 | 74 | ReleaseSearchResultsWs2 le = getMetadata(RELEASE).getReleaseResultsWs2(); 75 | setListElement(le); 76 | 77 | int sz = le.getReleaseResults().size(); 78 | if (sz>0) 79 | { 80 | setLastScore((int) le.getReleaseResults().get(sz-1).getScore()); 81 | } 82 | return le; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/ArtistSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.ArtistSearchFilterWs2; 7 | import org.musicbrainz.model.searchresult.listelement.ArtistSearchResultsWs2; 8 | import org.musicbrainz.model.searchresult.ArtistResultWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | 12 | public class ArtistSearchWs2 extends SearchWs2{ 13 | 14 | private ArtistSearchResultsWs2 artistSearchResults = null; 15 | 16 | public ArtistSearchWs2(ArtistSearchFilterWs2 filter){ 17 | super(filter); 18 | } 19 | 20 | public ArtistSearchWs2(WebService ws, ArtistSearchFilterWs2 filter){ 21 | super(ws, filter); 22 | } 23 | 24 | public List getFullList() { 25 | 26 | getFirstPage(); 27 | while (hasMore()) 28 | { 29 | getNextPage(); 30 | } 31 | return artistSearchResults.getArtistResults(); 32 | 33 | } 34 | public List getFirstPage() { 35 | 36 | artistSearchResults = new ArtistSearchResultsWs2(); 37 | setLastScore(100); 38 | getNextPage(); 39 | 40 | return artistSearchResults.getArtistResults(); 41 | } 42 | 43 | public List getNextPage() { 44 | 45 | List results = getOnePage(); 46 | 47 | artistSearchResults.getArtistResults().addAll(results); 48 | getFilter().setOffset(getFilter().getOffset()+results.size()); 49 | 50 | return results; 51 | } 52 | public List getResults(){ 53 | 54 | if (artistSearchResults.getArtistResults() == null) 55 | return getFirstPage(); 56 | 57 | return artistSearchResults.getArtistResults(); 58 | 59 | } 60 | private List getOnePage(){ 61 | 62 | List results 63 | = new ArrayList (); 64 | 65 | try { 66 | ArtistSearchResultsWs2 temp = execQuery(); 67 | results.addAll(temp.getArtistResults()); 68 | 69 | 70 | } catch (org.musicbrainz.MBWS2Exception ex) { 71 | 72 | ex.printStackTrace(); 73 | } 74 | 75 | return results; 76 | } 77 | 78 | private ArtistSearchResultsWs2 execQuery() throws MBWS2Exception 79 | { 80 | 81 | ArtistSearchResultsWs2 le = getMetadata(ARTIST).getArtistResultsWs2(); 82 | setListElement(le); 83 | 84 | int sz = le.getArtistResults().size(); 85 | if (sz>0) 86 | { 87 | setLastScore((int) le.getArtistResults().get(sz-1).getScore()); 88 | } 89 | return le; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/CollectionReleasesHandlerWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.model.entity.CollectionWs2; 6 | import org.musicbrainz.query.QueryWs2; 7 | import org.musicbrainz.webservice.WebService; 8 | import org.musicbrainz.webservice.WebServiceException; 9 | import org.musicbrainz.wsxml.MbXMLException; 10 | import org.musicbrainz.wsxml.element.Metadata; 11 | 12 | 13 | public class CollectionReleasesHandlerWs2 extends QueryWs2{ 14 | 15 | private List releases; 16 | private CollectionWs2 collection; 17 | 18 | public CollectionReleasesHandlerWs2(CollectionWs2 collection, List releases){ 19 | super(); 20 | this.releases=releases; 21 | this.collection=collection; 22 | } 23 | 24 | public CollectionReleasesHandlerWs2(WebService ws, CollectionWs2 collection, List releases){ 25 | super(ws); 26 | this.releases=releases; 27 | this.collection=collection; 28 | } 29 | 30 | public Metadata put() throws WebServiceException, MbXMLException{ 31 | 32 | List toAdd= new ArrayList(); 33 | int max=0; 34 | Metadata md=null; 35 | 36 | for (String rel : releases) 37 | { 38 | if (max>25) 39 | { 40 | md =super.putToWebService(COLLECTION, collection.getId(), toAdd); 41 | //Logger.getLogger(Collection.class.getName()).log(Level.INFO, md.getMessage(), md.getMessage()); 42 | toAdd.clear(); 43 | } 44 | toAdd.add(rel); 45 | } 46 | if (!toAdd.isEmpty()) 47 | { 48 | md= super.putToWebService(COLLECTION, collection.getId(), toAdd); 49 | //Logger.getLogger(Collection.class.getName()).log(Level.INFO, md.getMessage(), md.getMessage()); 50 | } 51 | return md; 52 | } 53 | public Metadata delete() throws WebServiceException, MbXMLException{ 54 | 55 | List toDelete= new ArrayList(); 56 | int max=0; 57 | Metadata md=null;; 58 | for (String rel : releases) 59 | { 60 | if (max>25) 61 | { 62 | md = super.deleteFromWebService(COLLECTION, collection.getId(), toDelete); 63 | //Logger.getLogger(Collection.class.getName()).log(Level.INFO, md.getMessage(), md.getMessage()); 64 | toDelete.clear(); 65 | } 66 | toDelete.add(rel); 67 | } 68 | if (!toDelete.isEmpty()) 69 | { 70 | md =super.deleteFromWebService(COLLECTION, collection.getId(), toDelete); 71 | //Logger.getLogger(Collection.class.getName()).log(Level.INFO, md.getMessage(), md.getMessage()); 72 | } 73 | return md; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/webservice/WebService.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.webservice; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.musicbrainz.wsxml.MbXMLException; 7 | import org.musicbrainz.wsxml.element.Metadata; 8 | 9 | /** 10 | * An interface all concrete web service classes have to implement. 11 | * 12 | */ 13 | public interface WebService { 14 | 15 | /** 16 | *

Queries the web service.

17 | * 18 | *

Using this method, you can either get a resource by id (using 19 | * the id parameter, or perform a query on all 20 | * resources of a type.

21 | * 22 | *

The filter and the id parameter exclude 23 | * each other. If you are using a filter, you may not set 24 | * id and vice versa.

25 | * 26 | *

Returns a populated {@link Metadata} object containing the result.

27 | * 28 | * @param entity a string containing the entity's name 29 | * @param id a string containing a UUID, or the empty string 30 | * @param includeParams a list containing values for the 'inc' parameter 31 | * @param filterParams parameters, depending on the entity 32 | * @return A populated {@link Metadata} object 33 | * 34 | * @throws WebServiceException A web service exception 35 | * @throws MbXMLException A parser exception 36 | */ 37 | public Metadata get(String entity, String id, List includeParams, Map filterParams) 38 | throws WebServiceException, MbXMLException; 39 | 40 | /** 41 | * Submit data to the web service. 42 | * 43 | * @param metadata Metada Object 44 | */ 45 | public Metadata post (Metadata metadata) 46 | throws WebServiceException, MbXMLException; 47 | 48 | /** 49 | * Put data to the web service. 50 | * 51 | * @param entity A string containing the entity's name 52 | * @param id A string containing a UUID, or the empty string 53 | * @param data A List containing the data to put, directly in 54 | * the URL (i.e. collection releases). 55 | */ 56 | public Metadata put (String entity, String id, List data) 57 | throws WebServiceException, MbXMLException; 58 | /** 59 | * Delete data from the web service. 60 | * 61 | * @param entity A string containing the entity's name 62 | * @param id A string containing a UUID, or the empty string 63 | * @param data A List containing the data to delete, directly in 64 | * the URL (i.e. collection releases). 65 | */ 66 | public Metadata delete (String entity, String id, List data) 67 | throws WebServiceException, MbXMLException; 68 | 69 | public void setUsername(String username); 70 | public void setPassword(String password); 71 | public void setClient(String client); 72 | } -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/submission/EntityTypeElementList.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.submission; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.DomainsWs2; 6 | 7 | /** 8 | * Each Submission could contain requests for 9 | * entities by different Entity Types. 10 | * A EntityTypeElementList is the sub list for 11 | * a specific entity Type. 12 | * 13 | **/ 14 | public class EntityTypeElementList extends DomainsWs2{ 15 | 16 | /* 17 | * The entity (list) type. Must be one of 18 | * LABELLIST 19 | * ARTISTLIST 20 | * RELEASEGROUPLIST 21 | * WORKLIST 22 | * RECORDINGLIST 23 | */ 24 | private String entityListType; 25 | /* 26 | * The List of Entity Elements. 27 | * 28 | */ 29 | private List entityElementList = new ArrayList(); 30 | 31 | /** 32 | * @return the entityListType 33 | */ 34 | public String getEntityListType() { 35 | return entityListType; 36 | } 37 | 38 | /** 39 | * @param entityListType the entityListType to set 40 | */ 41 | public void setEntityListType(String entityListType) { 42 | this.entityListType = entityListType; 43 | } 44 | 45 | /** 46 | * @return the entityElementList 47 | */ 48 | public List getEntityElementList() { 49 | return entityElementList; 50 | } 51 | 52 | /** 53 | * @param entityElementList the entityElementList to set 54 | */ 55 | public void setEntityElementList(List entityElementList) { 56 | this.entityElementList = entityElementList; 57 | } 58 | public void addEntityElement (EntityElement entityElement) { 59 | 60 | if (!checkEntityType(entityElement.getEntityType())); 61 | // reject 62 | 63 | boolean found=false; 64 | for (EntityElement e: entityElementList) 65 | { 66 | if (e.getId().equals(entityElement.getId())) 67 | { 68 | found=true; 69 | e.setTagList(entityElement.getTagList()); 70 | e.setUserRating(entityElement.getUserRating()); 71 | continue; 72 | } 73 | } 74 | if (!found){ 75 | entityElementList.add(entityElement); 76 | } 77 | } 78 | private boolean checkEntityType(String EntityType){ 79 | 80 | if(entityListType.equals(LABELLIST) && EntityType.equals(LABEL)) return true; 81 | if(entityListType.equals(ARTISTLIST) && EntityType.equals(ARTIST)) return true; 82 | if(entityListType.equals(RELEASEGROUPLIST) && EntityType.equals(RELEASEGROUP)) return true; 83 | if(entityListType.equals(RECORDINGLIST) && EntityType.equals(RECORDING)) return true; 84 | if(entityListType.equals(WORKLIST) && EntityType.equals(WORK)) return true; 85 | return false; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/RecordingBrowseWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.browse; 2 | 3 | import org.musicbrainz.webservice.WebService; 4 | 5 | import java.util.List; 6 | import java.util.ArrayList; 7 | import org.musicbrainz.MBWS2Exception; 8 | import org.musicbrainz.filter.browsefilter.RecordingBrowseFilterWs2; 9 | import org.musicbrainz.includes.RecordingIncludesWs2; 10 | import org.musicbrainz.model.entity.RecordingWs2; 11 | import org.musicbrainz.model.entity.listelement.RecordingListWs2; 12 | 13 | public class RecordingBrowseWs2 extends BrowseWs2{ 14 | 15 | RecordingListWs2 recordingList = null; 16 | 17 | public RecordingBrowseWs2(RecordingBrowseFilterWs2 filter, 18 | RecordingIncludesWs2 include){ 19 | 20 | super(filter, include); 21 | } 22 | public RecordingBrowseWs2(WebService ws, 23 | RecordingBrowseFilterWs2 filter, 24 | RecordingIncludesWs2 include){ 25 | 26 | super(ws,filter, include); 27 | } 28 | 29 | public List getFullList() { 30 | 31 | getFirstPage(); 32 | while (hasMore()) 33 | { 34 | getNextPage(); 35 | } 36 | return recordingList.getRecordings(); 37 | 38 | } 39 | public List getFirstPage() { 40 | 41 | recordingList = new RecordingListWs2(); 42 | getNextPage(); 43 | 44 | return recordingList.getRecordings(); 45 | } 46 | public List getNextPage() { 47 | 48 | if (recordingList == null) 49 | return getFirstPage(); 50 | 51 | List results = getOnePage(); 52 | 53 | recordingList.addAllRecordings(results); 54 | filter.setOffset(filter.getOffset()+results.size()); 55 | 56 | return results; 57 | } 58 | public List getResults(){ 59 | 60 | if (recordingList.getRecordings() == null) 61 | return getFirstPage(); 62 | 63 | return recordingList.getRecordings(); 64 | 65 | } 66 | private List getOnePage() { 67 | 68 | List results 69 | = new ArrayList(0); 70 | 71 | 72 | try { 73 | RecordingListWs2 temp = execQuery(); 74 | results.addAll(temp.getRecordings()); 75 | 76 | 77 | } catch (org.musicbrainz.MBWS2Exception ex) { 78 | 79 | ex.printStackTrace(); 80 | 81 | } 82 | return results; 83 | } 84 | 85 | 86 | private RecordingListWs2 execQuery() throws MBWS2Exception 87 | { 88 | 89 | RecordingListWs2 le = getMetadata(RECORDING).getRecordingListWs2(); 90 | listElement = le; 91 | 92 | int sz = le.getRecordings().size(); 93 | return le; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/RecordingSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | 6 | import org.musicbrainz.MBWS2Exception; 7 | import org.musicbrainz.filter.searchfilter.RecordingSearchFilterWs2; 8 | import org.musicbrainz.model.searchresult.RecordingResultWs2; 9 | import org.musicbrainz.model.searchresult.listelement.RecordingSearchResultsWs2; 10 | import org.musicbrainz.webservice.WebService; 11 | 12 | public class RecordingSearchWs2 extends SearchWs2{ 13 | 14 | RecordingSearchResultsWs2 recordingSearchResults = null; 15 | 16 | public RecordingSearchWs2(RecordingSearchFilterWs2 filter){ 17 | super(filter); 18 | } 19 | public RecordingSearchWs2(WebService ws, RecordingSearchFilterWs2 filter){ 20 | super(ws, filter); 21 | } 22 | 23 | public List getFullList() { 24 | 25 | getFirstPage(); 26 | while (hasMore()) 27 | { 28 | getNextPage(); 29 | } 30 | return recordingSearchResults.getRecordingResults(); 31 | 32 | } 33 | public List getFirstPage() { 34 | 35 | recordingSearchResults = new RecordingSearchResultsWs2(); 36 | setLastScore(100); 37 | getNextPage(); 38 | 39 | return recordingSearchResults.getRecordingResults(); 40 | } 41 | public List getNextPage() { 42 | 43 | List results = getOnePage(); 44 | 45 | recordingSearchResults.getRecordingResults().addAll(results); 46 | getFilter().setOffset(getFilter().getOffset()+results.size()); 47 | 48 | return results; 49 | } 50 | public List getResults(){ 51 | 52 | if (recordingSearchResults.getRecordingResults() == null) 53 | return getFirstPage(); 54 | 55 | return recordingSearchResults.getRecordingResults(); 56 | 57 | } 58 | private List getOnePage() { 59 | 60 | List results 61 | = new ArrayList(0); 62 | 63 | try { 64 | RecordingSearchResultsWs2 temp = execQuery(); 65 | results.addAll(temp.getRecordingResults()); 66 | 67 | 68 | } catch (org.musicbrainz.MBWS2Exception ex) { 69 | 70 | ex.printStackTrace(); 71 | } 72 | return results; 73 | } 74 | 75 | 76 | private RecordingSearchResultsWs2 execQuery() throws MBWS2Exception 77 | { 78 | 79 | RecordingSearchResultsWs2 le = getMetadata(RECORDING).getRecordingResultsWs2(); 80 | setListElement(le); 81 | 82 | int sz = le.getRecordingResults().size(); 83 | if (sz>0) 84 | { 85 | setLastScore((int) le.getRecordingResults().get(sz-1).getScore()); 86 | } 87 | return le; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/PuidWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.List; 4 | 5 | import java.util.logging.Logger; 6 | import org.musicbrainz.model.entity.RecordingWs2; 7 | import org.musicbrainz.model.entity.listelement.RecordingListWs2; 8 | 9 | /** 10 | *

A single Puid and the List of referring 11 | * recordings. 12 | */ 13 | public class PuidWs2 14 | { 15 | private static Logger log = Logger.getLogger(PuidWs2.class.getName()); 16 | 17 | private String id; 18 | private RecordingListWs2 recordingList = new RecordingListWs2(); 19 | 20 | 21 | /** 22 | * Default Constructor 23 | */ 24 | public PuidWs2() 25 | { 26 | 27 | } 28 | 29 | public PuidWs2(String id, 30 | RecordingListWs2 recordingList) 31 | { 32 | this.id = id; 33 | this.recordingList = recordingList; 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | public void setId(String id) { 40 | this.id = id; 41 | } 42 | /** 43 | * Gets the underlying List of recording. 44 | * 45 | * @return the recordings 46 | */ 47 | public List getRecordings() { 48 | return ( recordingList == null ? null : recordingList.getRecordings()); 49 | } 50 | /** 51 | * Sets the underlying List of recordings. 52 | * 53 | * Note: This will implicitly create a new {@link #recordingList} 54 | * if it is null. 55 | * 56 | * @param recordings the recordings to set 57 | */ 58 | public void setRecordings(List recordings) 59 | { 60 | if (recordingList == null) { 61 | recordingList = new RecordingListWs2(); 62 | } 63 | 64 | this.recordingList.setRecordings(recordings); 65 | } 66 | /** 67 | * @return the recordingList 68 | */ 69 | public RecordingListWs2 getRecordingList() { 70 | return recordingList; 71 | } 72 | 73 | /** 74 | * @param recordingList the recordingList to set 75 | */ 76 | public void setRecordingList(RecordingListWs2 recordingList) { 77 | this.recordingList = recordingList; 78 | } 79 | /** 80 | *

Adds a recording to the underlying List 81 | * of recordings.

82 | * 83 | *

Note: This will implicitly create a new {@link #recordingList} 84 | * if it is null.

85 | * 86 | * @param recording The {@link RecordingWs2} to add. 87 | */ 88 | public void addRecording(RecordingWs2 recording) 89 | { 90 | if (recordingList == null) { 91 | recordingList = new RecordingListWs2(); 92 | } 93 | recordingList.addRecording(recording); 94 | } 95 | @Override 96 | public String toString() { 97 | return id; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/AnnotationSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.AnnotationSearchtFilterWs2; 7 | import org.musicbrainz.model.searchresult.AnnotationResultWs2; 8 | import org.musicbrainz.model.searchresult.listelement.AnnotationSearchResultsWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | public class AnnotationSearchWs2 extends SearchWs2{ 12 | 13 | AnnotationSearchResultsWs2 annotationSearchResults = null; 14 | 15 | public AnnotationSearchWs2(AnnotationSearchtFilterWs2 filter){ 16 | super(filter); 17 | } 18 | public AnnotationSearchWs2(WebService ws, AnnotationSearchtFilterWs2 filter){ 19 | super(ws, filter); 20 | } 21 | 22 | public List getFullList() { 23 | 24 | getFirstPage(); 25 | while (hasMore()) 26 | { 27 | getNextPage(); 28 | } 29 | return annotationSearchResults.getAnnotationResults(); 30 | 31 | } 32 | public List getFirstPage() { 33 | 34 | annotationSearchResults = new AnnotationSearchResultsWs2(); 35 | setLastScore(100); 36 | getNextPage(); 37 | 38 | return annotationSearchResults.getAnnotationResults(); 39 | } 40 | 41 | public List getNextPage() { 42 | 43 | List results = getOnePage(); 44 | 45 | annotationSearchResults.getAnnotationResults().addAll(results); 46 | getFilter().setOffset(getFilter().getOffset()+results.size()); 47 | 48 | return results; 49 | } 50 | public List getResults(){ 51 | 52 | if (annotationSearchResults.getAnnotationResults() == null) 53 | return getFirstPage(); 54 | 55 | return annotationSearchResults.getAnnotationResults(); 56 | 57 | } 58 | private List getOnePage(){ 59 | 60 | List results 61 | = new ArrayList (); 62 | 63 | try { 64 | AnnotationSearchResultsWs2 temp = execQuery(); 65 | results.addAll(temp.getAnnotationResults()); 66 | 67 | } catch (org.musicbrainz.MBWS2Exception ex) { 68 | ex.printStackTrace(); 69 | } 70 | 71 | return results; 72 | } 73 | 74 | private AnnotationSearchResultsWs2 execQuery() throws MBWS2Exception 75 | { 76 | 77 | AnnotationSearchResultsWs2 le = getMetadata(ANNOTATION).getAnnotationResultsWs2(); 78 | setListElement(le); 79 | 80 | int sz = le.getAnnotationResults().size(); 81 | if (sz>0) 82 | { 83 | setLastScore((int) le.getAnnotationResults().get(sz-1).getScore()); 84 | } 85 | return le; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/IsrcWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.List; 4 | 5 | import java.util.logging.Logger; 6 | import org.musicbrainz.model.entity.RecordingWs2; 7 | import org.musicbrainz.model.entity.listelement.RecordingListWs2; 8 | 9 | /** 10 | *

A single Puid and the List of referring 11 | * recordings. 12 | */ 13 | public class IsrcWs2 14 | { 15 | private static Logger log = Logger.getLogger(IsrcWs2.class.getName()); 16 | 17 | private String id; 18 | private RecordingListWs2 recordingList = new RecordingListWs2(); 19 | 20 | 21 | /** 22 | * Default Constructor 23 | */ 24 | public IsrcWs2() 25 | { 26 | 27 | } 28 | 29 | public IsrcWs2(String id, 30 | RecordingListWs2 recordingList) 31 | { 32 | this.id = id; 33 | this.recordingList = recordingList; 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | public void setId(String id) { 40 | this.id = id; 41 | } 42 | /** 43 | * Gets the underlying List of recording. 44 | * 45 | * @return the recordings 46 | */ 47 | public List getRecordings() { 48 | return ( recordingList == null ? null : recordingList.getRecordings()); 49 | } 50 | /** 51 | * Sets the underlying List of recordings. 52 | * 53 | * Note: This will implicitly create a new {@link #recordingList} 54 | * if it is null. 55 | * 56 | * @param recordings the recordings to set 57 | */ 58 | public void setRecordings(List recordings) 59 | { 60 | if (recordingList == null) { 61 | recordingList = new RecordingListWs2(); 62 | } 63 | 64 | this.recordingList.setRecordings(recordings); 65 | } 66 | /** 67 | * @return the recordingList 68 | */ 69 | public RecordingListWs2 getRecordingList() { 70 | return recordingList; 71 | } 72 | 73 | /** 74 | * @param recordingList the recordingList to set 75 | */ 76 | public void setRecordingList(RecordingListWs2 recordingList) { 77 | this.recordingList = recordingList; 78 | } 79 | /** 80 | *

Adds a recording to the underlying List 81 | * of recordings.

82 | * 83 | *

Note: This will implicitly create a new {@link #recordingList} 84 | * if it is null.

85 | * 86 | * @param recording The {@link RecordingWs2} to add. 87 | */ 88 | public void addRecording(RecordingWs2 recording) 89 | { 90 | if (recordingList == null) { 91 | recordingList = new RecordingListWs2(); 92 | } 93 | recordingList.addRecording(recording); 94 | } 95 | 96 | /* (non-Javadoc) 97 | * @see java.lang.Object#toString() 98 | */ 99 | @Override 100 | public String toString() { 101 | return id; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/ReleaseGroupSearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import org.musicbrainz.MBWS2Exception; 6 | import org.musicbrainz.filter.searchfilter.ReleaseGroupSearchFilterWs2; 7 | import org.musicbrainz.model.searchresult.ReleaseGroupResultWs2; 8 | import org.musicbrainz.model.searchresult.listelement.ReleaseGroupSearchResultsWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | 11 | public class ReleaseGroupSearchWs2 extends SearchWs2{ 12 | 13 | ReleaseGroupSearchResultsWs2 releaseGroupSearchResults = null; 14 | 15 | public ReleaseGroupSearchWs2(ReleaseGroupSearchFilterWs2 filter){ 16 | super(filter); 17 | } 18 | public ReleaseGroupSearchWs2(WebService ws, ReleaseGroupSearchFilterWs2 filter){ 19 | super(ws, filter); 20 | } 21 | 22 | public List getFullList() { 23 | 24 | getFirstPage(); 25 | while (hasMore()) 26 | { 27 | getNextPage(); 28 | } 29 | return releaseGroupSearchResults.getReleaseGroupResults(); 30 | 31 | } 32 | public List getFirstPage() { 33 | 34 | releaseGroupSearchResults = new ReleaseGroupSearchResultsWs2(); 35 | setLastScore(100); 36 | getNextPage(); 37 | 38 | return releaseGroupSearchResults.getReleaseGroupResults(); 39 | } 40 | public List getNextPage() { 41 | 42 | List results = getOnePage(); 43 | 44 | releaseGroupSearchResults.getReleaseGroupResults().addAll(results); 45 | getFilter().setOffset(getFilter().getOffset()+results.size()); 46 | 47 | return results; 48 | } 49 | public List getResults(){ 50 | 51 | if (releaseGroupSearchResults.getReleaseGroupResults() == null) 52 | return getFirstPage(); 53 | 54 | return releaseGroupSearchResults.getReleaseGroupResults(); 55 | 56 | } 57 | private List getOnePage() { 58 | 59 | List results 60 | = new ArrayList(0); 61 | 62 | try { 63 | ReleaseGroupSearchResultsWs2 temp = execQuery(); 64 | results.addAll(temp.getReleaseGroupResults()); 65 | 66 | 67 | } catch (org.musicbrainz.MBWS2Exception ex) { 68 | 69 | ex.printStackTrace(); 70 | 71 | } 72 | return results; 73 | } 74 | 75 | 76 | private ReleaseGroupSearchResultsWs2 execQuery() throws MBWS2Exception 77 | { 78 | 79 | ReleaseGroupSearchResultsWs2 le = getMetadata(RELEASEGROUP).getReleaseGroupResultsWs2(); 80 | setListElement(le); 81 | 82 | int sz = le.getReleaseGroupResults().size(); 83 | if (sz>0) 84 | { 85 | setLastScore((int) le.getReleaseGroupResults().get(sz-1).getScore()); 86 | } 87 | return le; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/browse/ReleaseGroupBrowseWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.browse; 2 | 3 | import org.musicbrainz.webservice.WebService; 4 | 5 | import java.util.List; 6 | import java.util.ArrayList; 7 | import org.musicbrainz.MBWS2Exception; 8 | import org.musicbrainz.filter.browsefilter.ReleaseGroupBrowseFilterWs2; 9 | import org.musicbrainz.includes.ReleaseGroupIncludesWs2; 10 | import org.musicbrainz.model.entity.ReleaseGroupWs2; 11 | import org.musicbrainz.model.entity.listelement.ReleaseGroupListWs2; 12 | 13 | public class ReleaseGroupBrowseWs2 extends BrowseWs2{ 14 | 15 | ReleaseGroupListWs2 releaseGroupList = null; 16 | 17 | public ReleaseGroupBrowseWs2(ReleaseGroupBrowseFilterWs2 filter, 18 | ReleaseGroupIncludesWs2 include){ 19 | 20 | super(filter, include); 21 | } 22 | public ReleaseGroupBrowseWs2(WebService ws, 23 | ReleaseGroupBrowseFilterWs2 filter, 24 | ReleaseGroupIncludesWs2 include){ 25 | 26 | super(ws,filter, include); 27 | } 28 | 29 | public List getFullList() { 30 | 31 | getFirstPage(); 32 | while (hasMore()) 33 | { 34 | getNextPage(); 35 | } 36 | return releaseGroupList.getReleaseGroups(); 37 | 38 | } 39 | public List getFirstPage() { 40 | 41 | releaseGroupList = new ReleaseGroupListWs2(); 42 | getNextPage(); 43 | 44 | return releaseGroupList.getReleaseGroups(); 45 | } 46 | public List getNextPage() { 47 | 48 | if (releaseGroupList == null) 49 | return getFirstPage(); 50 | 51 | List results = getOnePage(); 52 | 53 | releaseGroupList.addAllReleaseGroups(results); 54 | filter.setOffset(filter.getOffset()+results.size()); 55 | 56 | return results; 57 | } 58 | public List getResults(){ 59 | 60 | if (releaseGroupList.getReleaseGroups() == null) 61 | return getFirstPage(); 62 | 63 | return releaseGroupList.getReleaseGroups(); 64 | 65 | } 66 | private List getOnePage() { 67 | 68 | List results 69 | = new ArrayList(0); 70 | 71 | try { 72 | ReleaseGroupListWs2 temp = execQuery(); 73 | results.addAll(temp.getReleaseGroups()); 74 | 75 | 76 | } catch (org.musicbrainz.MBWS2Exception ex) { 77 | 78 | ex.printStackTrace(); 79 | 80 | } 81 | return results; 82 | } 83 | 84 | 85 | private ReleaseGroupListWs2 execQuery() throws MBWS2Exception 86 | { 87 | 88 | ReleaseGroupListWs2 le = getMetadata(RELEASEGROUP).getReleaseGroupListWs2(); 89 | listElement = le; 90 | 91 | int sz = le.getReleaseGroups().size(); 92 | return le; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/includes/RecordingIncludesWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.includes; 2 | 3 | import java.util.List; 4 | /** 5 | *

A specification on how much data to return with a recording.

6 | * 7 | */ 8 | public class RecordingIncludesWs2 extends IncludesWs2 9 | { 10 | 11 | private boolean puids = false; 12 | private boolean isrcs = false; 13 | 14 | // Allowed only in Lookup, not in Browse. 15 | 16 | private boolean releases = false; 17 | 18 | /** 19 | * Default constructor 20 | */ 21 | public RecordingIncludesWs2() 22 | { 23 | super(); 24 | } 25 | 26 | @Override 27 | public List createIncludeTags() 28 | { 29 | List includeTags = super.createIncludeTags(); 30 | 31 | // not that elegant but straight forward :) 32 | 33 | if (isReleases()) includeTags.add(RELEASES_INC); 34 | 35 | if (isPuids()) includeTags.add(PUIDS_INC); 36 | if (isIsrcs()) includeTags.add(ISRCS_INC); 37 | 38 | return includeTags; 39 | } 40 | 41 | /** 42 | * @return the releases 43 | */ 44 | public boolean isReleases() { 45 | return releases; 46 | } 47 | 48 | /** 49 | * @param releases the releases to set 50 | */ 51 | public void setReleases(boolean releases) { 52 | this.releases = releases; 53 | } 54 | 55 | /** 56 | * @return the puids 57 | */ 58 | public boolean isPuids() { 59 | return puids; 60 | } 61 | 62 | /** 63 | * @param puids the puids to set 64 | */ 65 | public void setPuids(boolean puids) { 66 | this.puids = puids; 67 | } 68 | 69 | /** 70 | * @return the isrcs 71 | */ 72 | public boolean isIsrcs() { 73 | return isrcs; 74 | } 75 | 76 | /** 77 | * @param isrcs the isrcs to set 78 | */ 79 | public void setIsrcs(boolean isrcs) { 80 | this.isrcs = isrcs; 81 | } 82 | /** 83 | * set all the parameters to false. 84 | */ 85 | @Override 86 | public void excludeAll(){ 87 | 88 | super.excludeAll(); 89 | setReleases(false); 90 | setPuids(false); 91 | setIsrcs(false); 92 | } 93 | /** 94 | * set all the parameters to true. 95 | */ 96 | @Override 97 | public void includeAll(){ 98 | 99 | super.includeAll(); 100 | setReleases(true); 101 | setPuids(true); 102 | setIsrcs(true); 103 | } 104 | /** 105 | * clone the current status of IncludesWs2 to a new one. 106 | */ 107 | @Override 108 | public RecordingIncludesWs2 clone(){ 109 | 110 | RecordingIncludesWs2 target = new RecordingIncludesWs2(); 111 | copyTo(target); 112 | target.setReleases(isReleases()); 113 | target.setPuids(isPuids()); 114 | target.setIsrcs(isIsrcs()); 115 | return target; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/entity/CollectionWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model.entity; 2 | 3 | import java.util.List; 4 | 5 | import org.musicbrainz.model.entity.listelement.ReleaseListWs2; 6 | 7 | /** 8 | *

Represents a Collection.

9 | * 10 | */ 11 | public class CollectionWs2 extends EntityWs2 { 12 | 13 | 14 | private String name; 15 | private String editor; 16 | 17 | /** 18 | * The list of releases from this artist. 19 | 20 | */ 21 | private ReleaseListWs2 releaseList = new ReleaseListWs2(); 22 | 23 | /** 24 | * @return the name 25 | */ 26 | public String getName() { 27 | return name; 28 | } 29 | /** 30 | * @param name the name to set 31 | */ 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | /** 36 | * @return the editor 37 | */ 38 | public String getEditor() { 39 | return editor; 40 | } 41 | 42 | /** 43 | * @param editor the editor to set 44 | */ 45 | public void setEditor(String editor) { 46 | this.editor = editor; 47 | } 48 | /** 49 | * Gets the underlying List of releases. 50 | * 51 | * @return the releases 52 | */ 53 | public List getReleases() { 54 | return ( releaseList == null ? null : releaseList.getReleases()); 55 | } 56 | /** 57 | * Sets the underlying List of releases. 58 | * 59 | * Note: This will implicitly create a new {@link #releaseList} 60 | * if it is null. 61 | * 62 | * @param releases the releases to set 63 | */ 64 | public void setReleases(List releases) 65 | { 66 | if (releaseList == null) { 67 | releaseList = new ReleaseListWs2(); 68 | } 69 | 70 | this.releaseList.setReleases(releases); 71 | } 72 | /** 73 | * @return the releaseList 74 | */ 75 | public ReleaseListWs2 getReleaseList() { 76 | return releaseList; 77 | } 78 | 79 | /** 80 | * @param releaseList the releaseList to set 81 | */ 82 | public void setReleaseList(ReleaseListWs2 releaseList) { 83 | this.releaseList = releaseList; 84 | } 85 | /** 86 | *

Adds a release to the underlying List 87 | * of releases.

88 | * 89 | *

Note: This will implicitly create a new {@link #releaseList} 90 | * if it is null.

91 | * 92 | * @param release The {@link ReleaseWs2} to add. 93 | */ 94 | public void addRelease(ReleaseWs2 release) 95 | { 96 | if (releaseList == null) { 97 | releaseList = new ReleaseListWs2(); 98 | } 99 | releaseList.addRelease(release); 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return getEditor()+" - "+getName(); 105 | } 106 | @Override 107 | public boolean equals(Object object) { 108 | if (!(object instanceof CollectionWs2)) { 109 | return false; 110 | } 111 | CollectionWs2 other = (CollectionWs2) object; 112 | if (this.getIdUri().equals(other.getIdUri())) 113 | { 114 | return true; 115 | } 116 | 117 | return false; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/includes/CollectionIncludesWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.includes; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | *

A specification on how much data to return with a collection.

7 | * 8 | */ 9 | public class CollectionIncludesWs2 extends IncludesWs2 10 | { 11 | /* Subqueries 12 | * The inc= is parameter allows you to request more information to be 13 | * included about the entity. Any of the entities directly linked to 14 | * the entity can be included. 15 | */ 16 | 17 | private boolean releases = false; 18 | 19 | /* inc= arguments which affect subqueries 20 | * Some additional inc= parameters are supported to specify how 21 | * much of the data about the linked entities should be included: 22 | */ 23 | private boolean discids = false; 24 | private boolean media = false; 25 | 26 | 27 | /** 28 | * Default constructor 29 | */ 30 | public CollectionIncludesWs2() 31 | { 32 | super(); 33 | } 34 | 35 | @Override 36 | public List createIncludeTags() 37 | { 38 | List includeTags = super.createIncludeTags(); 39 | 40 | // not that elegant but straight forward :) 41 | if (releases) includeTags.add(RELEASES_INC); 42 | 43 | if (discids) includeTags.add(DISCIDS_INC); 44 | if (media) includeTags.add(MEDIA_INC); 45 | 46 | return includeTags; 47 | } 48 | 49 | /** 50 | * @return the releases 51 | */ 52 | public boolean isReleases() { 53 | return releases; 54 | } 55 | 56 | public void setReleases(boolean releases) { 57 | this.releases = releases; 58 | } 59 | 60 | /** 61 | * @return the discids 62 | */ 63 | public boolean isDiscids() { 64 | return discids; 65 | } 66 | /** 67 | * @param discids the discids to set 68 | */ 69 | public void setDiscids(boolean discids) { 70 | this.discids = discids; 71 | } 72 | /** 73 | * @return the media 74 | */ 75 | public boolean isMedia() { 76 | return media; 77 | } 78 | /** 79 | * @param media the media to set 80 | */ 81 | public void setMedia(boolean media) { 82 | this.media = media; 83 | } 84 | 85 | /** 86 | * set all the parameters to false. 87 | */ 88 | @Override 89 | public void excludeAll(){ 90 | 91 | super.excludeAll(); 92 | setReleases(false); 93 | setMedia(false); 94 | setDiscids(false); 95 | 96 | } 97 | /** 98 | * set all the parameters to true. 99 | */ 100 | @Override 101 | public void includeAll(){ 102 | 103 | super.includeAll(); 104 | setReleases(true); 105 | setMedia(true); 106 | setDiscids(true); 107 | 108 | } 109 | /** 110 | * clone the current status of IncludesWs2 to a new one. 111 | */ 112 | @Override 113 | public CollectionIncludesWs2 clone(){ 114 | 115 | CollectionIncludesWs2 target = new CollectionIncludesWs2(); 116 | copyTo(target); 117 | target.setReleases(isReleases()); 118 | target.setMedia(isMedia()); 119 | target.setDiscids(isDiscids()); 120 | 121 | return target; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/QueryWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query; 2 | 3 | 4 | import java.util.List; 5 | 6 | import org.musicbrainz.MBWS2Exception; 7 | import org.musicbrainz.filter.FilterWs2; 8 | import org.musicbrainz.includes.IncludesWs2; 9 | import org.musicbrainz.webservice.WebService; 10 | import org.musicbrainz.webservice.WebServiceException; 11 | import org.musicbrainz.webservice.impl.HttpClientWebServiceWs2; 12 | import org.musicbrainz.wsxml.MbXMLException; 13 | import org.musicbrainz.wsxml.element.Metadata; 14 | import org.musicbrainz.DomainsWs2; 15 | import java.util.logging.Level; 16 | import java.util.logging.Logger; 17 | //import com.sun.jmx.mbeanserver.MetaData; 18 | 19 | /** 20 | *

A simple interface to the MusicBrainz web service version 2.

21 | * 22 | *

This is a facade which provides a simple interface to the MusicBrainz 23 | * web service version 2. It hides all the details like fetching data from a server, 24 | * parsing the XML and creating an object tree. Using this class, you can 25 | * request data by ID or search the collection of all resources 26 | * (artists, releases, or tracks) to retrieve those matching given 27 | * criteria.

28 | * 29 | */ 30 | public class QueryWs2 extends DomainsWs2{ 31 | 32 | 33 | /** 34 | * A logger 35 | */ 36 | protected static Logger log = Logger.getLogger(QueryWs2.class.getName()); 37 | /** 38 | * The web service implementation to use 39 | */ 40 | private WebService ws; 41 | 42 | /** 43 | * Default Constructor 44 | */ 45 | protected QueryWs2() 46 | { 47 | this.ws = new HttpClientWebServiceWs2(); 48 | } 49 | 50 | /** 51 | * Custom WebService Constructor 52 | * 53 | * @param ws An implementation of {@link WebService} 54 | */ 55 | protected QueryWs2(WebService ws) 56 | { 57 | this.ws = ws; 58 | } 59 | 60 | /** 61 | * Uses the {@link WebService} instance to make a GET request and 62 | * returns a {@link Metadata} object. 63 | * 64 | * @param entity The entity 65 | * @param id The id 66 | * @param includes {@link IncludesWs2} 67 | * @param filter {@link FilterWs2} 68 | * @return A {@link Metadata} object. 69 | * @throws MBWS2Exception 70 | */ 71 | 72 | protected Metadata getFromWebService(String entity, String id, IncludesWs2 includes, FilterWs2 filter) throws MBWS2Exception 73 | { 74 | return getWs().get(entity, id, (includes == null ? null : includes.createIncludeTags()), (filter == null ? null : filter.createParameters())); 75 | } 76 | 77 | protected Metadata postToWebService (Metadata md) throws WebServiceException, MbXMLException{ 78 | 79 | return getWs().post(md); 80 | } 81 | protected Metadata putToWebService (String entity, String id, List data) throws WebServiceException, MbXMLException{ 82 | 83 | return getWs().put(entity, id, data); 84 | } 85 | protected Metadata deleteFromWebService (String entity, String id, List data) throws WebServiceException, MbXMLException{ 86 | 87 | return getWs().delete(entity, id, data); 88 | } 89 | /** 90 | * @return the ws 91 | */ 92 | protected WebService getWs() { 93 | return ws; 94 | } 95 | 96 | /** 97 | * @param ws the ws to set 98 | */ 99 | protected void setWs(WebService ws) { 100 | this.ws = ws; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/query/search/SearchWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.query.search; 2 | 3 | import org.musicbrainz.MBWS2Exception; 4 | import org.musicbrainz.webservice.WebService; 5 | 6 | import org.musicbrainz.filter.searchfilter.SearchFilterWs2; 7 | import org.musicbrainz.query.QueryWs2; 8 | import org.musicbrainz.wsxml.element.Metadata; 9 | import org.musicbrainz.wsxml.element.ListElement; 10 | 11 | /* 12 | * 13 | * Lucerne Search Implementation. 14 | * 15 | * Searches are implemented by the search server and are documented at 16 | * Next_Generation_Schema/SearchServerXML. 17 | * see: http://musicbrainz.org/doc/Next_Generation_Schema/SearchServerXML 18 | * 19 | * Use a filter subclass to set the search parameters. 20 | * Return a SearchResult subtype. 21 | * 22 | */ 23 | 24 | public class SearchWs2 extends QueryWs2 { 25 | 26 | private SearchFilterWs2 filter; 27 | private ListElement listElement; 28 | private int lastScore=100; 29 | 30 | 31 | protected SearchWs2(SearchFilterWs2 filter) 32 | { 33 | super(); 34 | this.filter=filter; 35 | } 36 | 37 | /** 38 | * Custom WebService Constructor 39 | * 40 | * @param ws An implementation of {@link WebService} 41 | */ 42 | protected SearchWs2(WebService ws, SearchFilterWs2 filter) 43 | { 44 | super(ws); 45 | this.filter=filter; 46 | } 47 | 48 | public boolean hasMore() 49 | { 50 | if (getListElement()== null) return false; 51 | if (getFilter() == null) return false; 52 | 53 | int count = getListElement().getCount() == null ? 0 : getListElement().getCount().intValue(); 54 | int offset =getListElement().getOffset() == null ? 0 : getListElement().getOffset().intValue(); 55 | int limit =getFilter().getLimit() == null ? 0 : getFilter().getLimit().intValue(); 56 | 57 | // maybe the real one is lower, if we reached the end 58 | // but it does'nt matter in this context. 59 | 60 | int newOffset = offset+limit; 61 | 62 | int minScore = getFilter().getMinScore()== null ? 0 : getFilter().getMinScore().intValue(); 63 | 64 | if (count >= newOffset && getLastScore()>=minScore) return true; 65 | return false; 66 | } 67 | 68 | protected Metadata getMetadata(String entity) throws MBWS2Exception 69 | { 70 | return getFromWebService(entity, "", null, getFilter()); 71 | } 72 | 73 | /** 74 | * @return the filter 75 | */ 76 | public SearchFilterWs2 getFilter() { 77 | return filter; 78 | } 79 | 80 | /** 81 | * @param filter the filter to set 82 | */ 83 | public void setFilter(SearchFilterWs2 filter) { 84 | this.filter = filter; 85 | } 86 | 87 | /** 88 | * @return the listElement 89 | */ 90 | public ListElement getListElement() { 91 | return listElement; 92 | } 93 | 94 | /** 95 | * @param listElement the listElement to set 96 | */ 97 | public void setListElement(ListElement listElement) { 98 | this.listElement = listElement; 99 | } 100 | 101 | /** 102 | * @return the lastScore 103 | */ 104 | public int getLastScore() { 105 | return lastScore; 106 | } 107 | 108 | /** 109 | * @param lastScore the lastScore to set 110 | */ 111 | public void setLastScore(int lastScore) { 112 | this.lastScore = lastScore; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/searchfilter/SearchFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.searchfilter; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.musicbrainz.filter.FilterWs2; 6 | import org.musicbrainz.DomainsWs2; 7 | 8 | 9 | /** 10 | * This abstract class implemets a {@link java.util.logging.Filter} and provides 11 | * some common properties and functions. 12 | * 13 | */ 14 | public abstract class SearchFilterWs2 implements FilterWs2 15 | { 16 | public static final String LIMIT = DomainsWs2.LIMIT_FILTER; 17 | public static final String OFFSET = DomainsWs2.OFFSET_FILTER; 18 | public static final String QUERY = DomainsWs2.QUERY_FILTER; 19 | /** 20 | * The maximum number of entities to return 21 | */ 22 | private Long limit = null; 23 | 24 | /** 25 | * Start results at this zero-based offset 26 | */ 27 | private Long offset = null; 28 | 29 | /** 30 | * The minimum score of the query results. 31 | * Only affect the execution of a next page fetch 32 | * if the last result of previous page was < minScore. 33 | */ 34 | private Long minScore=null; 35 | 36 | /** 37 | * A string containing a query in Lucene syntax 38 | */ 39 | 40 | private String query = null; 41 | 42 | /** 43 | * Default constructor 44 | */ 45 | protected SearchFilterWs2() 46 | { 47 | 48 | } 49 | /** 50 | * Full constructor 51 | * 52 | * The query parameter may contain a query in 53 | * 54 | * Lucene syntax. 55 | * 56 | * @param limit The maximum number of artists to return 57 | * @param offset Start results at this zero-based offset 58 | * @param query A string containing a query in Lucene syntax 59 | * @param minScore The minimum score of the query results. 60 | */ 61 | 62 | protected SearchFilterWs2(long limit, long offset, String query, long minScore) 63 | { 64 | this.limit = limit; 65 | this.offset = offset; 66 | this.query = query; 67 | this.minScore=minScore; 68 | } 69 | 70 | /* (non-Javadoc) 71 | * @see org.musicbrainz.webservice.Filter#createParameters() 72 | */ 73 | public Map createParameters() 74 | { 75 | Map map = new HashMap(); 76 | 77 | if (this.limit != null) map.put(LIMIT, this.limit.toString()); 78 | if (this.offset != null) map.put(OFFSET, this.offset.toString()); 79 | if (this.query != null) map.put(QUERY, this.query); 80 | 81 | return map; 82 | } 83 | 84 | /** 85 | * @return the limit 86 | */ 87 | public Long getLimit() { 88 | return limit; 89 | } 90 | /** 91 | * @param limit the limit to set 92 | */ 93 | public void setLimit(Long limit) { 94 | this.limit = limit; 95 | } 96 | /** 97 | * @return the offset 98 | */ 99 | public Long getOffset() { 100 | return offset; 101 | } 102 | /** 103 | * @param offset the offset to set 104 | */ 105 | public void setOffset(Long offset) { 106 | this.offset = offset; 107 | } 108 | public Long getMinScore() { 109 | return minScore; 110 | } 111 | public void setMinScore(Long minScore) { 112 | this.minScore = minScore; 113 | } 114 | /** 115 | * @return the query 116 | */ 117 | public String getQuery() { 118 | return query; 119 | } 120 | /** 121 | * @param query the query to set 122 | */ 123 | public void setQuery(String query) { 124 | this.query = query; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/browsefilter/BrowseFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter.browsefilter; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.musicbrainz.filter.FilterWs2; 6 | import org.musicbrainz.DomainsWs2; 7 | 8 | 9 | /** 10 | * This abstract class implemets a {@link java.util.logging.Filter} and provides 11 | * some common properties and functions. 12 | 13 | */ 14 | public abstract class BrowseFilterWs2 implements FilterWs2 15 | { 16 | public static final String LIMIT = DomainsWs2.LIMIT_FILTER; 17 | public static final String OFFSET = DomainsWs2.OFFSET_FILTER; 18 | /** 19 | * The maximum number of entities to return 20 | */ 21 | private Long limit = null; 22 | 23 | /** 24 | * Start results at this zero-based offset 25 | */ 26 | private Long offset = null; 27 | 28 | /** 29 | * A string containing the related entity from whom start browsing 30 | */ 31 | 32 | private String relatedEntity = null; 33 | 34 | /** 35 | *The Id of the related entity. 36 | */ 37 | 38 | private String relatedId = null; 39 | 40 | /** 41 | * Default constructor 42 | */ 43 | protected BrowseFilterWs2() 44 | { 45 | 46 | } 47 | /** 48 | * Full constructor 49 | * 50 | * The query parameter may contain a query in 51 | * 52 | * Lucene syntax. 53 | * 54 | * @param limit The maximum number of artists to return 55 | * @param offset Start results at this zero-based offset 56 | */ 57 | 58 | protected BrowseFilterWs2(long limit, long offset, 59 | String relatedEntity, String relatedId) 60 | { 61 | this.limit = limit; 62 | this.offset = offset; 63 | this.relatedEntity = relatedEntity; 64 | this.relatedId=relatedId; 65 | } 66 | 67 | /* (non-Javadoc) 68 | * @see org.musicbrainz.webservice.Filter#createParameters() 69 | */ 70 | public Map createParameters() 71 | { 72 | Map map = new HashMap(); 73 | 74 | if (this.relatedEntity != null && this.relatedId != null ) 75 | { 76 | map.put(relatedEntity, this.relatedId); 77 | } 78 | 79 | if (this.limit != null) map.put(LIMIT, this.limit.toString()); 80 | if (this.offset != null) map.put(OFFSET, this.offset.toString()); 81 | 82 | return map; 83 | } 84 | 85 | /** 86 | * @return the limit 87 | */ 88 | public Long getLimit() { 89 | return limit; 90 | } 91 | /** 92 | * @param limit the limit to set 93 | */ 94 | public void setLimit(Long limit) { 95 | this.limit = limit; 96 | } 97 | /** 98 | * @return the offset 99 | */ 100 | public Long getOffset() { 101 | return offset; 102 | } 103 | /** 104 | * @param offset the offset to set 105 | */ 106 | public void setOffset(Long offset) { 107 | this.offset = offset; 108 | } 109 | /** 110 | * @return the relatedEntity 111 | */ 112 | public String getRelatedEntity() { 113 | return relatedEntity; 114 | } 115 | /** 116 | * @param relatedEntity the relatedEntity to set 117 | */ 118 | public void setRelatedEntity(String relatedEntity) { 119 | this.relatedEntity = relatedEntity; 120 | } 121 | /** 122 | * @return the relatedId 123 | */ 124 | public String getRelatedId() { 125 | return relatedId; 126 | } 127 | /** 128 | * @param relatedId the relatedId to set 129 | */ 130 | public void setRelatedId(String relatedId) { 131 | this.relatedId = relatedId; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/model/AliasWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.model; 2 | 3 | import java.util.logging.Logger; 4 | 5 | /** 6 | *

Represents an alias for Artist, Works or Labels

7 | * The alias locale is interesting mostly for transliterations and indicates 8 | * which locale is used for the alias value. To represent the locale, 9 | * iso-3166-2 codes like 'ja', 'en', or 'it' are used. 10 | */ 11 | public class AliasWs2 12 | { 13 | 14 | private static Logger log = Logger.getLogger(AliasWs2.class.getName()); 15 | /** 16 | * The alias 17 | */ 18 | private String value; 19 | private String sortName; 20 | private String type; 21 | private String primary; 22 | private String beginDate; 23 | private String endDate; 24 | private boolean ended; 25 | 26 | /** 27 | * ISO-15924 script code 28 | */ 29 | private String locale; 30 | 31 | public String getDisplayValue(){ 32 | 33 | String out=""; 34 | 35 | if (!(primary== null) && !(primary.isEmpty())) out = out+primary; 36 | if (!(type== null) && !(type.isEmpty())) { 37 | 38 | if (!out.isEmpty())out= out+" "; 39 | out = out+type; 40 | } 41 | if (!out.isEmpty())out= out+": "; out = out+value; 42 | 43 | if (!(getLocale()== null) && (getLocale().isEmpty())) out = out+" ("+getLocale()+")"; 44 | 45 | return out; 46 | } 47 | 48 | public String getLocale() { 49 | return locale; 50 | } 51 | 52 | public void setLocale(String locale) { 53 | this.locale = locale; 54 | } 55 | 56 | /** 57 | * @return the value 58 | */ 59 | public String getValue() { 60 | return value; 61 | } 62 | 63 | /** 64 | * @param value the value to set 65 | */ 66 | public void setValue(String value) { 67 | this.value = value; 68 | } 69 | 70 | /** 71 | * @return the sortName 72 | */ 73 | public String getSortName() { 74 | return sortName; 75 | } 76 | 77 | /** 78 | * @param sortName the sortName to set 79 | */ 80 | public void setSortName(String sortName) { 81 | this.sortName = sortName; 82 | } 83 | 84 | /** 85 | * @return the type 86 | */ 87 | public String getType() { 88 | return type; 89 | } 90 | 91 | /** 92 | * @param type the type to set 93 | */ 94 | public void setType(String type) { 95 | this.type = type; 96 | } 97 | 98 | /** 99 | * @return the primary 100 | */ 101 | public String getPrimary() { 102 | return primary; 103 | } 104 | 105 | /** 106 | * @param primary the primary to set 107 | */ 108 | public void setPrimary(String primary) { 109 | this.primary = primary; 110 | } 111 | /** 112 | * @return the beginDate 113 | */ 114 | public String getBeginDate() { 115 | return beginDate; 116 | } 117 | 118 | /** 119 | * @param beginDate the beginDate to set 120 | */ 121 | public void setBeginDate(String beginDate) { 122 | this.beginDate = beginDate; 123 | } 124 | /** 125 | * @return the endDate 126 | */ 127 | public String getEndDate() { 128 | return endDate; 129 | } 130 | 131 | /** 132 | * @param endDate the endDate to set 133 | */ 134 | public void setEndDate(String endDate) { 135 | this.endDate = endDate; 136 | } 137 | /** 138 | * @return the ended 139 | */ 140 | public boolean isEnded() { 141 | return ended; 142 | } 143 | 144 | /** 145 | * @param ended the ended to set 146 | */ 147 | public void setEnded(boolean ended) { 148 | this.ended = ended; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/org/musicbrainz/filter/ReleaseStatusFilterWs2.java: -------------------------------------------------------------------------------- 1 | package org.musicbrainz.filter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.musicbrainz.model.entity.ReleaseWs2; 9 | 10 | public class ReleaseStatusFilterWs2 implements FilterWs2 11 | { 12 | 13 | private boolean statusAll = true; 14 | 15 | private boolean statusOfficial = false; 16 | private boolean statusPromotion = false; 17 | private boolean statusBootleg = false; 18 | private boolean statusPseudoRelease = false; 19 | 20 | public ReleaseStatusFilterWs2() { 21 | 22 | } 23 | 24 | private String createFilterString(){ 25 | 26 | if (isStatusAll()) return ""; 27 | 28 | List Status = new ArrayList(); 29 | 30 | if (isStatusOfficial()) Status.add(ReleaseWs2.STATUS_OFFICIAL); 31 | if (isStatusPromotion()) Status.add(ReleaseWs2.STATUS_PROMOTION); 32 | if (isStatusBootleg()) Status.add(ReleaseWs2.STATUS_BOOTLEG); 33 | if (isStatusPseudoRelease()) Status.add(ReleaseWs2.STATUS_PSEUDO_RELEASE); 34 | 35 | String filterString=""; 36 | 37 | for (String status : Status) 38 | { 39 | if (!filterString.equals("")) 40 | { 41 | filterString= filterString+"|"; 42 | } 43 | filterString= filterString+status; 44 | } 45 | 46 | return filterString; 47 | } 48 | 49 | public Map createParameters() 50 | { 51 | Map map = new HashMap(); 52 | 53 | String filterString=createFilterString(); 54 | 55 | // construct the track filter's map 56 | 57 | if (!filterString.equals("")) 58 | map.put("status",filterString); 59 | 60 | return map; 61 | } 62 | 63 | /** 64 | * @return the statusOfficial 65 | */ 66 | public boolean isStatusOfficial() { 67 | return statusOfficial; 68 | } 69 | 70 | /** 71 | * @param statusOfficial the statusOfficial to set 72 | */ 73 | public void setStatusOfficial(boolean statusOfficial) { 74 | this.statusOfficial = statusOfficial; 75 | } 76 | 77 | /** 78 | * @return the statusPromotion 79 | */ 80 | public boolean isStatusPromotion() { 81 | return statusPromotion; 82 | } 83 | 84 | /** 85 | * @param statusPromotion the statusPromotion to set 86 | */ 87 | public void setStatusPromotion(boolean statusPromotion) { 88 | this.statusPromotion = statusPromotion; 89 | } 90 | 91 | /** 92 | * @return the statusBootleg 93 | */ 94 | public boolean isStatusBootleg() { 95 | return statusBootleg; 96 | } 97 | 98 | /** 99 | * @param statusBootleg the statusBootleg to set 100 | */ 101 | public void setStatusBootleg(boolean statusBootleg) { 102 | this.statusBootleg = statusBootleg; 103 | } 104 | 105 | /** 106 | * @return the statusPseudoRelease 107 | */ 108 | public boolean isStatusPseudoRelease() { 109 | return statusPseudoRelease; 110 | } 111 | 112 | /** 113 | * @param statusPseudoRelease the statusPseudoRelease to set 114 | */ 115 | public void setStatusPseudoRelease(boolean statusPseudoRelease) { 116 | this.statusPseudoRelease = statusPseudoRelease; 117 | } 118 | 119 | /** 120 | * @return the statusAll 121 | */ 122 | public boolean isStatusAll() { 123 | return statusAll; 124 | } 125 | 126 | /** 127 | * @param statusAll the statusAll to set 128 | */ 129 | public void setStatusAll(boolean statusAll) { 130 | this.statusAll = statusAll; 131 | } 132 | 133 | } --------------------------------------------------------------------------------