mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'application-mgt-new' into 'application-mgt-new'
Fix image loading issue in tenants See merge request entgra/carbon-device-mgt!255
This commit is contained in:
commit
d9999ad5b2
@ -57,7 +57,7 @@ import javax.ws.rs.core.Response;
|
|||||||
public interface ArtifactDownloadAPI {
|
public interface ArtifactDownloadAPI {
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{uuid}/{folderName}/{fileName}")
|
@Path("/{tenantId}/{uuid}/{folderName}/{fileName}")
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
produces = MediaType.APPLICATION_OCTET_STREAM,
|
produces = MediaType.APPLICATION_OCTET_STREAM,
|
||||||
@ -81,6 +81,11 @@ public interface ArtifactDownloadAPI {
|
|||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
Response getArtifact(
|
Response getArtifact(
|
||||||
|
@ApiParam(
|
||||||
|
name = "tenantId",
|
||||||
|
value = "Tenant Id of the application artifact belongs.",
|
||||||
|
required = true)
|
||||||
|
@PathParam("tenantId") int tenantId,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "uuid",
|
name = "uuid",
|
||||||
value = "UUID of the application release.",
|
value = "UUID of the application release.",
|
||||||
|
|||||||
@ -47,14 +47,15 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI {
|
|||||||
@GET
|
@GET
|
||||||
@Override
|
@Override
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
@Path("/{uuid}/{folderName}/{fileName}")
|
@Path("/{tenantId}/{uuid}/{folderName}/{fileName}")
|
||||||
public Response getArtifact(
|
public Response getArtifact(
|
||||||
|
@PathParam("tenantId") int tenantId,
|
||||||
@PathParam("uuid") String uuid,
|
@PathParam("uuid") String uuid,
|
||||||
@PathParam("folderName") String folderName,
|
@PathParam("folderName") String folderName,
|
||||||
@PathParam("fileName") String fileName) {
|
@PathParam("fileName") String fileName) {
|
||||||
AppmDataHandler dataHandler = APIUtil.getDataHandler();
|
AppmDataHandler dataHandler = APIUtil.getDataHandler();
|
||||||
try {
|
try {
|
||||||
InputStream fileInputStream = dataHandler.getArtifactStream(uuid, folderName, fileName);
|
InputStream fileInputStream = dataHandler.getArtifactStream(tenantId, uuid, folderName, fileName);
|
||||||
Response.ResponseBuilder response = Response
|
Response.ResponseBuilder response = Response
|
||||||
.ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM);
|
.ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM);
|
||||||
response.status(Response.Status.OK);
|
response.status(Response.Status.OK);
|
||||||
|
|||||||
@ -35,6 +35,6 @@ public interface AppmDataHandler {
|
|||||||
|
|
||||||
Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException;
|
Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException;
|
||||||
|
|
||||||
InputStream getArtifactStream(String uuid, String folderName, String artifactName)
|
InputStream getArtifactStream(int tenantId, String uuid, String folderName, String artifactName)
|
||||||
throws ApplicationManagementException;
|
throws ApplicationManagementException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,9 +60,8 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
|
|||||||
return lifecycleStateManager.getLifecycleConfig();
|
return lifecycleStateManager.getLifecycleConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public InputStream getArtifactStream(String uuid, String folderName, String artifactName)
|
@Override public InputStream getArtifactStream(int tenantId, String uuid, String folderName, String artifactName)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
||||||
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
|
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
|
||||||
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
|
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
|
||||||
String appReleaseHashValue;
|
String appReleaseHashValue;
|
||||||
@ -83,9 +82,8 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
|
|||||||
}
|
}
|
||||||
return inputStream;
|
return inputStream;
|
||||||
} catch (ApplicationManagementDAOException e) {
|
} catch (ApplicationManagementDAOException e) {
|
||||||
String msg =
|
String msg = "Error occurred when retrieving application release hash value for given application release "
|
||||||
"Error occurred when retrieving application release hash value for given application release UUID: "
|
+ "UUID: " + uuid;
|
||||||
+ uuid;
|
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new ApplicationManagementException(msg, e);
|
throw new ApplicationManagementException(msg, e);
|
||||||
} catch (ApplicationStorageManagementException e) {
|
} catch (ApplicationStorageManagementException e) {
|
||||||
|
|||||||
@ -353,8 +353,7 @@ public class APIUtil {
|
|||||||
application.setRating(applicationDTO.getAppRating());
|
application.setRating(applicationDTO.getAppRating());
|
||||||
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
||||||
for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
|
for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
|
||||||
ApplicationRelease applicationRelease = releaseDtoToRelease(applicationReleaseDTO);
|
applicationReleases.add(releaseDtoToRelease(applicationReleaseDTO));
|
||||||
applicationReleases.add(applicationRelease);
|
|
||||||
}
|
}
|
||||||
application.setApplicationReleases(applicationReleases);
|
application.setApplicationReleases(applicationReleases);
|
||||||
return application;
|
return application;
|
||||||
@ -362,7 +361,9 @@ public class APIUtil {
|
|||||||
|
|
||||||
public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO)
|
public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
String basePath = getArtifactDownloadBaseURL() + applicationReleaseDTO.getUuid()
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
|
String basePath =
|
||||||
|
getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid()
|
||||||
+ Constants.FORWARD_SLASH;
|
+ Constants.FORWARD_SLASH;
|
||||||
|
|
||||||
List<String> screenshotPaths = new ArrayList<>();
|
List<String> screenshotPaths = new ArrayList<>();
|
||||||
|
|||||||
@ -92,7 +92,6 @@ class AppDetailsDrawer extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.getCategories();
|
this.getCategories();
|
||||||
this.getTags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState, snapshot) {
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
||||||
@ -117,7 +116,7 @@ class AppDetailsDrawer extends React.Component {
|
|||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const categories = JSON.parse(res.data.data);
|
const categories = JSON.parse(res.data.data);
|
||||||
|
this.getTags();
|
||||||
const globalCategories = categories.map(category => {
|
const globalCategories = categories.map(category => {
|
||||||
return (
|
return (
|
||||||
<Option
|
<Option
|
||||||
|
|||||||
@ -75,8 +75,6 @@ class FiltersForm extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.getCategories();
|
this.getCategories();
|
||||||
this.getTags();
|
|
||||||
this.getDeviceTypes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategories = () => {
|
getCategories = () => {
|
||||||
@ -86,6 +84,7 @@ class FiltersForm extends React.Component {
|
|||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
let categories = JSON.parse(res.data.data);
|
let categories = JSON.parse(res.data.data);
|
||||||
|
this.getTags();
|
||||||
this.setState({
|
this.setState({
|
||||||
categories: categories,
|
categories: categories,
|
||||||
loading: false
|
loading: false
|
||||||
@ -116,6 +115,7 @@ class FiltersForm extends React.Component {
|
|||||||
).then(res => {
|
).then(res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
let tags = JSON.parse(res.data.data);
|
let tags = JSON.parse(res.data.data);
|
||||||
|
this.getDeviceTypes();
|
||||||
this.setState({
|
this.setState({
|
||||||
tags: tags,
|
tags: tags,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
@ -38,8 +38,6 @@ import org.apache.http.entity.ContentType;
|
|||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.protocol.HTTP;
|
import org.apache.http.protocol.HTTP;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
|
import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
|
||||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
||||||
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
|
|
||||||
|
|
||||||
import javax.servlet.annotation.MultipartConfig;
|
import javax.servlet.annotation.MultipartConfig;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
@ -66,11 +64,6 @@ public class LoginHandler extends HttpServlet {
|
|||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
try {
|
try {
|
||||||
validateLoginRequest(req, resp);
|
validateLoginRequest(req, resp);
|
||||||
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance()
|
|
||||||
.getDeviceManagementConfig();
|
|
||||||
String adminUsername = deviceManagementConfig.getIdentityConfigurations().getAdminUsername();
|
|
||||||
String adminPwd = deviceManagementConfig.getIdentityConfigurations().getAdminPassword();
|
|
||||||
|
|
||||||
HttpSession httpSession = req.getSession(false);
|
HttpSession httpSession = req.getSession(false);
|
||||||
if (httpSession != null) {
|
if (httpSession != null) {
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
@ -120,7 +113,7 @@ public class LoginHandler extends HttpServlet {
|
|||||||
// default login
|
// default login
|
||||||
HttpPost apiRegEndpoint = new HttpPost(serverUrl + HandlerConstants.APP_REG_ENDPOINT);
|
HttpPost apiRegEndpoint = new HttpPost(serverUrl + HandlerConstants.APP_REG_ENDPOINT);
|
||||||
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
|
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
|
||||||
.encodeToString((adminUsername + HandlerConstants.COLON + adminPwd).getBytes()));
|
.encodeToString((username + HandlerConstants.COLON + password).getBytes()));
|
||||||
apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
|
apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
|
||||||
apiRegEndpoint.setEntity(constructAppRegPayload(tags));
|
apiRegEndpoint.setEntity(constructAppRegPayload(tags));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user