├── .gitignore └── oslcjira ├── .checkstyle ├── .classpath ├── .project ├── LICENSE ├── NOTICE ├── doc ├── tech_doc_diagram.png ├── tech_doc_oauth.png ├── technical_doc.md └── user_doc.md ├── pom.xml └── src └── main ├── java └── com │ └── ericsson │ ├── eif │ └── leansync │ │ └── mapping │ │ ├── SyncConfigLoader.java │ │ ├── SyncConstants.java │ │ ├── SyncHelper.java │ │ ├── data │ │ ├── ActionType.java │ │ ├── SyncConfiguration.java │ │ ├── SyncField.java │ │ ├── SyncGeneralField.java │ │ ├── SyncMapping.java │ │ ├── SyncSnapshot.java │ │ ├── SyncTemplate.java │ │ └── SyncXmlFieldConfig.java │ │ └── exceptions │ │ └── SyncConfigurationException.java │ └── jira │ └── oslc │ ├── Constants.java │ ├── Credentials.java │ ├── HTTP.java │ ├── PluginConfig.java │ ├── constants │ └── JiraConstants.java │ ├── customfields │ └── OSLCLink.java │ ├── events │ ├── IssueEventType.java │ ├── IssueEventsHandler.java │ └── RestIssueEvent.java │ ├── exceptions │ ├── GetIssueException.java │ ├── IssueTransitionException.java │ ├── IssueValidationException.java │ ├── NoResourceException.java │ ├── PermissionException.java │ ├── PreconditionException.java │ └── StatusException.java │ ├── handlers │ └── OAuthHandler.java │ ├── managers │ ├── FieldManager.java │ ├── JiraManager.java │ └── PermissionManager.java │ ├── oslcclient │ └── Client.java │ ├── provider │ ├── OslcRdfJsonArrayProvider.java │ ├── OslcRdfJsonErrorProvider.java │ ├── OslcRdfJsonProvider.java │ ├── OslcXmlRdfArrayProvider.java │ ├── OslcXmlRdfErrorProvider.java │ ├── OslcXmlRdfProvider.java │ └── ResponseArrayWrapper.java │ ├── resources │ ├── ChangeRequest.java │ ├── JiraChangeRequest.java │ ├── JiraHistoryRequest.java │ ├── JiraIssueComment.java │ ├── JiraIssueCustomField.java │ ├── JiraIssueHistory.java │ ├── JiraIssueHistoryItem.java │ ├── JiraIssueInternalLink.java │ ├── JiraIssuePriority.java │ ├── JiraIssueResolution.java │ ├── JiraIssueStatus.java │ ├── JiraIssueType.java │ ├── JiraIssueWebLink.java │ ├── JiraIssueWorklog.java │ ├── Person.java │ ├── RootServices.java │ ├── ServiceProvider.java │ ├── ServiceProviderDialog.java │ ├── ServiceProviderRef.java │ ├── Severity.java │ ├── Type.java │ ├── ao │ │ ├── AOAccessor.java │ │ ├── AOAccessorImpl.java │ │ ├── AOConsumerStore.java │ │ ├── AOManager.java │ │ ├── ConfigClobEntity.java │ │ ├── ConfigEntity.java │ │ ├── OAuthConsmrEntity.java │ │ ├── RootServicesEntity.java │ │ └── ServiceProvEntity.java │ ├── data │ │ └── OAuthConsumerView.java │ └── package-info.java │ ├── services │ ├── BaseService.java │ ├── CSRFPrevent.java │ ├── IssuePriorityService.java │ ├── IssueResolutionService.java │ ├── IssueStatusService.java │ ├── IssueTypeService.java │ ├── JiraChangeRequestService.java │ ├── OAuthServices.java │ ├── OSLCLinksServices.java │ ├── RootServicesService.java │ ├── ServiceHelper.java │ ├── ServiceProviderCatalogService.java │ └── ServiceProviderService.java │ ├── servlet │ ├── AddOslcLinkDialogServlet.java │ ├── CreateIssueServlet.java │ ├── CredentialsFilter.java │ ├── JiraServiceProviderFactory.java │ ├── JiraUserFilter.java │ ├── OAuthConsumerServlet.java │ ├── PluginConfigurationServlet.java │ ├── ProjectRelationshipsServlet.java │ ├── RootServicesManagementServlet.java │ ├── SelectIssueServlet.java │ ├── ServiceProviderCatalogSingleton.java │ ├── ServiceProviderCatalogsManagementServlet.java │ └── SyncConfigServlet.java │ ├── sync │ ├── InboundSyncUtils.java │ ├── JiraObjectMapping.java │ ├── OutboundSyncUtils.java │ ├── SyncConfig.java │ └── SyncUtils.java │ └── utils │ ├── AppLink.java │ ├── AppLinksRepository.java │ ├── ErrorSyncHandler.java │ ├── JiraIssueInputParameters.java │ ├── LogUtils.java │ ├── OSLCUtils.java │ ├── ServiceProviderRegistryURIs.java │ └── ServletUtils.java └── resources ├── RestExtension.properties ├── atlassian-plugin.xml ├── config └── leanSyncConfig.xsd ├── images ├── pluginIcon.png └── pluginLogo.png └── templates ├── AddOslcLinkDialog.vm ├── admin.vm ├── admin_project_relationships.vm ├── admin_rootservices.vm ├── admin_spcatalogs.vm ├── create_issue.vm ├── create_issue_response.vm ├── error_page.vm ├── oAuthConsumers.vm ├── oAuthConsumers_old.vm ├── oauth_authorize.vm ├── pluginConfiguration.vm ├── select_issue.vm ├── small_preview.vm ├── syncConfig.vm ├── view-oslclinks.vm ├── view-oslclinks_columns.vm ├── view-oslclinks_edit.vm └── view-oslclinks_xml.vm /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /oslcjira/.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /oslcjira/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | oslcjira 4 | This is the OSLC plugin for Atlassian JIRA. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /oslcjira/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2015, Ericsson AB. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or other 12 | materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 23 | OF SUCH DAMAGE. -------------------------------------------------------------------------------- /oslcjira/NOTICE: -------------------------------------------------------------------------------- 1 | Ericsson Jira OSLC Plugin 2 | Copyright (C) 2015 Ericsson AB. 3 | 4 | This product includes software developed at 5 | Ericsson AB. (www.ericsson.com). 6 | 7 | This product includes code available under a 8 | Eclipse Distribution License v. 1.0 9 | 10 | Copyright (c) 2011-2013 IBM Corporation. 11 | 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without modification, 15 | are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright notice, 20 | this list of conditions and the following disclaimer in the documentation 21 | and/or other materials provided with the distribution. 22 | * Neither the name of the Eclipse Foundation, Inc. nor the names of its 23 | contributors may be used to endorse or promote products derived from 24 | this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 33 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /oslcjira/doc/tech_doc_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ericsson/jira-oslc-plugin/211d4a7d40286ef1128f32301cecc4b6bf12ded6/oslcjira/doc/tech_doc_diagram.png -------------------------------------------------------------------------------- /oslcjira/doc/tech_doc_oauth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ericsson/jira-oslc-plugin/211d4a7d40286ef1128f32301cecc4b6bf12ded6/oslcjira/doc/tech_doc_oauth.png -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/SyncConstants.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The constants for LeanSync 32 | * 33 | */ 34 | public interface SyncConstants { 35 | public static final String CONFIG_CONTENT_TYPE_HTML = "html"; 36 | public static final String CONFIG_FIELD_TYPE_CUSTOM = "custom"; 37 | public static final String ID_PREFIX_DEFAULT_VALUE = "%"; 38 | public static final String ID_SUFFIX_DEFAULT_VALUE = "%"; 39 | public static final String BOOLEAN_FALSE = "false"; 40 | public static final String BOOLEAN_TRUE = "true"; 41 | public static final String INBOUND_SYNC_STATUS_MARK = "---Inbound sync---"; 42 | public static final String OUTBOUND_SYNC_STATUS_MARK = "---Outbound sync---"; 43 | public static final String END_OF_LINE = "\n"; 44 | public static final String HTML_END_OF_LINE = "
"; 45 | } 46 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/ActionType.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The enumeration for action type. 32 | * CREATE - a configuration is valid only when a resource in created 33 | * UPDATE - the configuration is valid only when the resource is updated 34 | * UNDEF - the configuration is valid for both action 35 | * 36 | */ 37 | public enum ActionType { 38 | CREATE, UPDATE, UNDEF; 39 | 40 | public static ActionType getActionType(String type) { 41 | if("CREATE".equalsIgnoreCase(type)){ 42 | return ActionType.CREATE; 43 | }else if ("UPDATE".equalsIgnoreCase(type)){ 44 | return UPDATE; 45 | } 46 | return ActionType.UNDEF; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.ArrayList; 31 | import java.util.HashSet; 32 | import java.util.List; 33 | import java.util.Set; 34 | import javax.xml.bind.annotation.XmlElement; 35 | 36 | /** 37 | * Data class representing the configuration. There can be one or more configurations for different projects 38 | * 39 | */ 40 | public class SyncConfiguration { 41 | 42 | private Set projects; 43 | private Set issueTypes; 44 | private Set domains; 45 | @XmlElement(name="inMappings") 46 | private List inMappingList; 47 | @XmlElement(name="outMappings") 48 | private List outMappingList; 49 | private String errorLog; 50 | 51 | public SyncConfiguration(){ 52 | projects = new HashSet(); 53 | issueTypes = new HashSet(); 54 | domains = new HashSet(); 55 | inMappingList = new ArrayList(); 56 | outMappingList = new ArrayList(); 57 | } 58 | 59 | public Set getProjects() { 60 | return projects; 61 | } 62 | 63 | public void setProjects(Set projects) { 64 | this.projects = projects; 65 | } 66 | 67 | public void addProject(String project) { 68 | this.projects.add(project); 69 | } 70 | 71 | public Set getIssueTypes() { 72 | return issueTypes; 73 | } 74 | 75 | public void setIssueTypes(Set issueTypes) { 76 | this.issueTypes = issueTypes; 77 | } 78 | 79 | public void addIssueType(String issueType) { 80 | this.issueTypes.add(issueType); 81 | } 82 | 83 | public boolean containsIssueType(String issueType) { 84 | return (this.issueTypes != null && this.issueTypes.contains(issueType)); 85 | } 86 | 87 | public List getInMappings() { 88 | return inMappingList; 89 | } 90 | 91 | public void setInMapping(List inMappings) { 92 | this.inMappingList = inMappings; 93 | } 94 | 95 | public List getOutMappings() { 96 | return outMappingList; 97 | } 98 | 99 | public void setOutMappings(List outMappings) { 100 | this.outMappingList = outMappings; 101 | } 102 | 103 | public void addOutMapping(SyncMapping mappings) { 104 | this.outMappingList.add(mappings); 105 | } 106 | public void addInMapping(SyncMapping mappings) { 107 | this.inMappingList.add(mappings); 108 | } 109 | 110 | public SyncMapping getFirstInMapping() { 111 | if(inMappingList != null && inMappingList.size() > 0){ 112 | return inMappingList.get(0); 113 | } 114 | return null; 115 | } 116 | 117 | public SyncMapping getFirstOutMapping() { 118 | if(outMappingList != null && outMappingList.size() > 0){ 119 | return outMappingList.get(0); 120 | } 121 | return null; 122 | } 123 | 124 | public String getErrorLog() { 125 | return errorLog; 126 | } 127 | 128 | public void setErrorLog(String errorLog) { 129 | this.errorLog = errorLog; 130 | } 131 | 132 | public Set getDomains() { 133 | return domains; 134 | } 135 | 136 | public void setDomains(Set domains) { 137 | this.domains = domains; 138 | } 139 | 140 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncField.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * Data class containing a configuration for the synchronization between fields 32 | * 33 | */ 34 | public class SyncField extends SyncGeneralField{ 35 | //unique ID of field which is used e,g, in the template 36 | private String id; 37 | //location of the field in the xml. The path is defined by XPATH 38 | private String xpath; 39 | //true - the tags from the value of the filed will not be removed 40 | private boolean keepTags; 41 | //true - encode HTML character e.g. '<' -> '!lt;' 42 | private boolean encodeHtml; 43 | // input value of date will be converted to this format 44 | private String toDateFormat; 45 | //specifies the date format in input value of date 46 | private String fromDateFormat; 47 | 48 | public String getId() { 49 | return id; 50 | } 51 | 52 | public void setId(String id) { 53 | this.id = id; 54 | } 55 | 56 | public String getXpath() { 57 | return xpath; 58 | } 59 | 60 | public void setXpath(String xpath) { 61 | this.xpath = xpath; 62 | } 63 | 64 | public boolean isKeepTags() { 65 | return keepTags; 66 | } 67 | 68 | public void setKeepTags(boolean keepTags) { 69 | this.keepTags = keepTags; 70 | } 71 | 72 | public boolean isEncodeHtml() { 73 | return encodeHtml; 74 | } 75 | 76 | public void setEncodeHtml(boolean encodeHtml) { 77 | this.encodeHtml = encodeHtml; 78 | } 79 | 80 | public String getToDateFormat() { 81 | return toDateFormat; 82 | } 83 | 84 | public void setToDateFormat(String toDateFormat) { 85 | this.toDateFormat = toDateFormat; 86 | } 87 | 88 | public String getFromDateFormat() { 89 | return fromDateFormat; 90 | } 91 | 92 | public void setFromDateFormat(String fromDateFormat) { 93 | this.fromDateFormat = fromDateFormat; 94 | } 95 | 96 | 97 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncGeneralField.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.Map; 31 | 32 | /** 33 | * Data class contains the common parameters for the fields of configuration 34 | * 35 | */ 36 | public abstract class SyncGeneralField { 37 | //the namespace of the field which will be mapped 38 | private String ns; 39 | //the name of the field whihc will be mapped 40 | private String name; 41 | //the type of field e.g. custom -> specifies the the field is custom and not general field of the system 42 | private String fieldType; 43 | //the type of field e.g. html - the characters "\n" will be replaced by
in outgoing data 44 | private String contentType; 45 | //The name of the field where the value will be put 46 | private String mapTo; 47 | //The type of action with resource - create or update 48 | private ActionType action; 49 | //the value can be mapped to another value e.g. for priority: A->1. B->2, C->3 50 | private Map valueMapping; 51 | //true - when the field is change then the change is propagated to a remote system 52 | private boolean notifyChange = true; 53 | //when the value mapping doesn't match the value then the default value is used 54 | private String defaultValue; 55 | 56 | public String getNs() { 57 | return ns; 58 | } 59 | public void setNs(String ns) { 60 | this.ns = ns; 61 | } 62 | public String getName() { 63 | return name; 64 | } 65 | public void setName(String name) { 66 | this.name = name; 67 | } 68 | public String getFieldType() { 69 | return fieldType; 70 | } 71 | public void setFieldType(String fieldType) { 72 | this.fieldType = fieldType; 73 | } 74 | public String getContentType() { 75 | return contentType; 76 | } 77 | public void setContentType(String contentType) { 78 | this.contentType = contentType; 79 | } 80 | public String getMapTo() { 81 | return mapTo; 82 | } 83 | public void setMapTo(String mapTo) { 84 | this.mapTo = mapTo; 85 | } 86 | public Map getValueMapping() { 87 | return valueMapping; 88 | } 89 | public void setValueMapping(Map valueMapping) { 90 | this.valueMapping = valueMapping; 91 | } 92 | public ActionType getAction() { 93 | return action; 94 | } 95 | public void setAction(ActionType action) { 96 | this.action = action; 97 | } 98 | public boolean isNotifyChange() { 99 | return notifyChange; 100 | } 101 | public void setNotifyChange(boolean notifyChange) { 102 | this.notifyChange = notifyChange; 103 | } 104 | public String getDefaultValue() { 105 | return defaultValue; 106 | } 107 | public void setDefaultValue(String defaultValue) { 108 | this.defaultValue = defaultValue; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncSnapshot.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * Data class contains the value of template and configuration of template field 32 | * It serves for saving a snapshot and for field mapping M:1 33 | * 34 | */ 35 | public class SyncSnapshot { 36 | //the configuration for template field 37 | private SyncTemplate templateConfig; 38 | //the value of the field which are mapped by the template 39 | private String value; 40 | 41 | public SyncSnapshot(SyncTemplate templateConfig) { 42 | this.templateConfig = templateConfig; 43 | } 44 | public SyncSnapshot(SyncTemplate templateConfig, String value) { 45 | this.templateConfig = templateConfig; 46 | this.value = value; 47 | } 48 | public SyncTemplate getTemplateConfig() { 49 | return templateConfig; 50 | } 51 | public void setTemplateConfig(SyncTemplate templateConfig) { 52 | this.templateConfig = templateConfig; 53 | } 54 | public String getValue() { 55 | return value; 56 | } 57 | public void setValue(String value) { 58 | this.value = value; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncTemplate.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import com.ericsson.eif.leansync.mapping.SyncConstants; 31 | 32 | /** 33 | * Data class contains the template for the field mapping M:1 or the snapshot 34 | * 35 | */ 36 | public class SyncTemplate extends SyncGeneralField{ 37 | //the template containing special marks for inserting the field values 38 | private String template; 39 | //prefix for id of the field in the template 40 | private String idPrefix; 41 | //suffix for id of the field in the template 42 | private String idSuffix; 43 | //true - the mapped value of the field will be save even when the error accurs 44 | private String alwaysSave; 45 | 46 | public SyncTemplate(){ 47 | idPrefix = SyncConstants.ID_PREFIX_DEFAULT_VALUE; 48 | idSuffix = SyncConstants.ID_SUFFIX_DEFAULT_VALUE; 49 | } 50 | 51 | public String getTemplate() { 52 | return template; 53 | } 54 | public void setTemplate(String template) { 55 | this.template = template; 56 | } 57 | public String getIdPrefix() { 58 | return idPrefix; 59 | } 60 | public void setIdPrefix(String idPrefix) { 61 | this.idPrefix = idPrefix; 62 | } 63 | public String getIdSuffix() { 64 | return idSuffix; 65 | } 66 | public void setIdSuffix(String idSuffix) { 67 | this.idSuffix = idSuffix; 68 | } 69 | 70 | public String getAlwaysSave() { 71 | return alwaysSave; 72 | } 73 | 74 | public void setAlwaysSave(String alwaysSave) { 75 | this.alwaysSave = alwaysSave; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/data/SyncXmlFieldConfig.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.List; 31 | 32 | /** 33 | * Data class containing a configuration for the synchronization between fields 34 | * The configuration is for the fields which are in the xml content of the field 35 | * 36 | */ 37 | public class SyncXmlFieldConfig { 38 | private String ns; 39 | private String name; 40 | private List fields; 41 | 42 | public String getNs() { 43 | return ns; 44 | } 45 | public void setNs(String ns) { 46 | this.ns = ns; 47 | } 48 | public String getName() { 49 | return name; 50 | } 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | public List getFields() { 55 | return fields; 56 | } 57 | public void setFields(List fields) { 58 | this.fields = fields; 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/eif/leansync/mapping/exceptions/SyncConfigurationException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.eif.leansync.mapping.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when the the Sync configuration is not valid. 32 | * 33 | */ 34 | public class SyncConfigurationException extends Exception { 35 | 36 | private static final long serialVersionUID = -9007611492783867749L; 37 | 38 | public SyncConfigurationException(){ 39 | } 40 | 41 | public SyncConfigurationException(String message){ 42 | super(message); 43 | } 44 | 45 | public SyncConfigurationException(Throwable cause){ 46 | super(cause); 47 | } 48 | 49 | public SyncConfigurationException(String message, Throwable cause){ 50 | super(message, cause); 51 | } 52 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/Credentials.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.ericsson.jira.oslc; 17 | 18 | /** 19 | * Encapsulates a Bugzilla username and password. 20 | * 21 | * @author Samuel Padgett 22 | */ 23 | public class Credentials { 24 | private String username; 25 | private String password; 26 | 27 | public String getUsername() { 28 | return username; 29 | } 30 | 31 | public void setUsername(String username) { 32 | this.username = username; 33 | } 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | public void setPassword(String password) { 40 | this.password = password; 41 | } 42 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/constants/JiraConstants.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.constants; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | public interface JiraConstants { 31 | public static final String REST_URL="/rest/jirarestresource/1.0/"; 32 | public static final String ACTIVATE_CONSUMER_URL="oauth/consumers/activate/"; 33 | public static final String REMOVE_CONSUMER_URL="oauth/consumers/remove/"; 34 | public static final String REMOVE_RS_LINK = "oauth/rootserviceslinks/removelink/"; 35 | public static final String REMOVE_SP_CATALOG_LINK = "oauth/serviceprovidercatalogslinks/removelink/"; 36 | public static final String REMOVE_SERVICEPROVIDER_LINK = "oauth/serviceproviderslinks/removelink/"; 37 | public static final String OAUTH_CONSUMER_PAGE_URL="/plugins/servlet/jiraservlet/OAuthConsumerServlet"; 38 | public static final String ROOTSEERVICES_MANAGEMENTT_PAGE = "/plugins/servlet/jiraservlet/RootServicesManagementServlet"; 39 | public static final String CATALOGS_MANAGEMENT_PAGE = "/plugins/servlet/jiraservlet/ServiceProviderCatalogsManagementServlet"; 40 | public static final String PROJECT_RELATIONSHIPS_PAGE = "/plugins/servlet/jiraservlet/ProjectRelationshipsServlet"; 41 | public static final String ISSUE_TYPE_PATH = "issueTypes/"; 42 | public static final String ISSUE_PRIORITY_PATH = "issuePriorities/"; 43 | public static final String ISSUE_STATUS_PATH = "issueStates/"; 44 | public static final String ISSUE_RESOLUTION_PATH = "issueResolutions/"; 45 | public static final String CREATION_DIALOG_WIDTH="900px"; 46 | public static final String CREATION_DIALOG_HEIGHT="600px"; 47 | public static final String SELECTION_DIALOG_WIDTH="900px"; 48 | public static final String SELECTION_DIALOG_HEIGHT="600px"; 49 | public static final String CM_CHANGE_REQUEST= "http://open-services.net/ns/cm#ChangeRequest"; 50 | public static final String CREATE_ISSUE = "/plugins/servlet/jiraservlet/createissue"; 51 | public static final String SELECT_ISSUE = "/plugins/servlet/jiraservlet/selectissue"; 52 | public static final String REMOVE_OSLC_LINK_FROM_REMOTE_APP = "oslc/links/removeFromRemoteApp/"; 53 | public static final String REMOVE_OSLC_LINK_FROM_JIRA = "oslc/links/removeFromJira/"; 54 | public static final String ADD_OSLC_LINK_DIALOG="/plugins/servlet/jiraservlet/addoslclinkdialog"; 55 | public static final String ADD_OSLC_LINK_TO_REMOTE_APP = "oslc/links/addToRemoteApp/"; 56 | public static final String ADD_OSLC_LINK_TO_JIRA = "oslc/links/addToJira/"; 57 | public static final String OSLC_CUSTOM_FIELD_NAME="External Links"; 58 | public static final String OSLC_CUSTOM_FIELD_LABEL="Label"; 59 | public static final String OSLC_CUSTOM_FIELD_URI="URI"; 60 | public static final String GET_OSLC_LINK_TYPES="oslc/links/types/"; 61 | public static final String OSLC_RESPONSE_TYPE_1 = "#oslc-windowName-1.0"; 62 | public static final String OSLC_RESPONSE_TYPE_2 = "#oslc-postMessage-1.0"; 63 | public static final String OSLC_RESPONSE_TYPE_3 = "#oslc-core-windowName-1.0"; 64 | public static final String OSLC_RESPONSE_TYPE_4 = "#oslc-core-postMessage-1.0"; 65 | public static final String SESSION_OAUTHACCESSOR = "oAuthAccessor"; 66 | public static final String SESSION_CURRENT_LINK = "currentOperationLink"; 67 | public static final String OAUTH_CALLBACK_SERVICE_URL = REST_URL + "oauth/authorizationcallback"; 68 | public static final String OAUTH_EXT_CALLBACK_SERVICE_URL = REST_URL + "oauth/authorizationexternalcallback"; 69 | public static final String RELATED_CHANGE_REQUEST_URL_APPENDIX = "?oslc.properties=oslc_cm%3ArelatedChangeRequest&oslc.prefix=oslc_cm%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Fcm%23%3E"; 70 | public static final String ISSUE_ICON = "/images/icons/favicon.png"; 71 | public static final String REALM_NAME = "JIRA"; 72 | public static final String SYNC_HEADER_NAME = "LeanSync"; 73 | public static final int SINGLE_TEXT_LIMIT = 255; 74 | public static final String XSD_PATH = "/config/leanSyncConfig.xsd"; 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/customfields/OSLCLink.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.customfields; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.Map; 31 | 32 | import org.slf4j.Logger; 33 | import org.slf4j.LoggerFactory; 34 | 35 | import com.atlassian.jira.component.ComponentAccessor; 36 | import com.atlassian.jira.issue.CustomFieldManager; 37 | import com.atlassian.jira.issue.Issue; 38 | import com.atlassian.jira.issue.customfields.impl.GenericTextCFType; 39 | import com.atlassian.jira.issue.customfields.manager.GenericConfigManager; 40 | import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister; 41 | import com.atlassian.jira.issue.fields.CustomField; 42 | import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem; 43 | import com.atlassian.jira.security.Permissions; 44 | import com.atlassian.jira.user.ApplicationUser; 45 | import com.ericsson.jira.oslc.constants.JiraConstants; 46 | import com.ericsson.jira.oslc.exceptions.PermissionException; 47 | import com.ericsson.jira.oslc.managers.JiraManager; 48 | import com.ericsson.jira.oslc.managers.PermissionManager; 49 | import com.ericsson.jira.oslc.utils.AppLinksRepository; 50 | import com.google.gson.Gson; 51 | import com.google.gson.GsonBuilder; 52 | 53 | /** 54 | * It represents the link to remote resource. 55 | * 56 | */ 57 | public class OSLCLink extends GenericTextCFType { 58 | private static final String CURRENT_CLASS = "OSLCLink"; 59 | private static final Logger logger = LoggerFactory.getLogger(OSLCLink.class); 60 | 61 | protected OSLCLink(CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager) { 62 | super(customFieldValuePersister, genericConfigManager); 63 | } 64 | 65 | @Override 66 | public Map getVelocityParameters(final Issue issue, final CustomField field, final FieldLayoutItem fieldLayoutItem) { 67 | final Map map = super.getVelocityParameters(issue, field, fieldLayoutItem); 68 | 69 | CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager(); 70 | 71 | 72 | if (issue == null || issue.getId() == null) { 73 | return map; 74 | } 75 | 76 | CustomField customField = customFieldManager.getCustomFieldObjectByName(JiraConstants.OSLC_CUSTOM_FIELD_NAME); 77 | 78 | if (customField == null) { 79 | return map; 80 | } 81 | 82 | String ApplicationLinks = (String) customField.getValue(issue); 83 | 84 | AppLinksRepository appLinkList = new AppLinksRepository(); 85 | try { 86 | GsonBuilder gsonBuilder = new GsonBuilder(); 87 | Gson gson = gsonBuilder.create(); 88 | appLinkList = gson.fromJson(ApplicationLinks, AppLinksRepository.class); 89 | 90 | } catch (com.google.gson.JsonSyntaxException e) { 91 | logger.error(CURRENT_CLASS, e); 92 | } 93 | 94 | if (appLinkList == null) { 95 | appLinkList = new AppLinksRepository(); 96 | } 97 | 98 | ApplicationUser user = PermissionManager.getLoggedUser(); 99 | boolean editable = false; 100 | if (user != null){ 101 | try { 102 | PermissionManager.checkPermissionWithUser(user, issue, Permissions.EDIT_ISSUE); 103 | editable = true; 104 | } catch (PermissionException e) { 105 | editable = false; 106 | } 107 | } 108 | map.put("editable", editable); 109 | map.put("restURL", JiraManager.getRestUrl()); 110 | map.put("baseURL", JiraManager.getBaseUrl()); 111 | map.put("link_addoslclinkdialog", JiraManager.getBaseUrl() + JiraConstants.ADD_OSLC_LINK_DIALOG + "?issuekey=" + issue.getKey()); 112 | map.put("removeOslcLinkURLFromRemoteApp", JiraConstants.REMOVE_OSLC_LINK_FROM_REMOTE_APP); 113 | map.put("removeOslcLinkURLFromJira", JiraConstants.REMOVE_OSLC_LINK_FROM_JIRA); 114 | map.put("issueID", issue.getId().toString()); 115 | map.put("appLinkList", appLinkList.GetAllAppLinks()); 116 | map.put("oauthcallback", JiraManager.getBaseUrl() + JiraConstants.OAUTH_CALLBACK_SERVICE_URL); 117 | 118 | return map; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/events/IssueEventType.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.events; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * Enum for type of events which are not fired automatically by JIRA and has to be fired manually. 32 | * 33 | */ 34 | public enum IssueEventType { 35 | ADD_EXT_LINK, REMOVE_EXT_LINK; 36 | } 37 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/events/RestIssueEvent.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.events; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.Map; 31 | 32 | import com.atlassian.crowd.embedded.api.User; 33 | import com.atlassian.jira.event.AbstractEvent; 34 | import com.atlassian.jira.issue.Issue; 35 | 36 | /** 37 | * It represents custom event which are fired manually from the code e.g. when 38 | * external link is added. 39 | * 40 | */ 41 | public class RestIssueEvent extends AbstractEvent { 42 | private Issue issue; 43 | private User user; 44 | private IssueEventType type; 45 | 46 | public RestIssueEvent(final Issue issue, final User user, IssueEventType type) { 47 | super(); 48 | this.issue = issue; 49 | this.user = user; 50 | this.type = type; 51 | } 52 | 53 | public RestIssueEvent(final Issue issue, final User user, Map parameters) { 54 | super(parameters); 55 | this.issue = issue; 56 | this.user = user; 57 | } 58 | 59 | public Issue getIssue() { 60 | return issue; 61 | } 62 | 63 | public User getUser() { 64 | return user; 65 | } 66 | 67 | public IssueEventType getType() { 68 | return type; 69 | } 70 | 71 | public void setType(IssueEventType type) { 72 | this.type = type; 73 | } 74 | 75 | 76 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/GetIssueException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when a issue is not available 32 | * 33 | */ 34 | public class GetIssueException extends Exception { 35 | 36 | private static final long serialVersionUID = -1945771994194731300L; 37 | 38 | public GetIssueException() { 39 | } 40 | 41 | public GetIssueException(String message) { 42 | super(message); 43 | } 44 | 45 | public GetIssueException(Throwable cause) { 46 | super(cause); 47 | } 48 | 49 | public GetIssueException(String message, Throwable cause) { 50 | super(message, cause); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/IssueTransitionException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when transition of issue failed 32 | * 33 | */ 34 | public class IssueTransitionException extends Exception{ 35 | private static final long serialVersionUID = 8985395102999065444L; 36 | 37 | public IssueTransitionException(){ 38 | } 39 | 40 | public IssueTransitionException(String message){ 41 | super(message); 42 | } 43 | 44 | public IssueTransitionException(Throwable cause){ 45 | super(cause); 46 | } 47 | 48 | public IssueTransitionException(String message, Throwable cause){ 49 | super(message, cause); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/IssueValidationException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when error occurs during a validation 32 | * 33 | */ 34 | public class IssueValidationException extends Exception{ 35 | private static final long serialVersionUID = -8581963580698927791L; 36 | 37 | public IssueValidationException(){ 38 | } 39 | 40 | public IssueValidationException(String message){ 41 | super(message); 42 | } 43 | 44 | public IssueValidationException(Throwable cause){ 45 | super(cause); 46 | } 47 | 48 | public IssueValidationException(String message, Throwable cause){ 49 | super(message, cause); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/NoResourceException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when a resource is not available 32 | * 33 | */ 34 | public class NoResourceException extends Exception { 35 | 36 | private static final long serialVersionUID = 1583709001536069481L; 37 | 38 | public NoResourceException(){ 39 | } 40 | 41 | public NoResourceException(String message){ 42 | super(message); 43 | } 44 | 45 | public NoResourceException(Throwable cause){ 46 | super(cause); 47 | } 48 | 49 | public NoResourceException(String message, Throwable cause){ 50 | super(message, cause); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/PermissionException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when permission problem occurs 32 | * 33 | */ 34 | public class PermissionException extends Exception { 35 | private static final long serialVersionUID = 2207461020664304332L; 36 | 37 | public PermissionException(){ 38 | } 39 | 40 | public PermissionException(String message){ 41 | super(message); 42 | } 43 | 44 | public PermissionException(Throwable cause){ 45 | super(cause); 46 | } 47 | 48 | public PermissionException(String message, Throwable cause){ 49 | super(message, cause); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/PreconditionException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when a precondition failed 32 | * 33 | */ 34 | public class PreconditionException extends Exception { 35 | 36 | private static final long serialVersionUID = 4468614532312055881L; 37 | 38 | public PreconditionException(){ 39 | } 40 | 41 | public PreconditionException(String message){ 42 | super(message); 43 | } 44 | 45 | public PreconditionException(Throwable cause){ 46 | super(cause); 47 | } 48 | 49 | public PreconditionException(String message, Throwable cause){ 50 | super(message, cause); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/exceptions/StatusException.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.exceptions; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * The exception is thrown when the validations or the operations with the issue failed in LeanSync. 32 | * 33 | */ 34 | public class StatusException extends Exception { 35 | private static final long serialVersionUID = 9139099220017790017L; 36 | 37 | 38 | public StatusException(){ 39 | } 40 | 41 | public StatusException(String message){ 42 | super(message); 43 | } 44 | 45 | public StatusException(Throwable cause){ 46 | super(cause); 47 | } 48 | 49 | public StatusException(String message, Throwable cause){ 50 | super(message, cause); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/provider/OslcRdfJsonErrorProvider.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.provider; 2 | 3 | /******************************************************************************* 4 | * Copyright (c) 2012, 2013 IBM Corporation. All rights reserved. This program 5 | * and the accompanying materials are made available under the terms of the 6 | * Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 which 7 | * accompanies this distribution. The Eclipse Public License is available at 8 | * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution 9 | * License is available at http://www.eclipse.org/org/documents/edl-v10.php. 10 | * Contributors: Russell Boykin - initial API and implementation Alberto 11 | * Giammaria - initial API and implementation Chris Peters - initial API and 12 | * implementation Gianluca Bernardini - initial API and implementation Steve 13 | * Pitschke - Add support for FilteredResource and ResponseInfo 14 | *******************************************************************************/ 15 | 16 | import java.io.IOException; 17 | import java.io.OutputStream; 18 | import java.lang.annotation.Annotation; 19 | import java.lang.reflect.Type; 20 | import java.util.Map; 21 | 22 | import javax.ws.rs.Consumes; 23 | import javax.ws.rs.Produces; 24 | import javax.ws.rs.WebApplicationException; 25 | import javax.ws.rs.core.MediaType; 26 | import javax.ws.rs.core.MultivaluedMap; 27 | import javax.ws.rs.ext.MessageBodyWriter; 28 | import javax.ws.rs.ext.Provider; 29 | 30 | import org.eclipse.lyo.oslc4j.core.model.Error; 31 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 32 | import org.eclipse.lyo.oslc4j.core.model.ResponseInfo; 33 | import org.eclipse.lyo.oslc4j.provider.json4j.AbstractOslcRdfJsonProvider; 34 | 35 | @Provider 36 | @Produces(OslcMediaType.APPLICATION_JSON) 37 | @Consumes(OslcMediaType.APPLICATION_JSON) 38 | public final class OslcRdfJsonErrorProvider extends AbstractOslcRdfJsonProvider implements MessageBodyWriter { 39 | public OslcRdfJsonErrorProvider() { 40 | super(); 41 | } 42 | 43 | @Override 44 | public long getSize(final Error object, final Class type, final Type genericType, final Annotation[] annotation, final MediaType mediaType) { 45 | return -1; 46 | } 47 | 48 | @Override 49 | public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { 50 | if (Error.class.isAssignableFrom(type)) { 51 | return isWriteable(type, annotations, OslcMediaType.APPLICATION_JSON_TYPE, mediaType); 52 | } 53 | 54 | return false; 55 | } 56 | 57 | @Override 58 | public void writeTo(final Error object, final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap map, final OutputStream outputStream) throws IOException, WebApplicationException { 59 | Object[] objects; 60 | Map properties = null; 61 | String descriptionURI = null; 62 | String responseInfoURI = null; 63 | ResponseInfo responseInfo = null; 64 | 65 | objects = new Object[] { object }; 66 | 67 | writeTo(objects, mediaType, map, outputStream, properties, descriptionURI, responseInfoURI, responseInfo); 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/provider/OslcXmlRdfErrorProvider.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.provider; 2 | 3 | /******************************************************************************* 4 | * Copyright (c) 2012, 2013 IBM Corporation. All rights reserved. This program 5 | * and the accompanying materials are made available under the terms of the 6 | * Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 which 7 | * accompanies this distribution. The Eclipse Public License is available at 8 | * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution 9 | * License is available at http://www.eclipse.org/org/documents/edl-v10.php. 10 | * Contributors: Russell Boykin - initial API and implementation Alberto 11 | * Giammaria - initial API and implementation Chris Peters - initial API and 12 | * implementation Gianluca Bernardini - initial API and implementation Steve 13 | * Pitschke - Add support for FilteredResource and ResponseInfo 14 | *******************************************************************************/ 15 | 16 | import java.io.IOException; 17 | import java.io.OutputStream; 18 | import java.lang.annotation.Annotation; 19 | import java.lang.reflect.Type; 20 | import java.util.Map; 21 | 22 | import javax.ws.rs.Consumes; 23 | import javax.ws.rs.Produces; 24 | import javax.ws.rs.WebApplicationException; 25 | import javax.ws.rs.core.MediaType; 26 | import javax.ws.rs.core.MultivaluedMap; 27 | import javax.ws.rs.ext.MessageBodyWriter; 28 | import javax.ws.rs.ext.Provider; 29 | 30 | import org.eclipse.lyo.oslc4j.core.model.Error; 31 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 32 | import org.eclipse.lyo.oslc4j.core.model.ResponseInfo; 33 | import org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider; 34 | 35 | @Provider 36 | @Produces({ OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.TEXT_XML }) 37 | @Consumes({ OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.TEXT_XML }) 38 | public class OslcXmlRdfErrorProvider extends AbstractOslcRdfXmlProvider implements MessageBodyWriter { 39 | public OslcXmlRdfErrorProvider() { 40 | super(); 41 | } 42 | 43 | @Override 44 | public long getSize(final Error object, final Class type, final Type genericType, final Annotation[] annotation, final MediaType mediaType) { 45 | return -1; 46 | } 47 | 48 | @Override 49 | public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { 50 | if (Error.class.isAssignableFrom(type)) { 51 | return isWriteable(type, annotations, mediaType, OslcMediaType.APPLICATION_RDF_XML_TYPE, OslcMediaType.APPLICATION_XML_TYPE, OslcMediaType.TEXT_XML_TYPE, OslcMediaType.TEXT_TURTLE_TYPE); 52 | } 53 | return false; 54 | } 55 | 56 | @Override 57 | public void writeTo(final Error object, final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap map, final OutputStream outputStream) throws IOException, WebApplicationException { 58 | Object[] objects; 59 | Map properties = null; 60 | String descriptionURI = null; 61 | String responseInfoURI = null; 62 | ResponseInfo responseInfo = null; 63 | objects = new Object[] { object }; 64 | 65 | writeTo(objects, mediaType, map, outputStream, properties, descriptionURI, responseInfoURI, responseInfo); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/provider/ResponseArrayWrapper.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.provider; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 31 | 32 | /** 33 | * It's a wrapper for our resources which are used by RS MessageWriter. 34 | * It's used for a array of Jira Change Requests 35 | */ 36 | public class ResponseArrayWrapper extends AbstractResource{ 37 | private T[] resource; 38 | 39 | public T[] getResource() { 40 | return resource; 41 | } 42 | 43 | public void setResource(T[] resource) { 44 | this.resource = resource; 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraHistoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | 33 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 36 | import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; 37 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 38 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 39 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 40 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 41 | import org.eclipse.lyo.oslc4j.core.model.Occurs; 42 | 43 | import com.atlassian.jira.issue.changehistory.ChangeHistory; 44 | import com.atlassian.jira.issue.history.ChangeItemBean; 45 | import com.ericsson.jira.oslc.Constants; 46 | 47 | /** 48 | * It represents a History request. It servers for fetching a history from an issue 49 | * 50 | */ 51 | @OslcNamespace(Constants.JIRA_NAMESPACE) 52 | @OslcName("IssueHistory") 53 | @OslcResourceShape(title = "Jira issue history shape", describes = Constants.JIRA_TYPE_HISTORY) 54 | public final class JiraHistoryRequest extends AbstractResource { 55 | 56 | private List history = null; 57 | 58 | //NOTE: default c'tor without parameters must be defined. If not, jena is not able to 59 | //create instance for further parsing in jersey. 60 | public JiraHistoryRequest() { 61 | this.history = new ArrayList(); 62 | } 63 | 64 | public JiraHistoryRequest(List hList) { 65 | this.history = new ArrayList(); 66 | 67 | for (ChangeHistory h : hList) { 68 | List beans = h.getChangeItemBeans(); 69 | for (ChangeItemBean bean : beans) { 70 | history.add(new JiraIssueHistoryItem(bean)); 71 | } 72 | } 73 | } 74 | 75 | @OslcDescription("The Jira history item.") 76 | @OslcOccurs(Occurs.ZeroOrMany) 77 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "issueHistoryItem") 78 | @OslcName("issueHistoryItem") 79 | @OslcTitle("History item") 80 | public List getIssueHistoryItems() { 81 | return this.history; 82 | } 83 | 84 | public void setIssueHistoryItems(List items) { 85 | this.history = items; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueComment.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.Date; 31 | 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 33 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; 36 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 37 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 38 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 39 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 40 | import org.eclipse.lyo.oslc4j.core.model.Occurs; 41 | 42 | import com.atlassian.jira.issue.comments.Comment; 43 | import com.atlassian.jira.user.ApplicationUser; 44 | import com.ericsson.jira.oslc.Constants; 45 | 46 | /** 47 | * It represents Issue comment. It's a part of JIRA Change Request 48 | * 49 | */ 50 | 51 | @OslcNamespace(Constants.JIRA_NAMESPACE) 52 | @OslcName("IssueComment") 53 | @OslcResourceShape(title = "Issue comment resource shape", describes = Constants.JIRA_NAMESPACE + "IssueComment") 54 | public class JiraIssueComment extends AbstractResource { 55 | 56 | private String author = null; 57 | private String body = null; 58 | private Date created = null; 59 | private Date updated = null; 60 | 61 | //NOTE: default c'tor without parameters must be defined. If not, jena is not able to 62 | // create instance for further parsing in jersey. 63 | public JiraIssueComment() { 64 | } 65 | 66 | public JiraIssueComment(Comment comment) { 67 | ApplicationUser appUser = comment.getAuthorApplicationUser(); 68 | this.author = appUser.getName(); 69 | this.body = comment.getBody(); 70 | this.created = comment.getCreated(); 71 | this.updated = comment.getUpdated(); 72 | } 73 | 74 | @OslcDescription("The Jira comment text for this change request.") 75 | @OslcOccurs(Occurs.ZeroOrOne) 76 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "commentBody") 77 | @OslcTitle("Comment body") 78 | public String getCommentBody() { 79 | return this.body; 80 | } 81 | 82 | public void setCommentBody(String body) { 83 | this.body = body; 84 | } 85 | 86 | @OslcDescription("Author of comment.") 87 | @OslcOccurs(Occurs.ExactlyOne) 88 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "commentAuthor") 89 | @OslcTitle("Comment author") 90 | public String getCommentAuthor() { 91 | return this.author; 92 | } 93 | 94 | public void setCommentAuthor(String name) { 95 | this.author = name; 96 | } 97 | 98 | @OslcDescription("Date of comment creation.") 99 | @OslcOccurs(Occurs.ExactlyOne) 100 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "commentCreated") 101 | @OslcTitle("Comment creation date") 102 | public Date getCommentCreated() { 103 | return this.created; 104 | } 105 | 106 | public void setCommentCreated(Date created) { 107 | this.created = created; 108 | } 109 | 110 | @OslcDescription("Date of comment update.") 111 | @OslcOccurs(Occurs.ExactlyOne) 112 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "commentUpdated") 113 | @OslcTitle("Comment update date") 114 | public Date getCommentUpdated() { 115 | return this.updated; 116 | } 117 | 118 | public void setCommentUpdated(Date updated) { 119 | this.updated = updated; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueCustomField.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 33 | import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcReadOnly; 36 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 37 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 38 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 39 | import org.eclipse.lyo.oslc4j.core.model.Occurs; 40 | 41 | import com.atlassian.jira.issue.Issue; 42 | import com.atlassian.jira.issue.fields.CustomField; 43 | import com.ericsson.jira.oslc.Constants; 44 | 45 | /** 46 | * It represents a Custom field. It's a part of JIRA Change Request 47 | * 48 | */ 49 | 50 | @OslcNamespace(Constants.JIRA_NAMESPACE) 51 | @OslcName("CustomField") 52 | @OslcResourceShape(title = "Issue custom field resource shape", describes = Constants.JIRA_NAMESPACE + "CustomField") 53 | public class JiraIssueCustomField extends AbstractResource { 54 | private String id = null; 55 | private String name = null; 56 | private String value = null; 57 | private String typeName = null; 58 | private String typeKey = null; 59 | 60 | //NOTE: default c'tor without parameters must be defined. If not, jena is not able to 61 | // create instance for further parsing in jersey. 62 | public JiraIssueCustomField() { 63 | } 64 | 65 | public JiraIssueCustomField(CustomField cf, Issue issue) { 66 | this.id = cf.getId(); 67 | this.name = cf.getName(); 68 | Object obj = cf.getValue(issue); 69 | if (obj != null) { 70 | this.value = obj.toString(); 71 | } 72 | this.typeKey = cf.getCustomFieldType().getKey(); 73 | this.typeName = cf.getCustomFieldType().getName(); 74 | } 75 | 76 | @OslcDescription("The id of custom field.") 77 | @OslcOccurs(Occurs.ZeroOrOne) 78 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "id") 79 | @OslcReadOnly 80 | @OslcTitle("Custom field id") 81 | public String getId() { 82 | return this.id; 83 | } 84 | 85 | public void setId(String id) { 86 | this.id = id; 87 | } 88 | 89 | @OslcDescription("The name of custom field.") 90 | @OslcOccurs(Occurs.ZeroOrOne) 91 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "name") 92 | @OslcReadOnly 93 | @OslcTitle("Custom field name") 94 | public String getName() { 95 | return this.name; 96 | } 97 | 98 | public void setName(String name) { 99 | this.name = name; 100 | } 101 | 102 | @OslcDescription("The value of custom field.") 103 | @OslcOccurs(Occurs.ZeroOrOne) 104 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "value") 105 | @OslcTitle("Custom field value") 106 | public String getValue() { 107 | return this.value; 108 | } 109 | 110 | public void setValue(String value) { 111 | this.value = value; 112 | } 113 | 114 | @OslcDescription("The type key of custom field.") 115 | @OslcOccurs(Occurs.ZeroOrOne) 116 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "typeKey") 117 | @OslcReadOnly 118 | @OslcTitle("Custom field type key") 119 | public String getTypeKey() { 120 | return this.typeKey; 121 | } 122 | 123 | public void setTypeKey(String typeKey) { 124 | this.typeKey = typeKey; 125 | } 126 | 127 | @OslcDescription("The type (name) of custom field.") 128 | @OslcOccurs(Occurs.ZeroOrOne) 129 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "typeName") 130 | @OslcReadOnly 131 | @OslcTitle("Custom field type name") 132 | public String getTypeName() { 133 | return this.typeName; 134 | } 135 | 136 | public void setTypeName(String typeName) { 137 | this.typeName = typeName; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueHistory.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 34 | 35 | import com.ericsson.jira.oslc.Constants; 36 | 37 | /** 38 | * It represent History resource 39 | * 40 | */ 41 | @OslcNamespace(Constants.JIRA_NAMESPACE) 42 | @OslcName("IssueHistory") 43 | @OslcResourceShape(title="Jira issue history") 44 | public class JiraIssueHistory extends AbstractResource { 45 | //no members, just for 'about' 46 | } 47 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueInternalLink.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.net.URI; 31 | 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 33 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; 36 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 37 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 38 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 39 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 40 | import org.eclipse.lyo.oslc4j.core.model.Occurs; 41 | 42 | import com.ericsson.jira.oslc.Constants; 43 | 44 | /** 45 | * It represents Internal link. It's a part of JIRA Change Request 46 | * 47 | */ 48 | @OslcNamespace(Constants.JIRA_NAMESPACE) 49 | @OslcName("IssueInternalLink") 50 | @OslcResourceShape(title = "Issue internal link resource shape") 51 | public class JiraIssueInternalLink extends AbstractResource { 52 | 53 | private URI urlToIssue = null; 54 | private String relationName = null; 55 | private String direction = null; 56 | 57 | //NOTE: default c'tor without parameters must be defined. If not, jena is not able to 58 | // create instance for further parsing in jersey. 59 | public JiraIssueInternalLink() { 60 | } 61 | 62 | public JiraIssueInternalLink(URI url, String relationName, String direction) { 63 | this.urlToIssue = url; 64 | this.relationName = relationName; 65 | this.direction = direction; 66 | } 67 | 68 | @OslcDescription("The Jira internal link url for this change request.") 69 | @OslcOccurs(Occurs.ZeroOrOne) 70 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "internalLinkUrl") 71 | @OslcTitle("InternalLinkUrl") 72 | public URI getInternalLinkUrl() { 73 | return this.urlToIssue; 74 | } 75 | 76 | public void setInternalLinkUrl(URI url) { 77 | this.urlToIssue = url; 78 | } 79 | 80 | @OslcDescription("The Jira internal link relation name for this change request.") 81 | @OslcOccurs(Occurs.ExactlyOne) 82 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "internalLinkRelation") 83 | @OslcTitle("InternalLinkRelation") 84 | public String getInternalLinkRelation() { 85 | return this.relationName; 86 | } 87 | 88 | public void setInternalLinkRelation(String value) { 89 | this.relationName = value; 90 | } 91 | 92 | @OslcDescription("The Jira internal link direction for this change request.") 93 | @OslcOccurs(Occurs.ExactlyOne) 94 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "internalLinkDirection") 95 | @OslcTitle("InternalLinkDirection") 96 | public String getInternalLinkDirection() { 97 | return this.direction; 98 | } 99 | 100 | public void setInternalLinkDirection(String value) { 101 | this.direction = value; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssuePriority.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 34 | 35 | import com.ericsson.jira.oslc.Constants; 36 | 37 | /** 38 | * It represents a priority. It's a part of JIRA Change Request 39 | * 40 | */ 41 | @OslcNamespace(Constants.JIRA_NAMESPACE) 42 | @OslcName("IssuePriority") 43 | @OslcResourceShape(title="Jira priorities") 44 | public class JiraIssuePriority extends AbstractResource { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueResolution.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 34 | 35 | import com.ericsson.jira.oslc.Constants; 36 | 37 | /** 38 | * It represents a resolution. It's a part of JIRA Change Request 39 | * 40 | */ 41 | @OslcNamespace(Constants.JIRA_NAMESPACE) 42 | @OslcName("IssueResolution") 43 | @OslcResourceShape(title="Jira resolutions") 44 | public class JiraIssueResolution extends AbstractResource { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueStatus.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 34 | 35 | import com.ericsson.jira.oslc.Constants; 36 | 37 | /** 38 | * It represents a status. It's a part of JIRA Change Request 39 | * 40 | */ 41 | 42 | @OslcNamespace(Constants.JIRA_NAMESPACE) 43 | @OslcName("IssueStatus") 44 | @OslcResourceShape(title="Jira issue status") 45 | public class JiraIssueStatus extends AbstractResource { 46 | 47 | } 48 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueType.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 34 | 35 | import com.ericsson.jira.oslc.Constants; 36 | 37 | /** 38 | * It represents an issue type. It's a part of JIRA Change Request 39 | * 40 | */ 41 | @OslcNamespace(Constants.JIRA_NAMESPACE) 42 | @OslcName("IssueType") 43 | @OslcResourceShape(title="Issue type resource shape") 44 | public class JiraIssueType extends AbstractResource { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/JiraIssueWebLink.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.net.URI; 31 | import java.net.URISyntaxException; 32 | 33 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 36 | import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; 37 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 38 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 39 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 40 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 41 | import org.eclipse.lyo.oslc4j.core.model.Occurs; 42 | 43 | import com.ericsson.jira.oslc.Constants; 44 | 45 | /** 46 | * It represents a web link. It's a part of JIRA Change Request 47 | * 48 | */ 49 | 50 | @OslcNamespace(Constants.JIRA_NAMESPACE) 51 | @OslcName("IssueWebLink") 52 | @OslcResourceShape(title = "Issue web link resource shape") 53 | public class JiraIssueWebLink extends AbstractResource { 54 | 55 | private URI url = null; 56 | private String name = null; 57 | 58 | //NOTE: default c'tor without parameters must be defined. If not, jena is not able to 59 | // create instance for further parsing in jersey. 60 | public JiraIssueWebLink() { 61 | } 62 | 63 | public JiraIssueWebLink(URI url, String name) { 64 | this.url = url; 65 | this.name = name; 66 | } 67 | 68 | public JiraIssueWebLink(String url, String name) { 69 | this.url = null; 70 | this.name = name; 71 | try { 72 | this.url = new URI(url); 73 | } 74 | catch (URISyntaxException e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | 79 | @OslcDescription("The Jira web link url for this change request.") 80 | @OslcOccurs(Occurs.ZeroOrOne) 81 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "webLinkUrl") 82 | @OslcTitle("WebLinkUrl") 83 | public URI getWebLinkUrl() { 84 | return this.url; 85 | } 86 | 87 | public void setWebLinkUrl(URI url) { 88 | this.url = url; 89 | } 90 | 91 | @OslcDescription("The Jira web link name for this change request.") 92 | @OslcOccurs(Occurs.ExactlyOne) 93 | @OslcPropertyDefinition(Constants.JIRA_NAMESPACE + "webLinkRelation") 94 | @OslcTitle("WebLinkRelation") 95 | public String getWebLinkRelation() { 96 | return this.name; 97 | } 98 | 99 | public void setWebLinkRelation(String value) { 100 | this.name = value; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/Person.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011, 2012 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | 17 | package com.ericsson.jira.oslc.resources; 18 | 19 | import java.net.URI; 20 | 21 | import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription; 22 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 23 | import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; 24 | import org.eclipse.lyo.oslc4j.core.annotation.OslcReadOnly; 25 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 26 | import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle; 27 | import org.eclipse.lyo.oslc4j.core.model.AbstractResource; 28 | 29 | import com.ericsson.jira.oslc.Constants; 30 | 31 | 32 | /** 33 | * A FOAF Person. 34 | * 35 | * @author Samuel Padgett 36 | * @see FOAF Vocabulary Specification 37 | */ 38 | @OslcNamespace(Constants.FOAF_NAMESPACE) 39 | @OslcResourceShape(title = "FOAF Person Resource Shape", describes = Constants.TYPE_PERSON) 40 | public class Person extends AbstractResource { 41 | private URI uri = null; 42 | private String name = null; 43 | private String mbox = null; 44 | 45 | public URI getUri() { 46 | return uri; 47 | } 48 | 49 | public void setUri(URI uri) { 50 | this.uri = uri; 51 | } 52 | 53 | @OslcDescription("A FOAF name ") 54 | @OslcPropertyDefinition(Constants.FOAF_NAMESPACE + "name") 55 | @OslcReadOnly 56 | @OslcTitle("Name") 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public void setName(String name) { 62 | this.name = name; 63 | } 64 | @OslcDescription("A FOAF Email address ") 65 | @OslcPropertyDefinition(Constants.FOAF_NAMESPACE + "mbox") 66 | @OslcReadOnly 67 | @OslcTitle("Email Address") 68 | public String getMbox() { 69 | return mbox; 70 | } 71 | 72 | public void setMbox(String mbox) { 73 | this.mbox = mbox; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/RootServices.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * It represents a rootservices. 32 | * 33 | */ 34 | public class RootServices { 35 | private String oauthDomain; 36 | private String oauthRequestTokenURL; 37 | private String oauthRequestConsumerKeyURL; 38 | private String oauthAccessTokenURL; 39 | private String oauthUserAuthorizationURL; 40 | 41 | public String getOAuthDomain() { 42 | return oauthDomain; 43 | } 44 | public void setOAuthDomain(String oauthDomain) { 45 | this.oauthDomain = oauthDomain; 46 | } 47 | public String getOAuthRequestTokenURL() { 48 | return oauthRequestTokenURL; 49 | } 50 | public void setOAuthRequestTokenURL(String oauthRequestTokenURL) { 51 | this.oauthRequestTokenURL = oauthRequestTokenURL; 52 | } 53 | public String getOAuthRequestConsumerKeyURL() { 54 | return oauthRequestConsumerKeyURL; 55 | } 56 | public void setOAuthRequestConsumerKeyURL(String oauthRequestConsumerKeyURL) { 57 | this.oauthRequestConsumerKeyURL = oauthRequestConsumerKeyURL; 58 | } 59 | public String getOAuthAccessTokenURL() { 60 | return oauthAccessTokenURL; 61 | } 62 | public void setOAuthAccessTokenURL(String oauthAccessTokenURL) { 63 | this.oauthAccessTokenURL = oauthAccessTokenURL; 64 | } 65 | public String getOAuthUserAuthorizationURL() { 66 | return oauthUserAuthorizationURL; 67 | } 68 | public void setOAuthUserAuthorizationURL(String oauthUserAuthorizationURL) { 69 | this.oauthUserAuthorizationURL = oauthUserAuthorizationURL; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ServiceProvider.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.ArrayList; 31 | 32 | /** 33 | * It represents OSLC service provider. 34 | * 35 | */ 36 | public class ServiceProvider { 37 | private ArrayList creationDialogs; 38 | private ArrayList selectionDialogs; 39 | private String title; 40 | private String creationFactoryUri; 41 | 42 | public ServiceProvider() { 43 | this.creationDialogs = new ArrayList(); 44 | this.selectionDialogs = new ArrayList(); 45 | } 46 | 47 | public int getCreationDialogsCount() { 48 | return this.creationDialogs.size(); 49 | } 50 | 51 | public int getSelectionDialogsCount() { 52 | return this.selectionDialogs.size(); 53 | } 54 | 55 | public void addDialog(ServiceProviderDialog dlg, boolean isCreation) { 56 | if (isCreation == true) { 57 | this.creationDialogs.add(dlg); 58 | } 59 | else { 60 | this.selectionDialogs.add(dlg); 61 | } 62 | } 63 | 64 | public ServiceProviderDialog getCreationDialog(int idx) { 65 | if (idx >= 0 && idx < this.creationDialogs.size()) { 66 | return this.creationDialogs.get(idx); 67 | } 68 | return null; 69 | } 70 | 71 | public ServiceProviderDialog getSelectionDialog(int idx) { 72 | if (idx >= 0 && idx < this.selectionDialogs.size()) { 73 | return this.selectionDialogs.get(idx); 74 | } 75 | return null; 76 | } 77 | 78 | public String getTitle() { 79 | return title; 80 | } 81 | 82 | public void setTitle(String title) { 83 | this.title = title; 84 | } 85 | 86 | public String getCreationFactoryUri() { 87 | return creationFactoryUri; 88 | } 89 | 90 | public void setCreationFactory(String creationFactoryUri) { 91 | this.creationFactoryUri = creationFactoryUri; 92 | } 93 | 94 | public ArrayList getCreationDialogs() { 95 | return creationDialogs; 96 | } 97 | 98 | public ArrayList getSelectionDialogs() { 99 | return selectionDialogs; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ServiceProviderDialog.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | * 32 | * It represents OSLC service provider catalog. 33 | * 34 | */ 35 | public class ServiceProviderDialog implements Comparable { 36 | private String type; 37 | private String link; 38 | private String width; 39 | private String height; 40 | 41 | public String getType() { 42 | return this.type; 43 | } 44 | 45 | public void setType(String type) { 46 | this.type = type; 47 | } 48 | 49 | public String getLink() { 50 | return this.link; 51 | } 52 | 53 | public void setLink(String link) { 54 | this.link = link; 55 | } 56 | 57 | public String getWidth() { 58 | return this.width; 59 | } 60 | 61 | public void setWidth(String w) { 62 | this.width = w; 63 | } 64 | 65 | public String getHeight() { 66 | return this.height; 67 | } 68 | 69 | public void setHeight(String h) { 70 | this.height = h; 71 | } 72 | 73 | @Override 74 | public int compareTo(ServiceProviderDialog compDlg) { 75 | if(this.type != null && compDlg != null){ 76 | String compType = compDlg.getType(); 77 | if(compType != null){ 78 | return this.type.compareTo(compType); 79 | } 80 | } 81 | return 0; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ServiceProviderRef.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import org.eclipse.lyo.oslc4j.core.annotation.OslcName; 31 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; 32 | import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape; 33 | import org.eclipse.lyo.oslc4j.core.model.OslcConstants; 34 | import org.eclipse.lyo.oslc4j.core.model.Service; 35 | import org.eclipse.lyo.oslc4j.core.model.ServiceProvider; 36 | 37 | /** 38 | * It represents OSLC service provider. It's short version of general service provider. It doesn't contain 39 | * creation and selection dialogs. It reduces the amount of data which are sent between the servers. 40 | * 41 | */ 42 | @OslcNamespace(OslcConstants.OSLC_CORE_NAMESPACE) 43 | @OslcName("ServiceProvider") 44 | @OslcResourceShape(title = "OSLC Service Provider Resource Shape", describes = OslcConstants.TYPE_SERVICE_PROVIDER) 45 | public class ServiceProviderRef extends ServiceProvider { 46 | //true - the service provider contains reduced data. It doesn't contain creation and selection dialogs. 47 | private boolean reduced = true; 48 | 49 | public Service[] getServices() { 50 | return (isReduced()?null:super.getServices()); 51 | } 52 | 53 | public boolean isReduced() { 54 | return reduced; 55 | } 56 | 57 | public void setReduced(boolean reduced) { 58 | this.reduced = reduced; 59 | } 60 | 61 | public Service[] getOSLCServices() { 62 | return super.getServices(); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/Severity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2012 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * Russell Boykin - initial API and implementation 15 | * Alberto Giammaria - initial API and implementation 16 | * Chris Peters - initial API and implementation 17 | * Gianluca Bernardini - initial API and implementation 18 | *******************************************************************************/ 19 | package com.ericsson.jira.oslc.resources; 20 | 21 | /** 22 | * An enumeration of available severities 23 | * 24 | */ 25 | public enum Severity 26 | { 27 | Unclassified, 28 | Minor, 29 | Normal, 30 | Major, 31 | Critical, 32 | Blocker 33 | } 34 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/Type.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2012 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * Russell Boykin - initial API and implementation 15 | * Alberto Giammaria - initial API and implementation 16 | * Chris Peters - initial API and implementation 17 | * Gianluca Bernardini - initial API and implementation 18 | *******************************************************************************/ 19 | package com.ericsson.jira.oslc.resources; 20 | 21 | /** 22 | * An enumeration of available types 23 | * 24 | */ 25 | public enum Type 26 | { 27 | Defect("Defect"), 28 | Task("Task"), 29 | Story("Story"), 30 | Bug_Report("Bug Report"), 31 | Feature_Request("Feature Request"); 32 | 33 | private String value; 34 | 35 | Type(final String value) 36 | { 37 | this.value = value; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return value; 43 | } 44 | 45 | public static Type fromString(final String string) 46 | { 47 | final Type[] values = Type.values(); 48 | for (final Type value : values) 49 | { 50 | if (value.value.equals(string)) 51 | { 52 | return value; 53 | } 54 | } 55 | 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/AOAccessor.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import com.atlassian.activeobjects.external.ActiveObjects; 31 | 32 | /** 33 | * AOAccessor enables to get to ActiveObjects from 34 | * "somewhere else". AOAccessor is component registered in plugin descriptor, 35 | * so it is injected with ActiveObjects instance and provide API do get it. 36 | * 37 | * Refer to: http://www.j-tricks.com/tutorials/active-objects-injection 38 | */ 39 | public interface AOAccessor { 40 | public ActiveObjects getActiveObjects(); 41 | } 42 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/AOAccessorImpl.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import com.atlassian.activeobjects.external.ActiveObjects; 31 | 32 | /** 33 | * This class serves as getter of ActiveObjects engine instance. 34 | * 35 | * It seems that only way, how to get ActiveObjects instance, is injection. 36 | * It is not problem, when using it in components and servlets (because 37 | * those are defined in plugin descriptor and injection happens automatically). 38 | * However if ActiveObjects is needed somewhere else (e.g. AOConsumerStore), 39 | * where injection can't be used, ActiveObjects must be provided in some other 40 | * way. 41 | * 42 | * AOAccessor (resp. AOAccessorImpl) enables to get to ActiveObjects from 43 | * "somewhere else". AOAccessor is component registered in plugin descriptor, 44 | * so it is injected with ActiveObjects instance and provide API do get it. 45 | * 46 | * Refer to: http://www.j-tricks.com/tutorials/active-objects-injection 47 | * 48 | */ 49 | public class AOAccessorImpl implements AOAccessor { 50 | 51 | private final ActiveObjects ao; 52 | 53 | public AOAccessorImpl(ActiveObjects ao) { 54 | this.ao = ao; 55 | } 56 | 57 | @Override 58 | public ActiveObjects getActiveObjects() { 59 | return this.ao; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/ConfigClobEntity.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import net.java.ao.Entity; 31 | import net.java.ao.Preload; 32 | import net.java.ao.schema.StringLength; 33 | 34 | /** 35 | * It represents a configuration which is loaded from db and saved to db 36 | * It's possible to save large configuration e.g. represented by xml 37 | * 38 | * NOTE: Class name should not be too long, 39 | * because database table name must not exceed 30 chars! 40 | * NOTE: Class must be registered in ActiveObject engine: 41 | * remember to add definition to in atlasian-plugin.xml! 42 | */ 43 | @Preload 44 | public interface ConfigClobEntity extends Entity { 45 | 46 | String getKey(); 47 | void setKey(String key); 48 | 49 | @StringLength(value=StringLength.UNLIMITED) 50 | String getValue(); 51 | void setValue(String value); 52 | } -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/ConfigEntity.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import net.java.ao.Entity; 31 | import net.java.ao.Preload; 32 | import net.java.ao.schema.StringLength; 33 | 34 | /** 35 | * It represents a configuration which is loaded from db and saved to db 36 | * It serves for handling the simple configuration. Use ConfigClobEntity for saving large configuration 37 | * 38 | * NOTE: Class name should not be too long, 39 | * because database table name must not exceed 30 chars! 40 | * NOTE: Class must be registered in ActiveObject engine: 41 | * remember to add definition to in atlasian-plugin.xml! 42 | */ 43 | @Preload 44 | public interface ConfigEntity extends Entity { 45 | 46 | String getKey(); 47 | void setKey(String key); 48 | 49 | String getValue(); 50 | void setValue(String value); 51 | } 52 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/OAuthConsmrEntity.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import net.java.ao.Entity; 31 | import net.java.ao.Preload; 32 | 33 | /** 34 | * 35 | * 36 | * Class is used to store OAuth consumer into database. 37 | * 38 | * NOTE: Class name should not be too long, 39 | * because database table name must not exceed 30 chars! 40 | * NOTE: Class must be registered in ActiveObject engine: 41 | * remember to add definition to in atlasian-plugin.xml! 42 | */ 43 | @Preload 44 | public interface OAuthConsmrEntity extends Entity { 45 | 46 | String getConsumerKey(); 47 | void setConsumerKey(String consumerKey); 48 | 49 | String getConsumerSecret(); 50 | void setConsumerSecret(String consumerSecret); 51 | 52 | String getName(); 53 | void setName(String name); 54 | 55 | boolean isProvisional(); 56 | void setProvisional(boolean provisional); 57 | } 58 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/RootServicesEntity.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import net.java.ao.Entity; 31 | import net.java.ao.Preload; 32 | import net.java.ao.Accessor; 33 | import net.java.ao.Mutator; 34 | 35 | 36 | /** 37 | * Class used to store root services or service provider catalogs in database. 38 | * 39 | * NOTE: Class name should not be too long, 40 | * because database table name must not exceed 30 chars! 41 | * NOTE: Class must be registered in ActiveObject engine: 42 | * remember to add definition to in atlasian-plugin.xml! 43 | */ 44 | @Preload 45 | public interface RootServicesEntity extends Entity { 46 | 47 | String getTitle(); 48 | void setTitle(String title); 49 | 50 | @Accessor("rsuri") 51 | String getRootServicesURI(); 52 | @Mutator("rsuri") 53 | void setRootServicesURI(String rootServicesURI); 54 | 55 | String getConsumerSecret(); 56 | void setConsumerSecret(String oAuthSecret); 57 | 58 | String getConsumerKey(); 59 | void setConsumerKey(String consumerKey); 60 | 61 | //OAuth mandatory values: 62 | 63 | @Accessor("requesttokenuri") 64 | String getRequestTokenURI(); 65 | @Mutator("requesttokenuri") 66 | void setRequsetTokenURI(String uri); 67 | 68 | @Accessor("userauthuri") 69 | String getUserAuthURI(); 70 | @Mutator("userauthuri") 71 | void setUserAuthUri(String uri); 72 | 73 | @Accessor("accesstokenuri") 74 | String getAccessTokenURI(); 75 | @Mutator("accesstokenuri") 76 | void setAccessTokenURI(String uri); 77 | 78 | @Accessor("oauthdomain") 79 | String getOAuthDomain(); 80 | @Mutator("oauthdomain") 81 | void setOAuthDomain(String uri); 82 | 83 | //distinguish between root services or service provider catalog 84 | boolean isRootServices(); 85 | void setRootServices(boolean value); 86 | } 87 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/ao/ServiceProvEntity.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.ao; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import net.java.ao.Entity; 31 | import net.java.ao.Preload; 32 | 33 | 34 | /** 35 | * Class used to store service provider in database. 36 | * 37 | * NOTE: Class name should not be too long, 38 | * because database table name must not exceed 30 chars! 39 | * NOTE: Class must be registered in ActiveObject engine: 40 | * remember to add definition to in atlasian-plugin.xml! 41 | */ 42 | 43 | @Preload 44 | public interface ServiceProvEntity extends Entity { 45 | 46 | int getServerId(); 47 | void setServerId(int id); 48 | 49 | String getServerTitle(); 50 | void setServerTitle(String id); 51 | 52 | String getTitle(); 53 | void setTitle(String title); 54 | 55 | String getURI(); 56 | void setURI(String URI); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/data/OAuthConsumerView.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.resources.data; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.ArrayList; 31 | import java.util.Collection; 32 | import java.util.List; 33 | 34 | import org.eclipse.lyo.server.oauth.core.consumer.LyoOAuthConsumer; 35 | 36 | /** 37 | * Data class which propagates the consumers to velocity template 38 | * 39 | * 40 | */ 41 | public class OAuthConsumerView { 42 | List provisionalConsumers; 43 | List activeConsumers; 44 | 45 | public OAuthConsumerView(Collection consumers){ 46 | provisionalConsumers = new ArrayList(); 47 | activeConsumers = new ArrayList(); 48 | categorizeConsumers(consumers); 49 | 50 | } 51 | 52 | /** 53 | * It divides the consumers to two groups according to if the consumer is provisional or not 54 | * @param consumers 55 | */ 56 | private void categorizeConsumers(Collection consumers){ 57 | if(consumers == null){ 58 | return; 59 | } 60 | 61 | for (LyoOAuthConsumer consumer: consumers) { 62 | if(consumer.isProvisional()){ 63 | provisionalConsumers.add(consumer); 64 | }else{ 65 | activeConsumers.add(consumer); 66 | } 67 | } 68 | } 69 | 70 | /** 71 | * Returns the list of provisional consumer 72 | * @return the list of provisional consumer 73 | */ 74 | public List getProvisionalConsumers(){ 75 | return provisionalConsumers; 76 | } 77 | 78 | /** 79 | * Returns the list of active consumer 80 | * @return the list of active consumer 81 | */ 82 | public List getActiveConsumers(){ 83 | return activeConsumers; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/resources/package-info.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2012 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * Russell Boykin - initial API and implementation 15 | * Alberto Giammaria - initial API and implementation 16 | * Chris Peters - initial API and implementation 17 | * Gianluca Bernardini - initial API and implementation 18 | *******************************************************************************/ 19 | @OslcSchema ({ 20 | @OslcNamespaceDefinition(prefix = OslcConstants.DCTERMS_NAMESPACE_PREFIX, namespaceURI = OslcConstants.DCTERMS_NAMESPACE), 21 | @OslcNamespaceDefinition(prefix = OslcConstants.OSLC_CORE_NAMESPACE_PREFIX, namespaceURI = OslcConstants.OSLC_CORE_NAMESPACE), 22 | @OslcNamespaceDefinition(prefix = OslcConstants.OSLC_DATA_NAMESPACE_PREFIX, namespaceURI = OslcConstants.OSLC_DATA_NAMESPACE), 23 | @OslcNamespaceDefinition(prefix = OslcConstants.RDF_NAMESPACE_PREFIX, namespaceURI = OslcConstants.RDF_NAMESPACE), 24 | @OslcNamespaceDefinition(prefix = OslcConstants.RDFS_NAMESPACE_PREFIX, namespaceURI = OslcConstants.RDFS_NAMESPACE), 25 | @OslcNamespaceDefinition(prefix = Constants.CHANGE_MANAGEMENT_NAMESPACE_PREFIX, namespaceURI = Constants.CHANGE_MANAGEMENT_NAMESPACE), 26 | @OslcNamespaceDefinition(prefix = Constants.JIRA_NAMESPACE_PREFIX, namespaceURI = Constants.JIRA_NAMESPACE), 27 | @OslcNamespaceDefinition(prefix = Constants.FOAF_NAMESPACE_PREFIX, namespaceURI = Constants.FOAF_NAMESPACE), 28 | @OslcNamespaceDefinition(prefix = Constants.QUALITY_MANAGEMENT_PREFIX, namespaceURI = Constants.QUALITY_MANAGEMENT_NAMESPACE), 29 | @OslcNamespaceDefinition(prefix = Constants.REQUIREMENTS_MANAGEMENT_PREFIX, namespaceURI = Constants.REQUIREMENTS_MANAGEMENT_NAMESPACE), 30 | @OslcNamespaceDefinition(prefix = Constants.SOFTWARE_CONFIGURATION_MANAGEMENT_PREFIX, namespaceURI = Constants.SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE) 31 | }) 32 | package com.ericsson.jira.oslc.resources; 33 | 34 | import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespaceDefinition; 35 | import org.eclipse.lyo.oslc4j.core.annotation.OslcSchema; 36 | import org.eclipse.lyo.oslc4j.core.model.OslcConstants; 37 | 38 | import com.ericsson.jira.oslc.Constants; 39 | 40 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import javax.ws.rs.core.Response; 31 | 32 | import org.slf4j.Logger; 33 | import org.slf4j.LoggerFactory; 34 | 35 | import com.ericsson.jira.oslc.exceptions.GetIssueException; 36 | import com.ericsson.jira.oslc.exceptions.IssueValidationException; 37 | import com.ericsson.jira.oslc.exceptions.NoResourceException; 38 | import com.ericsson.jira.oslc.exceptions.PermissionException; 39 | import com.ericsson.jira.oslc.exceptions.PreconditionException; 40 | import com.ericsson.jira.oslc.exceptions.StatusException; 41 | 42 | /** 43 | * General service for other the services. It contains the method for exception handling. 44 | * 45 | */ 46 | public class BaseService { 47 | protected static Logger logger = LoggerFactory.getLogger(BaseService.class); 48 | 49 | /** 50 | * It returns the response with a code based on the exception 51 | * @param e Exception 52 | */ 53 | protected Response handleException(Exception e){ 54 | String errorMessage = (e.getMessage() != null)?e.getMessage():""; 55 | 56 | if(e instanceof IssueValidationException){ 57 | logger.warn(e.getMessage()); 58 | return Response.status(Response.Status.FORBIDDEN).entity(errorMessage).build(); 59 | } 60 | 61 | if (e instanceof StatusException) { 62 | logger.warn(e.getMessage()); 63 | if (errorMessage.isEmpty()) { 64 | errorMessage = "Error during generating status information"; 65 | } 66 | return Response.status(Response.Status.FORBIDDEN).entity(errorMessage).build(); 67 | } 68 | 69 | if(e instanceof GetIssueException){ 70 | logger.warn(e.getMessage()); 71 | return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); 72 | } 73 | 74 | if(e instanceof PermissionException){ 75 | logger.warn(e.getMessage()); 76 | if(errorMessage == null || errorMessage.isEmpty()){ 77 | errorMessage = "Permission denied."; 78 | } 79 | return Response.status(Response.Status.FORBIDDEN).entity(errorMessage).build(); 80 | } 81 | 82 | if(e instanceof NoResourceException){ 83 | logger.warn(e.getMessage()); 84 | if(errorMessage == null || errorMessage.isEmpty()){ 85 | errorMessage = "Resource not found."; 86 | } 87 | return Response.status(Response.Status.NOT_FOUND).entity(errorMessage).build(); 88 | } 89 | 90 | if(e instanceof PreconditionException){ 91 | logger.warn(e.getMessage()); 92 | if(errorMessage == null || errorMessage.isEmpty()){ 93 | errorMessage = "Precondition failed."; 94 | } 95 | return Response.status(Response.Status.PRECONDITION_FAILED).entity(errorMessage).build(); 96 | } 97 | 98 | logger.error("Error: ", e); 99 | if(errorMessage.isEmpty()){ 100 | errorMessage = "Unexpected error. Please contact your administrator"; 101 | } 102 | 103 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/CSRFPrevent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2012 IBM Corporation. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 7 | * 8 | * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 9 | * and the Eclipse Distribution License is available at 10 | * http://www.eclipse.org/org/documents/edl-v10.php. 11 | * 12 | * Contributors: 13 | * 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.ericsson.jira.oslc.services; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.ws.rs.WebApplicationException; 20 | import javax.ws.rs.core.MediaType; 21 | import javax.ws.rs.core.Response; 22 | import javax.ws.rs.core.Response.Status; 23 | 24 | /** 25 | * Checks requests to see if they have the right X-CSRF-Prevent header values. 26 | * 27 | * @author Samuel Padgett 28 | */ 29 | public class CSRFPrevent { 30 | private static final String CSRF_PREVENT_HEADER = "X-CSRF-Prevent"; //$NON-NLS-1$ 31 | 32 | public static void check(HttpServletRequest httpRequest) { 33 | String csrfPrevent = httpRequest.getHeader(CSRF_PREVENT_HEADER); 34 | String sessionId = httpRequest.getSession().getId(); 35 | if (!sessionId.equals(csrfPrevent)) { 36 | throw new WebApplicationException(Response.status(Status.FORBIDDEN) 37 | .entity("Request denied due to possible CSRF attack.").type(MediaType.TEXT_PLAIN).build()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/IssuePriorityService.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.io.IOException; 31 | import java.util.Iterator; 32 | import java.util.List; 33 | 34 | import javax.servlet.http.HttpServletRequest; 35 | import javax.ws.rs.GET; 36 | import javax.ws.rs.Path; 37 | import javax.ws.rs.PathParam; 38 | import javax.ws.rs.core.Context; 39 | import javax.ws.rs.core.Response; 40 | 41 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 42 | 43 | import com.atlassian.jira.component.ComponentAccessor; 44 | import com.atlassian.jira.config.PriorityManager; 45 | import com.atlassian.jira.issue.priority.Priority; 46 | import com.atlassian.plugins.rest.common.security.AnonymousAllowed; 47 | import com.ericsson.jira.oslc.Constants; 48 | import com.ericsson.jira.oslc.managers.FieldManager; 49 | 50 | /** 51 | * A service for issue priority 52 | * 53 | */ 54 | @Path("/issuePriorities") 55 | @AnonymousAllowed 56 | public class IssuePriorityService { 57 | 58 | @Context private HttpServletRequest httpServletRequest; 59 | 60 | @GET 61 | @AnonymousAllowed 62 | public Response getPriorityTypes() throws IOException { 63 | 64 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 65 | 66 | StringBuilder builder = new StringBuilder(); 67 | 68 | builder.append("\n"); 69 | builder.append("\n"); 73 | 74 | PriorityManager prMngr = ComponentAccessor.getComponent(PriorityManager.class); 75 | List priorities = prMngr.getPriorities(); 76 | Iterator pit = priorities.iterator(); 77 | while (pit.hasNext()) 78 | { 79 | builder.append(" \n"); 84 | } 85 | 86 | builder.append(""); 87 | 88 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 89 | } 90 | 91 | @GET 92 | @AnonymousAllowed 93 | @Path("{issuePriorityId}") 94 | public Response getIssueType(@PathParam("issuePriorityId") String issuePriorityId) throws IOException { 95 | 96 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 97 | 98 | StringBuilder builder = new StringBuilder(); 99 | 100 | builder.append("\n"); 101 | builder.append("\n"); 105 | builder.append(" \n"); 106 | 107 | String priorityName = FieldManager.getPriorityName(issuePriorityId); 108 | 109 | builder.append(" "); 110 | builder.append(priorityName); //issue priority name 111 | builder.append("\n"); 112 | builder.append(" \n"); 113 | builder.append(""); 114 | 115 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/IssueResolutionService.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.io.IOException; 31 | import java.util.Iterator; 32 | import java.util.List; 33 | 34 | import javax.servlet.http.HttpServletRequest; 35 | import javax.ws.rs.GET; 36 | import javax.ws.rs.Path; 37 | import javax.ws.rs.PathParam; 38 | import javax.ws.rs.core.Context; 39 | import javax.ws.rs.core.Response; 40 | 41 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 42 | 43 | import com.atlassian.jira.component.ComponentAccessor; 44 | import com.atlassian.jira.config.ResolutionManager; 45 | import com.atlassian.jira.issue.resolution.Resolution; 46 | import com.atlassian.plugins.rest.common.security.AnonymousAllowed; 47 | import com.ericsson.jira.oslc.Constants; 48 | import com.ericsson.jira.oslc.managers.FieldManager; 49 | 50 | /** 51 | * A service for a resolution 52 | * 53 | */ 54 | @Path("/issueResolutions") 55 | @AnonymousAllowed 56 | public class IssueResolutionService { 57 | 58 | @Context private HttpServletRequest httpServletRequest; 59 | 60 | @GET 61 | @AnonymousAllowed 62 | public Response getPriorityTypes() throws IOException { 63 | 64 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 65 | 66 | StringBuilder builder = new StringBuilder(); 67 | 68 | builder.append("\n"); 69 | builder.append("\n"); 73 | 74 | ResolutionManager resMngr = ComponentAccessor.getComponent(ResolutionManager.class); 75 | List resolutions = resMngr.getResolutions(); 76 | Iterator rit = resolutions.iterator(); 77 | while (rit.hasNext()) 78 | { 79 | builder.append(" \n"); 84 | } 85 | 86 | builder.append(""); 87 | 88 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 89 | } 90 | 91 | @GET 92 | @AnonymousAllowed 93 | @Path("{issueResolutionId}") 94 | public Response getIssueType(@PathParam("issueResolutionId") String issueResolutionId) throws IOException { 95 | 96 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 97 | 98 | StringBuilder builder = new StringBuilder(); 99 | 100 | builder.append("\n"); 101 | builder.append("\n"); 105 | builder.append(" \n"); 106 | 107 | String resName = FieldManager.getResolutionName(issueResolutionId); 108 | 109 | builder.append(" "); 110 | builder.append(resName); //resolution name 111 | builder.append("\n"); 112 | builder.append(" \n"); 113 | builder.append(""); 114 | 115 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/IssueTypeService.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.io.IOException; 31 | import java.util.List; 32 | 33 | import javax.servlet.http.HttpServletRequest; 34 | import javax.ws.rs.GET; 35 | import javax.ws.rs.Path; 36 | import javax.ws.rs.PathParam; 37 | import javax.ws.rs.core.Context; 38 | import javax.ws.rs.core.Response; 39 | 40 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 41 | 42 | import com.atlassian.plugins.rest.common.security.AnonymousAllowed; 43 | import com.ericsson.jira.oslc.Constants; 44 | import com.ericsson.jira.oslc.managers.FieldManager; 45 | 46 | /** 47 | * A service for issue type 48 | * 49 | */ 50 | @Path("/issueTypes") 51 | @AnonymousAllowed 52 | public class IssueTypeService { 53 | 54 | @Context private HttpServletRequest httpServletRequest; 55 | 56 | @GET 57 | @AnonymousAllowed 58 | public Response getIssueTypes() throws Exception { 59 | 60 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 61 | 62 | StringBuilder builder = new StringBuilder(); 63 | 64 | builder.append("\n"); 65 | builder.append("\n"); 69 | List issueTypes = FieldManager.getFilteredIssueTypes(); 70 | if (issueTypes != null) { 71 | for (String id : issueTypes) { 72 | builder.append(" \n"); 77 | } 78 | } 79 | builder.append(""); 80 | 81 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 82 | } 83 | 84 | @GET 85 | @AnonymousAllowed 86 | @Path("{issueTypeId}") 87 | public Response getIssueType(@PathParam("issueTypeId") String issueTypeId) throws IOException { 88 | 89 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 90 | 91 | StringBuilder builder = new StringBuilder(); 92 | 93 | builder.append("\n"); 94 | builder.append("\n"); 98 | builder.append(" \n"); 99 | String itn = FieldManager.getIssueType(issueTypeId); 100 | builder.append(" "); 101 | builder.append(itn); //issue type name 102 | builder.append("\n"); 103 | builder.append(" \n"); 104 | builder.append(""); 105 | 106 | return Response.ok(builder.toString()).type(OslcMediaType.APPLICATION_RDF_XML).build(); 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/RootServicesService.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import javax.servlet.http.HttpServletRequest; 31 | import javax.ws.rs.GET; 32 | import javax.ws.rs.Path; 33 | import javax.ws.rs.core.Context; 34 | import javax.ws.rs.core.Response; 35 | 36 | import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; 37 | 38 | import com.atlassian.jira.component.ComponentAccessor; 39 | import com.atlassian.jira.config.properties.APKeys; 40 | import com.atlassian.plugins.rest.common.security.AnonymousAllowed; 41 | 42 | /** 43 | * A services for rootservices 44 | * 45 | */ 46 | @Path("/rootservices") 47 | public class RootServicesService { 48 | 49 | @Context 50 | private HttpServletRequest httpServletRequest; 51 | 52 | @GET 53 | @AnonymousAllowed 54 | public Response rootservices() { 55 | 56 | String jiraServiceBase = ServiceHelper.getOslcBaseUri(httpServletRequest); 57 | 58 | StringBuilder builder = new StringBuilder(); 59 | 60 | builder.append("\n"); 61 | builder.append("\n"); 70 | builder.append(" OSLC Adapter/Jira Root Services\n"); 71 | builder.append(" \n"); 72 | builder.append(" \n"); 73 | builder.append(" \n"); 74 | builder.append(" \n"); 75 | builder.append(" JIRA\n"); 76 | builder.append(" " + ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL) + "/\n"); 77 | builder.append(" \n"); 78 | builder.append(""); 79 | 80 | String responseBody = builder.toString(); 81 | 82 | return Response.ok().entity(responseBody).header("max-age", 0).header("pragma", "no-cache") 83 | .header("Cache-Control", "no-cache").header("OSLC-Core-Version", 2.0) 84 | .header("Content-Length", responseBody.getBytes().length).type(OslcMediaType.APPLICATION_RDF_XML) 85 | .build(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/services/ServiceHelper.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.services; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import javax.servlet.http.HttpServletRequest; 31 | 32 | /** 33 | * Utility class for services 34 | * 35 | */ 36 | public class ServiceHelper { 37 | 38 | public static String getOslcBaseUri(HttpServletRequest request) { 39 | return getJiraBaseUri(request) + "/rest/jirarestresource/1.0"; 40 | } 41 | 42 | /** 43 | * Gets base URI of JIRA server 44 | * @param request HttpServletRequest 45 | * @return ase URI of JIRA server 46 | */ 47 | public static String getJiraBaseUri(HttpServletRequest request) { 48 | StringBuilder builder = new StringBuilder(); 49 | 50 | builder.append(request.getScheme()); 51 | builder.append("://"); 52 | builder.append(request.getServerName()); 53 | 54 | if (request.getServerPort() != 80 && request.getServerPort() != 443) { 55 | builder.append(":"); 56 | builder.append(request.getServerPort()); 57 | } 58 | 59 | builder.append(request.getContextPath()); 60 | return builder.toString(); 61 | } 62 | 63 | private ServiceHelper() { 64 | // Prevent instantiation 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/sync/JiraObjectMapping.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.sync; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.Collections; 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | /** 35 | * The enumeration contains the names of the fields which are used in LeanSync configuration for mapping to conctrete JIRA field 36 | * 37 | */ 38 | public enum JiraObjectMapping { 39 | SUMMARY("Summary"), DESCRIPTION("Description"), ASSIGNEE_ID("AssigneeId"), 40 | ISSUE_KEY("IssueKey"), ISSUE_TYPE_NAME("IssueTypeName"), RESOLUTION_NAME("ResolutionName"), 41 | REPORTER_ID("ReporterId"), CREATOR_ID("CreatorId"), PROJECT_KEY("ProjectKey"), 42 | PROJECT_NAME("ProjectName"), STATUS_NAME("StatusName"), STATUS_ID("StatusId"), 43 | COMPONENT_NAMES("ComponentNames"), AFFECTED_VERSION_NAMES("AffectedVersionNames"), FIX_VERSION_NAMES("FixVersionNames"), 44 | DUE_DATE("DueDate"), ORIGINAL_ESTIMATE("OriginalEstimate"), ESTIMATE("Estimate"), 45 | TIME_SPENT("TimeSpent"), LABEL_NAMES("LabelNames"), SUBTASK_NAMES("SubtaskNames"), 46 | COMMENTS("Comments"), WORK_LOG("WorkLog"), HISTORY("History"), 47 | RESOLUTION_DATE("ResolutionDate"), VOTER_NAMES("VoterNames"), WATCHER_NAMES("WatcherNames"), 48 | INWARD_LINKS("InwardLinks"), OUTWARD_LINKS("OutwardLinks"), OUTSIDE_LINKS("OutsideLinks"), 49 | CREATED_DATE("CreatedDate"), UPDATED_DATE("UpdatedDate"), PRIORITY_NAME("PriorityName"), 50 | RESOLUTION_ID("ResolutionId"), ISSUE_TYPE_ID("IssueTypeId"), PRIORITY_ID("PriorityId"), 51 | ENVIRONMENT("Environment"), COMMENT("Comment"); 52 | 53 | 54 | static { 55 | Map result = new HashMap(); 56 | result.put("summary", SUMMARY.getName()); 57 | result.put("description", DESCRIPTION.getName()); 58 | result.put("assignee", ASSIGNEE_ID.getName()); 59 | result.put("Key", ISSUE_KEY.getName()); 60 | result.put("issuetype", ISSUE_TYPE_NAME.getName()); 61 | result.put("resolution", RESOLUTION_NAME.getName()); 62 | result.put("created", CREATOR_ID.getName()); 63 | result.put("reporter", REPORTER_ID.getName()); 64 | result.put("project", PROJECT_NAME.getName()); 65 | result.put("status", STATUS_NAME.getName()); 66 | result.put("Component", COMPONENT_NAMES.getName()); 67 | result.put("Version", AFFECTED_VERSION_NAMES.getName()); 68 | result.put("Fix Version", FIX_VERSION_NAMES.getName()); 69 | result.put("duedate", DUE_DATE.getName()); 70 | result.put("timeoriginalestimate", ORIGINAL_ESTIMATE.getName()); 71 | result.put("timeestimate", ESTIMATE.getName()); 72 | result.put("timespent", TIME_SPENT.getName()); 73 | result.put("labels", LABEL_NAMES.getName()); 74 | result.put("priority", PRIORITY_NAME.getName()); 75 | result.put("environment", ENVIRONMENT.getName()); 76 | 77 | fieldIdsToLabels = Collections.unmodifiableMap(result); 78 | } 79 | 80 | private static final Map fieldIdsToLabels; 81 | 82 | public static Map getFieldIdsToLabels() { 83 | return fieldIdsToLabels; 84 | } 85 | 86 | private String name; 87 | JiraObjectMapping(String name){ 88 | this.name = name; 89 | } 90 | 91 | 92 | /** 93 | * Get the name of mapped field 94 | * @return the name of mapped field 95 | */ 96 | public String getName() { 97 | return name; 98 | } 99 | 100 | /** 101 | * Compare the names 102 | * @param name the name which will be compared 103 | * @return true - the names are the same, otherwise false 104 | */ 105 | public boolean compare(String name) { 106 | if(this.name != null){ 107 | return this.name.equals(name); 108 | }else if (this.name == null && name == null){ 109 | return true; 110 | } 111 | return false; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/sync/SyncConfig.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.sync; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.HashMap; 31 | import java.util.Map; 32 | 33 | import javax.xml.bind.annotation.XmlRootElement; 34 | 35 | import com.ericsson.eif.leansync.mapping.SyncConfigLoader; 36 | import com.ericsson.eif.leansync.mapping.data.SyncConfiguration; 37 | import com.ericsson.jira.oslc.resources.ao.AOManager; 38 | 39 | /** 40 | * Sync configuration - handles LeanSync configuration including loading from DB 41 | */ 42 | @XmlRootElement 43 | public class SyncConfig { 44 | private static SyncConfig instance; 45 | private Map configurationMap; 46 | public static final String SYNC_CONFIG_PROPERTY = "syncConfig"; 47 | 48 | /** 49 | * Get a instance of the configuration - singleton 50 | * @return the configuration 51 | * @throws Exception 52 | */ 53 | public static SyncConfig getInstance() throws Exception { 54 | if (instance == null) { 55 | instance = new SyncConfig(true); 56 | } 57 | return instance; 58 | } 59 | 60 | private SyncConfig() throws Exception { 61 | } 62 | 63 | /** 64 | * Get a instance of the sync configuration - singleton 65 | * @param loadConfig - true - the sync configuration will be loaded from DB, false - it creates empty configuration 66 | * @return the sync configuration 67 | * @throws Exception 68 | */ 69 | public static SyncConfig getInstance(boolean loadConfig) throws Exception { 70 | if (instance == null) { 71 | instance = new SyncConfig(loadConfig); 72 | } 73 | return instance; 74 | } 75 | 76 | /** 77 | * It creates empty sync configuration and if the argument loadConfig is set on 'true' then the configuration 78 | * is loaded from DB 79 | * @param loadConfig the sync configuration will be loaded from DB, false - it creates empty configuration 80 | * @throws Exception 81 | */ 82 | private SyncConfig(boolean loadConfig) throws Exception { 83 | configurationMap = new HashMap(); 84 | if(loadConfig){ 85 | loadConfiguration(); 86 | } 87 | } 88 | 89 | /** 90 | * It loads sync configuration from DB 91 | * @throws Exception 92 | */ 93 | public void loadConfiguration() throws Exception { 94 | 95 | AOManager mngr = AOManager.getInstance(); 96 | String syncConfig = mngr.getConfigClobValue(SYNC_CONFIG_PROPERTY); 97 | if (syncConfig != null) { 98 | loadConfiguration(syncConfig); 99 | }else{ 100 | configurationMap.clear(); 101 | } 102 | } 103 | 104 | /** 105 | * It creates sync configuration from defined configuration which is stored in the argument inputConfiguration 106 | * @param inputConfiguration the sync configuration which will be loaded 107 | * @throws Exception 108 | */ 109 | public void loadConfiguration(String inputConfiguration) throws Exception { 110 | if (inputConfiguration != null && !inputConfiguration.isEmpty()) { 111 | SyncConfigLoader loader = new SyncConfigLoader(); 112 | configurationMap = loader.loadConfiguration(inputConfiguration); 113 | }else{ 114 | configurationMap.clear(); 115 | } 116 | } 117 | 118 | /** 119 | * Get the sync configuration 120 | * @return the sync configuration 121 | */ 122 | public Map getConfigurationMap() { 123 | return configurationMap; 124 | } 125 | 126 | /** 127 | * Set the sync configuration 128 | * @param map the sync configuration 129 | */ 130 | public void setConfigurationMap(Map map) { 131 | configurationMap = map; 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/utils/AppLink.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.utils; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.HashMap; 31 | import java.util.Map; 32 | 33 | /** 34 | * It represents the link to remote system 35 | * 36 | */ 37 | public class AppLink { 38 | 39 | private String label; 40 | private String URI; 41 | 42 | public AppLink(String mLabel, String mURI) { 43 | label = mLabel; 44 | URI = mURI; 45 | } 46 | 47 | public Map getAppLinkMap() { 48 | Map map = new HashMap(); 49 | map.put("Label", label); 50 | map.put("URI", URI); 51 | return map; 52 | } 53 | 54 | public String getLabel() { 55 | return this.label; 56 | } 57 | 58 | public String getURI() { 59 | return this.URI; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/utils/ErrorSyncHandler.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.utils; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.util.ArrayList; 31 | import java.util.Date; 32 | import java.util.List; 33 | 34 | import com.ericsson.eif.leansync.mapping.SyncConstants; 35 | 36 | /** 37 | * The ErrorSyncHandler class provides the methods for storing error state messages. 38 | * 39 | */ 40 | public class ErrorSyncHandler { 41 | private List errorMessages = new ArrayList(); 42 | 43 | /** 44 | * Append simple message without date time information. 45 | * @param errorMessage Message to be appended 46 | */ 47 | public void addMessageWithoutDateInfo(String errorMessage) { 48 | if (errorMessage != null) { 49 | this.errorMessages.add(errorMessage ); 50 | } 51 | } 52 | 53 | /** 54 | * Append message with date time information. The date time format will be added automaticalyThe format of message is: 55 | * @param errorMessage Message to be appended 56 | */ 57 | public void addMessage(String errorMessage) { 58 | if (errorMessage != null) { 59 | this.addMessage(errorMessage, new Date()); 60 | } 61 | } 62 | 63 | /** 64 | * Append message with specific Date object. 65 | * @param errorMessage Error message to be appended 66 | * @param actualDate Data object that contains date information which will be appended 67 | */ 68 | public void addMessage(String errorMessage, Date actualDate) { 69 | if (errorMessage != null && actualDate != null) { 70 | this.errorMessages.add(errorMessage + " (" + actualDate.toString() + ")"); 71 | } 72 | } 73 | 74 | /** 75 | * Append message and problematic object name. Automatically add actual date and time to the message. 76 | * @param errorMessage Error message to be appended 77 | * @param fieldName Problematic object name 78 | */ 79 | public void addMessage(String errorMessage, String fieldName) { 80 | if (errorMessage != null && fieldName != null) { 81 | this.addMessage("Field name: " + fieldName + ", " + "ErrorMsg:" + errorMessage, new Date()); 82 | } 83 | } 84 | /** 85 | * Get all messages 86 | * @return List of all messages 87 | */ 88 | public List getMessages() { 89 | return this.errorMessages; 90 | } 91 | 92 | /** 93 | * Return all messages in one String. Each message is on new line 94 | * @return String value of all messages. Each message is on new line 95 | */ 96 | public String getMessagesAsString() { 97 | StringBuilder sbResult = new StringBuilder(); 98 | 99 | for (String message : errorMessages) { 100 | sbResult.append(message); 101 | sbResult.append(SyncConstants.END_OF_LINE); 102 | } 103 | return sbResult.toString(); 104 | } 105 | 106 | /** 107 | * Check if ErrorSyncHandler contains some error messages 108 | * @return 109 | */ 110 | public boolean isLogEmpty() { 111 | if (!errorMessages.isEmpty()) { 112 | return false; 113 | } 114 | return true; 115 | } 116 | 117 | 118 | /** 119 | * Clear all messages in ErrorSyncHandler 120 | */ 121 | public void clearLog() { 122 | this.errorMessages.clear(); 123 | } 124 | 125 | /** 126 | * Get count of all messages 127 | * @return Return count of messages 128 | */ 129 | public int getCount() { 130 | return this.errorMessages.size(); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/utils/JiraIssueInputParameters.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.utils; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import com.atlassian.jira.bc.issue.IssueService; 31 | import com.atlassian.jira.component.ComponentAccessor; 32 | import com.atlassian.jira.issue.IssueInputParameters; 33 | import com.atlassian.jira.project.Project; 34 | 35 | /** 36 | * The data class which holds the IssueInput parameters, the list of error and warning messages and the project 37 | * in which the issue is created/updated 38 | * 39 | */ 40 | public class JiraIssueInputParameters { 41 | private IssueInputParameters issueInputParams; 42 | private ErrorSyncHandler errorSyncHandler = new ErrorSyncHandler(); 43 | private ErrorSyncHandler warnSyncHandler = new ErrorSyncHandler(); 44 | private Project project; 45 | 46 | public JiraIssueInputParameters() { 47 | IssueService issueService = ComponentAccessor.getIssueService(); 48 | issueInputParams = issueService.newIssueInputParameters(); 49 | } 50 | 51 | public JiraIssueInputParameters(IssueInputParameters inputParameters) { 52 | issueInputParams = inputParameters; 53 | } 54 | 55 | public IssueInputParameters getIssueInputParameters() { 56 | return issueInputParams; 57 | } 58 | 59 | public ErrorSyncHandler getErrorSyncHandler() { 60 | return errorSyncHandler; 61 | } 62 | 63 | public ErrorSyncHandler getWarnSyncHandler() { 64 | return warnSyncHandler; 65 | } 66 | 67 | public void setWarnSyncHandler(ErrorSyncHandler warnSyncHandler) { 68 | this.warnSyncHandler = warnSyncHandler; 69 | } 70 | 71 | public Project getProject() { 72 | return project; 73 | } 74 | 75 | public void setProject(Project project) { 76 | this.project = project; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/utils/ServiceProviderRegistryURIs.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.utils; 2 | 3 | import java.net.InetAddress; 4 | import java.util.logging.Logger; 5 | 6 | public final class ServiceProviderRegistryURIs 7 | { 8 | private static final Logger LOGGER = Logger.getLogger(ServiceProviderRegistryURIs.class.getName()); 9 | 10 | private static final String SYSTEM_PROPERTY_NAME_REGISTRY_URI = ServiceProviderRegistryURIs.class.getPackage().getName() + ".registryuri"; 11 | private static final String SYSTEM_PROPERTY_NAME_UI_URI = ServiceProviderRegistryURIs.class.getPackage().getName() + ".uiuri"; 12 | 13 | private static final String SERVICE_PROVIDER_REGISTRY_URI; 14 | private static final String UI_URI; 15 | 16 | 17 | static 18 | { 19 | final String registryURI = System.getProperty(SYSTEM_PROPERTY_NAME_REGISTRY_URI); 20 | final String uiURI = System.getProperty(SYSTEM_PROPERTY_NAME_UI_URI); 21 | 22 | System.out.println("SYSTEM_PROPERTY_NAME_REGISTRY_URI = " + SYSTEM_PROPERTY_NAME_REGISTRY_URI); 23 | System.out.println("SYSTEM_PROPERTY_NAME_UI_URI = " + SYSTEM_PROPERTY_NAME_UI_URI); 24 | 25 | String defaultBase = null; 26 | 27 | if ((registryURI == null) || 28 | (uiURI == null)) 29 | { 30 | // We need at least one default URI 31 | 32 | String hostName = "localhost"; 33 | 34 | try 35 | { 36 | hostName = InetAddress.getLocalHost().getCanonicalHostName(); 37 | } 38 | catch (final Exception exception) 39 | { 40 | // Default to localhost 41 | } 42 | 43 | defaultBase = "http://" + hostName + ":8080/"; 44 | } 45 | 46 | if (registryURI != null) 47 | { 48 | SERVICE_PROVIDER_REGISTRY_URI = registryURI; 49 | } 50 | else 51 | { 52 | // In order to force Jena to show SPC first in XML, add a bogus identifier to the SPC URI. 53 | // This is because Jena can show an object anywhere in its graph where it is referenced. Since the 54 | // SPC URI (without tailing identifier) is the same as its QueryCapability's queryBase, it can 55 | // be strangely rendered with the SPC nested under the queryBase. 56 | // This also allows us to distinguish between array and single results within the ServiceProviderCatalogResource. 57 | SERVICE_PROVIDER_REGISTRY_URI = defaultBase + "OSLC4JRegistry/catalog/singleton"; 58 | 59 | LOGGER.warning("System property '" + SYSTEM_PROPERTY_NAME_REGISTRY_URI + "' not set. Using calculated value '" + SERVICE_PROVIDER_REGISTRY_URI + "'"); 60 | } 61 | 62 | if (uiURI != null) 63 | { 64 | UI_URI = uiURI; 65 | } 66 | else 67 | { 68 | UI_URI = defaultBase + "OSLC4JUI"; 69 | 70 | LOGGER.warning("System property '" + SYSTEM_PROPERTY_NAME_UI_URI + "' not set. Using calculated value '" + UI_URI + "'"); 71 | } 72 | } 73 | 74 | private ServiceProviderRegistryURIs() 75 | { 76 | super(); 77 | } 78 | 79 | public static String getServiceProviderRegistryURI() 80 | { 81 | System.out.println("SERVICE_PROVIDER_REGISTRY_URI = " + SERVICE_PROVIDER_REGISTRY_URI); 82 | return SERVICE_PROVIDER_REGISTRY_URI; 83 | } 84 | 85 | public static String getUIURI() 86 | { 87 | System.out.println("UI_URI = " + UI_URI); 88 | return UI_URI; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /oslcjira/src/main/java/com/ericsson/jira/oslc/utils/ServletUtils.java: -------------------------------------------------------------------------------- 1 | package com.ericsson.jira.oslc.utils; 2 | 3 | /* 4 | * Copyright (C) 2015 Ericsson AB. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 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 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | import java.io.BufferedReader; 31 | import java.io.IOException; 32 | import java.io.InputStream; 33 | import java.io.InputStreamReader; 34 | import java.net.URI; 35 | 36 | import javax.servlet.http.HttpServletRequest; 37 | import javax.servlet.http.HttpServletResponse; 38 | 39 | import org.slf4j.Logger; 40 | import org.slf4j.LoggerFactory; 41 | 42 | import com.atlassian.sal.api.auth.LoginUriProvider; 43 | 44 | /** 45 | * A utility class for the servlets 46 | * 47 | */ 48 | public class ServletUtils { 49 | private static Logger logger = LoggerFactory.getLogger(ServletUtils.class); 50 | 51 | /** 52 | * In case of unauthorized access redirect a user to login page 53 | * @param request a request 54 | * @param response a response 55 | * @throws IOException 56 | */ 57 | public static void redirectToLogin(HttpServletRequest request, HttpServletResponse response, 58 | LoginUriProvider loginUriProvider ) throws IOException { 59 | response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString()); 60 | } 61 | 62 | /** 63 | * Get uri from a request 64 | * @param request a request 65 | * @return uri from a request 66 | */ 67 | public static URI getUri(HttpServletRequest request) { 68 | StringBuffer builder = request.getRequestURL(); 69 | if (request.getQueryString() != null) { 70 | builder.append("?"); 71 | builder.append(request.getQueryString()); 72 | } 73 | return URI.create(builder.toString()); 74 | } 75 | 76 | /** 77 | * Convert InputStream to String 78 | * @param is the InputStream which will be converted to the String 79 | * @return converted InsputStream 80 | */ 81 | public static String getStringFromInputStream(InputStream is) { 82 | 83 | BufferedReader br = null; 84 | StringBuilder sb = new StringBuilder(); 85 | 86 | String line; 87 | try { 88 | 89 | br = new BufferedReader(new InputStreamReader(is)); 90 | while ((line = br.readLine()) != null) { 91 | sb.append(line); 92 | } 93 | 94 | } catch (IOException e) { 95 | logger.error("GetStringFromInputStream", e); 96 | } finally { 97 | if (br != null) { 98 | try { 99 | br.close(); 100 | } catch (IOException e) { 101 | logger.error("GetStringFromInputStream", e); 102 | } 103 | } 104 | } 105 | 106 | return sb.toString(); 107 | } 108 | 109 | /** 110 | * Convert string value to boolean value 111 | * @param value the string value which will be converted to boolean 112 | * @return the boolean value 113 | */ 114 | public static Boolean parseBoolean(String value) { 115 | if(value == null){ 116 | return null; 117 | } else if("TRUE".equals(value.toUpperCase())){ 118 | return true; 119 | } else if("FALSE".equals(value.toUpperCase())){ 120 | return false; 121 | } else{ 122 | return null; 123 | } 124 | } 125 | 126 | /** 127 | * Convert white spaces like \n, \r, \t to \\n, \\r, \\t 128 | * @param value the string value which will be encoded 129 | * @return encoded string 130 | */ 131 | public static String encodeWhitespaces(String value) { 132 | if(value != null){ 133 | value=value.replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t"); 134 | } 135 | return value; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/RestExtension.properties: -------------------------------------------------------------------------------- 1 | put any key/value pairs here 2 | my.plugin.name=MyPlugin 3 | my-rest-resource.name=My Rest Resource 4 | my-rest-resource.description=The My Rest Resource Plugin 5 | 6 | my-servlet.name=My Servlet 7 | my-servlet.description=The My Servlet Plugin 8 | 9 | my-servlet-filter.name=My Servlet Filter 10 | my-servlet-filter.description=The My Servlet Filter Plugin 11 | 12 | my-servlet-context-listener.name=My Servlet Context Listener 13 | my-servlet-context-listener.description=The My Servlet Context Listener Plugin 14 | 15 | oslc-links.name=External Links 16 | oslc-links.description=The oslc links module 17 | oslc-links.tooltip=External Links Module 18 | 19 | add-oslc-link.label=External Link 20 | add-oslc-link.tooltip=Add external link 21 | add-oslc-link.name=addOslcLink 22 | add-oslc-link.description=The addOslcLink Plugin 23 | 24 | add-oslc-link-dialog.name=AddOslcLinkDialog 25 | add-oslc-link-dialog.description=The AddOslcLinkDialog Plugin 26 | 27 | add-oslc-link-dialog-servlet.name=Add OSLC Link Dialog Servlet 28 | add-oslc-link-dialog-servlet.description=The My Servlet Plugin 29 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/images/pluginIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ericsson/jira-oslc-plugin/211d4a7d40286ef1128f32301cecc4b6bf12ded6/oslcjira/src/main/resources/images/pluginIcon.png -------------------------------------------------------------------------------- /oslcjira/src/main/resources/images/pluginLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ericsson/jira-oslc-plugin/211d4a7d40286ef1128f32301cecc4b6bf12ded6/oslcjira/src/main/resources/images/pluginLogo.png -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/admin.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | XProduct Admin 4 | 5 | $webResourceManager.requireResource("com.atlassian.auiplugin:ajs") 6 | 7 | 8 |
9 |
10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/create_issue_response.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Create issue response 5 | 6 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/error_page.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 |
22 |

$errorMessage

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/oAuthConsumers_old.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $webResourceManager.requireResource("com.atlassian.auiplugin:ajs") 6 | 7 | 8 | 9 | 36 | 37 | 68 | 69 |
70 | OSLC - OAuth consumers administration 71 |
72 | 73 |
74 |
Provisional keys
75 |
76 | Consumer can request provisional OAuth key which is not active until it is authorized. The following keys need to be authorized to be used as OAuth consumer keys. 77 |
78 | #set($idx = 1) 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | #foreach( $consumer in ${consumers.provisionalConsumers}) 89 | 90 | 95 | 100 | 104 | 105 | #set($idx = $idx + 1) 106 | #end 107 | 108 |
NameConsumer keyAction
91 |
92 | ${consumer.name} 93 |
94 |
96 |
97 | ${consumer.key} 98 |
99 |
101 | Add 102 | Remove 103 |
109 |
110 | 111 |

112 |
113 |
Authorized keys
114 |
115 | The following keys are authorized for access on this server. 116 |
117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | #foreach( $consumer in ${consumers.activeConsumers}) 127 | 128 | 133 | 138 | 141 | 142 | #set($idx = $idx + 1) 143 | #end 144 | 145 |
NameConsumer keyAction
129 |
130 | ${consumer.name} 131 |
132 |
134 |
135 | ${consumer.key} 136 |
137 |
139 | Remove 140 |
146 |
147 | 148 | 149 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/oauth_authorize.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | Connect to $applicationName 4 | 9 | 14 | 15 | 16 |
17 |

Authorize Application

18 |

$consumerName is requesting access to your $applicationName data. Allow?

19 |

Only continue if you initiated this request directly from $consumerName

20 | 21 |
22 | 23 | 24 |
25 | 26 | 27 |
28 |
29 |
30 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/pluginConfiguration.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Plugin configuration 5 | 6 | $webResourceManager.requireResource("com.atlassian.auiplugin:ajs") 7 | 8 | 9 | 37 | 38 | 49 | 50 | 51 |
52 | Plugin configuration 53 |
54 | 55 |
56 |
Filter configuration
57 |
58 | Define the filters for projects and issue types separated by comma. Only specified projects and issue types will be visible from outside. 59 |
60 |
61 |
62 | 63 | 64 |
65 |
66 | 67 | 68 |
69 | 70 |
71 | 72 | 73 | 74 |
75 | 76 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/small_preview.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | Change Request: 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Status:$statusProject:$project
Assignee:$assigneeResolution:$resolution
Priority:$priorityCreator:$creator
Reported:$reportedModified:$modified
33 | 34 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/syncConfig.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LeanSync configuration 5 | 6 | $webResourceManager.requireResource("com.atlassian.auiplugin:ajs") 7 | 8 | 9 | 37 | 38 | 65 | 66 | 67 |
68 | LeanSync configuration 69 |
70 | 71 |
72 |
Mapping configuration
73 |
74 | Define the field mapping for inbound and outbound connections. 75 |
76 |
77 |
78 | 79 |
80 |
81 | 82 |
83 | 84 |
85 | 86 | 87 |
88 | 89 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/view-oslclinks_columns.vm: -------------------------------------------------------------------------------- 1 | #disable_html_escaping() 2 | #if ($value) 3 | #if ($textOnly || $excelView) 4 | #foreach($AppLink in ${appLinkList}) 5 | $textutils.htmlEncode($!{AppLink.Label}):$textutils.htmlEncode($!{AppLink.URI}); 6 | #end 7 | #else 8 | #if (${appLinkList}) 9 | 10 | #foreach($AppLink in ${appLinkList}) 11 | 12 | 13 | 14 | 15 | #end 16 |
$textutils.htmlEncode($!{AppLink.Label})$textutils.htmlEncode($!{AppLink.URI})
17 | #end 18 | #end 19 | #end 20 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/view-oslclinks_edit.vm: -------------------------------------------------------------------------------- 1 | $webResourceManager.requireResource("com.atlassian.auiplugin:ajs") 2 | 3 | ## hidden input field with actual custom field value prevents clear after issue is updated (Edit) 4 | 5 | -------------------------------------------------------------------------------- /oslcjira/src/main/resources/templates/view-oslclinks_xml.vm: -------------------------------------------------------------------------------- 1 | #disable_html_escaping() 2 | #if ($value) 3 | #if (${displayParameters.excel_view}) 4 | $textutils.br($textutils.htmlEncode($!value.toString(), false)) 5 | #else 6 | #if (${appLinkList}) 7 | #foreach($AppLink in ${appLinkList}) 8 | 9 | 10 | $!{AppLink.URI} 11 | 12 | #end 13 | #end 14 | #end 15 | #end 16 | --------------------------------------------------------------------------------