Code format fixes

mssqlenrolmentfix2
Pasindu Rupasinghe 2 years ago
parent aab94d8fdd
commit 34ae40e233

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api; package io.entgra.devicemgt.apimgt.extension.rest.api;
import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey;
@ -9,6 +27,7 @@ public interface APIApplicationServices {
APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException; APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException;
AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException;
AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException;
} }

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api; package io.entgra.devicemgt.apimgt.extension.rest.api;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -81,7 +99,6 @@ public class APIApplicationServicesImpl implements APIApplicationServices {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE); params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE);
//ToDo: Remove hardcoded value
params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken); params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken);
params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES);
return getToken(params, consumerKey, consumerSecret); return getToken(params, consumerKey, consumerSecret);

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api; package io.entgra.devicemgt.apimgt.extension.rest.api;
import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.bean; package io.entgra.devicemgt.apimgt.extension.rest.api.bean;
/** /**

@ -20,15 +20,6 @@ public final class Constants {
public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive";
public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000;
public static final int DEFAULT_MIN_THREAD_POOL_SIZE = 8;
public static final int DEFAULT_MAX_THREAD_POOL_SIZE = 100;
public static final int DEFAULT_EXECUTOR_JOB_QUEUE_SIZE = 2000;
public static final long DEFAULT_KEEP_ALIVE_TIME_IN_MILLIS = 20000;
public static final String ADAPTER_MIN_THREAD_POOL_SIZE_NAME = "minThread";
public static final String ADAPTER_MAX_THREAD_POOL_SIZE_NAME = "maxThread";
public static final String ADAPTER_KEEP_ALIVE_TIME_NAME = "keepAliveTimeInMillis";
public static final String ADAPTER_EXECUTOR_JOB_QUEUE_SIZE_NAME = "jobQueueSize";
public static final String DEFAULT_CALLBACK = ""; public static final String DEFAULT_CALLBACK = "";
public static final String DEFAULT_PASSWORD = ""; public static final String DEFAULT_PASSWORD = "";
public static final String TOKEN_SCOPE = "production"; public static final String TOKEN_SCOPE = "production";

@ -1,7 +1,25 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.dto; package io.entgra.devicemgt.apimgt.extension.rest.api.dto;
/** /**
* This holds api application consumer id and secret. * This holds the consumer application information that return from the register application endpoint
*/ */
public class APIApplicationKey { public class APIApplicationKey {
private String clientName; private String clientName;
@ -14,7 +32,7 @@ public class APIApplicationKey {
private String jsonAppAttribute; private String jsonAppAttribute;
private String tokenType; private String tokenType;
public APIApplicationKey(String clientId, String clientSecret){ public APIApplicationKey(String clientId, String clientSecret) {
this.clientId = clientId; this.clientId = clientId;
this.clientSecret = clientSecret; this.clientSecret = clientSecret;
} }
@ -34,6 +52,7 @@ public class APIApplicationKey {
public void setClientSecret(String clientSecret) { public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret; this.clientSecret = clientSecret;
} }
public String getClientName() { public String getClientName() {
return clientName; return clientName;
} }

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.dto; package io.entgra.devicemgt.apimgt.extension.rest.api.dto;
/** /**

@ -1,12 +1,38 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions;
public class APIApplicationServicesException extends Exception{ public class APIApplicationServicesException extends Exception {
public APIApplicationServicesException() {super();} public APIApplicationServicesException() {
super();
}
public APIApplicationServicesException(String message) {super();} public APIApplicationServicesException(String message) {
super();
}
public APIApplicationServicesException(String message, Throwable cause){super();} public APIApplicationServicesException(String message, Throwable cause) {
super();
}
public APIApplicationServicesException(Throwable cause){super();} public APIApplicationServicesException(Throwable cause) {
super();
}
} }

@ -1,22 +1,19 @@
/* /*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
* *
* * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* * * Version 2.0 (the "License"); you may not use this file except
* * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * in compliance with the License.
* * Version 2.0 (the "License"); you may not use this file except * You may obtain a copy of the License at
* * in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing,
* * software distributed under the License is distributed on an
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* * KIND, either express or implied. See the License for the
* * specific language governing permissions and limitations
* * under the License.
* *
* http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
/** /**

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.internal; package io.entgra.devicemgt.apimgt.extension.rest.api.internal;
import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices;
@ -8,12 +26,14 @@ public class PublisherRESTAPIDataHolder {
private APIApplicationServices apiApplicationServices; private APIApplicationServices apiApplicationServices;
public static PublisherRESTAPIDataHolder getInstance(){ public static PublisherRESTAPIDataHolder getInstance() {
return thisInstance; return thisInstance;
} }
public APIApplicationServices getApiApplicationServices() { public APIApplicationServices getApiApplicationServices() {
return apiApplicationServices; return apiApplicationServices;
} }
public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { public void setApiApplicationServices(APIApplicationServices apiApplicationServices) {
this.apiApplicationServices = apiApplicationServices; this.apiApplicationServices = apiApplicationServices;
} }

@ -1,3 +1,21 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.internal; package io.entgra.devicemgt.apimgt.extension.rest.api.internal;
import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices;

@ -1,8 +1,25 @@
/*
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.devicemgt.apimgt.extension.rest.api.util; package io.entgra.devicemgt.apimgt.extension.rest.api.util;
/** /**
* This class represents the data that are required to register * This class represents the scope data.
* the oauth application.
*/ */
public class ScopeUtils { public class ScopeUtils {

@ -432,15 +432,15 @@ public class APIPublisherServiceImpl implements APIPublisherService {
//Set scope id which related to the scope key //Set scope id which related to the scope key
JSONArray scopeList = (JSONArray) scopeObject.get("list"); JSONArray scopeList = (JSONArray) scopeObject.get("list");
JSONObject object = null; JSONObject jsonObject = null;
for (int i = 0; i < scopeList.length(); i++) { for (int i = 0; i < scopeList.length(); i++) {
JSONObject obj = null; JSONObject scopeObj = null;
obj = scopeList.getJSONObject(i); scopeObj = scopeList.getJSONObject(i);
if (obj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) {
object = obj; jsonObject = scopeObj;
} }
} }
scope.setId(object.getString("id")); scope.setId(jsonObject.getString("id"));
if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) {
publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope);

@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.core.ServerStartupObserver;
import java.util.Stack; import java.util.Stack;
public class APIPublisherStartupHandler implements ServerStartupObserver { public class APIPublisherStartupHandler implements ServerStartupObserver {
@ -34,10 +35,12 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
private static final int MAX_RETRY_COUNT = 5; private static final int MAX_RETRY_COUNT = 5;
private static Stack<APIConfig> failedAPIsStack = new Stack<>(); private static Stack<APIConfig> failedAPIsStack = new Stack<>();
private static Stack<APIConfig> currentAPIsStack; private static Stack<APIConfig> currentAPIsStack;
private APIPublisherService publisher; private APIPublisherService publisher;
@Override @Override
public void completingServerStartup() { public void completingServerStartup() {
} }
@Override @Override
@ -52,7 +55,6 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
log.debug("Total number of unpublished APIs: " log.debug("Total number of unpublished APIs: "
+ APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); + APIPublisherDataHolder.getInstance().getUnpublishedApis().size());
} }
publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); publisher = APIPublisherDataHolder.getInstance().getApiPublisherService();
int retryCount = 0; int retryCount = 0;
while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) {

@ -299,7 +299,7 @@ public class AnnotationProcessor {
// if (scope != null) { // if (scope != null) {
// resource.setScope(scope); // resource.setScope(scope);
// } else { // } else {
// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + // log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) +
// makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope");
// scope = new ApiScope(); // scope = new ApiScope();
// scope.setName(DEFAULT_SCOPE_NAME); // scope.setName(DEFAULT_SCOPE_NAME);
@ -537,7 +537,7 @@ public class AnnotationProcessor {
if (scope != null) { if (scope != null) {
apiResource.setScope(scope); apiResource.setScope(scope);
} else { } else {
// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + // log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) +
// makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope");
scope = new ApiScope(); scope = new ApiScope();
scope.setName(DEFAULT_SCOPE_NAME); scope.setName(DEFAULT_SCOPE_NAME);

@ -25,32 +25,6 @@
<version>5.0.26-SNAPSHOT</version> <version>5.0.26-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>

Loading…
Cancel
Save